X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FTarget%2FTargetMachineC.cpp;h=f2ac93e76847232774038c3ac24286c1f6254b17;hb=52f60f81d958c5ce7be81161dd6adee508605673;hp=3d5f8277f00e0be5869def0a312dd4d2887c12cf;hpb=e016a163e97d29a4c343189e678633066a3365ab;p=oota-llvm.git diff --git a/lib/Target/TargetMachineC.cpp b/lib/Target/TargetMachineC.cpp index 3d5f8277f00..f2ac93e7684 100644 --- a/lib/Target/TargetMachineC.cpp +++ b/lib/Target/TargetMachineC.cpp @@ -18,10 +18,11 @@ #include "llvm/IR/Module.h" #include "llvm/PassManager.h" #include "llvm/Support/CodeGen.h" +#include "llvm/Support/FileSystem.h" #include "llvm/Support/FormattedStream.h" +#include "llvm/Support/Host.h" #include "llvm/Support/TargetRegistry.h" #include "llvm/Support/raw_ostream.h" -#include "llvm/Support/Host.h" #include "llvm/Target/TargetMachine.h" #include #include @@ -62,7 +63,7 @@ inline LLVMTargetRef wrap(const Target * P) { LLVMTargetRef LLVMGetFirstTarget() { if(TargetRegistry::begin() == TargetRegistry::end()) { - return NULL; + return nullptr; } const Target* target = &*TargetRegistry::begin(); @@ -80,7 +81,7 @@ LLVMTargetRef LLVMGetTargetFromName(const char *Name) { return wrap(&*IT); } - return NULL; + return nullptr; } LLVMBool LLVMGetTargetFromTriple(const char* TripleStr, LLVMTargetRef *T, @@ -212,7 +213,8 @@ static LLVMBool LLVMTargetMachineEmit(LLVMTargetMachineRef T, LLVMModuleRef M, *ErrorMessage = strdup(error.c_str()); return true; } - pass.add(new DataLayout(*td)); + Mod->setDataLayout(td); + pass.add(new DataLayoutPass(Mod)); TargetMachine::CodeGenFileType ft; switch (codegen) { @@ -238,7 +240,7 @@ static LLVMBool LLVMTargetMachineEmit(LLVMTargetMachineRef T, LLVMModuleRef M, LLVMBool LLVMTargetMachineEmitToFile(LLVMTargetMachineRef T, LLVMModuleRef M, char* Filename, LLVMCodeGenFileType codegen, char** ErrorMessage) { std::string error; - raw_fd_ostream dest(Filename, error, sys::fs::F_Binary); + raw_fd_ostream dest(Filename, error, sys::fs::F_None); if (!error.empty()) { *ErrorMessage = strdup(error.c_str()); return true; @@ -267,3 +269,7 @@ LLVMBool LLVMTargetMachineEmitToMemoryBuffer(LLVMTargetMachineRef T, char *LLVMGetDefaultTargetTriple(void) { return strdup(sys::getDefaultTargetTriple().c_str()); } + +void LLVMAddAnalysisPasses(LLVMTargetMachineRef T, LLVMPassManagerRef PM) { + unwrap(T)->addAnalysisPasses(*unwrap(PM)); +}