Skip to content

Commit 6589046

Browse files
[AArch64] Add asm aliases for MOV, LDR, STR with predicate-as-counter
In the 2022-12 release of the A64 ISA it was updated that the assembler must also accept predicate-as-counter register names for the source predicate register and the destination predicate register for: * *MOV: Move predicate (unpredicated)* * *LDR (predicate): Load predicate register* * *STR (predicate): Store predicate register* Reviewed By: sdesmalen Differential Revision: https://reviews.llvm.org/D146311
1 parent 06f1623 commit 6589046

File tree

4 files changed

+69
-8
lines changed

4 files changed

+69
-8
lines changed

llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3844,6 +3844,25 @@ defm WHILEHS_CXX : sve2p1_int_while_rr_pn<"whilehs", 0b100>;
38443844
defm WHILEHI_CXX : sve2p1_int_while_rr_pn<"whilehi", 0b101>;
38453845
defm WHILELO_CXX : sve2p1_int_while_rr_pn<"whilelo", 0b110>;
38463846
defm WHILELS_CXX : sve2p1_int_while_rr_pn<"whilels", 0b111>;
3847+
3848+
3849+
// Aliases for existing SVE instructions for which predicate-as-counter are
3850+
// accepted as an operand to the instruction
3851+
def : InstAlias<"ldr $Pt, [$Rn, $imm9, mul vl]",
3852+
(LDR_PXI PNRAny:$Pt, GPR64sp:$Rn, simm9:$imm9), 0>;
3853+
def : InstAlias<"ldr $Pt, [$Rn]",
3854+
(LDR_PXI PNRAny:$Pt, GPR64sp:$Rn, 0), 0>;
3855+
3856+
def : InstAlias<"str $Pt, [$Rn, $imm9, mul vl]",
3857+
(STR_PXI PNRAny:$Pt, GPR64sp:$Rn, simm9:$imm9), 0>;
3858+
def : InstAlias<"str $Pt, [$Rn]",
3859+
(STR_PXI PNRAny:$Pt, GPR64sp:$Rn, 0), 0>;
3860+
3861+
def : InstAlias<"mov $Pd, $Pn",
3862+
(ORR_PPzPP PNR8:$Pd, PNR8:$Pn, PNR8:$Pn, PNR8:$Pn), 0>;
3863+
3864+
def : InstAlias<"pfalse\t$Pd", (PFALSE PNR8:$Pd), 0>;
3865+
38473866
} // End HasSVE2p1_or_HasSME2
38483867

38493868
//===----------------------------------------------------------------------===//

llvm/lib/Target/AArch64/SVEInstrFormats.td

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -728,8 +728,6 @@ class sve_int_pfalse<bits<6> opc, string asm>
728728
multiclass sve_int_pfalse<bits<6> opc, string asm> {
729729
def NAME : sve_int_pfalse<opc, asm>;
730730

731-
def : InstAlias<"pfalse\t$Pd", (!cast<Instruction>(NAME) PNR8:$Pd), 0>;
732-
733731
def : Pat<(nxv16i1 immAllZerosV), (!cast<Instruction>(NAME))>;
734732
def : Pat<(nxv8i1 immAllZerosV), (!cast<Instruction>(NAME))>;
735733
def : Pat<(nxv4i1 immAllZerosV), (!cast<Instruction>(NAME))>;

llvm/test/MC/AArch64/SVE/pfalse.s

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,3 @@ pfalse p15.b
1414
// CHECK-ENCODING: [0x0f,0xe4,0x18,0x25]
1515
// CHECK-ERROR: instruction requires: sve or sme
1616
// CHECK-UNKNOWN: 2518e40f <unknown>
17-
18-
pfalse pn15.b
19-
// CHECK-INST: pfalse p15.b
20-
// CHECK-ENCODING: [0x0f,0xe4,0x18,0x25]
21-
// CHECK-ERROR: instruction requires: sve or sme
22-
// CHECK-UNKNOWN: 2518e40f <unknown>
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// RUN: llvm-mc -triple=aarch64 -show-encoding -mattr=+sve2p1 < %s \
2+
// RUN: | FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
3+
// RUN: llvm-mc -triple=aarch64 -show-encoding -mattr=+sme2 < %s \
4+
// RUN: | FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
5+
// RUN: not llvm-mc -triple=aarch64 -show-encoding < %s 2>&1 \
6+
// RUN: | FileCheck %s --check-prefix=CHECK-ERROR
7+
// RUN: llvm-mc -triple=aarch64 -filetype=obj -mattr=+sve2p1 < %s \
8+
// RUN: | llvm-objdump --no-print-imm-hex -d --mattr=+sve2p1 - | FileCheck %s --check-prefix=CHECK-INST
9+
// RUN: llvm-mc -triple=aarch64 -filetype=obj -mattr=+sve2p1 < %s \
10+
// RUN: | llvm-objdump --no-print-imm-hex -d --mattr=-sve - | FileCheck %s --check-prefix=CHECK-UNKNOWN
11+
12+
13+
ldr pn0, [x0]
14+
// CHECK-INST: ldr p0, [x0]
15+
// CHECK-ENCODING: [0x00,0x00,0x80,0x85]
16+
// CHECK-ERROR: instruction requires: sme2 or sve2p1
17+
// CHECK-UNKNOWN: 85800000 <unknown>
18+
19+
ldr pn5, [x10, #255, mul vl]
20+
// CHECK-INST: ldr p5, [x10, #255, mul vl]
21+
// CHECK-ENCODING: [0x45,0x1d,0x9f,0x85]
22+
// CHECK-ERROR: instruction requires: sme2 or sve2p1
23+
// CHECK-UNKNOWN: 859f1d45 <unknown>
24+
25+
26+
str pn0, [x0]
27+
// CHECK-INST: str p0, [x0]
28+
// CHECK-ENCODING: [0x00,0x00,0x80,0xe5]
29+
// CHECK-ERROR: instruction requires: sme2 or sve2p1
30+
// CHECK-UNKNOWN: e5800000 <unknown>
31+
32+
str pn5, [x10, #255, mul vl]
33+
// CHECK-INST: str p5, [x10, #255, mul vl]
34+
// CHECK-ENCODING: [0x45,0x1d,0x9f,0xe5]
35+
// CHECK-ERROR: instruction requires: sme2 or sve2p1
36+
// CHECK-UNKNOWN: e59f1d45 <unknown>
37+
38+
39+
mov pn0.b, pn0.b
40+
// CHECK-INST: mov p0.b, p0.b
41+
// CHECK-ENCODING: [0x00,0x40,0x80,0x25]
42+
// CHECK-ERROR: instruction requires: sme2 or sve2p1
43+
// CHECK-UNKNOWN: 25804000 <unknown>
44+
45+
46+
pfalse pn15.b
47+
// CHECK-INST: pfalse p15.b
48+
// CHECK-ENCODING: [0x0f,0xe4,0x18,0x25]
49+
// CHECK-ERROR: instruction requires: sme2 or sve2p1
50+
// CHECK-UNKNOWN: 2518e40f <unknown>

0 commit comments

Comments
 (0)