Index: lib/Target/AArch64/AArch64InstructionSelector.h =================================================================== --- lib/Target/AArch64/AArch64InstructionSelector.h +++ lib/Target/AArch64/AArch64InstructionSelector.h @@ -11,8 +11,6 @@ /// AArch64. //===----------------------------------------------------------------------===// -#ifdef LLVM_BUILD_GLOBAL_ISEL - #ifndef LLVM_LIB_TARGET_AARCH64_AARCH64INSTRUCTIONSELECTOR_H #define LLVM_LIB_TARGET_AARCH64_AARCH64INSTRUCTIONSELECTOR_H @@ -68,4 +66,3 @@ } // end namespace llvm #endif // LLVM_LIB_TARGET_AARCH64_AARCH64INSTRUCTIONSELECTOR_H -#endif // LLVM_BUILD_GLOBAL_ISEL Index: lib/Target/AArch64/CMakeLists.txt =================================================================== --- lib/Target/AArch64/CMakeLists.txt +++ lib/Target/AArch64/CMakeLists.txt @@ -15,8 +15,9 @@ tablegen(LLVM AArch64GenSystemOperands.inc -gen-searchable-tables) if(LLVM_BUILD_GLOBAL_ISEL) tablegen(LLVM AArch64GenRegisterBank.inc FORMAT OPTIONS -gen-register-bank) - tablegen(LLVM AArch64GenGlobalISel.inc FORMAT OPTIONS -gen-global-isel) endif() +# -gen-global-isel handles LLVM_BUILD_GLOBAL_ISEL internally. +tablegen(LLVM AArch64GenGlobalISel.inc FORMAT OPTIONS -gen-global-isel) add_public_tablegen_target(AArch64CommonTableGen) Index: lib/Target/X86/CMakeLists.txt =================================================================== --- lib/Target/X86/CMakeLists.txt +++ lib/Target/X86/CMakeLists.txt @@ -13,8 +13,9 @@ tablegen(LLVM X86GenEVEX2VEXTables.inc -gen-x86-EVEX2VEX-tables) if(LLVM_BUILD_GLOBAL_ISEL) tablegen(LLVM X86GenRegisterBank.inc -gen-register-bank) - tablegen(LLVM X86GenGlobalISel.inc -gen-global-isel) endif() +# -gen-global-isel handles LLVM_BUILD_GLOBAL_ISEL internally. +tablegen(LLVM X86GenGlobalISel.inc -gen-global-isel) add_public_tablegen_target(X86CommonTableGen) Index: lib/Target/X86/X86InstructionSelector.h =================================================================== --- lib/Target/X86/X86InstructionSelector.h +++ lib/Target/X86/X86InstructionSelector.h @@ -10,7 +10,6 @@ /// This file declares the targeting of the InstructionSelector class for X86. //===----------------------------------------------------------------------===// -#ifdef LLVM_BUILD_GLOBAL_ISEL #ifndef LLVM_LIB_TARGET_X86_X86INSTRUCTIONSELECTOR_H #define LLVM_LIB_TARGET_X86_X86INSTRUCTIONSELECTOR_H @@ -60,4 +59,3 @@ } // end namespace llvm #endif // LLVM_LIB_TARGET_X86_X86INSTRUCTIONSELECTOR_H -#endif // LLVM_BUILD_GLOBAL_ISEL Index: utils/TableGen/GlobalISelEmitter.cpp =================================================================== --- utils/TableGen/GlobalISelEmitter.cpp +++ utils/TableGen/GlobalISelEmitter.cpp @@ -59,6 +59,9 @@ cl::desc("Explain why a pattern was skipped for inclusion " "in the GlobalISel selector"), cl::init(false), cl::cat(GlobalISelEmitterCat)); +static cl::opt BuildGlobalISelEnabled( + "build-global-isel", cl::desc("Is GlobalISel enabled for the compiler"), + cl::init(LLVM_BUILD_GLOBAL_ISEL), cl::cat(GlobalISelEmitterCat)); //===- Helper functions ---------------------------------------------------===// @@ -1146,6 +1149,22 @@ emitSourceFileHeader(("Global Instruction Selector for the " + Target.getName() + " target").str(), OS); + + if (!BuildGlobalISelEnabled) { + OS << "// GlobalISel is not enabled. See the -build-global-isel option\n" + "// and/or the cmake variable LLVM_BUILD_GLOBAL_ISEL which controls\n" + "// the default value of -build-global-isel\n"; + + OS << "#ifdef GET_GLOBALISEL_IMPL\n" + << "bool " << Target.getName() + << "InstructionSelector::selectImpl(MachineInstr &I) const {\n" + << " return false;\n" + << "}\n" + << "#endif // GET_GLOBALISEL_IMPL\n"; + + return; + } + std::vector Rules; // Look through the SelectionDAG patterns we found, possibly emitting some. for (const PatternToMatch &Pat : CGP.ptms()) {