in 32-bit pic mode for targets with a GOT, x86 emits jump table
authorChris Lattner <sabre@nondot.org>
Mon, 25 Jan 2010 23:38:14 +0000 (23:38 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 25 Jan 2010 23:38:14 +0000 (23:38 +0000)
entries with @GOTOFF whih is EK_GPRel32BlockAddress.

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

lib/Target/X86/X86ISelLowering.cpp
lib/Target/X86/X86ISelLowering.h

index 02582a044f12931518a54b6073b108a90ec50855..aae17a8cf1bb77536b5a3750510ff76d699d15e2 100644 (file)
@@ -31,6 +31,7 @@
 #include "llvm/CodeGen/MachineFrameInfo.h"
 #include "llvm/CodeGen/MachineFunction.h"
 #include "llvm/CodeGen/MachineInstrBuilder.h"
+#include "llvm/CodeGen/MachineJumpTableInfo.h"
 #include "llvm/CodeGen/MachineModuleInfo.h"
 #include "llvm/CodeGen/MachineRegisterInfo.h"
 #include "llvm/CodeGen/PseudoSourceValue.h"
@@ -1090,6 +1091,20 @@ X86TargetLowering::getOptimalMemOpType(uint64_t Size, unsigned Align,
   return MVT::i32;
 }
 
+/// getJumpTableEncoding - Return the entry encoding for a jump table in the
+/// current function.  The returned value is a member of the
+/// MachineJumpTableInfo::JTEntryKind enum.
+unsigned X86TargetLowering::getJumpTableEncoding() const {
+  // In GOT pic mode, each entry in the jump table is emitted as a @GOTOFF
+  // symbol.
+  if (getTargetMachine().getRelocationModel() == Reloc::PIC_ &&
+      Subtarget->isPICStyleGOT())
+    return MachineJumpTableInfo::EK_GPRel32BlockAddress;
+  
+  // Otherwise, use the normal jump table encoding heuristics.
+  return TargetLowering::getJumpTableEncoding();
+}
+
 /// getPICJumpTableRelocaBase - Returns relocation base for the given PIC
 /// jumptable.
 SDValue X86TargetLowering::getPICJumpTableRelocBase(SDValue Table,
index 11b52257f69b223b028e5d75d77360550485375b..8fc4ec9b33d7efd4b500093a12b858113f514310 100644 (file)
@@ -376,6 +376,8 @@ namespace llvm {
   public:
     explicit X86TargetLowering(X86TargetMachine &TM);
 
+    unsigned getJumpTableEncoding() const;
+
     /// getPICJumpTableRelocaBase - Returns relocation base for the given PIC
     /// jumptable.
     SDValue getPICJumpTableRelocBase(SDValue Table,