llvm.org GIT mirror llvm / ddb16df
Add ARM codegen for indirect branches. clang/test/CodeGen/indirect-goto.c runs! (unoptimized) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85577 91177308-0d34-0410-b5e6-96231b3b80d8 Bob Wilson 10 years ago
6 changed file(s) with 23 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
362362 setOperationAction(ISD::ConstantPool, MVT::i32, Custom);
363363 setOperationAction(ISD::GLOBAL_OFFSET_TABLE, MVT::i32, Custom);
364364 setOperationAction(ISD::GlobalTLSAddress, MVT::i32, Custom);
365 setOperationAction(ISD::BlockAddress, MVT::i32, Custom);
365366
366367 // Use the default implementation.
367368 setOperationAction(ISD::VASTART, MVT::Other, Custom);
11821183 return result;
11831184 }
11841185
1185 // ConstantPool, JumpTable, GlobalAddress, and ExternalSymbol are lowered as
1186 // their target counterpart wrapped in the ARMISD::Wrapper node. Suppose N is
1187 // one of the above mentioned nodes. It has to be wrapped because otherwise
1188 // Select(N) returns N. So the raw TargetGlobalAddress nodes, etc. can only
1189 // be used to form addressing mode. These wrapped nodes will be selected
1190 // into MOVi.
1186 // ConstantPool, BlockAddress, JumpTable, GlobalAddress, and ExternalSymbol are
1187 // lowered as their target counterpart wrapped in the ARMISD::Wrapper
1188 // node. Suppose N is one of the above mentioned nodes. It has to be wrapped
1189 // because otherwise Select(N) returns N. So the raw TargetGlobalAddress
1190 // nodes, etc. can only be used to form addressing mode. These wrapped nodes
1191 // will be selected into MOVi.
11911192 static SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG) {
11921193 EVT PtrVT = Op.getValueType();
11931194 // FIXME there is no actual debug info here
12011202 Res = DAG.getTargetConstantPool(CP->getConstVal(), PtrVT,
12021203 CP->getAlignment());
12031204 return DAG.getNode(ARMISD::Wrapper, dl, MVT::i32, Res);
1205 }
1206
1207 SDValue ARMTargetLowering::LowerBlockAddress(SDValue Op, SelectionDAG &DAG) {
1208 DebugLoc DL = Op.getDebugLoc();
1209 BlockAddress *BA = cast(Op)->getBlockAddress();
1210 SDValue Result = DAG.getBlockAddress(BA, DL, /*isTarget=*/true);
1211 return DAG.getNode(ARMISD::Wrapper, DL, getPointerTy(), Result);
12041212 }
12051213
12061214 // Lower ISD::GlobalTLSAddress using the "general dynamic" model
27432751 switch (Op.getOpcode()) {
27442752 default: llvm_unreachable("Don't know how to custom lower this!");
27452753 case ISD::ConstantPool: return LowerConstantPool(Op, DAG);
2754 case ISD::BlockAddress: return LowerBlockAddress(Op, DAG);
27462755 case ISD::GlobalAddress:
27472756 return Subtarget->isTargetDarwin() ? LowerGlobalAddressDarwin(Op, DAG) :
27482757 LowerGlobalAddressELF(Op, DAG);
267267 ISD::ArgFlagsTy Flags);
268268 SDValue LowerINTRINSIC_W_CHAIN(SDValue Op, SelectionDAG &DAG);
269269 SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG);
270 SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG);
270271 SDValue LowerGlobalAddressDarwin(SDValue Op, SelectionDAG &DAG);
271272 SDValue LowerGlobalAddressELF(SDValue Op, SelectionDAG &DAG);
272273 SDValue LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG);
16061606 // ConstantPool, GlobalAddress, and JumpTable
16071607 def : ARMPat<(ARMWrapper tglobaladdr :$dst), (LEApcrel tglobaladdr :$dst)>;
16081608 def : ARMPat<(ARMWrapper tconstpool :$dst), (LEApcrel tconstpool :$dst)>;
1609 def : ARMPat<(ARMWrapper tblockaddress:$dst), (LEApcrel tblockaddress:$dst)>;
16091610 def : ARMPat<(ARMWrapperJT tjumptable:$dst, imm:$id),
16101611 (LEApcrelJT tjumptable:$dst, imm:$id)>;
16111612
675675 // ConstantPool, GlobalAddress
676676 def : T1Pat<(ARMWrapper tglobaladdr :$dst), (tLEApcrel tglobaladdr :$dst)>;
677677 def : T1Pat<(ARMWrapper tconstpool :$dst), (tLEApcrel tconstpool :$dst)>;
678 def : T1Pat<(ARMWrapper tblockaddress:$dst), (tLEApcrel tblockaddress:$dst)>;
678679
679680 // JumpTable
680681 def : T1Pat<(ARMWrapperJT tjumptable:$dst, imm:$id),
11661166 // ConstantPool, GlobalAddress, and JumpTable
11671167 def : T2Pat<(ARMWrapper tglobaladdr :$dst), (t2LEApcrel tglobaladdr :$dst)>;
11681168 def : T2Pat<(ARMWrapper tconstpool :$dst), (t2LEApcrel tconstpool :$dst)>;
1169 def : T2Pat<(ARMWrapper tblockaddress:$dst), (t2LEApcrel tblockaddress:$dst)>;
11691170 def : T2Pat<(ARMWrapperJT tjumptable:$dst, imm:$id),
11701171 (t2LEApcrelJT tjumptable:$dst, imm:$id)>;
11711172
157157 case MachineOperand::MO_ConstantPoolIndex:
158158 MCOp = LowerSymbolOperand(MO, GetConstantPoolIndexSymbol(MO));
159159 break;
160 case MachineOperand::MO_BlockAddress:
161 MCOp = LowerSymbolOperand(MO, Printer.GetBlockAddressSymbol(
162 MO.getBlockAddress()));
163 break;
160164 }
161165
162166 OutMI.addOperand(MCOp);