diff gen/toobj.cpp @ 583:12bda38ea366

Fixed choosing default target machine without needing to link in targets.
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Sun, 07 Sep 2008 17:44:25 -0700
parents 7824c21a58e3
children e235b80c92bc
line wrap: on
line diff
--- a/gen/toobj.cpp	Sun Sep 07 16:16:10 2008 +0200
+++ b/gen/toobj.cpp	Sun Sep 07 17:44:25 2008 -0700
@@ -95,15 +95,7 @@
     ir.module->setTargetTriple(target_triple);
     ir.module->setDataLayout(global.params.data_layout);
 
-    // heavily inspired by tools/llc/llc.cpp:200-230
-    const llvm::TargetMachineRegistry::entry* targetEntry;
-    std::string targetError;
-    targetEntry = llvm::TargetMachineRegistry::getClosestStaticTargetForModule(*ir.module, targetError);
-    assert(targetEntry && "Failed to find a static target for module");
-    std::auto_ptr<llvm::TargetMachine> targetPtr(targetEntry->CtorFn(*ir.module, "")); // TODO: replace "" with features
-    assert(targetPtr.get() && "Could not allocate target machine!");
-    llvm::TargetMachine &targetMachine = *targetPtr.get();
-    gTargetData = targetMachine.getTargetData();
+    gTargetData = new llvm::TargetData(global.params.data_layout);
 
     // debug info
     if (global.params.symdebug) {