[llvm] r329687 - AArch64: diagnose unpredictable store-exclusive instructions

Tim Northover via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 10 04:04:29 PDT 2018


Author: tnorthover
Date: Tue Apr 10 04:04:29 2018
New Revision: 329687

URL: http://llvm.org/viewvc/llvm-project?rev=329687&view=rev
Log:
AArch64: diagnose unpredictable store-exclusive instructions

Much like any written register in load/store instructions, the status register
is not allowed to overlap with any others. So diagnose it like we already do
with the other cases.

Modified:
    llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
    llvm/trunk/test/MC/AArch64/arm64-diags.s
    llvm/trunk/test/MC/AArch64/arm64-memory.s

Modified: llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp?rev=329687&r1=329686&r2=329687&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp (original)
+++ llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp Tue Apr 10 04:04:29 2018
@@ -3435,7 +3435,39 @@ bool AArch64AsmParser::validateInstructi
                            "is also a source");
     break;
   }
+  case AArch64::STXRB:
+  case AArch64::STXRH:
+  case AArch64::STXRW:
+  case AArch64::STXRX:
+  case AArch64::STLXRB:
+  case AArch64::STLXRH:
+  case AArch64::STLXRW:
+  case AArch64::STLXRX: {
+    unsigned Rs = Inst.getOperand(0).getReg();
+    unsigned Rt = Inst.getOperand(1).getReg();
+    unsigned Rn = Inst.getOperand(2).getReg();
+    if (RI->isSubRegisterEq(Rt, Rs) ||
+        (RI->isSubRegisterEq(Rn, Rs) && Rn != AArch64::SP))
+      return Error(Loc[0],
+                   "unpredictable STXR instruction, status is also a source");
+    break;
+  }
+  case AArch64::STXPW:
+  case AArch64::STXPX:
+  case AArch64::STLXPW:
+  case AArch64::STLXPX: {
+    unsigned Rs = Inst.getOperand(0).getReg();
+    unsigned Rt1 = Inst.getOperand(1).getReg();
+    unsigned Rt2 = Inst.getOperand(2).getReg();
+    unsigned Rn = Inst.getOperand(3).getReg();
+    if (RI->isSubRegisterEq(Rt1, Rs) || RI->isSubRegisterEq(Rt2, Rs) ||
+        (RI->isSubRegisterEq(Rn, Rs) && Rn != AArch64::SP))
+      return Error(Loc[0],
+                   "unpredictable STXP instruction, status is also a source");
+    break;
   }
+  }
+
 
   // Now check immediate ranges. Separate from the above as there is overlap
   // in the instructions being checked and this keeps the nested conditionals

