Skip to content

Commit 1034262

Browse files
committed
[VE] Support TargetBlockAddress
Change to handle TargetBlockAddress and add a regression test for it. Reviewed By: simoll Differential Revision: https://reviews.llvm.org/D88576
1 parent 05ae04c commit 1034262

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

llvm/lib/Target/VE/VEInstrInfo.td

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,6 +1661,14 @@ def : Pat<(add (VEhi tglobaladdr:$in1), (VElo tglobaladdr:$in2)),
16611661
(LEASLrii (ANDrm (LEAzii 0, 0, tglobaladdr:$in2), !add(32, 64)), 0,
16621662
(tglobaladdr:$in1))>;
16631663

1664+
// Address calculation and its optimization
1665+
def : Pat<(VEhi tblockaddress:$in), (LEASLzii 0, 0, tblockaddress:$in)>;
1666+
def : Pat<(VElo tblockaddress:$in),
1667+
(ANDrm (LEAzii 0, 0, tblockaddress:$in), !add(32, 64))>;
1668+
def : Pat<(add (VEhi tblockaddress:$in1), (VElo tblockaddress:$in2)),
1669+
(LEASLrii (ANDrm (LEAzii 0, 0, tblockaddress:$in2), !add(32, 64)), 0,
1670+
(tblockaddress:$in1))>;
1671+
16641672
// GlobalTLS address calculation and its optimization
16651673
def : Pat<(VEhi tglobaltlsaddr:$in), (LEASLzii 0, 0, tglobaltlsaddr:$in)>;
16661674
def : Pat<(VElo tglobaltlsaddr:$in),

llvm/lib/Target/VE/VEMCInstLower.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ static MCOperand LowerOperand(const MachineInstr *MI, const MachineOperand &MO,
5151
break;
5252
return MCOperand::createReg(MO.getReg());
5353

54+
case MachineOperand::MO_BlockAddress:
55+
return LowerSymbolOperand(
56+
MI, MO, AP.GetBlockAddressSymbol(MO.getBlockAddress()), AP);
5457
case MachineOperand::MO_ConstantPoolIndex:
5558
return LowerSymbolOperand(MI, MO, AP.GetCPISymbol(MO.getIndex()), AP);
5659
case MachineOperand::MO_ExternalSymbol:

llvm/test/CodeGen/VE/blockaddress.ll

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
; RUN: llc < %s -mtriple=ve | FileCheck %s
2+
3+
@addr = global i8* null, align 8
4+
5+
; Function Attrs: nofree norecurse nounwind writeonly
6+
define void @test() {
7+
; CHECK-LABEL: test:
8+
; CHECK: .LBB0_3: # %entry
9+
; CHECK-NEXT: .Ltmp0: # Block address taken
10+
; CHECK-NEXT: # %bb.1: # %test1
11+
; CHECK-NEXT: lea %s0, addr@lo
12+
; CHECK-NEXT: and %s0, %s0, (32)0
13+
; CHECK-NEXT: lea.sl %s0, addr@hi(, %s0)
14+
; CHECK-NEXT: lea %s1, .Ltmp0@lo
15+
; CHECK-NEXT: and %s1, %s1, (32)0
16+
; CHECK-NEXT: lea.sl %s1, .Ltmp0@hi(, %s1)
17+
; CHECK-NEXT: st %s1, (, %s0)
18+
; CHECK-NEXT: or %s11, 0, %s9
19+
entry:
20+
br label %test1
21+
22+
test1:
23+
store i8* blockaddress(@test, %test1), i8** @addr, align 8
24+
ret void
25+
}

0 commit comments

Comments
 (0)