Skip to content

[LLVM][AArch64] Remove aliases of LSUI instructions #126072

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 13, 2025

Conversation

kmclaughlin-arm
Copy link
Contributor

@kmclaughlin-arm kmclaughlin-arm commented Feb 6, 2025

Removes MnemonicAliases added for instructions available with
the LSUI feature (e.g. CAS -> CAST) which are not equivalent.
The aliases stt[add|clr|set]a & stt[add|clr|set]al are also removed.

…tions

Replaces the MnemonicAliases added for compare and swap instructions
to use InstAlias. This ensures we don't try to map to instructions
where the operands do not match when both the LSE & LSUI features
are available.
@llvmbot
Copy link
Member

llvmbot commented Feb 6, 2025

@llvm/pr-subscribers-backend-aarch64

Author: Kerry McLaughlin (kmclaughlin-arm)

Changes

Replaces the MnemonicAliases added for compare and swap instructions
to use InstAlias. This ensures we don't try to map to instructions where the
operands do not match when both the LSE & LSUI features are available.


Full diff: https://github.com/llvm/llvm-project/pull/126072.diff

3 Files Affected:

  • (modified) llvm/lib/Target/AArch64/AArch64InstrInfo.td (+12-8)
  • (modified) llvm/test/MC/AArch64/armv8.1a-lse.s (+47)
  • (added) llvm/test/MC/AArch64/lse-lsui-diagnostics.s (+40)
diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.td b/llvm/lib/Target/AArch64/AArch64InstrInfo.td
index a0928b9095fccdd..99ac26dff4b2210 100644
--- a/llvm/lib/Target/AArch64/AArch64InstrInfo.td
+++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.td
@@ -2665,10 +2665,10 @@ defm CASLT  : CompareAndSwapUnprivileged<0b11, 0, 1, "l">;
 defm CASAT  : CompareAndSwapUnprivileged<0b11, 1, 0, "a">;
 defm CASALT : CompareAndSwapUnprivileged<0b11, 1, 1, "al">;
 
-def : MnemonicAlias<"cas", "cast">;
-def : MnemonicAlias<"casl", "caslt">;
-def : MnemonicAlias<"casa", "casat">;
-def : MnemonicAlias<"casal", "casalt">;
+def : InstAlias<"cast $Rs, $Rt, [$Rn]", (CASX GPR64:$Rs, GPR64:$Rt, GPR64sp0:$Rn)>;
+def : InstAlias<"caslt $Rs, $Rt, [$Rn]", (CASLX GPR64:$Rs, GPR64:$Rt, GPR64sp0:$Rn)>;
+def : InstAlias<"casat $Rs, $Rt, [$Rn]", (CASAX GPR64:$Rs, GPR64:$Rt, GPR64sp0:$Rn)>;
+def : InstAlias<"casalt $Rs, $Rt, [$Rn]", (CASALX GPR64:$Rs, GPR64:$Rt, GPR64sp0:$Rn)>;
 
 // v9.6-a atomic CASPT
 defm CASPT   : CompareAndSwapPairUnprivileged<0b01, 0, 0, "">;
@@ -2676,10 +2676,14 @@ defm CASPLT  : CompareAndSwapPairUnprivileged<0b01, 0, 1, "l">;
 defm CASPAT  : CompareAndSwapPairUnprivileged<0b01, 1, 0, "a">;
 defm CASPALT : CompareAndSwapPairUnprivileged<0b01, 1, 1, "al">;
 
-def : MnemonicAlias<"casp", "caspt">;
-def : MnemonicAlias<"caspl", "casplt">;
-def : MnemonicAlias<"caspa", "caspat">;
-def : MnemonicAlias<"caspal", "caspalt">;
+def : InstAlias<"caspt $Rs, $Rt, [$Rn]",
+                (CASPX XSeqPairClassOperand:$Rs, XSeqPairClassOperand:$Rt, GPR64sp0:$Rn)>;
+def : InstAlias<"casplt $Rs, $Rt, [$Rn]",
+                (CASPLX XSeqPairClassOperand:$Rs, XSeqPairClassOperand:$Rt, GPR64sp0:$Rn)>;
+def : InstAlias<"caspat $Rs, $Rt, [$Rn]",
+                (CASPAX XSeqPairClassOperand:$Rs, XSeqPairClassOperand:$Rt, GPR64sp0:$Rn)>;
+def : InstAlias<"caspalt $Rs, $Rt, [$Rn]",
+                (CASPALX XSeqPairClassOperand:$Rs, XSeqPairClassOperand:$Rt, GPR64sp0:$Rn)>;
 }
 
 // v8.1 atomic SWP
