mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-21 03:29:40 +00:00
Add XCore support for indirectbr / blockaddress.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89273 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
74f2ca8c4a
commit
bea7df56ce
@ -333,6 +333,8 @@ void XCoreAsmPrinter::printOperand(const MachineInstr *MI, int opNum) {
|
||||
case MachineOperand::MO_JumpTableIndex:
|
||||
O << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
|
||||
<< '_' << MO.getIndex();
|
||||
case MachineOperand::MO_BlockAddress:
|
||||
GetBlockAddressSymbol(MO.getBlockAddress())->print(O, MAI);
|
||||
break;
|
||||
default:
|
||||
llvm_unreachable("not implemented");
|
||||
|
@ -111,7 +111,8 @@ XCoreTargetLowering::XCoreTargetLowering(XCoreTargetMachine &XTM)
|
||||
setOperationAction(ISD::JumpTable, MVT::i32, Custom);
|
||||
|
||||
setOperationAction(ISD::GlobalAddress, MVT::i32, Custom);
|
||||
|
||||
setOperationAction(ISD::BlockAddress, MVT::i32 , Custom);
|
||||
|
||||
// Thread Local Storage
|
||||
setOperationAction(ISD::GlobalTLSAddress, MVT::i32, Custom);
|
||||
|
||||
@ -158,6 +159,7 @@ LowerOperation(SDValue Op, SelectionDAG &DAG) {
|
||||
{
|
||||
case ISD::GlobalAddress: return LowerGlobalAddress(Op, DAG);
|
||||
case ISD::GlobalTLSAddress: return LowerGlobalTLSAddress(Op, DAG);
|
||||
case ISD::BlockAddress: return LowerBlockAddress(Op, DAG);
|
||||
case ISD::ConstantPool: return LowerConstantPool(Op, DAG);
|
||||
case ISD::JumpTable: return LowerJumpTable(Op, DAG);
|
||||
case ISD::LOAD: return LowerLOAD(Op, DAG);
|
||||
@ -287,6 +289,17 @@ LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG)
|
||||
return DAG.getNode(ISD::ADD, dl, MVT::i32, base, offset);
|
||||
}
|
||||
|
||||
SDValue XCoreTargetLowering::
|
||||
LowerBlockAddress(SDValue Op, SelectionDAG &DAG)
|
||||
{
|
||||
DebugLoc DL = Op.getDebugLoc();
|
||||
|
||||
BlockAddress *BA = cast<BlockAddressSDNode>(Op)->getBlockAddress();
|
||||
SDValue Result = DAG.getBlockAddress(BA, DL, /*isTarget=*/true);
|
||||
|
||||
return DAG.getNode(XCoreISD::PCRelativeWrapper, DL, getPointerTy(), Result);
|
||||
}
|
||||
|
||||
SDValue XCoreTargetLowering::
|
||||
LowerConstantPool(SDValue Op, SelectionDAG &DAG)
|
||||
{
|
||||
|
@ -120,6 +120,7 @@ namespace llvm {
|
||||
SDValue LowerSTORE(SDValue Op, SelectionDAG &DAG);
|
||||
SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG);
|
||||
SDValue LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG);
|
||||
SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG);
|
||||
SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG);
|
||||
SDValue LowerJumpTable(SDValue Op, SelectionDAG &DAG);
|
||||
SDValue LowerSELECT_CC(SDValue Op, SelectionDAG &DAG);
|
||||
|
@ -679,6 +679,12 @@ def LDAP_lu10 : _FLU10<
|
||||
"ldap r11, $addr",
|
||||
[(set R11, (pcrelwrapper tglobaladdr:$addr))]>;
|
||||
|
||||
let Defs = [R11], isReMaterializable = 1 in
|
||||
def LDAP_lu10_ba : _FLU10<(outs),
|
||||
(ins i32imm:$addr),
|
||||
"ldap r11, $addr",
|
||||
[(set R11, (pcrelwrapper tblockaddress:$addr))]>;
|
||||
|
||||
let isCall=1,
|
||||
// All calls clobber the the link register and the non-callee-saved registers:
|
||||
Defs = [R0, R1, R2, R3, R11, LR] in {
|
||||
|
45
test/CodeGen/XCore/indirectbr.ll
Normal file
45
test/CodeGen/XCore/indirectbr.ll
Normal file
@ -0,0 +1,45 @@
|
||||
; RUN: llc < %s -march=xcore | FileCheck %s
|
||||
|
||||
@nextaddr = global i8* null ; <i8**> [#uses=2]
|
||||
@C.0.2070 = private constant [5 x i8*] [i8* blockaddress(@foo, %L1), i8* blockaddress(@foo, %L2), i8* blockaddress(@foo, %L3), i8* blockaddress(@foo, %L4), i8* blockaddress(@foo, %L5)] ; <[5 x i8*]*> [#uses=1]
|
||||
|
||||
define internal i32 @foo(i32 %i) nounwind {
|
||||
; CHECK: foo:
|
||||
entry:
|
||||
%0 = load i8** @nextaddr, align 4 ; <i8*> [#uses=2]
|
||||
%1 = icmp eq i8* %0, null ; <i1> [#uses=1]
|
||||
br i1 %1, label %bb3, label %bb2
|
||||
|
||||
bb2: ; preds = %entry, %bb3
|
||||
%gotovar.4.0 = phi i8* [ %gotovar.4.0.pre, %bb3 ], [ %0, %entry ] ; <i8*> [#uses=1]
|
||||
; CHECK: bau
|
||||
indirectbr i8* %gotovar.4.0, [label %L5, label %L4, label %L3, label %L2, label %L1]
|
||||
|
||||
bb3: ; preds = %entry
|
||||
%2 = getelementptr inbounds [5 x i8*]* @C.0.2070, i32 0, i32 %i ; <i8**> [#uses=1]
|
||||
%gotovar.4.0.pre = load i8** %2, align 4 ; <i8*> [#uses=1]
|
||||
br label %bb2
|
||||
|
||||
L5: ; preds = %bb2
|
||||
br label %L4
|
||||
|
||||
L4: ; preds = %L5, %bb2
|
||||
%res.0 = phi i32 [ 385, %L5 ], [ 35, %bb2 ] ; <i32> [#uses=1]
|
||||
br label %L3
|
||||
|
||||
L3: ; preds = %L4, %bb2
|
||||
%res.1 = phi i32 [ %res.0, %L4 ], [ 5, %bb2 ] ; <i32> [#uses=1]
|
||||
br label %L2
|
||||
|
||||
L2: ; preds = %L3, %bb2
|
||||
%res.2 = phi i32 [ %res.1, %L3 ], [ 1, %bb2 ] ; <i32> [#uses=1]
|
||||
%phitmp = mul i32 %res.2, 6 ; <i32> [#uses=1]
|
||||
br label %L1
|
||||
|
||||
L1: ; preds = %L2, %bb2
|
||||
%res.3 = phi i32 [ %phitmp, %L2 ], [ 2, %bb2 ] ; <i32> [#uses=1]
|
||||
; CHECK: ldap r11, .LBA3_foo_L5
|
||||
; CHECK: stw r11, dp[nextaddr]
|
||||
store i8* blockaddress(@foo, %L5), i8** @nextaddr, align 4
|
||||
ret i32 %res.3
|
||||
}
|
Loading…
Reference in New Issue
Block a user