Index: llvm/CMakeLists.txt =================================================================== --- llvm/CMakeLists.txt +++ llvm/CMakeLists.txt @@ -878,6 +878,7 @@ set(LLVM_ENUM_ASM_PARSERS "") set(LLVM_ENUM_DISASSEMBLERS "") set(LLVM_ENUM_TARGETMCAS "") +set(LLVM_ENUM_EXEGESIS "") foreach(t ${LLVM_TARGETS_TO_BUILD}) set( td ${LLVM_MAIN_SRC_DIR}/lib/Target/${t} ) @@ -907,10 +908,14 @@ set(LLVM_ENUM_DISASSEMBLERS "${LLVM_ENUM_DISASSEMBLERS}LLVM_DISASSEMBLER(${t})\n") endif() - if( EXISTS ${td}/MCA/CMakeLists.txt ) + if( EXISTS ${td}/MCA/CMakeLists.txt ) set(LLVM_ENUM_TARGETMCAS "${LLVM_ENUM_TARGETMCAS}LLVM_TARGETMCA(${t})\n") endif() + if( EXISTS ${LLVM_MAIN_SRC_DIR}/tools/llvm-exegesis/lib/$(t)/CMakeLists.txt ) + set(LLVM_ENUM_EXEGESIS + "${LLVM_ENUM_EXEGESIS}LLVM_EXEGESIS(${t})\n") + endif() endforeach(t) # Provide an LLVM_ namespaced alias for use in #cmakedefine. @@ -938,6 +943,10 @@ ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/TargetMCAs.def.in ${LLVM_INCLUDE_DIR}/llvm/Config/TargetMCAs.def ) +configure_file( + ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/TargetExegesis.def.in + ${LLVM_INCLUDE_DIR}/llvm/Config/TargetExegesis.def + ) # They are not referenced. See set_output_directory(). set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/bin ) Index: llvm/tools/llvm-exegesis/CMakeLists.txt =================================================================== --- llvm/tools/llvm-exegesis/CMakeLists.txt +++ llvm/tools/llvm-exegesis/CMakeLists.txt @@ -20,13 +20,7 @@ # Has side effect of defining LLVM_EXEGESIS_TARGETS add_subdirectory(lib) -# 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}") - 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 +# Link all enabled exegesis targets set(libs) foreach(t ${LLVM_EXEGESIS_TARGETS}) string(STRIP ${t} t) Index: llvm/tools/llvm-exegesis/lib/TargetSelect.h =================================================================== --- llvm/tools/llvm-exegesis/lib/TargetSelect.h +++ llvm/tools/llvm-exegesis/lib/TargetSelect.h @@ -8,30 +8,26 @@ /// /// \file /// -/// Utilities to handle the creation of the native exegesis target. +/// Utilities to handle the creation of the enabled exegesis target(s). /// //===----------------------------------------------------------------------===// #ifndef LLVM_TOOLS_LLVM_EXEGESIS_TARGET_SELECT_H #define LLVM_TOOLS_LLVM_EXEGESIS_TARGET_SELECT_H +#include "llvm/Config/llvm-config.h" + namespace llvm { namespace exegesis { -#ifdef LLVM_EXEGESIS_INITIALIZE_NATIVE_TARGET -void LLVM_EXEGESIS_INITIALIZE_NATIVE_TARGET(); -#endif +// Forward declare all of the initialize methods for targets compiled in +#define LLVM_EXEGESIS(TargetName) void Initialize##TargetName##ExegesisTarget(); +#include "llvm/Config/TargetExegesis.def" -// Initializes the native exegesis target, or returns false if there is no -// native target (either because llvm-exegesis does not support the target or -// because it's not linked in). -inline bool InitializeNativeExegesisTarget() { -#ifdef LLVM_EXEGESIS_INITIALIZE_NATIVE_TARGET - LLVM_EXEGESIS_INITIALIZE_NATIVE_TARGET(); - return true; -#else - return false; -#endif +// Initializes all exegesis targets compiled in. +inline void InitializeAllExegesisTargets() { +#define LLVM_EXEGESIS(TargetName) Initialize##TargetName##ExegesisTarget(); +#include "llvm/Config/TargetExegesis.def" } } // namespace exegesis Index: llvm/tools/llvm-exegesis/llvm-exegesis.cpp =================================================================== --- llvm/tools/llvm-exegesis/llvm-exegesis.cpp +++ llvm/tools/llvm-exegesis/llvm-exegesis.cpp @@ -302,7 +302,7 @@ InitializeAllTargetMCs(); InitializeAllAsmPrinters(); InitializeAllAsmParsers(); - InitializeNativeExegesisTarget(); + InitializeAllExegesisTargets(); const LLVMState State(CpuName); @@ -411,9 +411,10 @@ "and --analysis-inconsistencies-output-file must be specified"); } - InitializeNativeTarget(); - InitializeNativeTargetAsmPrinter(); - InitializeNativeTargetDisassembler(); + InitializeAllTargets(); + InitializeAllTargetMCs(); + InitializeAllAsmPrinters(); + InitializeAllDisassemblers(); // Read benchmarks. const LLVMState State("");