diff --git a/llvm/test/MC/AArch64/armv8.1a-lse.s b/llvm/test/MC/AArch64/armv8.1a-lse.s
index b5bbbe66c6ae26b..f78bb50b6a4ae86 100644
--- a/llvm/test/MC/AArch64/armv8.1a-lse.s
+++ b/llvm/test/MC/AArch64/armv8.1a-lse.s
@@ -7,6 +7,8 @@
 // RUN: not llvm-mc -triple aarch64-none-linux-gnu -mcpu=tsv110 -show-encoding < %s 2> %t | FileCheck %s
 // RUN: FileCheck -check-prefix=CHECK-ERROR < %t %s
 // RUN: not llvm-mc -triple aarch64-none-linux-gnu -mattr=+v8r -show-encoding < %s 2> %t | FileCheck %s
+// RUN: FileCheck -check-prefix=CHECK-ERROR < %t %s
+// RUN: not llvm-mc -triple aarch64-none-linux-gnu -mattr=+v8.1a,+lse,+lsui -show-encoding < %s 2> %t | FileCheck %s -check-prefix=CHECK-FEAT-LSUI
 // RUN: FileCheck -check-prefix=CHECK-ERROR < %t %s
   .text
 
@@ -78,6 +80,15 @@
   // CHECK: casal x0, x1, [x2]    // encoding: [0x41,0xfc,0xe0,0xc8]
   // CHECK: casal x2, x3, [sp]    // encoding: [0xe3,0xff,0xe2,0xc8]
 
+  // CHECK-FEAT-LSUI: cast x0, x1, [x2]      // encoding: [0x41,0x7c,0xa0,0xc8]
+  // CHECK-FEAT-LSUI: cast x2, x3, [sp]      // encoding: [0xe3,0x7f,0xa2,0xc8]
+  // CHECK-FEAT-LSUI: casat x0, x1, [x2]     // encoding: [0x41,0x7c,0xe0,0xc8]
+  // CHECK-FEAT-LSUI: casat x2, x3, [sp]     // encoding: [0xe3,0x7f,0xe2,0xc8]
+  // CHECK-FEAT-LSUI: caslt x0, x1, [x2]     // encoding: [0x41,0xfc,0xa0,0xc8]
+  // CHECK-FEAT-LSUI: caslt x2, x3, [sp]     // encoding: [0xe3,0xff,0xa2,0xc8]
+  // CHECK-FEAT-LSUI: casalt x0, x1, [x2]    // encoding: [0x41,0xfc,0xe0,0xc8]
+  // CHECK-FEAT-LSUI: casalt x2, x3, [sp]    // encoding: [0xe3,0xff,0xe2,0xc8]
+
   swp w0, w1, [x2]
   swp w2, w3, [sp]
   swpa w0, w1, [x2]
@@ -95,6 +106,15 @@
   // CHECK: swpal w0, w1, [x2]    // encoding: [0x41,0x80,0xe0,0xb8]
   // CHECK: swpal w2, w3, [sp]    // encoding: [0xe3,0x83,0xe2,0xb8]
 
+  // CHECK-FEAT-LSUI: swpt w0, w1, [x2]      // encoding: [0x41,0x84,0x20,0x19]
+  // CHECK-FEAT-LSUI: swpt w2, w3, [sp]      // encoding: [0xe3,0x87,0x22,0x19]
+  // CHECK-FEAT-LSUI: swpta w0, w1, [x2]     // encoding: [0x41,0x84,0xa0,0x19]
+  // CHECK-FEAT-LSUI: swpta w2, w3, [sp]     // encoding: [0xe3,0x87,0xa2,0x19]
+  // CHECK-FEAT-LSUI: swptl w0, w1, [x2]     // encoding: [0x41,0x84,0x60,0x19]
+  // CHECK-FEAT-LSUI: swptl w2, w3, [sp]     // encoding: [0xe3,0x87,0x62,0x19]
+  // CHECK-FEAT-LSUI: swptal w0, w1, [x2]    // encoding: [0x41,0x84,0xe0,0x19]
+  // CHECK-FEAT-LSUI: swptal w2, w3, [sp]    // encoding: [0xe3,0x87,0xe2,0x19]
+
   swpb w0, w1, [x2]
   swpb w2, w3, [sp]
   swph w0, w1, [x2]
