diff gen/main.cpp @ 1518:26d061e61b02

Initialize LLVM target and asmprinter for the native and extra targets. Uses some CMake hackery to get the native LLVM target name, since it only provides a conveniance function for initializing the native target and not the native asmprinter.
author Christian Kamm <kamm incasoftware de>
date Fri, 26 Jun 2009 21:02:23 +0200
parents 7d3b47852a7a
children 982eb70e83b2
line wrap: on
line diff
--- a/gen/main.cpp	Fri Jun 26 21:00:12 2009 +0200
+++ b/gen/main.cpp	Fri Jun 26 21:02:23 2009 +0200
@@ -4,6 +4,7 @@
 // which uses the llvm license
 
 #include "gen/llvm.h"
+#include "gen/llvm-version.h"
 #include "llvm/LinkAllVMCore.h"
 #include "llvm/Linker.h"
 #include "llvm/System/Signals.h"
@@ -11,6 +12,9 @@
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Target/TargetOptions.h"
 #include "llvm/Target/TargetMachineRegistry.h"
+#if LLVM_REV >= 73610
+#include "llvm/Target/TargetSelect.h"
+#endif
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -421,8 +425,17 @@
 
     mod.setTargetTriple(global.params.targetTriple);
 
-    // Allocate target machine.  First, check whether the user has
-    // explicitly specified an architecture to compile for.
+    // Allocate target machine.
+    
+    // first initialize llvm
+#if LLVM_REV >= 73610
+#define LLVM_TARGET(A) LLVMInitialize##A##Target(); LLVMInitialize##A##AsmPrinter();
+// this is defined to be LLVM_TARGET(target name 1) LLVM_TARGET(target name 2) ...
+LDC_TARGETS
+#undef LLVM_TARGET
+#endif
+
+    // Check whether the user has explicitly specified an architecture to compile for.
     if (mArch == 0)
     {
         std::string Err;