diff options
author | Alex Bradbury <asb@lowrisc.org> | 2017-12-12 15:17:45 +0000 |
---|---|---|
committer | Alex Bradbury <asb@lowrisc.org> | 2017-12-12 15:17:45 +0000 |
commit | 15d22cecdfe4a36a63f63e55118fbb4787906c06 (patch) | |
tree | 94d402dcf417ccbc5f005bdfb5c3b99c6c6e70fb /lib | |
parent | 50ead9021f9c9ad106e5e70f625fe33c4bf1878a (diff) |
[RISCV] MC layer support for the instructions added in the privileged spec
Adds support for the instructions added in the RISC-V privileged ISA
(https://content.riscv.org/wp-content/uploads/2017/05/riscv-privileged-v1.10.pdf):
uret, sret, mret, wfi, and sfence.vma.
Note from the committer: I made very minor formatting changes prior to commit,
which didn't seem worth creating another review round-trip for.
Differential Revision: https://reviews.llvm.org/D40383
Patch by David Craven.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320484 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Target/RISCV/RISCVInstrInfo.td | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/lib/Target/RISCV/RISCVInstrInfo.td b/lib/Target/RISCV/RISCVInstrInfo.td index 9512435cf2f..dcfcccf4960 100644 --- a/lib/Target/RISCV/RISCVInstrInfo.td +++ b/lib/Target/RISCV/RISCVInstrInfo.td @@ -211,6 +211,11 @@ class ALUW_rr<bits<7> funct7, bits<3> funct3, string opcodestr> : RVInstR<funct7, funct3, OPC_OP_32, (outs GPR:$rd), (ins GPR:$rs1, GPR:$rs2), opcodestr, "$rd, $rs1, $rs2">; +let hasSideEffects = 1, mayLoad = 0, mayStore = 0 in +class Priv<string opcodestr, bits<7> funct7> + : RVInstR<funct7, 0b000, OPC_SYSTEM, (outs), (ins GPR:$rs1, GPR:$rs2), + opcodestr, "">; + //===----------------------------------------------------------------------===// // Instructions //===----------------------------------------------------------------------===// @@ -334,6 +339,43 @@ def SRAW : ALUW_rr<0b0100000, 0b101, "sraw">; } // Predicates = [IsRV64] //===----------------------------------------------------------------------===// +// Privileged instructions +//===----------------------------------------------------------------------===// + +let isBarrier = 1, isReturn = 1, isTerminator = 1 in { +def URET : Priv<"uret", 0b0000000> { + let rd = 0; + let rs1 = 0; + let rs2 = 0b00010; +} + +def SRET : Priv<"sret", 0b0001000> { + let rd = 0; + let rs1 = 0; + let rs2 = 0b00010; +} + +def MRET : Priv<"mret", 0b0011000> { + let rd = 0; + let rs1 = 0; + let rs2 = 0b00010; +} +} // isBarrier = 1, isReturn = 1, isTerminator = 1 + +def WFI : Priv<"wfi", 0b0001000> { + let rd = 0; + let rs1 = 0; + let rs2 = 0b00101; +} + +let hasSideEffects = 1, mayLoad = 0, mayStore = 0 in +def SFENCE_VMA : RVInstR<0b0001001, 0b000, OPC_SYSTEM, (outs), + (ins GPR:$rs1, GPR:$rs2), + "sfence.vma", "$rs1, $rs2"> { + let rd = 0; +} + +//===----------------------------------------------------------------------===// // Pseudo-instructions and codegen patterns // // Naming convention: For 'generic' pattern classes, we use the naming |