Modified: llvm/trunk/test/MC/AArch64/arm64-diags.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AArch64/arm64-diags.s?rev=329687&r1=329686&r2=329687&view=diff
==============================================================================
--- llvm/trunk/test/MC/AArch64/arm64-diags.s (original)
+++ llvm/trunk/test/MC/AArch64/arm64-diags.s Tue Apr 10 04:04:29 2018
@@ -246,6 +246,67 @@ ldr    q1, [x3, w3, sxtw #1]
 ; CHECK-ERRORS:   str w2, [x2, #8]!
 ; CHECK-ERRORS:       ^
 
+; Store exclusive instructions are unpredictable if the status register clashes
+; with anything.
+  stlxrb w1, w1, [x5]
+  stxrb w3, w5, [x3]
+  stxrh w7, w9, [x7]
+  stlxrh wzr, wzr, [x13]
+  stxr w9, w9, [x12]
+  stlxr w22, x1, [x22]
+  stxr w4, x4, [x9]
+  stlxr w5, x0, [x5]
+; CHECK-ERRORS: error: unpredictable STXR instruction, status is also a source
+; CHECK-ERRORS:   stlxrb w1, w1, [x5]
+; CHECK-ERRORS:          ^
+; CHECK-ERRORS: error: unpredictable STXR instruction, status is also a source
+; CHECK-ERRORS:   stxrb w3, w5, [x3]
+; CHECK-ERRORS:         ^
+; CHECK-ERRORS: error: unpredictable STXR instruction, status is also a source
+; CHECK-ERRORS:   stxrh w7, w9, [x7]
+; CHECK-ERRORS:         ^
+; CHECK-ERRORS: error: unpredictable STXR instruction, status is also a source
+; CHECK-ERRORS:   stlxrh wzr, wzr, [x13]
+; CHECK-ERRORS:          ^
+; CHECK-ERRORS: error: unpredictable STXR instruction, status is also a source
+; CHECK-ERRORS:   stxr w9, w9, [x12]
+; CHECK-ERRORS:        ^
+; CHECK-ERRORS: error: unpredictable STXR instruction, status is also a source
+; CHECK-ERRORS:   stlxr w22, x1, [x22]
+; CHECK-ERRORS:         ^
+; CHECK-ERRORS: error: unpredictable STXR instruction, status is also a source
+; CHECK-ERRORS:   stxr w4, x4, [x9]
+; CHECK-ERRORS:        ^
+; CHECK-ERRORS: error: unpredictable STXR instruction, status is also a source
+; CHECK-ERRORS:   stlxr w5, x0, [x5]
+; CHECK-ERRORS:         ^
+
+  stxp w0, w0, w1, [x3]
+  stxp w0, w1, w0, [x5]
+  stxp w10, w4, w5, [x10]
+  stxp wzr, xzr, x4, [x5]
+  stxp w3, x5, x3, [sp]
+  stxp w25, x4, x2, [x25]
+; CHECK-ERRORS: error: unpredictable STXP instruction, status is also a source
+; CHECK-ERRORS:   stxp w0, w0, w1, [x3]
+; CHECK-ERRORS:        ^
+; CHECK-ERRORS: error: unpredictable STXP instruction, status is also a source
+; CHECK-ERRORS:   stxp w0, w1, w0, [x5]
+; CHECK-ERRORS:        ^
+; CHECK-ERRORS: error: unpredictable STXP instruction, status is also a source
+; CHECK-ERRORS:   stxp w10, w4, w5, [x10]
+; CHECK-ERRORS:        ^
+; CHECK-ERRORS: error: unpredictable STXP instruction, status is also a source
+; CHECK-ERRORS:   stxp wzr, xzr, x4, [x5]
+; CHECK-ERRORS:        ^
+; CHECK-ERRORS: error: unpredictable STXP instruction, status is also a source
+; CHECK-ERRORS:   stxp w3, x5, x3, [sp]
+; CHECK-ERRORS:        ^
+; CHECK-ERRORS: error: unpredictable STXP instruction, status is also a source
+; CHECK-ERRORS:   stxp w25, x4, x2, [x25]
+; CHECK-ERRORS:        ^
+
+
 ; The validity checking for shifted-immediate operands.  rdar://13174476
 ; Where the immediate is out of range.
   add w1, w2, w3, lsr #75

Modified: llvm/trunk/test/MC/AArch64/arm64-memory.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AArch64/arm64-memory.s?rev=329687&r1=329686&r2=329687&view=diff
==============================================================================
--- llvm/trunk/test/MC/AArch64/arm64-memory.s (original)
+++ llvm/trunk/test/MC/AArch64/arm64-memory.s Tue Apr 10 04:04:29 2018
@@ -469,15 +469,15 @@ foo:
   stxr   w1, w4, [x3]
   stxrb  w1, w4, [x3]
   stxrh  w1, w4, [x3]
-  stxp   w1, x2, x6, [x1]
-  stxp   w1, w2, w6, [x1]
+  stxp   w1, x2, x6, [x7]
+  stxp   w1, w2, w6, [x9]
 
 ; CHECK: stxr   w1, x4, [x3]            ; encoding: [0x64,0x7c,0x01,0xc8]
 ; CHECK: stxr   w1, w4, [x3]            ; encoding: [0x64,0x7c,0x01,0x88]
 ; CHECK: stxrb  w1, w4, [x3]            ; encoding: [0x64,0x7c,0x01,0x08]
 ; CHECK: stxrh  w1, w4, [x3]            ; encoding: [0x64,0x7c,0x01,0x48]
-; CHECK: stxp   w1, x2, x6, [x1]        ; encoding: [0x22,0x18,0x21,0xc8]
-; CHECK: stxp   w1, w2, w6, [x1]        ; encoding: [0x22,0x18,0x21,0x88]
+; CHECK: stxp   w1, x2, x6, [x7]        ; encoding: [0xe2,0x18,0x21,0xc8]
+; CHECK: stxp   w1, w2, w6, [x9]        ; encoding: [0x22,0x19,0x21,0x88]
 
 ;-----------------------------------------------------------------------------
 ; Load-acquire/Store-release non-exclusive
@@ -525,15 +525,15 @@ foo:
   stlxr   w8, w7, [x1]
   stlxrb  w8, w7, [x1]
   stlxrh  w8, w7, [x1]
-  stlxp   w1, x2, x6, [x1]
-  stlxp   w1, w2, w6, [x1]
+  stlxp   w1, x2, x6, [x7]
+  stlxp   w1, w2, w6, [x9]
 
 ; CHECK: stlxr  w8, x7, [x1]            ; encoding: [0x27,0xfc,0x08,0xc8]
 ; CHECK: stlxr  w8, w7, [x1]            ; encoding: [0x27,0xfc,0x08,0x88]
 ; CHECK: stlxrb w8, w7, [x1]            ; encoding: [0x27,0xfc,0x08,0x08]
 ; CHECK: stlxrh w8, w7, [x1]            ; encoding: [0x27,0xfc,0x08,0x48]
-; CHECK: stlxp  w1, x2, x6, [x1]        ; encoding: [0x22,0x98,0x21,0xc8]
-; CHECK: stlxp  w1, w2, w6, [x1]        ; encoding: [0x22,0x98,0x21,0x88]
+; CHECK: stlxp  w1, x2, x6, [x7]        ; encoding: [0xe2,0x98,0x21,0xc8]
+; CHECK: stlxp  w1, w2, w6, [x9]        ; encoding: [0x22,0x99,0x21,0x88]
 
 
 ;-----------------------------------------------------------------------------




More information about the llvm-commits mailing list