Mercurial > projects > ldc
comparison gen/toobj.cpp @ 1535:61f12f4651b5
Don't use llvm::getGlobalContext() anymore
author | Benjamin Kramer <benny.kra@gmail.com> |
---|---|
date | Mon, 13 Jul 2009 20:16:15 +0200 |
parents | 8ca25bd765a3 |
children | 1e7a09548e67 |
comparison
equal
deleted
inserted
replaced
1534:8ca25bd765a3 | 1535:61f12f4651b5 |
---|---|
69 void write_asm_to_file(llvm::TargetMachine &Target, llvm::Module& m, llvm::raw_fd_ostream& Out); | 69 void write_asm_to_file(llvm::TargetMachine &Target, llvm::Module& m, llvm::raw_fd_ostream& Out); |
70 void assemble(const llvm::sys::Path& asmpath, const llvm::sys::Path& objpath); | 70 void assemble(const llvm::sys::Path& asmpath, const llvm::sys::Path& objpath); |
71 | 71 |
72 ////////////////////////////////////////////////////////////////////////////////////////// | 72 ////////////////////////////////////////////////////////////////////////////////////////// |
73 | 73 |
74 llvm::Module* Module::genLLVMModule(Ir* sir) | 74 llvm::Module* Module::genLLVMModule(llvm::LLVMContext& context, Ir* sir) |
75 { | 75 { |
76 bool logenabled = Logger::enabled(); | 76 bool logenabled = Logger::enabled(); |
77 if (llvmForceLogging && !logenabled) | 77 if (llvmForceLogging && !logenabled) |
78 { | 78 { |
79 Logger::enable(); | 79 Logger::enable(); |
92 if (md != 0) | 92 if (md != 0) |
93 mname = md->toChars(); | 93 mname = md->toChars(); |
94 | 94 |
95 // create a new ir state | 95 // create a new ir state |
96 // TODO look at making the instance static and moving most functionality into IrModule where it belongs | 96 // TODO look at making the instance static and moving most functionality into IrModule where it belongs |
97 IRState ir(new llvm::Module(mname, llvm::getGlobalContext())); | 97 IRState ir(new llvm::Module(mname, context)); |
98 gIR = &ir; | 98 gIR = &ir; |
99 ir.dmodule = this; | 99 ir.dmodule = this; |
100 | 100 |
101 // reset all IR data stored in Dsymbols | 101 // reset all IR data stored in Dsymbols |
102 IrDsymbol::resetAll(); | 102 IrDsymbol::resetAll(); |
552 LLFunction* ctor = LLFunction::Create(fty, LLGlobalValue::InternalLinkage, fname, gIR->module); | 552 LLFunction* ctor = LLFunction::Create(fty, LLGlobalValue::InternalLinkage, fname, gIR->module); |
553 | 553 |
554 // provide the default initializer | 554 // provide the default initializer |
555 const LLStructType* modulerefTy = DtoModuleReferenceType(); | 555 const LLStructType* modulerefTy = DtoModuleReferenceType(); |
556 std::vector<LLConstant*> mrefvalues; | 556 std::vector<LLConstant*> mrefvalues; |
557 mrefvalues.push_back(llvm::getGlobalContext().getNullValue(modulerefTy->getContainedType(0))); | 557 mrefvalues.push_back(gIR->context().getNullValue(modulerefTy->getContainedType(0))); |
558 mrefvalues.push_back(llvm::ConstantExpr::getBitCast(moduleinfo, modulerefTy->getContainedType(1))); | 558 mrefvalues.push_back(llvm::ConstantExpr::getBitCast(moduleinfo, modulerefTy->getContainedType(1))); |
559 LLConstant* thismrefinit = LLConstantStruct::get(modulerefTy, mrefvalues); | 559 LLConstant* thismrefinit = LLConstantStruct::get(modulerefTy, mrefvalues); |
560 | 560 |
561 // create the ModuleReference node for this module | 561 // create the ModuleReference node for this module |
562 std::string thismrefname = "_D"; | 562 std::string thismrefname = "_D"; |