mirror of
https://github.com/intel/llvm.git
synced 2026-02-05 13:21:04 +08:00
[llvm-exegesis] Initialize all supported targets
Enable registration of multiple exegesis targets at once. Use idiomatic approach to defining target select macros, but leave code in the llvm-mca sub-directories for now. This is a stepping stone towards allowing llvm-exegesis benchmarking via simulator or testing in non-target dependent tests. Differential Revision: https://reviews.llvm.org/D133605
This commit is contained in:
committed by
Philip Reames
parent
32dc1151e2
commit
47afaf2eb0
@@ -878,6 +878,7 @@ set(LLVM_ENUM_ASM_PRINTERS "")
|
||||
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 @@ foreach(t ${LLVM_TARGETS_TO_BUILD})
|
||||
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 @@ configure_file(
|
||||
${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_TOOLS_BINARY_DIR} )
|
||||
|
||||
29
llvm/include/llvm/Config/TargetExegesis.def.in
Normal file
29
llvm/include/llvm/Config/TargetExegesis.def.in
Normal file
@@ -0,0 +1,29 @@
|
||||
/*===----- llvm/Config/TargetExegesis.def - LLVM Target Exegesis-*- C++ -*-===*\
|
||||
|* *|
|
||||
|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
|
||||
|* Exceptions. *|
|
||||
|* See https://llvm.org/LICENSE.txt for license information. *|
|
||||
|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
|
||||
|* *|
|
||||
|*===----------------------------------------------------------------------===*|
|
||||
|* *|
|
||||
|* This file enumerates all of the target's of llvm-exegesis *|
|
||||
|* supported by this build of LLVM. Clients of this file should define *|
|
||||
|* the LLVM_EXEGISIS macro to be a function-like macro with a *|
|
||||
|* single parameter (the name of the target whose assembly can be *|
|
||||
|* generated); including this file will then enumerate all of the *|
|
||||
|* targets with target llvm-exegsis support. *|
|
||||
|* *|
|
||||
|* The set of targets supported by LLVM is generated at configuration *|
|
||||
|* time, at which point this header is generated. Do not modify this *|
|
||||
|* header directly. *|
|
||||
|* *|
|
||||
\*===----------------------------------------------------------------------===*/
|
||||
|
||||
#ifndef LLVM_EXEGESIS
|
||||
# error Please define the macro LLVM_EXEGESIS(TargetName)
|
||||
#endif
|
||||
|
||||
@LLVM_ENUM_EXEGESIS@
|
||||
|
||||
#undef LLVM_EXEGESIS
|
||||
@@ -20,13 +20,7 @@ add_llvm_tool(llvm-exegesis
|
||||
# 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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -302,7 +302,7 @@ void benchmarkMain() {
|
||||
InitializeAllTargetMCs();
|
||||
InitializeAllAsmPrinters();
|
||||
InitializeAllAsmParsers();
|
||||
InitializeNativeExegesisTarget();
|
||||
InitializeAllExegesisTargets();
|
||||
|
||||
const LLVMState State = ExitOnErr(LLVMState::Create("", CpuName));
|
||||
|
||||
@@ -411,10 +411,11 @@ static void analysisMain() {
|
||||
"and --analysis-inconsistencies-output-file must be specified");
|
||||
}
|
||||
|
||||
InitializeNativeTarget();
|
||||
InitializeNativeTargetAsmPrinter();
|
||||
InitializeNativeTargetDisassembler();
|
||||
InitializeNativeExegesisTarget();
|
||||
InitializeAllTargets();
|
||||
InitializeAllTargetMCs();
|
||||
InitializeAllAsmPrinters();
|
||||
InitializeAllDisassemblers();
|
||||
InitializeAllExegesisTargets();
|
||||
|
||||
auto MemoryBuffer = ExitOnFileError(
|
||||
BenchmarkFile,
|
||||
|
||||
Reference in New Issue
Block a user