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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 8 additions & 15 deletions llvm/lib/Target/AArch64/AArch64InstrFormats.td
Original file line number Diff line number Diff line change
Expand Up @@ -12529,26 +12529,19 @@ multiclass STOPregister<string asm, string instr> {
!cast<Instruction>(instr # "X")>;
}

let Predicates = [HasLSUI] in
class BaseSTOPregisterLSUI<string asm, RegisterClass OP, Register Reg,
Instruction inst> :
InstAlias<asm # "\t$Rs, [$Rn]", (inst Reg, OP:$Rs, GPR64sp:$Rn)>;
InstAlias<asm # "\t$Rs, [$Rn]", (inst Reg, OP:$Rs, GPR64sp:$Rn), 0>;

multiclass STOPregisterLSUI<string asm, string instr> {
def : BaseSTOPregisterLSUI<asm # "a", GPR32, WZR,
!cast<Instruction>(instr # "W")>;
def : BaseSTOPregisterLSUI<asm # "a", GPR64, XZR,
!cast<Instruction>(instr # "X")>;
def : BaseSTOPregisterLSUI<asm # "l", GPR32, WZR,
!cast<Instruction>(instr # "W")>;
def : BaseSTOPregisterLSUI<asm # "l", GPR64, XZR,
!cast<Instruction>(instr # "X")>;
def : BaseSTOPregisterLSUI<asm # "al", GPR32, WZR,
!cast<Instruction>(instr # "W")>;
def : BaseSTOPregisterLSUI<asm # "al", GPR64, XZR,
!cast<Instruction>(instr # "X")>;
def : BaseSTOPregisterLSUI<asm, GPR32, WZR,
def : BaseSTOPregisterLSUI<asm # "l", GPR32, WZR,
!cast<Instruction>(instr # "LW")>;
def : BaseSTOPregisterLSUI<asm # "l", GPR64, XZR,
!cast<Instruction>(instr # "LX")>;
def : BaseSTOPregisterLSUI<asm, GPR32, WZR,
!cast<Instruction>(instr # "W")>;
def : BaseSTOPregisterLSUI<asm, GPR64, XZR,
def : BaseSTOPregisterLSUI<asm, GPR64, XZR,
!cast<Instruction>(instr # "X")>;
}

Expand Down
23 changes: 0 additions & 23 deletions llvm/lib/Target/AArch64/AArch64InstrInfo.td
Original file line number Diff line number Diff line change
Expand Up @@ -2665,21 +2665,11 @@ 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">;

// v9.6-a atomic CASPT
defm CASPT : CompareAndSwapPairUnprivileged<0b01, 0, 0, "">;
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">;
}

// v8.1 atomic SWP
Expand All @@ -2694,11 +2684,6 @@ let Predicates = [HasLSUI] in {
defm SWPTA : SwapLSUI<1, 0, "a">;
defm SWPTL : SwapLSUI<0, 1, "l">;
defm SWPTAL : SwapLSUI<1, 1, "al">;

def : MnemonicAlias<"swp", "swpt">;
def : MnemonicAlias<"swpa", "swpta">;
def : MnemonicAlias<"swpl", "swptl">;
def : MnemonicAlias<"swpal", "swptal">;
}

// v9.6-a unprivileged atomic LD<OP> (FEAT_LSUI)
Expand Down Expand Up @@ -4863,22 +4848,14 @@ let Predicates = [HasLSUI] in {
defm LDTXRW : LoadUnprivilegedLSUI<0b10, GPR32, "ldtxr">;
defm LDTXRX : LoadUnprivilegedLSUI<0b11, GPR64, "ldtxr">;

def : MnemonicAlias<"ldxr", "ldtxr">;

def LDATXRW : LoadExclusiveLSUI <0b10, 1, 1, GPR32, "ldatxr">;
def LDATXRX : LoadExclusiveLSUI <0b11, 1, 1, GPR64, "ldatxr">;

def : MnemonicAlias<"ldaxr", "ldatxr">;

defm STTXRW : StoreUnprivilegedLSUI<0b10, GPR32, "sttxr">;
defm STTXRX : StoreUnprivilegedLSUI<0b11, GPR64, "sttxr">;

def : MnemonicAlias<"stxr", "sttxr">;

def STLTXRW : StoreExclusiveLSUI<0b10, 0, 1, GPR32, "stltxr">;
def STLTXRX : StoreExclusiveLSUI<0b11, 0, 1, GPR64, "stltxr">;

def : MnemonicAlias<"stlxr", "stltxr">;
}

//===----------------------------------------------------------------------===//
Expand Down
2 changes: 2 additions & 0 deletions llvm/test/MC/AArch64/armv8.1a-lse.s
Original file line number Diff line number Diff line change
Expand Up @@ -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
// RUN: FileCheck -check-prefix=CHECK-ERROR < %t %s
.text

Expand Down
102 changes: 12 additions & 90 deletions llvm/test/MC/AArch64/armv9.6a-lsui.s
Original file line number Diff line number Diff line change
Expand Up @@ -313,42 +313,16 @@ _func:
// ERROR: instruction requires: lsui

sttaddl w0, [x2]
// CHECK: ldtadd w0, wzr, [x2] // encoding: [0x5f,0x04,0x20,0x19]
// CHECK: ldtaddl w0, wzr, [x2] // encoding: [0x5f,0x04,0x60,0x19]
// ERROR: instruction requires: lsui
sttaddl w2, [sp]
// CHECK: ldtadd w2, wzr, [sp] // encoding: [0xff,0x07,0x22,0x19]
// CHECK: ldtaddl w2, wzr, [sp] // encoding: [0xff,0x07,0x62,0x19]
// ERROR: instruction requires: lsui
sttaddl x0, [x2]
// CHECK: ldtadd x0, xzr, [x2] // encoding: [0x5f,0x04,0x20,0x59]
// CHECK: ldtaddl x0, xzr, [x2] // encoding: [0x5f,0x04,0x60,0x59]
// ERROR: instruction requires: lsui
sttaddl x2, [sp]
// CHECK: ldtadd x2, xzr, [sp] // encoding: [0xff,0x07,0x22,0x59]
// ERROR: instruction requires: lsui

sttadda w0, [x2]
// CHECK: ldtadd w0, wzr, [x2] // encoding: [0x5f,0x04,0x20,0x19]
// ERROR: instruction requires: lsui
sttadda w2, [sp]
// CHECK: ldtadd w2, wzr, [sp] // encoding: [0xff,0x07,0x22,0x19]
// ERROR: instruction requires: lsui
sttadda x0, [x2]
// CHECK: ldtadd x0, xzr, [x2] // encoding: [0x5f,0x04,0x20,0x59]
// ERROR: instruction requires: lsui
sttadda x2, [sp]
// CHECK: ldtadd x2, xzr, [sp] // encoding: [0xff,0x07,0x22,0x59]
// ERROR: instruction requires: lsui

sttaddal w0, [x2]
// CHECK: ldtadd w0, wzr, [x2] // encoding: [0x5f,0x04,0x20,0x19]
// ERROR: instruction requires: lsui
sttaddal w2, [sp]
// CHECK: ldtadd w2, wzr, [sp] // encoding: [0xff,0x07,0x22,0x19]
// ERROR: instruction requires: lsui
sttaddal x0, [x2]
// CHECK: ldtadd x0, xzr, [x2] // encoding: [0x5f,0x04,0x20,0x59]
// ERROR: instruction requires: lsui
sttaddal x2, [sp]
// CHECK: ldtadd x2, xzr, [sp] // encoding: [0xff,0x07,0x22,0x59]
// CHECK: ldtaddl x2, xzr, [sp] // encoding: [0xff,0x07,0x62,0x59]
// ERROR: instruction requires: lsui

sttclr w0, [x2]
Expand All @@ -362,45 +336,19 @@ _func:
// ERROR: instruction requires: lsui
sttclr x2, [sp]
// CHECK: ldtclr x2, xzr, [sp] // encoding: [0xff,0x17,0x22,0x59]
// ERROR: instruction requires: lsui

sttclra w0, [x2]
// CHECK: ldtclr w0, wzr, [x2] // encoding: [0x5f,0x14,0x20,0x19]
// ERROR: instruction requires: lsui
sttclra w2, [sp]
// CHECK: ldtclr w2, wzr, [sp] // encoding: [0xff,0x17,0x22,0x19]
// ERROR: instruction requires: lsui
sttclra x0, [x2]
// CHECK: ldtclr x0, xzr, [x2] // encoding: [0x5f,0x14,0x20,0x59]
// ERROR: instruction requires: lsui
sttclra x2, [sp]
// CHECK: ldtclr x2, xzr, [sp] // encoding: [0xff,0x17,0x22,0x59]
// ERROR: instruction requires: lsui

sttclrl w0, [x2]
// CHECK: ldtclr w0, wzr, [x2] // encoding: [0x5f,0x14,0x20,0x19]
// CHECK: ldtclrl w0, wzr, [x2] // encoding: [0x5f,0x14,0x60,0x19]
// ERROR: instruction requires: lsui
sttclrl w2, [sp]
// CHECK: ldtclr w2, wzr, [sp] // encoding: [0xff,0x17,0x22,0x19]
// CHECK: ldtclrl w2, wzr, [sp] // encoding: [0xff,0x17,0x62,0x19]
// ERROR: instruction requires: lsui
sttclrl x0, [x2]
// CHECK: ldtclr x0, xzr, [x2] // encoding: [0x5f,0x14,0x20,0x59]
// CHECK: ldtclrl x0, xzr, [x2] // encoding: [0x5f,0x14,0x60,0x59]
// ERROR: instruction requires: lsui
sttclrl x2, [sp]
// CHECK: ldtclr x2, xzr, [sp] // encoding: [0xff,0x17,0x22,0x59]
// ERROR: instruction requires: lsui

sttclral w0, [x2]
// CHECK: ldtclr w0, wzr, [x2] // encoding: [0x5f,0x14,0x20,0x19]
// ERROR: instruction requires: lsui
sttclral x2, [sp]
// CHECK: ldtclr x2, xzr, [sp] // encoding: [0xff,0x17,0x22,0x59]
// ERROR: instruction requires: lsui
sttclral x0, [x2]
// CHECK: ldtclr x0, xzr, [x2] // encoding: [0x5f,0x14,0x20,0x59]
// ERROR: instruction requires: lsui
sttclral x2, [sp]
// CHECK: ldtclr x2, xzr, [sp] // encoding: [0xff,0x17,0x22,0x59]
// CHECK: ldtclrl x2, xzr, [sp] // encoding: [0xff,0x17,0x62,0x59]
// ERROR: instruction requires: lsui

sttset w0, [x2]
Expand All @@ -414,45 +362,19 @@ _func:
// ERROR: instruction requires: lsui
sttset x2, [sp]
// CHECK: ldtset x2, xzr, [sp] // encoding: [0xff,0x37,0x22,0x59]
// ERROR: instruction requires: lsui

sttseta w0, [x2]
// CHECK: ldtset w0, wzr, [x2] // encoding: [0x5f,0x34,0x20,0x19]
// ERROR: instruction requires: lsui
sttseta w2, [sp]
// CHECK: ldtset w2, wzr, [sp] // encoding: [0xff,0x37,0x22,0x19]
// ERROR: instruction requires: lsui
sttseta x0, [x2]
// CHECK: ldtset x0, xzr, [x2] // encoding: [0x5f,0x34,0x20,0x59]
// ERROR: instruction requires: lsui
sttseta x2, [sp]
// CHECK: ldtset x2, xzr, [sp] // encoding: [0xff,0x37,0x22,0x59]
// ERROR: instruction requires: lsui

sttsetl w0, [x2]
// CHECK: ldtset w0, wzr, [x2] // encoding: [0x5f,0x34,0x20,0x19]
// CHECK: ldtsetl w0, wzr, [x2] // encoding: [0x5f,0x34,0x60,0x19]
// ERROR: instruction requires: lsui
sttsetl w2, [sp]
// CHECK: ldtset w2, wzr, [sp] // encoding: [0xff,0x37,0x22,0x19]
// CHECK: ldtsetl w2, wzr, [sp] // encoding: [0xff,0x37,0x62,0x19]
// ERROR: instruction requires: lsui
sttsetl x0, [x2]
// CHECK: ldtset x0, xzr, [x2] // encoding: [0x5f,0x34,0x20,0x59]
// CHECK: ldtsetl x0, xzr, [x2] // encoding: [0x5f,0x34,0x60,0x59]
// ERROR: instruction requires: lsui
sttsetl x2, [sp]
// CHECK: ldtset x2, xzr, [sp] // encoding: [0xff,0x37,0x22,0x59]
// ERROR: instruction requires: lsui

sttsetal w0, [x2]
// CHECK: ldtset w0, wzr, [x2] // encoding: [0x5f,0x34,0x20,0x19]
// ERROR: instruction requires: lsui
sttsetal x2, [sp]
// CHECK: ldtset x2, xzr, [sp] // encoding: [0xff,0x37,0x22,0x59]
// ERROR: instruction requires: lsui
sttsetal x0, [x2]
// CHECK: ldtset x0, xzr, [x2] // encoding: [0x5f,0x34,0x20,0x59]
// ERROR: instruction requires: lsui
sttsetal x2, [sp]
// CHECK: ldtset x2, xzr, [sp] // encoding: [0xff,0x37,0x22,0x59]
// CHECK: ldtsetl x2, xzr, [sp] // encoding: [0xff,0x37,0x62,0x59]
// ERROR: instruction requires: lsui

//------------------------------------------------------------------------------
Expand Down