LLVM API Documentation

Target.h

Go to the documentation of this file.
00001 /*===-- llvm-c/Target.h - Target Lib C Iface --------------------*- C++ -*-===*\
00002 |*                                                                            *|
00003 |*                     The LLVM Compiler Infrastructure                       *|
00004 |*                                                                            *|
00005 |* This file is distributed under the University of Illinois Open Source      *|
00006 |* License. See LICENSE.TXT for details.                                      *|
00007 |*                                                                            *|
00008 |*===----------------------------------------------------------------------===*|
00009 |*                                                                            *|
00010 |* This header declares the C interface to libLLVMTarget.a, which             *|
00011 |* implements target information.                                             *|
00012 |*                                                                            *|
00013 |* Many exotic languages can interoperate with C code but have a harder time  *|
00014 |* with C++ due to name mangling. So in addition to C, this interface enables *|
00015 |* tools written in such languages.                                           *|
00016 |*                                                                            *|
00017 \*===----------------------------------------------------------------------===*/
00018 
00019 #ifndef LLVM_C_TARGET_H
00020 #define LLVM_C_TARGET_H
00021 
00022 #include "llvm-c/Core.h"
00023 
00024 #ifdef __cplusplus
00025 extern "C" {
00026 #endif
00027 
00028 enum { LLVMBigEndian, LLVMLittleEndian };
00029 typedef int LLVMByteOrdering;
00030 
00031 typedef struct LLVMOpaqueTargetData *LLVMTargetDataRef;
00032 typedef struct LLVMStructLayout *LLVMStructLayoutRef;
00033 
00034 
00035 /*===-- Target Data -------------------------------------------------------===*/
00036 
00037 /** Creates target data from a target layout string.
00038     See the constructor llvm::TargetData::TargetData. */
00039 LLVMTargetDataRef LLVMCreateTargetData(const char *StringRep);
00040 
00041 /** Adds target data information to a pass manager. This does not take ownership
00042     of the target data.
00043     See the method llvm::PassManagerBase::add. */
00044 void LLVMAddTargetData(LLVMTargetDataRef, LLVMPassManagerRef);
00045 
00046 /** Converts target data to a target layout string. The string must be disposed
00047     with LLVMDisposeMessage.
00048     See the constructor llvm::TargetData::TargetData. */
00049 char *LLVMCopyStringRepOfTargetData(LLVMTargetDataRef);
00050 
00051 /** Returns the byte order of a target, either LLVMBigEndian or
00052     LLVMLittleEndian.
00053     See the method llvm::TargetData::isLittleEndian. */
00054 LLVMByteOrdering LLVMByteOrder(LLVMTargetDataRef);
00055 
00056 /** Returns the pointer size in bytes for a target.
00057     See the method llvm::TargetData::getPointerSize. */
00058 unsigned LLVMPointerSize(LLVMTargetDataRef);
00059 
00060 /** Returns the integer type that is the same size as a pointer on a target.
00061     See the method llvm::TargetData::getIntPtrType. */
00062 LLVMTypeRef LLVMIntPtrType(LLVMTargetDataRef);
00063 
00064 /** Computes the size of a type in bytes for a target.
00065     See the method llvm::TargetData::getTypeSizeInBits. */
00066 unsigned long long LLVMSizeOfTypeInBits(LLVMTargetDataRef, LLVMTypeRef);
00067 
00068 /** Computes the storage size of a type in bytes for a target.
00069     See the method llvm::TargetData::getTypeStoreSize. */
00070 unsigned long long LLVMStoreSizeOfType(LLVMTargetDataRef, LLVMTypeRef);
00071 
00072 /** Computes the ABI size of a type in bytes for a target.
00073     See the method llvm::TargetData::getABITypeSize. */
00074 unsigned long long LLVMABISizeOfType(LLVMTargetDataRef, LLVMTypeRef);
00075 
00076 /** Computes the ABI alignment of a type in bytes for a target.
00077     See the method llvm::TargetData::getTypeABISize. */
00078 unsigned LLVMABIAlignmentOfType(LLVMTargetDataRef, LLVMTypeRef);
00079 
00080 /** Computes the call frame alignment of a type in bytes for a target.
00081     See the method llvm::TargetData::getTypeABISize. */
00082 unsigned LLVMCallFrameAlignmentOfType(LLVMTargetDataRef, LLVMTypeRef);
00083 
00084 /** Computes the preferred alignment of a type in bytes for a target.
00085     See the method llvm::TargetData::getTypeABISize. */
00086 unsigned LLVMPreferredAlignmentOfType(LLVMTargetDataRef, LLVMTypeRef);
00087 
00088 /** Computes the preferred alignment of a global variable in bytes for a target.
00089     See the method llvm::TargetData::getPreferredAlignment. */
00090 unsigned LLVMPreferredAlignmentOfGlobal(LLVMTargetDataRef,
00091                                         LLVMValueRef GlobalVar);
00092 
00093 /** Computes the structure element that contains the byte offset for a target.
00094     See the method llvm::StructLayout::getElementContainingOffset. */
00095 unsigned LLVMElementAtOffset(LLVMTargetDataRef, LLVMTypeRef StructTy,
00096                              unsigned long long Offset);
00097 
00098 /** Computes the byte offset of the indexed struct element for a target.
00099     See the method llvm::StructLayout::getElementContainingOffset. */
00100 unsigned long long LLVMOffsetOfElement(LLVMTargetDataRef, LLVMTypeRef StructTy,
00101                                        unsigned Element);
00102 
00103 /** Struct layouts are speculatively cached. If a TargetDataRef is alive when
00104     types are being refined and removed, this method must be called whenever a
00105     struct type is removed to avoid a dangling pointer in this cache.
00106     See the method llvm::TargetData::InvalidateStructLayoutInfo. */
00107 void LLVMInvalidateStructLayout(LLVMTargetDataRef, LLVMTypeRef StructTy);
00108 
00109 /** Deallocates a TargetData.
00110     See the destructor llvm::TargetData::~TargetData. */
00111 void LLVMDisposeTargetData(LLVMTargetDataRef);
00112 
00113 
00114 #ifdef __cplusplus
00115 }
00116 
00117 namespace llvm {
00118   class TargetData;
00119 
00120   inline TargetData *unwrap(LLVMTargetDataRef P) {
00121     return reinterpret_cast<TargetData*>(P);
00122   }
00123   
00124   inline LLVMTargetDataRef wrap(const TargetData *P) {
00125     return reinterpret_cast<LLVMTargetDataRef>(const_cast<TargetData*>(P));
00126   }
00127 }
00128 
00129 #endif /* defined(__cplusplus) */
00130 
00131 #endif



This web site is hosted by the Computer Science Department at the University of Illinois at Urbana-Champaign.