X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FTarget%2FTarget.cpp;h=d277f82eb869bd2f983f9bca31a535e1085a4fe0;hb=7ee57ccbc603e74b38e745304694cbb643f4b9f9;hp=219cbf1afc9e97ec6ad330dd57d63e07850a628e;hpb=e3d0e86919730784faaddcb5d9b0257c39b0804b;p=oota-llvm.git diff --git a/lib/Target/Target.cpp b/lib/Target/Target.cpp index 219cbf1afc9..d277f82eb86 100644 --- a/lib/Target/Target.cpp +++ b/lib/Target/Target.cpp @@ -14,19 +14,28 @@ #include "llvm-c/Target.h" #include "llvm-c/Initialization.h" +#include "llvm/IR/DataLayout.h" +#include "llvm/IR/LLVMContext.h" +#include "llvm/IR/Value.h" #include "llvm/InitializePasses.h" #include "llvm/PassManager.h" -#include "llvm/DataLayout.h" #include "llvm/Target/TargetLibraryInfo.h" -#include "llvm/LLVMContext.h" #include using namespace llvm; +inline TargetLibraryInfo *unwrap(LLVMTargetLibraryInfoRef P) { + return reinterpret_cast(P); +} + +inline LLVMTargetLibraryInfoRef wrap(const TargetLibraryInfo *P) { + TargetLibraryInfo *X = const_cast(P); + return reinterpret_cast(X); +} + void llvm::initializeTarget(PassRegistry &Registry) { - initializeDataLayoutPass(Registry); + initializeDataLayoutPassPass(Registry); initializeTargetLibraryInfoPass(Registry); - initializeTargetTransformInfoPass(Registry); } void LLVMInitializeTarget(LLVMPassRegistryRef R) { @@ -38,7 +47,9 @@ LLVMTargetDataRef LLVMCreateTargetData(const char *StringRep) { } void LLVMAddTargetData(LLVMTargetDataRef TD, LLVMPassManagerRef PM) { - unwrap(PM)->add(new DataLayout(*unwrap(TD))); + // The DataLayoutPass must now be in sync with the module. Unfortunatelly we + // cannot enforce that from the C api. + unwrap(PM)->add(new DataLayoutPass(*unwrap(TD))); } void LLVMAddTargetLibraryInfo(LLVMTargetLibraryInfoRef TLI, @@ -56,13 +67,29 @@ LLVMByteOrdering LLVMByteOrder(LLVMTargetDataRef TD) { } unsigned LLVMPointerSize(LLVMTargetDataRef TD) { - return unwrap(TD)->getPointerSize(); + return unwrap(TD)->getPointerSize(0); +} + +unsigned LLVMPointerSizeForAS(LLVMTargetDataRef TD, unsigned AS) { + return unwrap(TD)->getPointerSize(AS); } LLVMTypeRef LLVMIntPtrType(LLVMTargetDataRef TD) { return wrap(unwrap(TD)->getIntPtrType(getGlobalContext())); } +LLVMTypeRef LLVMIntPtrTypeForAS(LLVMTargetDataRef TD, unsigned AS) { + return wrap(unwrap(TD)->getIntPtrType(getGlobalContext(), AS)); +} + +LLVMTypeRef LLVMIntPtrTypeInContext(LLVMContextRef C, LLVMTargetDataRef TD) { + return wrap(unwrap(TD)->getIntPtrType(*unwrap(C))); +} + +LLVMTypeRef LLVMIntPtrTypeForASInContext(LLVMContextRef C, LLVMTargetDataRef TD, unsigned AS) { + return wrap(unwrap(TD)->getIntPtrType(*unwrap(C), AS)); +} + unsigned long long LLVMSizeOfTypeInBits(LLVMTargetDataRef TD, LLVMTypeRef Ty) { return unwrap(TD)->getTypeSizeInBits(unwrap(Ty)); } @@ -80,7 +107,7 @@ unsigned LLVMABIAlignmentOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty) { } unsigned LLVMCallFrameAlignmentOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty) { - return unwrap(TD)->getCallFrameTypeAlignment(unwrap(Ty)); + return unwrap(TD)->getABITypeAlignment(unwrap(Ty)); } unsigned LLVMPreferredAlignmentOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty) {