diff options
| author | Evan Cheng <evan.cheng@apple.com> | 2007-11-09 01:32:10 +0000 |
|---|---|---|
| committer | Evan Cheng <evan.cheng@apple.com> | 2007-11-09 01:32:10 +0000 |
| commit | 797d56ff17126abcf113a7dbaa02159d9a5a3b06 (patch) | |
| tree | 6c40d111ace6416414baab7f71ba76f4478d1786 /llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp | |
| parent | f14006f4d692ae78ae448ca21e6282c9b75d42f5 (diff) | |
| download | bcm5719-llvm-797d56ff17126abcf113a7dbaa02159d9a5a3b06.tar.gz bcm5719-llvm-797d56ff17126abcf113a7dbaa02159d9a5a3b06.zip | |
Much improved pic jumptable codegen:
Then:
call "L1$pb"
"L1$pb":
popl %eax
...
LBB1_1: # entry
imull $4, %ecx, %ecx
leal LJTI1_0-"L1$pb"(%eax), %edx
addl LJTI1_0-"L1$pb"(%ecx,%eax), %edx
jmpl *%edx
.align 2
.set L1_0_set_3,LBB1_3-LJTI1_0
.set L1_0_set_2,LBB1_2-LJTI1_0
.set L1_0_set_5,LBB1_5-LJTI1_0
.set L1_0_set_4,LBB1_4-LJTI1_0
LJTI1_0:
.long L1_0_set_3
.long L1_0_set_2
Now:
call "L1$pb"
"L1$pb":
popl %eax
...
LBB1_1: # entry
addl LJTI1_0-"L1$pb"(%eax,%ecx,4), %eax
jmpl *%eax
.align 2
.set L1_0_set_3,LBB1_3-"L1$pb"
.set L1_0_set_2,LBB1_2-"L1$pb"
.set L1_0_set_5,LBB1_5-"L1$pb"
.set L1_0_set_4,LBB1_4-"L1$pb"
LJTI1_0:
.long L1_0_set_3
.long L1_0_set_2
llvm-svn: 43924
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp')
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp index 6e58631f0c1..0731299f359 100644 --- a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -1599,21 +1599,17 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) { case 8: LD = DAG.getLoad(MVT::i64, Chain, Addr, NULL, 0); break; } + Addr = LD; 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 - SDOperand Reloc; - if (TLI.usesGlobalOffsetTable()) - Reloc = DAG.getNode(ISD::GLOBAL_OFFSET_TABLE, PTy); - else - Reloc = Table; - Addr = (PTy != MVT::i32) ? DAG.getNode(ISD::SIGN_EXTEND, PTy, LD) : LD; - Addr = DAG.getNode(ISD::ADD, PTy, Addr, Reloc); - Result = DAG.getNode(ISD::BRIND, MVT::Other, LD.getValue(1), Addr); - } else { - Result = DAG.getNode(ISD::BRIND, MVT::Other, LD.getValue(1), LD); + // RelocBase can be JumpTable, GOT or some sort of global base. + if (PTy != MVT::i32) + Addr = DAG.getNode(ISD::SIGN_EXTEND, PTy, Addr); + Addr = DAG.getNode(ISD::ADD, PTy, Addr, + TLI.getPICJumpTableRelocBase(Table, DAG)); } + Result = DAG.getNode(ISD::BRIND, MVT::Other, LD.getValue(1), Addr); } } break; |

