Skip to content

Commit 6194446

Browse files
committed
[AArch64] Add Missing Custom Target Operands
I noticed, when examining the generated Asm Matcher table, that some of these custom immediate operands are missing, and so we are not parsing some hint aliases into the correct MCInst. Where this becomes apparent is when you parse e.g. `hint rust-lang#7` into an MCInst - without these cases, it becomes the MCInst `(HINT 17)`, which will always be printed as `hint rust-lang#17`. With these cases, it becomes the MCInst `XPACLRI`, which will be printed as `xpaclri` with pauth, or `hint rust-lang#17` without, matching how `xpaclri` is parsed. We only handle some specific hint aliases in this manner, usually where these hints have specific effects that need to be modelled for accurate code-generation. Otherwise, we just use the normal `InstAlias` system to have the aliases parsed into a `(HINT N)` MCInst. Differential Revision: https://reviews.llvm.org/D146630
1 parent 82c83d7 commit 6194446

File tree

2 files changed

+53
-3
lines changed

2 files changed

+53
-3
lines changed

llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp

+14-3
Original file line numberDiff line numberDiff line change
@@ -7642,9 +7642,10 @@ unsigned AArch64AsmParser::validateTargetOperandClass(MCParsedAsmOperand &AsmOp,
76427642
return Match_Success;
76437643
return Match_InvalidOperand;
76447644

7645-
// If the kind is a token for a literal immediate, check if our asm
7646-
// operand matches. This is for InstAliases which have a fixed-value
7647-
// immediate in the syntax.
7645+
// If the kind is a token for a literal immediate, check if our asm operand
7646+
// matches. This is for InstAliases which have a fixed-value immediate in
7647+
// the asm string, such as hints which are parsed into a specific
7648+
// instruction definition.
76487649
#define MATCH_HASH(N) \
76497650
case MCK__HASH_##N: \
76507651
return MatchesOpImmediate(N);
@@ -7654,10 +7655,20 @@ unsigned AArch64AsmParser::validateTargetOperandClass(MCParsedAsmOperand &AsmOp,
76547655
MATCH_HASH(3)
76557656
MATCH_HASH(4)
76567657
MATCH_HASH(6)
7658+
MATCH_HASH(7)
76577659
MATCH_HASH(8)
7660+
MATCH_HASH(10)
76587661
MATCH_HASH(12)
7662+
MATCH_HASH(14)
76597663
MATCH_HASH(16)
76607664
MATCH_HASH(24)
7665+
MATCH_HASH(25)
7666+
MATCH_HASH(26)
7667+
MATCH_HASH(27)
7668+
MATCH_HASH(28)
7669+
MATCH_HASH(29)
7670+
MATCH_HASH(30)
7671+
MATCH_HASH(31)
76617672
MATCH_HASH(32)
76627673
MATCH_HASH(40)
76637674
MATCH_HASH(48)

llvm/test/MC/AArch64/armv8.3a-signed-pointer.s

+39
Original file line numberDiff line numberDiff line change
@@ -96,44 +96,83 @@
9696

9797
// ALL-EMPTY:
9898
// ALL-EMPTY:
99+
hint #25
99100
paciasp
100101
// CHECK-NEXT: paciasp // encoding: [0x3f,0x23,0x03,0xd5]
102+
// CHECK-NEXT: paciasp // encoding: [0x3f,0x23,0x03,0xd5]
103+
// NO83-NEXT: hint #25 // encoding: [0x3f,0x23,0x03,0xd5]
101104
// NO83-NEXT: hint #25 // encoding: [0x3f,0x23,0x03,0xd5]
105+
hint #29
102106
autiasp
103107
// CHECK-NEXT: autiasp // encoding: [0xbf,0x23,0x03,0xd5]
108+
// CHECK-NEXT: autiasp // encoding: [0xbf,0x23,0x03,0xd5]
109+
// NO83-NEXT: hint #29 // encoding: [0xbf,0x23,0x03,0xd5]
104110
// NO83-NEXT: hint #29 // encoding: [0xbf,0x23,0x03,0xd5]
111+
hint #24
105112
paciaz
106113
// CHECK-NEXT: paciaz // encoding: [0x1f,0x23,0x03,0xd5]
114+
// CHECK-NEXT: paciaz // encoding: [0x1f,0x23,0x03,0xd5]
115+
// NO83-NEXT: hint #24 // encoding: [0x1f,0x23,0x03,0xd5]
107116
// NO83-NEXT: hint #24 // encoding: [0x1f,0x23,0x03,0xd5]
117+
hint #28
108118
autiaz
109119
// CHECK-NEXT: autiaz // encoding: [0x9f,0x23,0x03,0xd5]
120+
// CHECK-NEXT: autiaz // encoding: [0x9f,0x23,0x03,0xd5]
110121
// NO83-NEXT: hint #28 // encoding: [0x9f,0x23,0x03,0xd5]
122+
// NO83-NEXT: hint #28 // encoding: [0x9f,0x23,0x03,0xd5]
123+
hint #8
111124
pacia1716
112125
// CHECK-NEXT: pacia1716 // encoding: [0x1f,0x21,0x03,0xd5]
126+
// CHECK-NEXT: pacia1716 // encoding: [0x1f,0x21,0x03,0xd5]
127+
// NO83-NEXT: hint #8 // encoding: [0x1f,0x21,0x03,0xd5]
113128
// NO83-NEXT: hint #8 // encoding: [0x1f,0x21,0x03,0xd5]
129+
hint #12
114130
autia1716
115131
// CHECK-NEXT: autia1716 // encoding: [0x9f,0x21,0x03,0xd5]
132+
// CHECK-NEXT: autia1716 // encoding: [0x9f,0x21,0x03,0xd5]
133+
// NO83-NEXT: hint #12 // encoding: [0x9f,0x21,0x03,0xd5]
116134
// NO83-NEXT: hint #12 // encoding: [0x9f,0x21,0x03,0xd5]
135+
hint #27
117136
pacibsp
118137
// CHECK-NEXT: pacibsp // encoding: [0x7f,0x23,0x03,0xd5]
138+
// CHECK-NEXT: pacibsp // encoding: [0x7f,0x23,0x03,0xd5]
119139
// NO83-NEXT: hint #27 // encoding: [0x7f,0x23,0x03,0xd5]
140+
// NO83-NEXT: hint #27 // encoding: [0x7f,0x23,0x03,0xd5]
141+
hint #31
120142
autibsp
121143
// CHECK-NEXT: autibsp // encoding: [0xff,0x23,0x03,0xd5]
144+
// CHECK-NEXT: autibsp // encoding: [0xff,0x23,0x03,0xd5]
122145
// NO83-NEXT: hint #31 // encoding: [0xff,0x23,0x03,0xd5]
146+
// NO83-NEXT: hint #31 // encoding: [0xff,0x23,0x03,0xd5]
147+
hint #26
123148
pacibz
124149
// CHECK-NEXT: pacibz // encoding: [0x5f,0x23,0x03,0xd5]
150+
// CHECK-NEXT: pacibz // encoding: [0x5f,0x23,0x03,0xd5]
125151
// NO83-NEXT: hint #26 // encoding: [0x5f,0x23,0x03,0xd5]
152+
// NO83-NEXT: hint #26 // encoding: [0x5f,0x23,0x03,0xd5]
153+
hint #30
126154
autibz
127155
// CHECK-NEXT: autibz // encoding: [0xdf,0x23,0x03,0xd5]
156+
// CHECK-NEXT: autibz // encoding: [0xdf,0x23,0x03,0xd5]
157+
// NO83-NEXT: hint #30 // encoding: [0xdf,0x23,0x03,0xd5]
128158
// NO83-NEXT: hint #30 // encoding: [0xdf,0x23,0x03,0xd5]
159+
hint #10
129160
pacib1716
130161
// CHECK-NEXT: pacib1716 // encoding: [0x5f,0x21,0x03,0xd5]
162+
// CHECK-NEXT: pacib1716 // encoding: [0x5f,0x21,0x03,0xd5]
163+
// NO83-NEXT: hint #10 // encoding: [0x5f,0x21,0x03,0xd5]
131164
// NO83-NEXT: hint #10 // encoding: [0x5f,0x21,0x03,0xd5]
165+
hint #14
132166
autib1716
133167
// CHECK-NEXT: autib1716 // encoding: [0xdf,0x21,0x03,0xd5]
168+
// CHECK-NEXT: autib1716 // encoding: [0xdf,0x21,0x03,0xd5]
134169
// NO83-NEXT: hint #14 // encoding: [0xdf,0x21,0x03,0xd5]
170+
// NO83-NEXT: hint #14 // encoding: [0xdf,0x21,0x03,0xd5]
171+
hint #7
135172
xpaclri
136173
// CHECK-NEXT: xpaclri // encoding: [0xff,0x20,0x03,0xd5]
174+
// CHECK-NEXT: xpaclri // encoding: [0xff,0x20,0x03,0xd5]
175+
// NO83-NEXT: hint #7 // encoding: [0xff,0x20,0x03,0xd5]
137176
// NO83-NEXT: hint #7 // encoding: [0xff,0x20,0x03,0xd5]
138177

139178
// ALL-EMPTY:

0 commit comments

Comments
 (0)