Enable some pointer authentication instructions for aarch64 v8a targets
authorLuke Cheeseman <luke.cheeseman@arm.com>
Thu, 26 Jul 2018 14:00:50 +0000 (14:00 +0000)
committerLuke Cheeseman <luke.cheeseman@arm.com>
Thu, 26 Jul 2018 14:00:50 +0000 (14:00 +0000)
- Some of the v8.3 pointer authentication instruction inhabit the Hint space
- These instructions can be assembled to hint instructions which act as NOP instructions prior to v8.3
- This patch permits using the hint instructions for all v8a targets
- Also, correct the RETA{A,B} instructions to match the instruction attributes of RET (set isTerminator and isBarrier)

Differential Revision: https://reviews.llvm.org/D49786

llvm-svn: 338029

llvm/lib/Target/AArch64/AArch64InstrInfo.td
llvm/test/MC/AArch64/armv8.3a-signed-pointer.s

index 62c9599..d6b8bb5 100644 (file)
@@ -516,31 +516,34 @@ defm FCADD : SIMDThreeSameVectorComplexHSD<1, 0b111, complexrotateopodd,
 defm FCMLA : SIMDIndexedTiedComplexHSD<1, 0, 1, complexrotateop, "fcmla",
                                        null_frag>;
 
-let Predicates = [HasV8_3a] in {
-  // v8.3a Pointer Authentication
-  let Uses = [LR], Defs = [LR] in {
-    def PACIAZ   : SystemNoOperands<0b000, "paciaz">;
-    def PACIBZ   : SystemNoOperands<0b010, "pacibz">;
-    def AUTIAZ   : SystemNoOperands<0b100, "autiaz">;
-    def AUTIBZ   : SystemNoOperands<0b110, "autibz">;
-  }
-  let Uses = [LR, SP], Defs = [LR] in {
-    def PACIASP  : SystemNoOperands<0b001, "paciasp">;
-    def PACIBSP  : SystemNoOperands<0b011, "pacibsp">;
-    def AUTIASP  : SystemNoOperands<0b101, "autiasp">;
-    def AUTIBSP  : SystemNoOperands<0b111, "autibsp">;
-  }
-  let Uses = [X16, X17], Defs = [X17], CRm = 0b0001 in {
-    def PACIA1716  : SystemNoOperands<0b000, "pacia1716">;
-    def PACIB1716  : SystemNoOperands<0b010, "pacib1716">;
-    def AUTIA1716  : SystemNoOperands<0b100, "autia1716">;
-    def AUTIB1716  : SystemNoOperands<0b110, "autib1716">;
-  }
+// v8.3a Pointer Authentication
+// These instructions inhabit part of the hint space and so can be used for
+// armv8 targets
+let Uses = [LR], Defs = [LR] in {
+  def PACIAZ   : SystemNoOperands<0b000, "paciaz">;
+  def PACIBZ   : SystemNoOperands<0b010, "pacibz">;
+  def AUTIAZ   : SystemNoOperands<0b100, "autiaz">;
+  def AUTIBZ   : SystemNoOperands<0b110, "autibz">;
+}
+let Uses = [LR, SP], Defs = [LR] in {
+  def PACIASP  : SystemNoOperands<0b001, "paciasp">;
+  def PACIBSP  : SystemNoOperands<0b011, "pacibsp">;
+  def AUTIASP  : SystemNoOperands<0b101, "autiasp">;
+  def AUTIBSP  : SystemNoOperands<0b111, "autibsp">;
+}
+let Uses = [X16, X17], Defs = [X17], CRm = 0b0001 in {
+  def PACIA1716  : SystemNoOperands<0b000, "pacia1716">;
+  def PACIB1716  : SystemNoOperands<0b010, "pacib1716">;
+  def AUTIA1716  : SystemNoOperands<0b100, "autia1716">;
+  def AUTIB1716  : SystemNoOperands<0b110, "autib1716">;
+}
 
-  let Uses = [LR], Defs = [LR], CRm = 0b0000 in {
-    def XPACLRI   : SystemNoOperands<0b111, "xpaclri">;
-  }
+let Uses = [LR], Defs = [LR], CRm = 0b0000 in {
+  def XPACLRI   : SystemNoOperands<0b111, "xpaclri">;
+}
 
+// These pointer authentication isntructions require armv8.3a
+let Predicates = [HasV8_3a] in {
   multiclass SignAuth<bits<3> prefix, bits<3> prefix_z, string asm> {
     def IA   : SignAuthOneData<prefix, 0b00, !strconcat(asm, "ia")>;
     def IB   : SignAuthOneData<prefix, 0b01, !strconcat(asm, "ib")>;
@@ -570,7 +573,7 @@ let Predicates = [HasV8_3a] in {
   def BLRAAZ  : AuthOneOperand<0b001, 0, "blraaz">;
   def BLRABZ  : AuthOneOperand<0b001, 1, "blrabz">;
 
-  let isReturn = 1 in {
+  let isReturn = 1, isTerminator = 1, isBarrier = 1 in {
     def RETAA   : AuthReturn<0b010, 0, "retaa">;
     def RETAB   : AuthReturn<0b010, 1, "retab">;
     def ERETAA  : AuthReturn<0b100, 0, "eretaa">;
index e0bc67e..156ab08 100644 (file)
 
   paciasp
 // CHECK: paciasp        // encoding: [0x3f,0x23,0x03,0xd5]
-// CHECK-REQ: error: instruction requires: armv8.3a
+// CHECK-REQ-NOT: error: instruction requires: armv8.3a
   autiasp
 // CHECK: autiasp        // encoding: [0xbf,0x23,0x03,0xd5]
-// CHECK-REQ: error: instruction requires: armv8.3a
+// CHECK-REQ-NOT: error: instruction requires: armv8.3a
   paciaz
 // CHECK: paciaz         // encoding: [0x1f,0x23,0x03,0xd5]
-// CHECK-REQ: error: instruction requires: armv8.3a
+// CHECK-REQ-NOT: error: instruction requires: armv8.3a
   autiaz
 // CHECK: autiaz         // encoding: [0x9f,0x23,0x03,0xd5]
-// CHECK-REQ: error: instruction requires: armv8.3a
+// CHECK-REQ-NOT: error: instruction requires: armv8.3a
   pacia1716
 // CHECK: pacia1716      // encoding: [0x1f,0x21,0x03,0xd5]
-// CHECK-REQ: error: instruction requires: armv8.3a
+// CHECK-REQ-NOT: error: instruction requires: armv8.3a
   autia1716
 // CHECK: autia1716      // encoding: [0x9f,0x21,0x03,0xd5]
-// CHECK-REQ: error: instruction requires: armv8.3a
+// CHECK-REQ-NOT: error: instruction requires: armv8.3a
   pacibsp
 // CHECK: pacibsp        // encoding: [0x7f,0x23,0x03,0xd5]
-// CHECK-REQ: error: instruction requires: armv8.3a
+// CHECK-REQ-NOT: error: instruction requires: armv8.3a
   autibsp
 // CHECK: autibsp        // encoding: [0xff,0x23,0x03,0xd5]
-// CHECK-REQ: error: instruction requires: armv8.3a
+// CHECK-REQ-NOT: error: instruction requires: armv8.3a
   pacibz
 // CHECK: pacibz         // encoding: [0x5f,0x23,0x03,0xd5]
-// CHECK-REQ: error: instruction requires: armv8.3a
+// CHECK-REQ-NOT: error: instruction requires: armv8.3a
   autibz
 // CHECK: autibz         // encoding: [0xdf,0x23,0x03,0xd5]
-// CHECK-REQ: error: instruction requires: armv8.3a
+// CHECK-REQ-NOT: error: instruction requires: armv8.3a
   pacib1716
 // CHECK: pacib1716      // encoding: [0x5f,0x21,0x03,0xd5]
-// CHECK-REQ: error: instruction requires: armv8.3a
+// CHECK-REQ-NOT: error: instruction requires: armv8.3a
   autib1716
 // CHECK: autib1716      // encoding: [0xdf,0x21,0x03,0xd5]
-// CHECK-REQ: error: instruction requires: armv8.3a
+// CHECK-REQ-NOT: error: instruction requires: armv8.3a
   xpaclri
 // CHECK: xpaclri           // encoding: [0xff,0x20,0x03,0xd5]
-// CHECK-REQ: error: instruction requires: armv8.3a
+// CHECK-REQ-NOT: error: instruction requires: armv8.3a
 
   pacia x0, x1
 // CHECK: pacia x0, x1     // encoding: [0x20,0x00,0xc1,0xda]