Skip to content

Commit 946af48

Browse files
committed
[AArch64] Fix GCS{PUSHX|POPCX|POPX} instrs to take an optional register
The Arm Archicture Reference Manual (DDI 0487K.a) says that: * `GCSPUSHX` * `GCSPOPCX` * `GCSPOPX` instructions, which are `SYS` aliases, can take an optional register, e.g. `GCSPUSHX {<Xt>}` Fix the code and tests to allow this to be encoded.
1 parent 7c99601 commit 946af48

File tree

3 files changed

+31
-11
lines changed

3 files changed

+31
-11
lines changed

llvm/lib/Target/AArch64/AArch64InstrInfo.td

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1537,16 +1537,6 @@ def : TokenAlias<"IALL", "iall">;
15371537

15381538

15391539
// ARMv9.4-A Guarded Control Stack
1540-
class GCSNoOp<bits<3> op2, string mnemonic>
1541-
: SimpleSystemI<0, (ins), mnemonic, "">, Sched<[]> {
1542-
let Inst{20-8} = 0b0100001110111;
1543-
let Inst{7-5} = op2;
1544-
let Predicates = [HasGCS];
1545-
}
1546-
def GCSPUSHX : GCSNoOp<0b100, "gcspushx">;
1547-
def GCSPOPCX : GCSNoOp<0b101, "gcspopcx">;
1548-
def GCSPOPX : GCSNoOp<0b110, "gcspopx">;
1549-
15501540
class GCSRtIn<bits<3> op1, bits<3> op2, string mnemonic,
15511541
list<dag> pattern = []>
15521542
: RtSystemI<0, (outs), (ins GPR64:$Rt), mnemonic, "\t$Rt", pattern> {
@@ -1560,8 +1550,17 @@ class GCSRtIn<bits<3> op1, bits<3> op2, string mnemonic,
15601550

15611551
let mayStore = 1, mayLoad = 1 in
15621552
def GCSSS1 : GCSRtIn<0b011, 0b010, "gcsss1">;
1563-
let mayStore = 1 in
1553+
1554+
let mayStore = 1 in {
15641555
def GCSPUSHM : GCSRtIn<0b011, 0b000, "gcspushm">;
1556+
def GCSPUSHX : GCSRtIn<0b000, 0b100, "gcspushx">;
1557+
def GCSPOPCX : GCSRtIn<0b000, 0b101, "gcspopcx">;
1558+
def GCSPOPX : GCSRtIn<0b000, 0b110, "gcspopx">;
1559+
}
1560+
1561+
def GCSPUSHX_NoOp : InstAlias<"gcspushx", (GCSPUSHX XZR)>, Requires<[HasGCS]>; // Rt defaults to XZR if absent
1562+
def GCSPOPCX_NoOp : InstAlias<"gcspopcx", (GCSPOPCX XZR)>, Requires<[HasGCS]>; // Rt defaults to XZR if absent
1563+
def GCSPOPX_NoOp : InstAlias<"gcspopx", (GCSPOPX XZR)>, Requires<[HasGCS]>; // Rt defaults to XZR if absent
15651564

15661565
class GCSRtOut<bits<3> op1, bits<3> op2, string mnemonic,
15671566
list<dag> pattern = []>

llvm/test/MC/AArch64/armv9.4a-gcs.s

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,15 @@ gcspopcx
113113
gcspopx
114114
// CHECK: gcspopx // encoding: [0xdf,0x77,0x08,0xd5]
115115
// ERROR-NO-GCS: [[@LINE-2]]:1: error: instruction requires: gcs
116+
117+
gcspushx x3
118+
// CHECK: gcspushx x3 // encoding: [0x83,0x77,0x08,0xd5]
119+
// ERROR-NO-GCS: [[@LINE-2]]:1: error: instruction requires: gcs
120+
121+
gcspopcx x3
122+
// CHECK: gcspopcx x3 // encoding: [0xa3,0x77,0x08,0xd5]
123+
// ERROR-NO-GCS: [[@LINE-2]]:1: error: instruction requires: gcs
124+
125+
gcspopx x3
126+
// CHECK: gcspopx x3 // encoding: [0xc3,0x77,0x08,0xd5]
127+
// ERROR-NO-GCS: [[@LINE-2]]:1: error: instruction requires: gcs

llvm/test/MC/Disassembler/AArch64/armv9.4a-gcs.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,12 @@
8888

8989
[0xdf,0x77,0x08,0xd5]
9090
// CHECK: gcspopx
91+
92+
[0x83,0x77,0x08,0xd5]
93+
// CHECK: gcspushx x3
94+
95+
[0xa3,0x77,0x08,0xd5]
96+
// CHECK: gcspopcx x3
97+
98+
[0xc3,0x77,0x08,0xd5]
99+
// CHECK: gcspopx x3

0 commit comments

Comments
 (0)