[AArch64] Change the CMake to avoid to build GlobalISel related APIs
authorQuentin Colombet <qcolombet@apple.com>
Wed, 6 Apr 2016 17:38:12 +0000 (17:38 +0000)
committerQuentin Colombet <qcolombet@apple.com>
Wed, 6 Apr 2016 17:38:12 +0000 (17:38 +0000)
when GISel is not built.
The positive side effects are:
- We do not have to define dummy implementation
- We do not have to do weird gymnastic to avoid like issues (like
  missing constructor or vtable for the base classes)

llvm-svn: 265570

llvm/lib/Target/AArch64/AArch64RegisterBankInfo.cpp
llvm/lib/Target/AArch64/CMakeLists.txt

index 9f8d4d5..83dccda 100644 (file)
 using namespace llvm;
 
 #ifndef LLVM_BUILD_GLOBAL_ISEL
-AArch64RegisterBankInfo::AArch64RegisterBankInfo(const TargetRegisterInfo &TRI)
-    : RegisterBankInfo() {
-  llvm_unreachable("This API shouldn't be useful outside of GlobalISel");
-}
+#error You shouldn't build this
+#endif
 
-unsigned AArch64RegisterBankInfo::copyCost(const RegisterBank &A,
-                                           const RegisterBank &B) const {
-  return 0;
-}
-#else
 AArch64RegisterBankInfo::AArch64RegisterBankInfo(const TargetRegisterInfo &TRI)
     : RegisterBankInfo(AArch64::NumRegisterBanks) {
   // Initialize the GPR bank.
@@ -70,4 +63,3 @@ unsigned AArch64RegisterBankInfo::copyCost(const RegisterBank &A,
   // * build_sequence cost.
   return 0;
 }
-#endif
index 37e2e64..0f2c55c 100644 (file)
@@ -14,18 +14,20 @@ tablegen(LLVM AArch64GenSubtargetInfo.inc -gen-subtarget)
 tablegen(LLVM AArch64GenDisassemblerTables.inc -gen-disassembler)
 add_public_tablegen_target(AArch64CommonTableGen)
 
+# List of all GlobalISel files.
 set(GLOBAL_ISEL_FILES
-  AArch64RegisterBankInfo.cpp
-  )
+      AArch64RegisterBankInfo.cpp
+      )
 
-if(NOT LLVM_BUILD_GLOBAL_ISEL)
-  set(LLVM_OPTIONAL_SOURCES ${GLOBAL_ISEL_FILES})
-  set(GLOBAL_ISEL_FILES)
+# Add GlobalISel files to the dependencies if the user wants to build it.
+if(LLVM_BUILD_GLOBAL_ISEL)
+  set(GLOBAL_ISEL_BUILD_FILES ${GLOBAL_ISEL_FILES})
+else()
+  set(GLOBAL_ISEL_BUILD_FILES"")
+  set(LLVM_OPTIONAL_SOURCES LLVMGlobalISel ${GLOBAL_ISEL_FILES})
 endif()
 
 
-set(LLVM_OPTIONAL_SOURCES AArch64RegisterBankInfo.cpp)
-
 add_llvm_target(AArch64CodeGen
   AArch64A57FPLoadBalancing.cpp
   AArch64AddressTypePromotion.cpp
@@ -57,7 +59,7 @@ add_llvm_target(AArch64CodeGen
   AArch64TargetMachine.cpp
   AArch64TargetObjectFile.cpp
   AArch64TargetTransformInfo.cpp
-  ${GLOBAL_ISEL_FILES}
+  ${GLOBAL_ISEL_BUILD_FILES}
 )
 
 add_dependencies(LLVMAArch64CodeGen intrinsics_gen)