+
+# FIXME: We don't distinguish the target and the host. :(
+set(TARGET_TRIPLE "${LLVM_HOSTTRIPLE}")
+
+# Determine the native architecture.
+string(TOLOWER "${LLVM_TARGET_ARCH}" LLVM_NATIVE_ARCH)
+if( LLVM_NATIVE_ARCH STREQUAL "host" )
+ string(REGEX MATCH "^[^-]*" LLVM_NATIVE_ARCH ${LLVM_HOSTTRIPLE})
+endif ()
+
+if (LLVM_NATIVE_ARCH MATCHES "i[2-6]86")
+ set(LLVM_NATIVE_ARCH X86)
+elseif (LLVM_NATIVE_ARCH STREQUAL "x86")
+ 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 "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)
+ set(LLVM_NATIVE_ARCHNAME ${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()