[llvm] 39f8384 - [ARM] Correct features on pacbti instructions.

David Green via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 27 01:15:19 PDT 2022


Author: David Green
Date: 2022-07-27T09:15:14+01:00
New Revision: 39f83849640114340fb2144450383a7bd90d5f0b

URL: https://github.com/llvm/llvm-project/commit/39f83849640114340fb2144450383a7bd90d5f0b
DIFF: https://github.com/llvm/llvm-project/commit/39f83849640114340fb2144450383a7bd90d5f0b.diff

LOG: [ARM] Correct features on pacbti instructions.

Given a patch like D129506, using instructions not valid for the current
feature set becomes an error. This updates the Arm hint-space
instructions for pac/bti to require thumbv7m as opposed to 8.1-m.main, to
make them valid when compiling for thumbv7m with -mbranch-protection.

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

Added: 
    

Modified: 
    llvm/lib/Target/ARM/ARMInstrThumb2.td
    llvm/lib/Target/ARM/ARMScheduleA57.td
    llvm/test/MC/ARM/armv8.1m-pacbti.s

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/ARM/ARMInstrThumb2.td b/llvm/lib/Target/ARM/ARMInstrThumb2.td
index 20d8a45aaf491..c80c184bd77ae 100644
--- a/llvm/lib/Target/ARM/ARMInstrThumb2.td
+++ b/llvm/lib/Target/ARM/ARMInstrThumb2.td
@@ -5717,7 +5717,8 @@ let isBranch = 1, isTerminator = 1, isIndirectBranch = 1 in {
 
 
 class PACBTIHintSpaceInst<string asm, string ops, bits<8> imm>
-  : V8_1MI<(outs), (ins), AddrModeNone, NoItinerary, asm, ops, "", []> {
+  : Thumb2XI<(outs), (ins), AddrModeNone, 4, NoItinerary, !strconcat(asm, "\t", ops), "", []>,
+    Requires<[HasV7, IsMClass]> {
   let Inst{31-8} = 0b111100111010111110000000;
   let Inst{7-0}  = imm;
 

diff  --git a/llvm/lib/Target/ARM/ARMScheduleA57.td b/llvm/lib/Target/ARM/ARMScheduleA57.td
index 0c610a4839f8a..0a440555a0c44 100644
--- a/llvm/lib/Target/ARM/ARMScheduleA57.td
+++ b/llvm/lib/Target/ARM/ARMScheduleA57.td
@@ -83,7 +83,7 @@ def CortexA57Model : SchedMachineModel {
   // FIXME: Remove when all errors have been fixed.
   let FullInstRWOverlapCheck = 0;
 
-  let UnsupportedFeatures = [HasV8_1MMainline, HasMVEInt, HasMVEFloat,
+  let UnsupportedFeatures = [HasV8_1MMainline, HasMVEInt, HasMVEFloat, IsMClass,
                              HasFPRegsV8_1M, HasFP16FML, HasMatMulInt8, HasBF16];
 }
 

diff  --git a/llvm/test/MC/ARM/armv8.1m-pacbti.s b/llvm/test/MC/ARM/armv8.1m-pacbti.s
index ec09142e8da84..7c0c19aee73fc 100644
--- a/llvm/test/MC/ARM/armv8.1m-pacbti.s
+++ b/llvm/test/MC/ARM/armv8.1m-pacbti.s
@@ -1,134 +1,142 @@
-// RUN: llvm-mc -triple thumbv8.1m.main-arm-none-eabi -mattr=+pacbti %s -show-encoding -o - | FileCheck %s
-// RUN: not llvm-mc -triple thumbv8.1m.main-arm-none-eabi -mattr=-pacbti %s -show-encoding -o - 2>&1 | FileCheck %s --check-prefix=CHECK-NOPACBTI
+// RUN: llvm-mc -triple thumbv8.1m.main-arm-none-eabi -mattr=+pacbti %s -show-encoding -o - | FileCheck %s --check-prefixes=CHECK,CHECK-PACBTI
+// RUN: not llvm-mc -triple thumbv8.1m.main-arm-none-eabi -mattr=-pacbti %s -show-encoding -o - 2>&1 | FileCheck %s --check-prefixes=CHECK,CHECK-NOPACBTI
+// RUN: not llvm-mc -triple thumbv7m-arm-none-eabi %s -show-encoding -o - 2>&1 | FileCheck %s --check-prefixes=CHECK,CHECK-NOPACBTI
 
-// CHECK: autg	r0, r1, r2              @ encoding: [0x51,0xfb,0x02,0x0f]
+// Non Hint Space instructions and system regs
+
+// CHECK-PACBTI: autg	r0, r1, r2             @ encoding: [0x51,0xfb,0x02,0x0f]
 // CHECK-NOPACBTI: error: instruction requires: pacbti
 autg r0, r1, r2
-// CHECK: autg	r12, lr, sp             @ encoding: [0x5e,0xfb,0x0d,0xcf]
+// CHECK-PACBTI: autg	r12, lr, sp            @ encoding: [0x5e,0xfb,0x0d,0xcf]
 // CHECK-NOPACBTI: error: instruction requires: pacbti
 autg ip, lr, sp
-// CHECK: aut	r12, lr, sp               @ encoding: [0xaf,0xf3,0x2d,0x80]
-aut ip, lr, sp
-// CHECK: aut	r12,lr,sp               @ encoding: [0xaf,0xf3,0x2d,0x80]
-hint.w #45
-// CHECK: bxaut	r0, r1, r2              @ encoding: [0x51,0xfb,0x12,0x0f]
+// CHECK-PACBTI: bxaut	r0, r1, r2             @ encoding: [0x51,0xfb,0x12,0x0f]
 // CHECK-NOPACBTI: error: instruction requires: pacbti
 bxaut r0, r1, r2
 
-// CHECK: bti	                          @ encoding: [0xaf,0xf3,0x0f,0x80]
-bti
-// CHECK: bti	                          @ encoding: [0xaf,0xf3,0x0f,0x80]
-hint.w #15
-
-// CHECK: pacg r0, r1, r2               @ encoding: [0x61,0xfb,0x02,0xf0]
+// CHECK-PACBTI: pacg r0, r1, r2               @ encoding: [0x61,0xfb,0x02,0xf0]
 // CHECK-NOPACBTI: error: instruction requires: pacbti
 pacg r0, r1, r2
-// CHECK: pacg r12, lr, sp              @ encoding: [0x6e,0xfb,0x0d,0xfc]
+// CHECK-PACBTI: pacg r12, lr, sp              @ encoding: [0x6e,0xfb,0x0d,0xfc]
 // CHECK-NOPACBTI: error: instruction requires: pacbti
 pacg ip, lr, sp
-// CHECK: pac r12, lr, sp               @ encoding: [0xaf,0xf3,0x1d,0x80]
-pac ip, lr, sp
-// CHECK: pac r12,lr,sp               @ encoding: [0xaf,0xf3,0x1d,0x80]
-hint.w #29
-// CHECK: pacbti r12, lr, sp            @ encoding: [0xaf,0xf3,0x0d,0x80]
-pacbti ip, lr, sp
-// CHECK: pacbti r12,lr,sp            @ encoding: [0xaf,0xf3,0x0d,0x80]
-hint.w #13
 
-// CHECK: msr	pac_key_p_0, r0           @ encoding: [0x80,0xf3,0x20,0x88]
+// CHECK-PACBTI: msr	pac_key_p_0, r0           @ encoding: [0x80,0xf3,0x20,0x88]
 // CHECK-NOPACBTI: error: invalid operand for instruction
 msr pac_key_p_0, r0
-// CHECK: msr	pac_key_p_1, r0           @ encoding: [0x80,0xf3,0x21,0x88]
+// CHECK-PACBTI: msr	pac_key_p_1, r0           @ encoding: [0x80,0xf3,0x21,0x88]
 // CHECK-NOPACBTI: error: invalid operand for instruction
 msr pac_key_p_1, r0
-// CHECK: msr	pac_key_p_2, r0           @ encoding: [0x80,0xf3,0x22,0x88]
+// CHECK-PACBTI: msr	pac_key_p_2, r0           @ encoding: [0x80,0xf3,0x22,0x88]
 // CHECK-NOPACBTI: error: invalid operand for instruction
 msr pac_key_p_2, r0
-// CHECK: msr	pac_key_p_3, r0           @ encoding: [0x80,0xf3,0x23,0x88]
+// CHECK-PACBTI: msr	pac_key_p_3, r0           @ encoding: [0x80,0xf3,0x23,0x88]
 // CHECK-NOPACBTI: error: invalid operand for instruction
 msr pac_key_p_3, r0
-// CHECK: msr	pac_key_u_0, r0           @ encoding: [0x80,0xf3,0x24,0x88]
+// CHECK-PACBTI: msr	pac_key_u_0, r0           @ encoding: [0x80,0xf3,0x24,0x88]
 // CHECK-NOPACBTI: error: invalid operand for instruction
 msr pac_key_u_0, r0
-// CHECK: msr	pac_key_u_1, r0           @ encoding: [0x80,0xf3,0x25,0x88]
+// CHECK-PACBTI: msr	pac_key_u_1, r0           @ encoding: [0x80,0xf3,0x25,0x88]
 // CHECK-NOPACBTI: error: invalid operand for instruction
 msr pac_key_u_1, r0
-// CHECK: msr	pac_key_u_2, r0           @ encoding: [0x80,0xf3,0x26,0x88]
+// CHECK-PACBTI: msr	pac_key_u_2, r0           @ encoding: [0x80,0xf3,0x26,0x88]
 // CHECK-NOPACBTI: error: invalid operand for instruction
 msr pac_key_u_2, r0
-// CHECK: msr	pac_key_u_3, r0           @ encoding: [0x80,0xf3,0x27,0x88]
+// CHECK-PACBTI: msr	pac_key_u_3, r0           @ encoding: [0x80,0xf3,0x27,0x88]
 // CHECK-NOPACBTI: error: invalid operand for instruction
 msr pac_key_u_3, r0
-// CHECK: msr	pac_key_p_0_ns, r0        @ encoding: [0x80,0xf3,0xa0,0x88]
+// CHECK-PACBTI: msr	pac_key_p_0_ns, r0        @ encoding: [0x80,0xf3,0xa0,0x88]
 // CHECK-NOPACBTI: error: invalid operand for instruction
 msr pac_key_p_0_ns, r0
-// CHECK: msr	pac_key_p_1_ns, r0        @ encoding: [0x80,0xf3,0xa1,0x88]
+// CHECK-PACBTI: msr	pac_key_p_1_ns, r0        @ encoding: [0x80,0xf3,0xa1,0x88]
 // CHECK-NOPACBTI: error: invalid operand for instruction
 msr pac_key_p_1_ns, r0
-// CHECK: msr	pac_key_p_2_ns, r0        @ encoding: [0x80,0xf3,0xa2,0x88]
+// CHECK-PACBTI: msr	pac_key_p_2_ns, r0        @ encoding: [0x80,0xf3,0xa2,0x88]
 // CHECK-NOPACBTI: error: invalid operand for instruction
 msr pac_key_p_2_ns, r0
-// CHECK: msr	pac_key_p_3_ns, r0        @ encoding: [0x80,0xf3,0xa3,0x88]
+// CHECK-PACBTI: msr	pac_key_p_3_ns, r0        @ encoding: [0x80,0xf3,0xa3,0x88]
 // CHECK-NOPACBTI: error: invalid operand for instruction
 msr pac_key_p_3_ns, r0
-// CHECK: msr	pac_key_u_0_ns, r0        @ encoding: [0x80,0xf3,0xa4,0x88]
+// CHECK-PACBTI: msr	pac_key_u_0_ns, r0        @ encoding: [0x80,0xf3,0xa4,0x88]
 // CHECK-NOPACBTI: error: invalid operand for instruction
 msr pac_key_u_0_ns, r0
-// CHECK: msr	pac_key_u_1_ns, r0        @ encoding: [0x80,0xf3,0xa5,0x88]
+// CHECK-PACBTI: msr	pac_key_u_1_ns, r0        @ encoding: [0x80,0xf3,0xa5,0x88]
 // CHECK-NOPACBTI: error: invalid operand for instruction
 msr pac_key_u_1_ns, r0
-// CHECK: msr	pac_key_u_2_ns, r0        @ encoding: [0x80,0xf3,0xa6,0x88]
+// CHECK-PACBTI: msr	pac_key_u_2_ns, r0        @ encoding: [0x80,0xf3,0xa6,0x88]
 // CHECK-NOPACBTI: error: invalid operand for instruction
 msr pac_key_u_2_ns, r0
-// CHECK: msr	pac_key_u_3_ns, r0        @ encoding: [0x80,0xf3,0xa7,0x88]
+// CHECK-PACBTI: msr	pac_key_u_3_ns, r0        @ encoding: [0x80,0xf3,0xa7,0x88]
 // CHECK-NOPACBTI: error: invalid operand for instruction
 msr pac_key_u_3_ns, r0
 
-// CHECK: mrs	r0, pac_key_p_0           @ encoding: [0xef,0xf3,0x20,0x80]
+// CHECK-PACBTI: mrs	r0, pac_key_p_0           @ encoding: [0xef,0xf3,0x20,0x80]
 // CHECK-NOPACBTI: error: invalid operand for instruction
 mrs r0, pac_key_p_0
-// CHECK: mrs	r0, pac_key_p_1           @ encoding: [0xef,0xf3,0x21,0x80]
+// CHECK-PACBTI: mrs	r0, pac_key_p_1           @ encoding: [0xef,0xf3,0x21,0x80]
 // CHECK-NOPACBTI: error: invalid operand for instruction
 mrs r0, pac_key_p_1
-// CHECK: mrs	r0, pac_key_p_2           @ encoding: [0xef,0xf3,0x22,0x80]
+// CHECK-PACBTI: mrs	r0, pac_key_p_2           @ encoding: [0xef,0xf3,0x22,0x80]
 // CHECK-NOPACBTI: error: invalid operand for instruction
 mrs r0, pac_key_p_2
-// CHECK: mrs	r0, pac_key_p_3           @ encoding: [0xef,0xf3,0x23,0x80]
+// CHECK-PACBTI: mrs	r0, pac_key_p_3           @ encoding: [0xef,0xf3,0x23,0x80]
 // CHECK-NOPACBTI: error: invalid operand for instruction
 mrs r0, pac_key_p_3
-// CHECK: mrs	r0, pac_key_u_0           @ encoding: [0xef,0xf3,0x24,0x80]
+// CHECK-PACBTI: mrs	r0, pac_key_u_0           @ encoding: [0xef,0xf3,0x24,0x80]
 // CHECK-NOPACBTI: error: invalid operand for instruction
 mrs r0, pac_key_u_0
-// CHECK: mrs	r0, pac_key_u_1           @ encoding: [0xef,0xf3,0x25,0x80]
+// CHECK-PACBTI: mrs	r0, pac_key_u_1           @ encoding: [0xef,0xf3,0x25,0x80]
 // CHECK-NOPACBTI: error: invalid operand for instruction
 mrs r0, pac_key_u_1
-// CHECK: mrs	r0, pac_key_u_2           @ encoding: [0xef,0xf3,0x26,0x80]
+// CHECK-PACBTI: mrs	r0, pac_key_u_2           @ encoding: [0xef,0xf3,0x26,0x80]
 // CHECK-NOPACBTI: error: invalid operand for instruction
 mrs r0, pac_key_u_2
-// CHECK: mrs	r0, pac_key_u_3           @ encoding: [0xef,0xf3,0x27,0x80]
+// CHECK-PACBTI: mrs	r0, pac_key_u_3           @ encoding: [0xef,0xf3,0x27,0x80]
 // CHECK-NOPACBTI: error: invalid operand for instruction
 mrs r0, pac_key_u_3
-// CHECK: mrs	r0, pac_key_p_0_ns        @ encoding: [0xef,0xf3,0xa0,0x80]
+// CHECK-PACBTI: mrs	r0, pac_key_p_0_ns        @ encoding: [0xef,0xf3,0xa0,0x80]
 // CHECK-NOPACBTI: error: invalid operand for instruction
 mrs r0, pac_key_p_0_ns
-// CHECK: mrs	r0, pac_key_p_1_ns        @ encoding: [0xef,0xf3,0xa1,0x80]
+// CHECK-PACBTI: mrs	r0, pac_key_p_1_ns        @ encoding: [0xef,0xf3,0xa1,0x80]
 // CHECK-NOPACBTI: error: invalid operand for instruction
 mrs r0, pac_key_p_1_ns
-// CHECK: mrs	r0, pac_key_p_2_ns        @ encoding: [0xef,0xf3,0xa2,0x80]
+// CHECK-PACBTI: mrs	r0, pac_key_p_2_ns        @ encoding: [0xef,0xf3,0xa2,0x80]
 // CHECK-NOPACBTI: error: invalid operand for instruction
 mrs r0, pac_key_p_2_ns
-// CHECK: mrs	r0, pac_key_p_3_ns        @ encoding: [0xef,0xf3,0xa3,0x80]
+// CHECK-PACBTI: mrs	r0, pac_key_p_3_ns        @ encoding: [0xef,0xf3,0xa3,0x80]
 // CHECK-NOPACBTI: error: invalid operand for instruction
 mrs r0, pac_key_p_3_ns
-// CHECK: mrs	r0, pac_key_u_0_ns        @ encoding: [0xef,0xf3,0xa4,0x80]
+// CHECK-PACBTI: mrs	r0, pac_key_u_0_ns        @ encoding: [0xef,0xf3,0xa4,0x80]
 // CHECK-NOPACBTI: error: invalid operand for instruction
 mrs r0, pac_key_u_0_ns
-// CHECK: mrs	r0, pac_key_u_1_ns        @ encoding: [0xef,0xf3,0xa5,0x80]
+// CHECK-PACBTI: mrs	r0, pac_key_u_1_ns        @ encoding: [0xef,0xf3,0xa5,0x80]
 // CHECK-NOPACBTI: error: invalid operand for instruction
 mrs r0, pac_key_u_1_ns
-// CHECK: mrs	r0, pac_key_u_2_ns        @ encoding: [0xef,0xf3,0xa6,0x80]
+// CHECK-PACBTI: mrs	r0, pac_key_u_2_ns        @ encoding: [0xef,0xf3,0xa6,0x80]
 // CHECK-NOPACBTI: error: invalid operand for instruction
 mrs r0, pac_key_u_2_ns
-// CHECK: mrs	r0, pac_key_u_3_ns        @ encoding: [0xef,0xf3,0xa7,0x80]
+// CHECK-PACBTI: mrs	r0, pac_key_u_3_ns        @ encoding: [0xef,0xf3,0xa7,0x80]
 // CHECK-NOPACBTI: error: invalid operand for instruction
 mrs r0, pac_key_u_3_ns
+
+// Hint space instructions - deliberately at the bottom of the file as the
+// error's are emitted first.
+
+// CHECK: aut	r12, lr, sp             @ encoding: [0xaf,0xf3,0x2d,0x80]
+aut ip, lr, sp
+// CHECK: aut	r12,lr,sp               @ encoding: [0xaf,0xf3,0x2d,0x80]
+hint.w #45
+
+// CHECK: bti	                        @ encoding: [0xaf,0xf3,0x0f,0x80]
+bti
+// CHECK: bti	                        @ encoding: [0xaf,0xf3,0x0f,0x80]
+hint.w #15
+
+// CHECK: pac r12, lr, sp               @ encoding: [0xaf,0xf3,0x1d,0x80]
+pac ip, lr, sp
+// CHECK: pac r12,lr,sp                 @ encoding: [0xaf,0xf3,0x1d,0x80]
+hint.w #29
+// CHECK: pacbti r12, lr, sp            @ encoding: [0xaf,0xf3,0x0d,0x80]
+pacbti ip, lr, sp
+// CHECK: pacbti r12,lr,sp              @ encoding: [0xaf,0xf3,0x0d,0x80]
+hint.w #13
\ No newline at end of file


        


More information about the llvm-commits mailing list