diff options
author | Evan Cheng <evan.cheng@apple.com> | 2006-08-01 01:03:13 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2006-08-01 01:03:13 +0000 |
commit | 8825a485e2e99216adc0c469a7c43895cd4eae40 (patch) | |
tree | 12c7f3f8c41fd840b2eec831dd8bd894d2902730 | |
parent | 03ed625c66745073adf1799f83ec8af651d15d8d (diff) | |
download | external_llvm-8825a485e2e99216adc0c469a7c43895cd4eae40.zip external_llvm-8825a485e2e99216adc0c469a7c43895cd4eae40.tar.gz external_llvm-8825a485e2e99216adc0c469a7c43895cd4eae40.tar.bz2 |
PIC jump table entries are always 32-bit even in 64-bit mode.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29422 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index f3c9802..4327e47 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -846,15 +846,22 @@ void SelectionDAGLowering::visitJumpTable(SelectionDAGISel::JumpTable &JT) { // Emit the code for the jump table MVT::ValueType PTy = TLI.getPointerTy(); - unsigned PTyBytes = MVT::getSizeInBits(PTy)/8; + assert((PTy == MVT::i32 || PTy == MVT::i64) && + "Jump table entries are 32-bit values"); + // PIC jump table entries are 32-bit values. + unsigned EntrySize = + (TLI.getTargetMachine().getRelocationModel() == Reloc::PIC_) + ? 4 : MVT::getSizeInBits(PTy)/8; SDOperand Copy = DAG.getCopyFromReg(getRoot(), JT.Reg, PTy); SDOperand IDX = DAG.getNode(ISD::MUL, PTy, Copy, - DAG.getConstant(PTyBytes, PTy)); + DAG.getConstant(EntrySize, PTy)); SDOperand TAB = DAG.getJumpTable(JT.JTI,PTy); SDOperand ADD = DAG.getNode(ISD::ADD, PTy, IDX, TAB); - SDOperand LD = DAG.getLoad(PTy, Copy.getValue(1), ADD, DAG.getSrcValue(0)); + SDOperand LD = DAG.getLoad(MVT::i32, Copy.getValue(1), ADD, + DAG.getSrcValue(0)); if (TLI.getTargetMachine().getRelocationModel() == Reloc::PIC_) { - ADD = DAG.getNode(ISD::ADD, PTy, LD.getValue(0), TAB); + ADD = DAG.getNode(ISD::ADD, PTy, + ((PTy != MVT::i32) ? DAG.getNode(ISD::SIGN_EXTEND, PTy, LD) : LD), TAB); DAG.setRoot(DAG.getNode(ISD::BRIND, MVT::Other, LD.getValue(1), ADD)); } else { DAG.setRoot(DAG.getNode(ISD::BRIND, MVT::Other, LD.getValue(1), LD)); |