Skip to content

[AArch64] Add assembly/disaasembly of atomic ld/st #112892

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 2 commits into from
Oct 21, 2024
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
61 changes: 61 additions & 0 deletions llvm/lib/Target/AArch64/AArch64InstrFormats.td
Original file line number Diff line number Diff line change
Expand Up @@ -12626,3 +12626,64 @@ def : TokenAlias<".H", ".h">;
def : TokenAlias<".S", ".s">;
def : TokenAlias<".D", ".d">;
def : TokenAlias<".Q", ".q">;

//----------------------------------------------------------------------------
// 2024 Armv9.6 Extensions
//----------------------------------------------------------------------------

let mayLoad = 1, mayStore = 1 in
class BaseAtomicFPLoad<RegisterClass regtype, bits<2> sz, bits<2> AR,
bits<3> op0, string asm>
: I<(outs regtype:$Rt),
(ins regtype:$Rs, GPR64sp:$Rn),
asm, "\t$Rs, $Rt, [$Rn]","", []>,
Sched<[]> {
bits<5> Rt;
bits<5> Rs;
bits<5> Rn;
let Inst{31-30} = sz;
let Inst{29-24} = 0b111100;
let Inst{23-22} = AR;
let Inst{21} = 0b1;
let Inst{20-16} = Rs;
let Inst{15} = 0b0;
let Inst{14-12} = op0;
let Inst{11-10} = 0b00;
let Inst{9-5} = Rn;
let Inst{4-0} = Rt;
}

multiclass AtomicFPLoad<bits<2> AR, bits<3> op0, string asm> {
def D : BaseAtomicFPLoad<FPR64, 0b11, AR, op0, asm>;
def S : BaseAtomicFPLoad<FPR32, 0b10, AR, op0, asm>;
def H : BaseAtomicFPLoad<FPR16, 0b01, AR, op0, asm>;
}

let mayLoad = 1, mayStore = 1 in
class BaseAtomicFPStore<RegisterClass regtype, bits<2> sz, bit R,
bits<3> op0, string asm>
: I<(outs),
(ins regtype:$Rs, GPR64sp:$Rn),
asm, "\t$Rs, [$Rn]",
"", []>,
Sched<[]> {
bits<5> Rt;
bits<5> Rs;
bits<5> Rn;
let Inst{31-30} = sz;
let Inst{29-23} = 0b1111000;
let Inst{22} = R;
let Inst{21} = 0b1;
let Inst{20-16} = Rs;
let Inst{15} = 0b1;
let Inst{14-12} = op0;
let Inst{11-10} = 0b00;
let Inst{9-5} = Rn;
let Inst{4-0} = 0b11111;
}

multiclass AtomicFPStore<bit R, bits<3> op0, string asm> {
def D : BaseAtomicFPStore<FPR64, 0b11, R, op0, asm>;
def S : BaseAtomicFPStore<FPR32, 0b10, R, op0, asm>;
def H : BaseAtomicFPStore<FPR16, 0b01, R, op0, asm>;
}
72 changes: 72 additions & 0 deletions llvm/lib/Target/AArch64/AArch64InstrInfo.td
Original file line number Diff line number Diff line change
Expand Up @@ -10378,6 +10378,78 @@ defm : PromoteBinaryv8f16Tov4f32<any_fdiv, FDIVv4f32>;
defm : PromoteBinaryv8f16Tov4f32<any_fmul, FMULv4f32>;
defm : PromoteBinaryv8f16Tov4f32<any_fsub, FSUBv4f32>;

//===-----------------------------------------------------===//
// Atomic floating-point in-memory instructions (FEAT_LSFE)
//===-----------------------------------------------------===//