@@ -112,6 +132,15 @@
   // CHECK: swplb w0, w1, [x2]    // encoding: [0x41,0x80,0x60,0x38]
   // CHECK: swplb w2, w3, [sp]    // encoding: [0xe3,0x83,0x62,0x38]
 
+  // CHECK-FEAT-LSUI: swpt x0, x1, [x2]      // encoding: [0x41,0x84,0x20,0x59]
+  // CHECK-FEAT-LSUI: swpt x2, x3, [sp]      // encoding: [0xe3,0x87,0x22,0x59]
+  // CHECK-FEAT-LSUI: swpta x0, x1, [x2]     // encoding: [0x41,0x84,0xa0,0x59]
+  // CHECK-FEAT-LSUI: swpta x2, x3, [sp]     // encoding: [0xe3,0x87,0xa2,0x59]
+  // CHECK-FEAT-LSUI: swptl x0, x1, [x2]     // encoding: [0x41,0x84,0x60,0x59]
+  // CHECK-FEAT-LSUI: swptl x2, x3, [sp]     // encoding: [0xe3,0x87,0x62,0x59]
+  // CHECK-FEAT-LSUI: swptal x0, x1, [x2]    // encoding: [0x41,0x84,0xe0,0x59]
+  // CHECK-FEAT-LSUI: swptal x2, x3, [sp]    // encoding: [0xe3,0x87,0xe2,0x59]
+
   swpalb w0, w1, [x2]
   swpalb w2, w3, [sp]
   swpah w0, w1, [x2]
@@ -163,6 +192,15 @@
   // CHECK: caspa x0, x1, x2, x3, [x2]    // encoding: [0x42,0x7c,0x60,0x48]
   // CHECK: caspa x4, x5, x6, x7, [sp]    // encoding: [0xe6,0x7f,0x64,0x48]
 
+  // CHECK-FEAT-LSUI: casp w0, w1, w2, w3, [x5]     // encoding: [0xa2,0x7c,0x20,0x08]
+  // CHECK-FEAT-LSUI: casp w4, w5, w6, w7, [sp]     // encoding: [0xe6,0x7f,0x24,0x08]
+  // CHECK-FEAT-LSUI: caspt x0, x1, x2, x3, [x2]    // encoding: [0x42,0x7c,0x20,0x48]
+  // CHECK-FEAT-LSUI: caspt x4, x5, x6, x7, [sp]    // encoding: [0xe6,0x7f,0x24,0x48]
+  // CHECK-FEAT-LSUI: caspa w0, w1, w2, w3, [x5]    // encoding: [0xa2,0x7c,0x60,0x08]
+  // CHECK-FEAT-LSUI: caspa w4, w5, w6, w7, [sp]    // encoding: [0xe6,0x7f,0x64,0x08]
+  // CHECK-FEAT-LSUI: caspat x0, x1, x2, x3, [x2]   // encoding: [0x42,0x7c,0x60,0x48]
+  // CHECK-FEAT-LSUI: caspat x4, x5, x6, x7, [sp]   // encoding: [0xe6,0x7f,0x64,0x48]
+
   caspl w0, w1, w2, w3, [x5]
   caspl w4, w5, w6, w7, [sp]
   caspl x0, x1, x2, x3, [x2]
@@ -180,6 +218,15 @@
   // CHECK: caspal x0, x1, x2, x3, [x2]   // encoding: [0x42,0xfc,0x60,0x48]
   // CHECK: caspal x4, x5, x6, x7, [sp]   // encoding: [0xe6,0xff,0x64,0x48]
 
