Define LLVM_NATIVE_ARCH in CMake, so that lli can actually JIT
authorDouglas Gregor <dgregor@apple.com>
Wed, 17 Jun 2009 17:01:56 +0000 (17:01 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 17 Jun 2009 17:01:56 +0000 (17:01 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73616 91177308-0d34-0410-b5e6-96231b3b80d8

cmake/config-ix.cmake
include/llvm/Config/config.h.cmake

index c18ac44172f990dd4ac827093dfa016d3b3c7333..c460fa2aa0581c3400773b11d08cd1995851dfd2 100755 (executable)
@@ -78,6 +78,50 @@ include(GetTargetTriple)
 get_target_triple(LLVM_HOSTTRIPLE)
 message(STATUS "LLVM_HOSTTRIPLE: ${LLVM_HOSTTRIPLE}")
 
+# Determine the native architecture.
+# FIXME: this will have to change for cross-compiling.
+string(REGEX MATCH "^[^-]*" LLVM_NATIVE_ARCH ${LLVM_HOSTTRIPLE})
+if (LLVM_NATIVE_ARCH MATCHES "i[2-6]86")
+  set(LLVM_NATIVE_ARCH X86)
+elseif (LLVM_NATIVE_ARCH STREQUAL amd64)
+  set(LLVM_NATIVE_ARCH X86)
+elseif (LLVM_NATIVE_ARCH STREQUAL x86_64)
+  set(LLVM_NATIVE_ARCH X86)
+elseif (LLVM_NATIVE_ARCH MATCHES "sparc")
+  set(LLVM_NATIVE_ARCH Sparc)
+elseif (LLVM_NATIVE_ARCH MATCHES "powerpc")
+  set(LLVM_NATIVE_ARCH PowerPC)
+elseif (LLVM_NATIVE_ARCH MATCHES "alpha")
+  set(LLVM_NATIVE_ARCH Alpha)
+elseif (LLVM_NATIVE_ARCH MATCHES "ia64")
+  set(LLVM_NATIVE_ARCH IA64)
+elseif (LLVM_NATIVE_ARCH MATCHES "arm")
+  set(LLVM_NATIVE_ARCH ARM)
+elseif (LLVM_NATIVE_ARCH MATCHES "mips")
+  set(LLVM_NATIVE_ARCH Mips)
+elseif (LLVM_NATIVE_ARCH MATCHES "pic16")
+  set(LLVM_NATIVE_ARCH "PIC16")
+elseif (LLVM_NATIVE_ARCH MATCHES "xcore")
+  set(LLVM_NATIVE_ARCH XCore)
+elseif (LLVM_NATIVE_ARCH MATCHES "msp430")
+  set(LLVM_NATIVE_ARCH MSP430)
+else ()
+  message(STATUS 
+    "Unknown architecture ${LLVM_NATIVE_ARCH}; lli will not JIT code")
+  set(LLVM_NATIVE_ARCH)
+endif ()
+  
+if (LLVM_NATIVE_ARCH)
+  list(FIND LLVM_TARGETS_TO_BUILD ${LLVM_NATIVE_ARCH} NATIVE_ARCH_IDX)
+  if (NATIVE_ARCH_IDX EQUAL -1)
+    message(STATUS 
+      "Native target ${LLVM_NATIVE_ARCH} is not selected; lli will not JIT code")
+    set(LLVM_NATIVE_ARCH)
+  else ()
+    message(STATUS "Native target architecture is ${LLVM_NATIVE_ARCH}")
+  endif ()
+endif()
+
 if( MINGW )
   set(HAVE_LIBIMAGEHLP 1)
   set(HAVE_LIBPSAPI 1)
index 33e2e002e231a7be6ac1957f524680a4831dffae..c59ed23d8b25f58743e79a128455048d50f2c1f8 100644 (file)
 
 /* Define to a function implementing strdup */
 #cmakedefine strdup ${strdup}
+
+/* Native LLVM architecture */
+#cmakedefine LLVM_NATIVE_ARCH ${LLVM_NATIVE_ARCH}