let Predicates = [HasLSFE] in {
// Floating-point Atomic Load
defm LDFADDA : AtomicFPLoad<0b10, 0b000, "ldfadda">;
defm LDFADDAL : AtomicFPLoad<0b11, 0b000, "ldfaddal">;
defm LDFADD : AtomicFPLoad<0b00, 0b000, "ldfadd">;
defm LDFADDL : AtomicFPLoad<0b01, 0b000, "ldfaddl">;
defm LDFMAXA : AtomicFPLoad<0b10, 0b100, "ldfmaxa">;
defm LDFMAXAL : AtomicFPLoad<0b11, 0b100, "ldfmaxal">;
defm LDFMAX : AtomicFPLoad<0b00, 0b100, "ldfmax">;
defm LDFMAXL : AtomicFPLoad<0b01, 0b100, "ldfmaxl">;
defm LDFMINA : AtomicFPLoad<0b10, 0b101, "ldfmina">;
defm LDFMINAL : AtomicFPLoad<0b11, 0b101, "ldfminal">;
defm LDFMIN : AtomicFPLoad<0b00, 0b101, "ldfmin">;
defm LDFMINL : AtomicFPLoad<0b01, 0b101, "ldfminl">;
defm LDFMAXNMA : AtomicFPLoad<0b10, 0b110, "ldfmaxnma">;
defm LDFMAXNMAL : AtomicFPLoad<0b11, 0b110, "ldfmaxnmal">;
defm LDFMAXNM : AtomicFPLoad<0b00, 0b110, "ldfmaxnm">;
defm LDFMAXNML : AtomicFPLoad<0b01, 0b110, "ldfmaxnml">;
defm LDFMINNMA : AtomicFPLoad<0b10, 0b111, "ldfminnma">;
defm LDFMINNMAL : AtomicFPLoad<0b11, 0b111, "ldfminnmal">;
defm LDFMINMN : AtomicFPLoad<0b00, 0b111, "ldfminnm">;
defm LDFMINNML : AtomicFPLoad<0b01, 0b111, "ldfminnml">;
// BFloat16
def LDBFADDA : BaseAtomicFPLoad<FPR16, 0b00, 0b10, 0b000, "ldbfadda">;
def LDBFADDAL : BaseAtomicFPLoad<FPR16, 0b00, 0b11, 0b000, "ldbfaddal">;
def LDBFADD : BaseAtomicFPLoad<FPR16, 0b00, 0b00, 0b000, "ldbfadd">;
def LDBFADDL : BaseAtomicFPLoad<FPR16, 0b00, 0b01, 0b000, "ldbfaddl">;
def LDBFMAXA : BaseAtomicFPLoad<FPR16, 0b00, 0b10, 0b100, "ldbfmaxa">;
def LDBFMAXAL : BaseAtomicFPLoad<FPR16, 0b00, 0b11, 0b100, "ldbfmaxal">;
def LDBFMAX : BaseAtomicFPLoad<FPR16, 0b00, 0b00, 0b100, "ldbfmax">;
def LDBFMAXL : BaseAtomicFPLoad<FPR16, 0b00, 0b01, 0b100, "ldbfmaxl">;
def LDBFMINA : BaseAtomicFPLoad<FPR16, 0b00, 0b10, 0b101, "ldbfmina">;
def LDBFMINAL : BaseAtomicFPLoad<FPR16, 0b00, 0b11, 0b101, "ldbfminal">;
def LDBFMIN : BaseAtomicFPLoad<FPR16, 0b00, 0b00, 0b101, "ldbfmin">;
def LDBFMINL : BaseAtomicFPLoad<FPR16, 0b00, 0b01, 0b101, "ldbfminl">;
def LDBFMAXNMA : BaseAtomicFPLoad<FPR16, 0b00, 0b10, 0b110, "ldbfmaxnma">;
def LDBFMAXNMAL : BaseAtomicFPLoad<FPR16, 0b00, 0b11, 0b110, "ldbfmaxnmal">;
def LDBFMAXNM : BaseAtomicFPLoad<FPR16, 0b00, 0b00, 0b110, "ldbfmaxnm">;
def LDBFMAXNML : BaseAtomicFPLoad<FPR16, 0b00, 0b01, 0b110, "ldbfmaxnml">;
def LDBFMINNMA : BaseAtomicFPLoad<FPR16, 0b00, 0b10, 0b111, "ldbfminnma">;
def LDBFMINNMAL : BaseAtomicFPLoad<FPR16, 0b00, 0b11, 0b111, "ldbfminnmal">;
def LDBFMINNM : BaseAtomicFPLoad<FPR16, 0b00, 0b00, 0b111, "ldbfminnm">;
def LDBFMINNML : BaseAtomicFPLoad<FPR16, 0b00, 0b01, 0b111, "ldbfminnml">;

// Floating-point Atomic Store
defm STFADD : AtomicFPStore<0b0, 0b000, "stfadd">;
defm STFADDL : AtomicFPStore<0b1, 0b000, "stfaddl">;
defm STFMAX : AtomicFPStore<0b0, 0b100, "stfmax">;
defm STFMAXL : AtomicFPStore<0b1, 0b100, "stfmaxl">;
defm STFMIN : AtomicFPStore<0b0, 0b101, "stfmin">;
defm STFMINL : AtomicFPStore<0b1, 0b101, "stfminl">;
defm STFMAXNM : AtomicFPStore<0b0, 0b110, "stfmaxnm">;
defm STFMAXNML : AtomicFPStore<0b1, 0b110, "stfmaxnml">;
defm STFMINNM : AtomicFPStore<0b0, 0b111, "stfminnm">;
defm STFMINNML : AtomicFPStore<0b1, 0b111, "stfminnml">;
// BFloat16
def STBFADD : BaseAtomicFPStore<FPR16, 0b00, 0b0, 0b000, "stbfadd">;
def STBFADDL : BaseAtomicFPStore<FPR16, 0b00, 0b1, 0b000, "stbfaddl">;
def STBFMAX : BaseAtomicFPStore<FPR16, 0b00, 0b0, 0b100, "stbfmax">;
def STBFMAXL : BaseAtomicFPStore<FPR16, 0b00, 0b1, 0b100, "stbfmaxl">;
def STBFMIN : BaseAtomicFPStore<FPR16, 0b00, 0b0, 0b101, "stbfmin">;
def STBFMINL : BaseAtomicFPStore<FPR16, 0b00, 0b1, 0b101, "stbfminl">;
def STBFMAXNM : BaseAtomicFPStore<FPR16, 0b00, 0b0, 0b110, "stbfmaxnm">;
def STBFMAXNML : BaseAtomicFPStore<FPR16, 0b00, 0b1, 0b110, "stbfmaxnml">;
def STBFMINNM : BaseAtomicFPStore<FPR16, 0b00, 0b0, 0b111, "stbfminnm">;
def STBFMINNML : BaseAtomicFPStore<FPR16, 0b00, 0b1, 0b111, "stbfminnml">;
}