+  // CHECK-FEAT-LSUI: caspl w0, w1, w2, w3, [x5]     // encoding: [0xa2,0xfc,0x20,0x08]
+  // CHECK-FEAT-LSUI: caspl w4, w5, w6, w7, [sp]     // encoding: [0xe6,0xff,0x24,0x08]
+  // CHECK-FEAT-LSUI: casplt x0, x1, x2, x3, [x2]    // encoding: [0x42,0xfc,0x20,0x48]
+  // CHECK-FEAT-LSUI: casplt x4, x5, x6, x7, [sp]    // encoding: [0xe6,0xff,0x24,0x48]
+  // CHECK-FEAT-LSUI: caspal w0, w1, w2, w3, [x5]    // encoding: [0xa2,0xfc,0x60,0x08]
+  // CHECK-FEAT-LSUI: caspal w4, w5, w6, w7, [sp]    // encoding: [0xe6,0xff,0x64,0x08]
+  // CHECK-FEAT-LSUI: caspalt x0, x1, x2, x3, [x2]   // encoding: [0x42,0xfc,0x60,0x48]
+  // CHECK-FEAT-LSUI: caspalt x4, x5, x6, x7, [sp]   // encoding: [0xe6,0xff,0x64,0x48]
+
   ldadd w0, w1, [x2]
   ldadd w2, w3, [sp]
   ldadda w0, w1, [x2]
diff --git a/llvm/test/MC/AArch64/lse-lsui-diagnostics.s b/llvm/test/MC/AArch64/lse-lsui-diagnostics.s
new file mode 100644
index 000000000000000..75202cface97083
--- /dev/null
+++ b/llvm/test/MC/AArch64/lse-lsui-diagnostics.s
@@ -0,0 +1,40 @@
+// RUN: llvm-mc -triple aarch64 -mattr=+lse -mattr=+lsui -show-encoding %s  | FileCheck %s
+// RUN: not llvm-mc -triple aarch64 -mattr=+lsui -show-encoding %s 2>&1  | FileCheck %s --check-prefix=ERROR
+
+_func:
+// CHECK: _func:
+
+//------------------------------------------------------------------------------
+// CAS(P)T instructions
+//------------------------------------------------------------------------------
+cas w26, w28, [x21]
+// CHECK: cas  w26, w28, [x21]
+// ERROR: error: instruction requires: lse
+
+casl w26, w28, [x21]
+// CHECK: casl  w26, w28, [x21]
+// ERROR: error: instruction requires: lse
+
+casa w26, w28, [x21]
+// CHECK: casa  w26, w28, [x21]
+// ERROR: error: instruction requires: lse
+
+casal w26, w28, [x21]
+// CHECK: casal  w26, w28, [x21]
+// ERROR: error: instruction requires: lse
+
+casp w26, w27, w28, w29, [x21]
+// CHECK: casp w26, w27, w28, w29, [x21]
+// ERROR: error: instruction requires: lse
+
+caspl w26, w27, w28, w29, [x21]
+// CHECK: caspl w26, w27, w28, w29, [x21]
+// ERROR: error: instruction requires: lse
+
+caspa w26, w27, w28, w29, [x21]
+// CHECK: caspa w26, w27, w28, w29, [x21]
+// ERROR: error: instruction requires: lse
+
+caspal w26, w27, w28, w29, [x21]
+// CHECK: caspal w26, w27, w28, w29, [x21]
+// ERROR: error: instruction requires: lse

@llvmbot
Copy link
Member

llvmbot commented Feb 6, 2025

@llvm/pr-subscribers-mc

Author: Kerry McLaughlin (kmclaughlin-arm)

Changes

Replaces the MnemonicAliases added for compare and swap instructions
to use InstAlias. This ensures we don't try to map to instructions where the
operands do not match when both the LSE & LSUI features are available.


Full diff: https://github.com/llvm/llvm-project/pull/126072.diff

3 Files Affected:

  • (modified) llvm/lib/Target/AArch64/AArch64InstrInfo.td (+12-8)
  • (modified) llvm/test/MC/AArch64/armv8.1a-lse.s (+47)
  • (added) llvm/test/MC/AArch64/lse-lsui-diagnostics.s (+40)
diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.td b/llvm/lib/Target/AArch64/AArch64InstrInfo.td
index a0928b9095fccdd..99ac26dff4b2210 100644
--- a/llvm/lib/Target/AArch64/AArch64InstrInfo.td
+++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.td
@@ -2665,10 +2665,10 @@ defm CASLT  : CompareAndSwapUnprivileged<0b11, 0, 1, "l">;
 defm CASAT  : CompareAndSwapUnprivileged<0b11, 1, 0, "a">;
 defm CASALT : CompareAndSwapUnprivileged<0b11, 1, 1, "al">;
 
-def : MnemonicAlias<"cas", "cast">;
-def : MnemonicAlias<"casl", "caslt">;
-def : MnemonicAlias<"casa", "casat">;
-def : MnemonicAlias<"casal", "casalt">;
+def : InstAlias<"cast $Rs, $Rt, [$Rn]", (CASX GPR64:$Rs, GPR64:$Rt, GPR64sp0:$Rn)>;
+def : InstAlias<"caslt $Rs, $Rt, [$Rn]", (CASLX GPR64:$Rs, GPR64:$Rt, GPR64sp0:$Rn)>;
+def : InstAlias<"casat $Rs, $Rt, [$Rn]", (CASAX GPR64:$Rs, GPR64:$Rt, GPR64sp0:$Rn)>;
+def : InstAlias<"casalt $Rs, $Rt, [$Rn]", (CASALX GPR64:$Rs, GPR64:$Rt, GPR64sp0:$Rn)>;
 
 // v9.6-a atomic CASPT
 defm CASPT   : CompareAndSwapPairUnprivileged<0b01, 0, 0, "">;
@@ -2676,10 +2676,14 @@ defm CASPLT  : CompareAndSwapPairUnprivileged<0b01, 0, 1, "l">;
 defm CASPAT  : CompareAndSwapPairUnprivileged<0b01, 1, 0, "a">;
 defm CASPALT : CompareAndSwapPairUnprivileged<0b01, 1, 1, "al">;
 
-def : MnemonicAlias<"casp", "caspt">;
-def : MnemonicAlias<"caspl", "casplt">;
-def : MnemonicAlias<"caspa", "caspat">;
-def : MnemonicAlias<"caspal", "caspalt">;
+def : InstAlias<"caspt $Rs, $Rt, [$Rn]",
+                (CASPX XSeqPairClassOperand:$Rs, XSeqPairClassOperand:$Rt, GPR64sp0:$Rn)>;
+def : InstAlias<"casplt $Rs, $Rt, [$Rn]",
+                (CASPLX XSeqPairClassOperand:$Rs, XSeqPairClassOperand:$Rt, GPR64sp0:$Rn)>;
+def : InstAlias<"caspat $Rs, $Rt, [$Rn]",
+                (CASPAX XSeqPairClassOperand:$Rs, XSeqPairClassOperand:$Rt, GPR64sp0:$Rn)>;
+def : InstAlias<"caspalt $Rs, $Rt, [$Rn]",
+                (CASPALX XSeqPairClassOperand:$Rs, XSeqPairClassOperand:$Rt, GPR64sp0:$Rn)>;
 }
 
 // v8.1 atomic SWP
diff --git a/llvm/test/MC/AArch64/armv8.1a-lse.s b/llvm/test/MC/AArch64/armv8.1a-lse.s
index b5bbbe66c6ae26b..f78bb50b6a4ae86 100644
--- a/llvm/test/MC/AArch64/armv8.1a-lse.s
+++ b/llvm/test/MC/AArch64/armv8.1a-lse.s
@@ -7,6 +7,8 @@
 // RUN: not llvm-mc -triple aarch64-none-linux-gnu -mcpu=tsv110 -show-encoding < %s 2> %t | FileCheck %s
 // RUN: FileCheck -check-prefix=CHECK-ERROR < %t %s
 // RUN: not llvm-mc -triple aarch64-none-linux-gnu -mattr=+v8r -show-encoding < %s 2> %t | FileCheck %s
+// RUN: FileCheck -check-prefix=CHECK-ERROR < %t %s
+// RUN: not llvm-mc -triple aarch64-none-linux-gnu -mattr=+v8.1a,+lse,+lsui -show-encoding < %s 2> %t | FileCheck %s -check-prefix=CHECK-FEAT-LSUI
 // RUN: FileCheck -check-prefix=CHECK-ERROR < %t %s
   .text
 
