diff gen/llvmhelpers.cpp @ 284:70c370e97944 trunk

[svn r305] Started support for custom class allocators/deallocators. Allocators with more than one argument still need to be fixed. Removed the LLVM stacktrace code from mars.c. Moved the LLVM based default target detection code from mars.c to llvmhelpers.cpp.
author lindquist
date Sat, 21 Jun 2008 02:48:53 +0200
parents fc9c1a0eabbd
children 17d3b3236334
line wrap: on
line diff
--- a/gen/llvmhelpers.cpp	Sat Jun 21 00:54:55 2008 +0200
+++ b/gen/llvmhelpers.cpp	Sat Jun 21 02:48:53 2008 +0200
@@ -1,4 +1,5 @@
 #include "gen/llvm.h"
+#include "llvm/Target/TargetMachineRegistry.h"
 
 #include "mars.h"
 #include "init.h"
@@ -1096,3 +1097,18 @@
         return llvm::ConstantExpr::getBitCast(c, typeinfotype);
     return c;
 }
+
+void findDefaultTarget()
+{
+    std::string err_str;
+    const llvm::TargetMachineRegistry::entry* e = llvm::TargetMachineRegistry::getClosestTargetForJIT(err_str);
+    if (e == 0)
+    {
+        error("Failed to find a default target machine: %s", err_str.c_str());
+        fatal();
+    }
+    else
+    {
+        global.params.llvmArch = const_cast<char*>(e->Name);
+    }
+}