llvm-exegesis is rather odd in the LLVM ecosystem in code is selectively compiled based on the native machine. LLVM is cross compiler by default, so this stands out as odd. It's also less then helpful when working on code for a target other than your native dev environment.
This change only changes the build setup. A later change will enable -march support to allow actual benchmarking under e.g. simulators in a cross compilation environment.
Differential Revision: https://reviews.llvm.org/D133150
set(LLVM_LINK_COMPONENTS
+ AllTargetsAsmParsers
+ AllTargetsCodeGens
+ AllTargetsDescs
+ AllTargetsInfos
MC
MCParser
Support
- native
)
add_llvm_tool(llvm-exegesis
intrinsics_gen
)
+# Has side effect of defining LLVM_EXEGESIS_TARGETS
add_subdirectory(lib)
-# Link the native exegesis target if compiled and on the right host.
-if ((LLVM_TARGETS_TO_BUILD MATCHES "${LLVM_NATIVE_ARCH}") AND (LLVM_EXEGESIS_TARGETS MATCHES "${LLVM_NATIVE_ARCH}"))
+# Register the native target (we don't yet support -march)
+if (LLVM_EXEGESIS_TARGETS MATCHES "${LLVM_NATIVE_ARCH}")
set(LLVM_EXEGESIS_NATIVE_ARCH "${LLVM_NATIVE_ARCH}")
-endif()
-
-if (LLVM_EXEGESIS_NATIVE_ARCH)
- set(LLVM_EXEGESIS_NATIVE_TARGET "LLVMExegesis${LLVM_EXEGESIS_NATIVE_ARCH}")
set_source_files_properties(llvm-exegesis.cpp PROPERTIES COMPILE_FLAGS "-DLLVM_EXEGESIS_INITIALIZE_NATIVE_TARGET=Initialize${LLVM_EXEGESIS_NATIVE_ARCH}ExegesisTarget")
endif()
+# Link the native exegesis targets
+set(libs)
+foreach(t ${LLVM_EXEGESIS_TARGETS})
+ string(STRIP ${t} t)
+ list(APPEND libs "LLVMExegesis${t}")
+endforeach()
+
target_link_libraries(llvm-exegesis PRIVATE
LLVMExegesis
- ${LLVM_EXEGESIS_NATIVE_TARGET}
+ ${libs}
)
-set(TARGETS_TO_APPEND "")
+set(LLVM_EXEGESIS_TARGETS)
if (LLVM_TARGETS_TO_BUILD MATCHES "X86")
- add_subdirectory(X86)
- set(TARGETS_TO_APPEND "${TARGETS_TO_APPEND} X86")
+ list(APPEND LLVM_EXEGESIS_TARGETS "X86")
endif()
if (LLVM_TARGETS_TO_BUILD MATCHES "AArch64")
- add_subdirectory(AArch64)
- set(TARGETS_TO_APPEND "${TARGETS_TO_APPEND} AArch64")
+ list(APPEND LLVM_EXEGESIS_TARGETS "AArch64")
endif()
if (LLVM_TARGETS_TO_BUILD MATCHES "PowerPC")
- add_subdirectory(PowerPC)
- set(TARGETS_TO_APPEND "${TARGETS_TO_APPEND} PowerPC")
+ list(APPEND LLVM_EXEGESIS_TARGETS "PowerPC")
endif()
if (LLVM_TARGETS_TO_BUILD MATCHES "Mips")
- add_subdirectory(Mips)
- set(TARGETS_TO_APPEND "${TARGETS_TO_APPEND} Mips")
+ list(APPEND LLVM_EXEGESIS_TARGETS "Mips")
endif()
-set(LLVM_EXEGESIS_TARGETS "${LLVM_EXEGESIS_TARGETS} ${TARGETS_TO_APPEND}" PARENT_SCOPE)
+set(LLVM_EXEGESIS_TARGETS ${LLVM_EXEGESIS_TARGETS} PARENT_SCOPE)
+
+foreach(t ${LLVM_EXEGESIS_TARGETS})
+ add_subdirectory(${t})
+endforeach()
set(LLVM_LINK_COMPONENTS
Analysis
if (exegesis::pfm::pfmInitialize())
ExitWithError("cannot initialize libpfm");
- InitializeNativeTarget();
- InitializeNativeTargetAsmPrinter();
- InitializeNativeTargetAsmParser();
+ InitializeAllTargets();
+ InitializeAllTargetMCs();
+ InitializeAllAsmPrinters();
+ InitializeAllAsmParsers();
InitializeNativeExegesisTarget();
const LLVMState State(CpuName);