@@ -78,6 +80,15 @@
   // CHECK: casal x0, x1, [x2]    // encoding: [0x41,0xfc,0xe0,0xc8]
   // CHECK: casal x2, x3, [sp]    // encoding: [0xe3,0xff,0xe2,0xc8]
 
+  // CHECK-FEAT-LSUI: cast x0, x1, [x2]      // encoding: [0x41,0x7c,0xa0,0xc8]
+  // CHECK-FEAT-LSUI: cast x2, x3, [sp]      // encoding: [0xe3,0x7f,0xa2,0xc8]
+  // CHECK-FEAT-LSUI: casat x0, x1, [x2]     // encoding: [0x41,0x7c,0xe0,0xc8]
+  // CHECK-FEAT-LSUI: casat x2, x3, [sp]     // encoding: [0xe3,0x7f,0xe2,0xc8]
+  // CHECK-FEAT-LSUI: caslt x0, x1, [x2]     // encoding: [0x41,0xfc,0xa0,0xc8]
+  // CHECK-FEAT-LSUI: caslt x2, x3, [sp]     // encoding: [0xe3,0xff,0xa2,0xc8]
+  // CHECK-FEAT-LSUI: casalt x0, x1, [x2]    // encoding: [0x41,0xfc,0xe0,0xc8]
+  // CHECK-FEAT-LSUI: casalt x2, x3, [sp]    // encoding: [0xe3,0xff,0xe2,0xc8]
+
   swp w0, w1, [x2]
   swp w2, w3, [sp]
   swpa w0, w1, [x2]
@@ -95,6 +106,15 @@
   // CHECK: swpal w0, w1, [x2]    // encoding: [0x41,0x80,0xe0,0xb8]
   // CHECK: swpal w2, w3, [sp]    // encoding: [0xe3,0x83,0xe2,0xb8]
 
+  // CHECK-FEAT-LSUI: swpt w0, w1, [x2]      // encoding: [0x41,0x84,0x20,0x19]
+  // CHECK-FEAT-LSUI: swpt w2, w3, [sp]      // encoding: [0xe3,0x87,0x22,0x19]
+  // CHECK-FEAT-LSUI: swpta w0, w1, [x2]     // encoding: [0x41,0x84,0xa0,0x19]
+  // CHECK-FEAT-LSUI: swpta w2, w3, [sp]     // encoding: [0xe3,0x87,0xa2,0x19]
+  // CHECK-FEAT-LSUI: swptl w0, w1, [x2]     // encoding: [0x41,0x84,0x60,0x19]
+  // CHECK-FEAT-LSUI: swptl w2, w3, [sp]     // encoding: [0xe3,0x87,0x62,0x19]
+  // CHECK-FEAT-LSUI: swptal w0, w1, [x2]    // encoding: [0x41,0x84,0xe0,0x19]
+  // CHECK-FEAT-LSUI: swptal w2, w3, [sp]    // encoding: [0xe3,0x87,0xe2,0x19]
+
   swpb w0, w1, [x2]
   swpb w2, w3, [sp]
   swph w0, w1, [x2]
@@ -112,6 +132,15 @@
   // CHECK: swplb w0, w1, [x2]    // encoding: [0x41,0x80,0x60,0x38]
   // CHECK: swplb w2, w3, [sp]    // encoding: [0xe3,0x83,0x62,0x38]
 
+  // CHECK-FEAT-LSUI: swpt x0, x1, [x2]      // encoding: [0x41,0x84,0x20,0x59]
+  // CHECK-FEAT-LSUI: swpt x2, x3, [sp]      // encoding: [0xe3,0x87,0x22,0x59]
+  // CHECK-FEAT-LSUI: swpta x0, x1, [x2]     // encoding: [0x41,0x84,0xa0,0x59]
+  // CHECK-FEAT-LSUI: swpta x2, x3, [sp]     // encoding: [0xe3,0x87,0xa2,0x59]
+  // CHECK-FEAT-LSUI: swptl x0, x1, [x2]     // encoding: [0x41,0x84,0x60,0x59]
+  // CHECK-FEAT-LSUI: swptl x2, x3, [sp]     // encoding: [0xe3,0x87,0x62,0x59]
+  // CHECK-FEAT-LSUI: swptal x0, x1, [x2]    // encoding: [0x41,0x84,0xe0,0x59]
+  // CHECK-FEAT-LSUI: swptal x2, x3, [sp]    // encoding: [0xe3,0x87,0xe2,0x59]
+
   swpalb w0, w1, [x2]
   swpalb w2, w3, [sp]
   swpah w0, w1, [x2]
