X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FTarget%2FTarget.cpp;h=d7793a7b6b0f57d40847375cec1b00037cfdbdff;hb=9ba9d4d76bfa8de2b05cbce02a5a3ff7d46cb331;hp=ed544b73eaeda36d5bc33a9354daeca6e785f7a1;hpb=777d2306b36816a53bc1ae1244c0dc7d998ae691;p=oota-llvm.git diff --git a/lib/Target/Target.cpp b/lib/Target/Target.cpp index ed544b73eae..d7793a7b6b0 100644 --- a/lib/Target/Target.cpp +++ b/lib/Target/Target.cpp @@ -7,18 +7,31 @@ // //===----------------------------------------------------------------------===// // -// This file implements the C bindings for libLLVMTarget.a, which implements -// target information. +// This file implements the common infrastructure (including C bindings) for +// libLLVMTarget.a, which implements target information. // //===----------------------------------------------------------------------===// #include "llvm-c/Target.h" +#include "llvm-c/Initialization.h" +#include "llvm/InitializePasses.h" #include "llvm/PassManager.h" #include "llvm/Target/TargetData.h" +#include "llvm/Target/TargetLibraryInfo.h" +#include "llvm/LLVMContext.h" #include using namespace llvm; +void llvm::initializeTarget(PassRegistry &Registry) { + initializeDataLayoutPass(Registry); + initializeTargetLibraryInfoPass(Registry); +} + +void LLVMInitializeTarget(LLVMPassRegistryRef R) { + initializeTarget(*unwrap(R)); +} + LLVMTargetDataRef LLVMCreateTargetData(const char *StringRep) { return wrap(new TargetData(StringRep)); } @@ -27,13 +40,18 @@ void LLVMAddTargetData(LLVMTargetDataRef TD, LLVMPassManagerRef PM) { unwrap(PM)->add(new TargetData(*unwrap(TD))); } +void LLVMAddTargetLibraryInfo(LLVMTargetLibraryInfoRef TLI, + LLVMPassManagerRef PM) { + unwrap(PM)->add(new TargetLibraryInfo(*unwrap(TLI))); +} + char *LLVMCopyStringRepOfTargetData(LLVMTargetDataRef TD) { std::string StringRep = unwrap(TD)->getStringRepresentation(); return strdup(StringRep.c_str()); } LLVMByteOrdering LLVMByteOrder(LLVMTargetDataRef TD) { - return unwrap(TD)->isLittleEndian(); + return unwrap(TD)->isLittleEndian() ? LLVMLittleEndian : LLVMBigEndian; } unsigned LLVMPointerSize(LLVMTargetDataRef TD) { @@ -41,7 +59,7 @@ unsigned LLVMPointerSize(LLVMTargetDataRef TD) { } LLVMTypeRef LLVMIntPtrType(LLVMTargetDataRef TD) { - return wrap(unwrap(TD)->getIntPtrType()); + return wrap(unwrap(TD)->getIntPtrType(getGlobalContext())); } unsigned long long LLVMSizeOfTypeInBits(LLVMTargetDataRef TD, LLVMTypeRef Ty) { @@ -75,20 +93,16 @@ unsigned LLVMPreferredAlignmentOfGlobal(LLVMTargetDataRef TD, unsigned LLVMElementAtOffset(LLVMTargetDataRef TD, LLVMTypeRef StructTy, unsigned long long Offset) { - const StructType *STy = unwrap(StructTy); + StructType *STy = unwrap(StructTy); return unwrap(TD)->getStructLayout(STy)->getElementContainingOffset(Offset); } unsigned long long LLVMOffsetOfElement(LLVMTargetDataRef TD, LLVMTypeRef StructTy, unsigned Element) { - const StructType *STy = unwrap(StructTy); + StructType *STy = unwrap(StructTy); return unwrap(TD)->getStructLayout(STy)->getElementOffset(Element); } -void LLVMInvalidateStructLayout(LLVMTargetDataRef TD, LLVMTypeRef StructTy) { - unwrap(TD)->InvalidateStructLayoutInfo(unwrap(StructTy)); -} - void LLVMDisposeTargetData(LLVMTargetDataRef TD) { delete unwrap(TD); }