[BOLT][PR] Target compilation based on LLVM CMake configuration

Summary:

Minimalist implementation of target configurable compilation.

Fixes https://github.com/facebookincubator/BOLT/issues/59
Pull Request resolved: https://github.com/facebookincubator/BOLT/pull/60
GitHub Author: Pierre RAMOIN <pierre.ramoin@amadeus.com>

(cherry picked from FBD16461879)
This commit is contained in:
Facebook Github Bot 2019-07-24 11:05:08 -07:00 committed by Maksim Panchenko
parent 2c9c6b164b
commit 86800abc81
2 changed files with 30 additions and 9 deletions

View File

@ -48,8 +48,6 @@ add_public_gen_version_target(GenBoltRevision)
set(LLVM_LINK_COMPONENTS set(LLVM_LINK_COMPONENTS
${LLVM_TARGETS_TO_BUILD} ${LLVM_TARGETS_TO_BUILD}
BOLTPasses BOLTPasses
BOLTTargetAArch64
BOLTTargetX86
CodeGen CodeGen
Core Core
DebugInfoDWARF DebugInfoDWARF
@ -61,6 +59,18 @@ set(LLVM_LINK_COMPONENTS
Support Support
) )
string(FIND "${LLVM_TARGETS_TO_BUILD}" "AArch64" POSITION)
if (NOT ${POSITION} EQUAL -1)
list(APPEND LLVM_LINK_COMPONENTS BOLTTargetAArch64)
set(BOLT_AArcb64 On)
endif()
string(FIND "${LLVM_TARGETS_TO_BUILD}" "X86" POSITION)
if (NOT ${POSITION} EQUAL -1)
list(APPEND LLVM_LINK_COMPONENTS BOLTTargetX86)
set(BOLT_X64 On)
endif()
add_llvm_tool(llvm-bolt add_llvm_tool(llvm-bolt
llvm-bolt.cpp llvm-bolt.cpp
BinaryBasicBlock.cpp BinaryBasicBlock.cpp
@ -93,6 +103,14 @@ add_llvm_tool(llvm-bolt
intrinsics_gen intrinsics_gen
) )
if (DEFINED BOLT_AArcb64)
target_compile_definitions(llvm-bolt PRIVATE AARCH64_AVAILABLE)
endif()
if (DEFINED BOLT_X64)
target_compile_definitions(llvm-bolt PRIVATE X86_AVAILABLE)
endif()
add_llvm_tool_symlink(perf2bolt llvm-bolt) add_llvm_tool_symlink(perf2bolt llvm-bolt)
add_llvm_tool_symlink(llvm-boltdiff llvm-bolt) add_llvm_tool_symlink(llvm-boltdiff llvm-bolt)
add_llvm_tool_symlink(llvm-bolt-heatmap llvm-bolt) add_llvm_tool_symlink(llvm-bolt-heatmap llvm-bolt)

View File

@ -535,15 +535,18 @@ namespace {
MCPlusBuilder *createMCPlusBuilder(const Triple::ArchType Arch, MCPlusBuilder *createMCPlusBuilder(const Triple::ArchType Arch,
const MCInstrAnalysis *Analysis, const MCInstrInfo *Info, const MCInstrAnalysis *Analysis, const MCInstrInfo *Info,
const MCRegisterInfo *RegInfo) { const MCRegisterInfo *RegInfo) {
if (Arch == Triple::x86_64) { #ifdef X86_AVAILABLE
if (Arch == Triple::x86_64)
return createX86MCPlusBuilder(Analysis, Info, RegInfo); return createX86MCPlusBuilder(Analysis, Info, RegInfo);
} else if (Arch == Triple::aarch64) { #endif
return createAArch64MCPlusBuilder(Analysis, Info, RegInfo);
} else {
llvm_unreachable("architecture unsupport by MCPlusBuilder");
}
}
#ifdef AARCH64_AVAILABLE
if (Arch == Triple::aarch64)
return createAArch64MCPlusBuilder(Analysis, Info, RegInfo);
#endif
llvm_unreachable("architecture unsupport by MCPlusBuilder");
}
} }
constexpr const char *RewriteInstance::SectionsToOverwrite[]; constexpr const char *RewriteInstance::SectionsToOverwrite[];