@@ -163,6 +192,15 @@
   // CHECK: caspa x0, x1, x2, x3, [x2]    // encoding: [0x42,0x7c,0x60,0x48]
   // CHECK: caspa x4, x5, x6, x7, [sp]    // encoding: [0xe6,0x7f,0x64,0x48]
 
+  // CHECK-FEAT-LSUI: casp w0, w1, w2, w3, [x5]     // encoding: [0xa2,0x7c,0x20,0x08]
+  // CHECK-FEAT-LSUI: casp w4, w5, w6, w7, [sp]     // encoding: [0xe6,0x7f,0x24,0x08]
+  // CHECK-FEAT-LSUI: caspt x0, x1, x2, x3, [x2]    // encoding: [0x42,0x7c,0x20,0x48]
+  // CHECK-FEAT-LSUI: caspt x4, x5, x6, x7, [sp]    // encoding: [0xe6,0x7f,0x24,0x48]
+  // CHECK-FEAT-LSUI: caspa w0, w1, w2, w3, [x5]    // encoding: [0xa2,0x7c,0x60,0x08]
+  // CHECK-FEAT-LSUI: caspa w4, w5, w6, w7, [sp]    // encoding: [0xe6,0x7f,0x64,0x08]
+  // CHECK-FEAT-LSUI: caspat x0, x1, x2, x3, [x2]   // encoding: [0x42,0x7c,0x60,0x48]
+  // CHECK-FEAT-LSUI: caspat x4, x5, x6, x7, [sp]   // encoding: [0xe6,0x7f,0x64,0x48]
+
   caspl w0, w1, w2, w3, [x5]
   caspl w4, w5, w6, w7, [sp]
   caspl x0, x1, x2, x3, [x2]
@@ -180,6 +218,15 @@
   // CHECK: caspal x0, x1, x2, x3, [x2]   // encoding: [0x42,0xfc,0x60,0x48]
   // CHECK: caspal x4, x5, x6, x7, [sp]   // encoding: [0xe6,0xff,0x64,0x48]
 
+  // CHECK-FEAT-LSUI: caspl w0, w1, w2, w3, [x5]     // encoding: [0xa2,0xfc,0x20,0x08]
+  // CHECK-FEAT-LSUI: caspl w4, w5, w6, w7, [sp]     // encoding: [0xe6,0xff,0x24,0x08]
+  // CHECK-FEAT-LSUI: casplt x0, x1, x2, x3, [x2]    // encoding: [0x42,0xfc,0x20,0x48]
+  // CHECK-FEAT-LSUI: casplt x4, x5, x6, x7, [sp]    // encoding: [0xe6,0xff,0x24,0x48]
+  // CHECK-FEAT-LSUI: caspal w0, w1, w2, w3, [x5]    // encoding: [0xa2,0xfc,0x60,0x08]
+  // CHECK-FEAT-LSUI: caspal w4, w5, w6, w7, [sp]    // encoding: [0xe6,0xff,0x64,0x08]
+  // CHECK-FEAT-LSUI: caspalt x0, x1, x2, x3, [x2]   // encoding: [0x42,0xfc,0x60,0x48]
+  // CHECK-FEAT-LSUI: caspalt x4, x5, x6, x7, [sp]   // encoding: [0xe6,0xff,0x64,0x48]
+
   ldadd w0, w1, [x2]
   ldadd w2, w3, [sp]
   ldadda w0, w1, [x2]
