diff --git a/llvm/lib/Support/RISCVISAInfo.cpp b/llvm/lib/Support/RISCVISAInfo.cpp --- a/llvm/lib/Support/RISCVISAInfo.cpp +++ b/llvm/lib/Support/RISCVISAInfo.cpp @@ -102,6 +102,7 @@ }; static const RISCVSupportedExtension SupportedExperimentalExtensions[] = { + {"zawrs", RISCVExtensionVersion{1, 0}}, {"zbe", RISCVExtensionVersion{0, 93}}, {"zbf", RISCVExtensionVersion{0, 93}}, {"zbm", RISCVExtensionVersion{0, 93}}, diff --git a/llvm/lib/Target/RISCV/RISCV.td b/llvm/lib/Target/RISCV/RISCV.td --- a/llvm/lib/Target/RISCV/RISCV.td +++ b/llvm/lib/Target/RISCV/RISCV.td @@ -114,6 +114,13 @@ AssemblerPredicate<(all_of FeatureStdExtC), "'C' (Compressed Instructions)">; +def FeatureStdExtZawrs + : SubtargetFeature<"experimental-zawrs", "HasStdExtZawrs", "true", + "'Zawrs' (Wait on Reservation Set)">; +def HasStdExtZawrs : Predicate<"Subtarget->hasStdExtZawrs()">, + AssemblerPredicate<(all_of FeatureStdExtZawrs), + "'Zawrs' (Wait on Reservation Set)">; + def FeatureStdExtZba : SubtargetFeature<"zba", "HasStdExtZba", "true", "'Zba' (Address Generation Instructions)">; diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfo.td b/llvm/lib/Target/RISCV/RISCVInstrInfo.td --- a/llvm/lib/Target/RISCV/RISCVInstrInfo.td +++ b/llvm/lib/Target/RISCV/RISCVInstrInfo.td @@ -707,6 +707,23 @@ let rd = 0; let imm12 = 0b110000000000; } + +let Predicates = [HasStdExtZawrs] in { +def WRS_NTO : RVInstI<0b000, OPC_SYSTEM, (outs), (ins), "wrs.nto", "">, + Sched<[]> { + let rs1 = 0; + let rd = 0; + let imm12 = 0b000000001101; +} + +def WRS_STO : RVInstI<0b000, OPC_SYSTEM, (outs), (ins), "wrs.sto", "">, + Sched<[]> { + let rs1 = 0; + let rd = 0; + let imm12 = 0b000000011101; +} +} // Predicates = [HasStdExtZawrs] + } // hasSideEffects = 1, mayLoad = 0, mayStore = 0 def CSRRW : CSR_ir<0b001, "csrrw">; diff --git a/llvm/lib/Target/RISCV/RISCVSubtarget.h b/llvm/lib/Target/RISCV/RISCVSubtarget.h --- a/llvm/lib/Target/RISCV/RISCVSubtarget.h +++ b/llvm/lib/Target/RISCV/RISCVSubtarget.h @@ -50,6 +50,7 @@ bool HasStdExtD = false; bool HasStdExtC = false; bool HasStdExtZihintpause = false; + bool HasStdExtZawrs = false; bool HasStdExtZba = false; bool HasStdExtZbb = false; bool HasStdExtZbc = false; @@ -154,6 +155,7 @@ bool hasStdExtC() const { return HasStdExtC; } bool hasStdExtV() const { return HasStdExtV; } bool hasStdExtZihintpause() const { return HasStdExtZihintpause; } + bool hasStdExtZawrs() const { return HasStdExtZawrs; } bool hasStdExtZba() const { return HasStdExtZba; } bool hasStdExtZbb() const { return HasStdExtZbb; } bool hasStdExtZbc() const { return HasStdExtZbc; } diff --git a/llvm/test/MC/RISCV/rv32zawrs-valid.s b/llvm/test/MC/RISCV/rv32zawrs-valid.s new file mode 100644 --- /dev/null +++ b/llvm/test/MC/RISCV/rv32zawrs-valid.s @@ -0,0 +1,18 @@ +# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-zawrs -riscv-no-aliases -show-encoding \ +# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s +# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zawrs -riscv-no-aliases -show-encoding \ +# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s +# RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+experimental-zawrs < %s \ +# RUN: | llvm-objdump --mattr=+experimental-zawrs -M no-aliases -d -r - \ +# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s +# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+experimental-zawrs < %s \ +# RUN: | llvm-objdump --mattr=+experimental-zawrs -M no-aliases -d -r - \ +# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s + +# CHECK-ASM-AND-OBJ: wrs.nto +# CHECK-ASM: encoding: [0x73,0x00,0xd0,0x00] +wrs.nto + +# CHECK-ASM-AND-OBJ: wrs.sto +# CHECK-ASM: encoding: [0x73,0x00,0xd0,0x01] +wrs.sto