Mercurial > projects > ldc
comparison gen/toobj.cpp @ 735:eee9efe5b51f
Attempt at getting LLVM to provide a proper target data layout. Should assert now if things are borked.
Added untested support for Thumb target.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Mon, 27 Oct 2008 17:37:34 +0100 |
parents | cc8ba72c0350 |
children | 041c1596d217 |
comparison
equal
deleted
inserted
replaced
734:6dcab994ddc3 | 735:eee9efe5b51f |
---|---|
102 this->ir.irModule = new IrModule(this, srcfile->toChars()); | 102 this->ir.irModule = new IrModule(this, srcfile->toChars()); |
103 | 103 |
104 // set target stuff | 104 // set target stuff |
105 | 105 |
106 ir.module->setTargetTriple(global.params.targetTriple); | 106 ir.module->setTargetTriple(global.params.targetTriple); |
107 ir.module->setDataLayout(global.params.dataLayout); | |
107 | 108 |
108 // get the target machine | 109 // get the target machine |
109 const llvm::TargetMachineRegistry::entry* MArch; | 110 const llvm::TargetMachineRegistry::entry* MArch; |
110 | 111 |
111 std::string Err; | 112 std::string Err; |
129 std::auto_ptr<llvm::TargetMachine> target(MArch->CtorFn(*ir.module, Features.getString())); | 130 std::auto_ptr<llvm::TargetMachine> target(MArch->CtorFn(*ir.module, Features.getString())); |
130 assert(target.get() && "Could not allocate target machine!"); | 131 assert(target.get() && "Could not allocate target machine!"); |
131 llvm::TargetMachine &Target = *target.get(); | 132 llvm::TargetMachine &Target = *target.get(); |
132 | 133 |
133 gTargetData = Target.getTargetData(); | 134 gTargetData = Target.getTargetData(); |
134 ir.module->setDataLayout(gTargetData->getStringRepresentation()); | 135 |
136 // set final data layout | |
137 std::string datalayout = gTargetData->getStringRepresentation(); | |
138 ir.module->setDataLayout(datalayout); | |
139 if (Logger::enabled()) | |
140 Logger::cout() << "Final data layout: " << datalayout << '\n'; | |
141 assert(memcmp(global.params.dataLayout, datalayout.c_str(), 9) == 0); // "E-p:xx:xx" | |
135 | 142 |
136 // debug info | 143 // debug info |
137 if (global.params.symdebug) { | 144 if (global.params.symdebug) { |
138 RegisterDwarfSymbols(ir.module); | 145 RegisterDwarfSymbols(ir.module); |
139 DtoDwarfCompileUnit(this); | 146 DtoDwarfCompileUnit(this); |