diff --git a/llvm/test/MC/AArch64/lse-lsui-diagnostics.s b/llvm/test/MC/AArch64/lse-lsui-diagnostics.s
new file mode 100644
index 000000000000000..75202cface97083
--- /dev/null
+++ b/llvm/test/MC/AArch64/lse-lsui-diagnostics.s
@@ -0,0 +1,40 @@
+// RUN: llvm-mc -triple aarch64 -mattr=+lse -mattr=+lsui -show-encoding %s  | FileCheck %s
+// RUN: not llvm-mc -triple aarch64 -mattr=+lsui -show-encoding %s 2>&1  | FileCheck %s --check-prefix=ERROR
+
+_func:
+// CHECK: _func:
+
+//------------------------------------------------------------------------------
+// CAS(P)T instructions
+//------------------------------------------------------------------------------
+cas w26, w28, [x21]
+// CHECK: cas  w26, w28, [x21]
+// ERROR: error: instruction requires: lse
+
+casl w26, w28, [x21]
+// CHECK: casl  w26, w28, [x21]
+// ERROR: error: instruction requires: lse
+
+casa w26, w28, [x21]
+// CHECK: casa  w26, w28, [x21]
+// ERROR: error: instruction requires: lse
+
+casal w26, w28, [x21]
+// CHECK: casal  w26, w28, [x21]
+// ERROR: error: instruction requires: lse
+
+casp w26, w27, w28, w29, [x21]
+// CHECK: casp w26, w27, w28, w29, [x21]
+// ERROR: error: instruction requires: lse
+
+caspl w26, w27, w28, w29, [x21]
+// CHECK: caspl w26, w27, w28, w29, [x21]
+// ERROR: error: instruction requires: lse
+
+caspa w26, w27, w28, w29, [x21]
+// CHECK: caspa w26, w27, w28, w29, [x21]
+// ERROR: error: instruction requires: lse
+
+caspal w26, w27, w28, w29, [x21]
+// CHECK: caspal w26, w27, w28, w29, [x21]
+// ERROR: error: instruction requires: lse

Copy link
Contributor

@jthackray jthackray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 😃

@kmclaughlin-arm kmclaughlin-arm changed the title [LLVM][AArch64] Replace MnemonicAlias with InstAlias for CAS* instructions [LLVM][AArch64] Remove aliases of LSUI instructions Feb 11, 2025
Copy link
Contributor

@CarolineConcatto CarolineConcatto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you Kerry for the patch.
LGTM!

@CarolineConcatto CarolineConcatto added this to the LLVM 20.X Release milestone Feb 12, 2025
@kmclaughlin-arm kmclaughlin-arm merged commit d44d806 into llvm:main Feb 13, 2025
8 checks passed
flovent pushed a commit to flovent/llvm-project that referenced this pull request Feb 13, 2025
Removes MnemonicAliases added for instructions available with
the LSUI feature (e.g. CAS -> CAST) which are not equivalent.
The aliases stt[add|clr|set]a & stt[add|clr|set]al are also removed.
@kmclaughlin-arm
Copy link
Contributor Author

/cherry-pick d44d806

@llvmbot
Copy link
Member

llvmbot commented Feb 13, 2025

/pull-request #127084

joaosaffran pushed a commit to joaosaffran/llvm-project that referenced this pull request Feb 14, 2025
Removes MnemonicAliases added for instructions available with
the LSUI feature (e.g. CAS -> CAST) which are not equivalent.
The aliases stt[add|clr|set]a & stt[add|clr|set]al are also removed.
swift-ci pushed a commit to swiftlang/llvm-project that referenced this pull request Feb 20, 2025
Removes MnemonicAliases added for instructions available with
the LSUI feature (e.g. CAS -> CAST) which are not equivalent.
The aliases stt[add|clr|set]a & stt[add|clr|set]al are also removed.

(cherry picked from commit d44d806)
sivan-shani pushed a commit to sivan-shani/llvm-project that referenced this pull request Feb 24, 2025
Removes MnemonicAliases added for instructions available with
the LSUI feature (e.g. CAS -> CAST) which are not equivalent.
The aliases stt[add|clr|set]a & stt[add|clr|set]al are also removed.
@kmclaughlin-arm kmclaughlin-arm deleted the lsui-alias branch May 27, 2025 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:AArch64 mc Machine (object) code
Projects
Development

Successfully merging this pull request may close these issues.

4 participants