[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp

Jim Laskey jlaskey at apple.com
Thu Dec 14 11:17:52 PST 2006



Changes in directory llvm/lib/CodeGen/SelectionDAG:

LegalizeDAG.cpp updated: 1.440 -> 1.441
---
Log message:

1. Tidy up jump table info.
2. Allow the jit to handle PIC relocable jump tables.


---
Diffs of the changes:  (+12 -5)

 LegalizeDAG.cpp |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)


Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.440 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.441
--- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.440	Wed Dec 13 14:57:08 2006
+++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp	Thu Dec 14 13:17:33 2006
@@ -14,6 +14,7 @@
 #include "llvm/CodeGen/SelectionDAG.h"
 #include "llvm/CodeGen/MachineFunction.h"
 #include "llvm/CodeGen/MachineFrameInfo.h"
+#include "llvm/CodeGen/MachineJumpTableInfo.h"
 #include "llvm/Target/TargetLowering.h"
 #include "llvm/Target/TargetData.h"
 #include "llvm/Target/TargetMachine.h"
@@ -1275,13 +1276,19 @@
       SDOperand Index = Result.getOperand(2);
 
       MVT::ValueType PTy = TLI.getPointerTy();
-      bool isPIC = TLI.getTargetMachine().getRelocationModel() == Reloc::PIC_;
-      // PIC jump table entries are 32-bit values.
-      unsigned EntrySize = isPIC ? 4 : MVT::getSizeInBits(PTy)/8;
+      MachineFunction &MF = DAG.getMachineFunction();
+      unsigned EntrySize = MF.getJumpTableInfo()->getEntrySize();
       Index= DAG.getNode(ISD::MUL, PTy, Index, DAG.getConstant(EntrySize, PTy));
       SDOperand Addr = DAG.getNode(ISD::ADD, PTy, Index, Table);
-      SDOperand LD = DAG.getLoad(isPIC ? MVT::i32 : PTy, Chain, Addr, NULL, 0);
-      if (isPIC) {
+      
+      SDOperand LD;
+      switch (EntrySize) {
+      default: assert(0 && "Size of jump table not supported yet."); break;
+      case 4: LD = DAG.getLoad(MVT::i32, Chain, Addr, NULL, 0); break;
+      case 8: LD = DAG.getLoad(MVT::i64, Chain, Addr, NULL, 0); break;
+      }
+
+      if (TLI.getTargetMachine().getRelocationModel() == Reloc::PIC_) {
         // For PIC, the sequence is:
         // BRIND(load(Jumptable + index) + RelocBase)
         // RelocBase is the JumpTable on PPC and X86, GOT on Alpha






More information about the llvm-commits mailing list