diff 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
line wrap: on
line diff
--- a/gen/toobj.cpp	Mon Oct 27 16:36:59 2008 +0100
+++ b/gen/toobj.cpp	Mon Oct 27 17:37:34 2008 +0100
@@ -104,6 +104,7 @@
     // set target stuff
 
     ir.module->setTargetTriple(global.params.targetTriple);
+    ir.module->setDataLayout(global.params.dataLayout);
 
     // get the target machine
     const llvm::TargetMachineRegistry::entry* MArch;
@@ -131,7 +132,13 @@
     llvm::TargetMachine &Target = *target.get();
 
     gTargetData = Target.getTargetData();
-    ir.module->setDataLayout(gTargetData->getStringRepresentation());
+
+    // set final data layout
+    std::string datalayout = gTargetData->getStringRepresentation();
+    ir.module->setDataLayout(datalayout);
+    if (Logger::enabled())
+        Logger::cout() << "Final data layout: " << datalayout << '\n';
+    assert(memcmp(global.params.dataLayout, datalayout.c_str(), 9) == 0); // "E-p:xx:xx"
 
     // debug info
     if (global.params.symdebug) {