Hi list:<br><br>I have been trying to get my feet wet with the ARM backend.<br>As a warmup exercise I wanted to be able to move<br>jumptables especially large ones out of the code section.<br>Currently the idiom for jump tables loooks like this<br>
<br>// .set PCRELV0, (.LJTI9_0_0-(.LPCRELL0+8))<br>// .LPCRELL0:<br>// add r3, pc, #PCRELV0<br>// ldr pc, [r3, +r0, lsl #2]<br>// .LJTI9_0_0:<br>// .long .LBB9_2<br>// .long .LBB9_5<br>
// .long .LBB9_7<br>// .long .LBB9_4<br>// .long .LBB9_8<br><br>I would like to be able to change this to something like:<br><br> ldr r3, .POOL_ADDR<br>
ldr pc, [r3, +r0, lsl #2<br><br>.POOL_ADDR:<br> .text .LJTI9_0_0:<br> <br> .data<br>
.LJTI9_0_0:<br>
.long .LBB9_2<br>
.long .LBB9_5<br>
.long .LBB9_7<br>
.long .LBB9_4<br>
.long .LBB9_8<br> .text<br><br>The code for the lowering lives mostly in SDValue ARMTargetLowering::LowerBR_JT<br>with some more heavy lifting done by ARMISD::WrapperJT<br>My attempts at this are marked in the code below.<br>
My problem is to come up with the right item/value to put into the constant pool.<br><br>SDValue ARMTargetLowering::LowerBR_JT(SDValue Op, SelectionDAG &DAG) {<br> SDValue Chain = Op.getOperand(0);<br> SDValue Table = Op.getOperand(1);<br>
SDValue Index = Op.getOperand(2);<br> DebugLoc dl = Op.getDebugLoc();<br><br> MVT PTy = getPointerTy();<br> JumpTableSDNode *JT = cast<JumpTableSDNode>(Table);<br> ARMFunctionInfo *AFI = DAG.getMachineFunction().getInfo<ARMFunctionInfo>();<br>
SDValue UId = DAG.getConstant(AFI->createJumpTableUId(), PTy);<br> SDValue JTI = DAG.getTargetJumpTable(JT->getIndex(), PTy);<br><br>#if 1 <br>// @@ GET TABLE BASE: current code<br> Table = DAG.getNode(ARMISD::WrapperJT, MVT::i32, JTI, UId);<br>
#else<br> // @ MY ATTEMPT AT MOVING THIS OUT<br> ARMConstantPoolValue *CPV = new ARMConstantPoolValue("a_jump_table", 666);<br> SDValue TableValue = DAG.getTargetConstantPool(CPV, PTy, 2);<br> SDValue CPAddr = DAG.getNode(ARMISD::Wrapper, MVT::i32, TableValue);<br>
Table = DAG.getLoad(PTy, dl, DAG.getEntryNode(), CPAddr, NULL, 0);<br>#endif<br><br> Index = DAG.getNode(ISD::MUL, dl, PTy, Index, DAG.getConstant(4, PTy));<br> //Index = DAG.getNode(ISD::MUL, dl, PTy, TableAddress, DAG.getConstant(4, PTy));<br>
SDValue Addr = DAG.getNode(ISD::ADD, dl, PTy, Index, Table);SDValue APTy, Index, Table);<br><br><br><br>Any help would be greatly appreciated.<br><br>Robert<br>