[llvm] 6194446 - [AArch64] Add Missing Custom Target Operands

Archibald Elliott via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 23 08:15:27 PDT 2023


Author: Archibald Elliott
Date: 2023-03-23T15:14:07Z
New Revision: 61944469625d4b3ba4a87f4f8fffefb73e9f8cdc

URL: https://github.com/llvm/llvm-project/commit/61944469625d4b3ba4a87f4f8fffefb73e9f8cdc
DIFF: https://github.com/llvm/llvm-project/commit/61944469625d4b3ba4a87f4f8fffefb73e9f8cdc.diff

LOG: [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 #7` into an
MCInst - without these cases, it becomes the MCInst `(HINT 17)`, which
will always be printed as `hint #17`. With these cases, it becomes the
MCInst `XPACLRI`, which will be printed as `xpaclri` with pauth, or
`hint #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

Added: 
    

Modified: 
    llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
    llvm/test/MC/AArch64/armv8.3a-signed-pointer.s

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
index d5162d39ce43c..b0c554780edfd 100644
--- a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
+++ b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
@@ -7642,9 +7642,10 @@ unsigned AArch64AsmParser::validateTargetOperandClass(MCParsedAsmOperand &AsmOp,
       return Match_Success;
     return Match_InvalidOperand;
 
-    // If the kind is a token for a literal immediate, check if our asm
-    // operand matches. This is for InstAliases which have a fixed-value
-    // immediate in the syntax.
+    // If the kind is a token for a literal immediate, check if our asm operand
+    // matches. This is for InstAliases which have a fixed-value immediate in
+    // the asm string, such as hints which are parsed into a specific
+    // instruction definition.
 #define MATCH_HASH(N)                                                          \
   case MCK__HASH_##N:                                                          \
     return MatchesOpImmediate(N);
@@ -7654,10 +7655,20 @@ unsigned AArch64AsmParser::validateTargetOperandClass(MCParsedAsmOperand &AsmOp,
     MATCH_HASH(3)
     MATCH_HASH(4)
     MATCH_HASH(6)
+    MATCH_HASH(7)
     MATCH_HASH(8)
+    MATCH_HASH(10)
     MATCH_HASH(12)
+    MATCH_HASH(14)
     MATCH_HASH(16)
     MATCH_HASH(24)
+    MATCH_HASH(25)
+    MATCH_HASH(26)
+    MATCH_HASH(27)
+    MATCH_HASH(28)
+    MATCH_HASH(29)
+    MATCH_HASH(30)
+    MATCH_HASH(31)
     MATCH_HASH(32)
     MATCH_HASH(40)
     MATCH_HASH(48)

diff  --git a/llvm/test/MC/AArch64/armv8.3a-signed-pointer.s b/llvm/test/MC/AArch64/armv8.3a-signed-pointer.s
index dad4bc667853b..e13b1bf3c98d8 100644
--- a/llvm/test/MC/AArch64/armv8.3a-signed-pointer.s
+++ b/llvm/test/MC/AArch64/armv8.3a-signed-pointer.s
@@ -96,44 +96,83 @@
 
 // ALL-EMPTY:
 // ALL-EMPTY:
+  hint #25
   paciasp
 // CHECK-NEXT: paciasp        // encoding: [0x3f,0x23,0x03,0xd5]
+// CHECK-NEXT: paciasp        // encoding: [0x3f,0x23,0x03,0xd5]
+// NO83-NEXT: hint #25        // encoding: [0x3f,0x23,0x03,0xd5]
 // NO83-NEXT: hint #25        // encoding: [0x3f,0x23,0x03,0xd5]
+  hint #29
   autiasp
 // CHECK-NEXT: autiasp        // encoding: [0xbf,0x23,0x03,0xd5]
+// CHECK-NEXT: autiasp        // encoding: [0xbf,0x23,0x03,0xd5]
+// NO83-NEXT: hint #29        // encoding: [0xbf,0x23,0x03,0xd5]
 // NO83-NEXT: hint #29        // encoding: [0xbf,0x23,0x03,0xd5]
+  hint #24
   paciaz
 // CHECK-NEXT: paciaz         // encoding: [0x1f,0x23,0x03,0xd5]
+// CHECK-NEXT: paciaz         // encoding: [0x1f,0x23,0x03,0xd5]
+// NO83-NEXT: hint #24        // encoding: [0x1f,0x23,0x03,0xd5]
 // NO83-NEXT: hint #24        // encoding: [0x1f,0x23,0x03,0xd5]
+  hint #28
   autiaz
 // CHECK-NEXT: autiaz         // encoding: [0x9f,0x23,0x03,0xd5]
+// CHECK-NEXT: autiaz         // encoding: [0x9f,0x23,0x03,0xd5]
 // NO83-NEXT: hint #28        // encoding: [0x9f,0x23,0x03,0xd5]
+// NO83-NEXT: hint #28        // encoding: [0x9f,0x23,0x03,0xd5]
+  hint #8
   pacia1716
 // CHECK-NEXT: pacia1716      // encoding: [0x1f,0x21,0x03,0xd5]
+// CHECK-NEXT: pacia1716      // encoding: [0x1f,0x21,0x03,0xd5]
+// NO83-NEXT: hint #8         // encoding: [0x1f,0x21,0x03,0xd5]
 // NO83-NEXT: hint #8         // encoding: [0x1f,0x21,0x03,0xd5]
+  hint #12
   autia1716
 // CHECK-NEXT: autia1716      // encoding: [0x9f,0x21,0x03,0xd5]
+// CHECK-NEXT: autia1716      // encoding: [0x9f,0x21,0x03,0xd5]
+// NO83-NEXT: hint #12        // encoding: [0x9f,0x21,0x03,0xd5]
 // NO83-NEXT: hint #12        // encoding: [0x9f,0x21,0x03,0xd5]
+  hint #27
   pacibsp
 // CHECK-NEXT: pacibsp        // encoding: [0x7f,0x23,0x03,0xd5]
+// CHECK-NEXT: pacibsp        // encoding: [0x7f,0x23,0x03,0xd5]
 // NO83-NEXT: hint #27        // encoding: [0x7f,0x23,0x03,0xd5]
+// NO83-NEXT: hint #27        // encoding: [0x7f,0x23,0x03,0xd5]
+  hint #31
   autibsp
 // CHECK-NEXT: autibsp        // encoding: [0xff,0x23,0x03,0xd5]
+// CHECK-NEXT: autibsp        // encoding: [0xff,0x23,0x03,0xd5]
 // NO83-NEXT: hint #31        // encoding: [0xff,0x23,0x03,0xd5]
+// NO83-NEXT: hint #31        // encoding: [0xff,0x23,0x03,0xd5]
+  hint #26
   pacibz
 // CHECK-NEXT: pacibz         // encoding: [0x5f,0x23,0x03,0xd5]
+// CHECK-NEXT: pacibz         // encoding: [0x5f,0x23,0x03,0xd5]
 // NO83-NEXT: hint #26        // encoding: [0x5f,0x23,0x03,0xd5]
+// NO83-NEXT: hint #26        // encoding: [0x5f,0x23,0x03,0xd5]
+  hint #30
   autibz
 // CHECK-NEXT: autibz         // encoding: [0xdf,0x23,0x03,0xd5]
+// CHECK-NEXT: autibz         // encoding: [0xdf,0x23,0x03,0xd5]
+// NO83-NEXT: hint #30        // encoding: [0xdf,0x23,0x03,0xd5]
 // NO83-NEXT: hint #30        // encoding: [0xdf,0x23,0x03,0xd5]
+  hint #10
   pacib1716
 // CHECK-NEXT: pacib1716      // encoding: [0x5f,0x21,0x03,0xd5]
+// CHECK-NEXT: pacib1716      // encoding: [0x5f,0x21,0x03,0xd5]
+// NO83-NEXT: hint #10        // encoding: [0x5f,0x21,0x03,0xd5]
 // NO83-NEXT: hint #10        // encoding: [0x5f,0x21,0x03,0xd5]
+  hint #14
   autib1716
 // CHECK-NEXT: autib1716      // encoding: [0xdf,0x21,0x03,0xd5]
+// CHECK-NEXT: autib1716      // encoding: [0xdf,0x21,0x03,0xd5]
 // NO83-NEXT: hint #14        // encoding: [0xdf,0x21,0x03,0xd5]
+// NO83-NEXT: hint #14        // encoding: [0xdf,0x21,0x03,0xd5]
+  hint #7
   xpaclri
 // CHECK-NEXT: xpaclri        // encoding: [0xff,0x20,0x03,0xd5]
+// CHECK-NEXT: xpaclri        // encoding: [0xff,0x20,0x03,0xd5]
+// NO83-NEXT: hint #7         // encoding: [0xff,0x20,0x03,0xd5]
 // NO83-NEXT: hint #7         // encoding: [0xff,0x20,0x03,0xd5]
 
 // ALL-EMPTY:


        


More information about the llvm-commits mailing list