include "AArch64InstrAtomics.td"
include "AArch64SVEInstrInfo.td"
include "AArch64SMEInstrInfo.td"
Expand Down
7 changes: 7 additions & 0 deletions llvm/test/MC/AArch64/LSFE/directive-arch-negative.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// RUN: not llvm-mc -triple aarch64 -filetype asm -o - %s 2>&1 | FileCheck %s

.arch armv9.6-a+lsfe
.arch armv9.6-a+nolsfe
ldfadd h0, h1, [x2]
// CHECK: error: instruction requires: lsfe
// CHECK: ldfadd h0, h1, [x2]
5 changes: 5 additions & 0 deletions llvm/test/MC/AArch64/LSFE/directive-arch.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// RUN: llvm-mc -triple aarch64 -o - %s 2>&1 | FileCheck %s

.arch armv9.6-a+lsfe
ldfadd h0, h1, [x2]
// CHECK: ldfadd h0, h1, [x2]
7 changes: 7 additions & 0 deletions llvm/test/MC/AArch64/LSFE/directive-arch_extension-negative.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// RUN: not llvm-mc -triple aarch64 -filetype asm -o - %s 2>&1 | FileCheck %s

.arch_extension lsfe
.arch_extension nolsfe
ldfadd h0, h1, [x2]
// CHECK: error: instruction requires: lsfe
// CHECK-NEXT: ldfadd h0, h1, [x2]
5 changes: 5 additions & 0 deletions llvm/test/MC/AArch64/LSFE/directive-arch_extension.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// RUN: llvm-mc -triple aarch64 -filetype asm -o - %s 2>&1 | FileCheck %s

.arch_extension lsfe
ldfadd h0, h1, [x2]
// CHECK: ldfadd h0, h1, [x2]
7 changes: 7 additions & 0 deletions llvm/test/MC/AArch64/LSFE/directive-cpu-negative.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// RUN: not llvm-mc -triple aarch64 -filetype asm -o - %s 2>&1 | FileCheck %s

.cpu generic+lsfe
.cpu generic+nolsfe
ldfadd h0, h1, [x2]
// CHECK: error: instruction requires: lsfe
// CHECK-NEXT: ldfadd h0, h1, [x2]
5 changes: 5 additions & 0 deletions llvm/test/MC/AArch64/LSFE/directive-cpu.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// RUN: llvm-mc -triple aarch64 -filetype asm -o - %s 2>&1 | FileCheck %s

.cpu generic+lsfe
ldfadd h0, h1, [x2]
// CHECK: ldfadd h0, h1, [x2]
Loading
Loading