Add a flag to disable jump table generation (all
authorDale Johannesen <dalej@apple.com>
Thu, 31 Jul 2008 18:13:12 +0000 (18:13 +0000)
committerDale Johannesen <dalej@apple.com>
Thu, 31 Jul 2008 18:13:12 +0000 (18:13 +0000)
switches use the binary search algorithm) for
environments that don't support it.  PPC64 JIT
is such an environment; turn the flag on for that.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54248 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Target/TargetOptions.h
lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
lib/Target/PowerPC/PPCISelLowering.cpp
lib/Target/PowerPC/PPCTargetMachine.cpp
lib/Target/TargetMachine.cpp

index a9964f766b135a32211ee2a97dcf55791bc939d2..fa739507db0f05ecbc3e80ba756dc504e5409086 100644 (file)
@@ -97,6 +97,10 @@ namespace llvm {
   /// VerboseAsm - When this flag is set, the asm printer prints additional
   /// comments to asm directives.
   extern bool VerboseAsm;
+
+  /// DisableJumpTables - This flag indicates jump tables should not be 
+  /// generated.
+  extern bool DisableJumpTables;
 } // End llvm namespace
 
 #endif
index 6267eb9fea8ab6e4ea9cb86546807535665720d9..ef90400023c5117990af51f80952129678e93830 100644 (file)
@@ -1916,8 +1916,9 @@ bool SelectionDAGLowering::handleSmallSwitchRange(CaseRec& CR,
 }
 
 static inline bool areJTsAllowed(const TargetLowering &TLI) {
-  return (TLI.isOperationLegal(ISD::BR_JT, MVT::Other) ||
-          TLI.isOperationLegal(ISD::BRIND, MVT::Other));
+  return !DisableJumpTables &&
+          (TLI.isOperationLegal(ISD::BR_JT, MVT::Other) ||
+           TLI.isOperationLegal(ISD::BRIND, MVT::Other));
 }
   
 /// handleJTSwitchCase - Emit jumptable for current switch case range
index 1fe2e8c0ce7854db7a3eeda5886f48cafa846d04..fcf235ccd11c205b8cd388187c462bb7b9efaf47 100644 (file)
@@ -43,7 +43,7 @@ PPCTargetLowering::PPCTargetLowering(PPCTargetMachine &TM)
   : TargetLowering(TM), PPCSubTarget(*TM.getSubtargetImpl()) {
     
   setPow2DivIsCheap();
-  
+
   // Use _setjmp/_longjmp instead of setjmp/longjmp.
   setUseUnderscoreSetJmp(true);
   setUseUnderscoreLongJmp(true);
index 8fa0809c1a79e2afe0448d64a9f0e2dde32b41d6..7c90eca3c44d977818f1f3cd54c53a09c2c82726 100644 (file)
@@ -17,6 +17,7 @@
 #include "llvm/Module.h"
 #include "llvm/PassManager.h"
 #include "llvm/Target/TargetMachineRegistry.h"
+#include "llvm/Target/TargetOptions.h"
 using namespace llvm;
 
 // Register the targets
@@ -144,6 +145,9 @@ bool PPCTargetMachine::addCodeEmitter(PassManagerBase &PM, bool Fast,
     // instructions to materialize arbitrary global variable + function +
     // constant pool addresses.
     setRelocationModel(Reloc::PIC_);
+    // Temporary workaround for the inability of PPC64 JIT to handle jump
+    // tables.
+    DisableJumpTables = true;      
   } else {
     setRelocationModel(Reloc::Static);
   }
index 0764968b23011f2d287c3cc17afd3d04d97ab409..600a120e867c559d70e7eb1ac597ad9de4ade752 100644 (file)
@@ -39,6 +39,7 @@ namespace llvm {
   unsigned StackAlignment;
   bool RealignStack;
   bool VerboseAsm;
+  bool DisableJumpTables;
 }
 
 static cl::opt<bool, true> PrintCode("print-machineinstrs",
@@ -156,6 +157,11 @@ AsmVerbose("asm-verbose", cl::desc("Add comments to directives."),
            cl::location(VerboseAsm),
            cl::init(false));
 
+static cl::opt<bool, true>
+DisableSwitchTables(cl::Hidden, "disable-jump-tables", 
+           cl::desc("Do not generate jump tables."),
+           cl::location(DisableJumpTables),
+           cl::init(false));
 
 //---------------------------------------------------------------------------
 // TargetMachine Class