1 //===-- RISCVInstrInfoZimop.td -----------------------------*- tablegen -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file describes the RISC-V instructions from the standard
10 // May-Be-Operations Extension (Zimop).
12 //===----------------------------------------------------------------------===//
14 class RVInstIMopr<bits<7> imm7, bits<5> imm5, bits<3> funct3, RISCVOpcode opcode,
15 dag outs, dag ins, string opcodestr, string argstr>
16 : RVInstIBase<funct3, opcode, outs, ins, opcodestr, argstr> {
17 let Inst{31} = imm7{6};
18 let Inst{30} = imm5{4};
19 let Inst{29-28} = imm7{5-4};
20 let Inst{27-26} = imm5{3-2};
21 let Inst{25-22} = imm7{3-0};
22 let Inst{21-20} = imm5{1-0};
25 class RVInstRMoprr<bits<4> imm4, bits<3> imm3, bits<3> funct3, RISCVOpcode opcode,
26 dag outs, dag ins, string opcodestr, string argstr>
27 : RVInstRBase<funct3, opcode, outs, ins, opcodestr, argstr> {
28 let Inst{31} = imm4{3};
29 let Inst{30} = imm3{2};
30 let Inst{29-28} = imm4{2-1};
31 let Inst{27-26} = imm3{1-0};
32 let Inst{25} = imm4{0};
35 def riscv_mopr : SDNode<"RISCVISD::MOPR",
36 SDTypeProfile<1, 2, [SDTCisInt<0>, SDTCisSameAs<0, 1>,
37 SDTCisSameAs<0, 2>]>>;
38 def riscv_moprr : SDNode<"RISCVISD::MOPRR",
39 SDTypeProfile<1, 3, [SDTCisInt<0>, SDTCisSameAs<0, 1>,
41 SDTCisSameAs<0, 3>]>>;
43 let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
44 class RVMopr<bits<7> imm7, bits<5> imm5, bits<3> funct3,
45 RISCVOpcode opcode, string opcodestr>
46 : RVInstIMopr<imm7, imm5, funct3, opcode, (outs GPR:$rd), (ins GPR:$rs1),
47 opcodestr, "$rd, $rs1">;
49 let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
50 class RVMoprr<bits<4> imm4, bits<3> imm3, bits<3> funct3,
51 RISCVOpcode opcode, string opcodestr>
52 : RVInstRMoprr<imm4, imm3, funct3, opcode, (outs GPR:$rd), (ins GPR:$rs1, GPR:$rs2),
53 opcodestr, "$rd, $rs1, $rs2">;
55 foreach i = 0...31 in {
56 let Predicates = [HasStdExtZimop] in
57 def MOPR#i : RVMopr<0b1000111, i, 0b100, OPC_SYSTEM, "mop.r."#i>,
61 foreach i = 0...7 in {
62 let Predicates = [HasStdExtZimop] in
63 def MOPRR#i : RVMoprr<0b1001, i, 0b100, OPC_SYSTEM, "mop.rr."#i>,
67 let Predicates = [HasStdExtZimop] in {
69 foreach i = 0...31 in {
70 def : Pat<(XLenVT (riscv_mopr GPR:$rs1, (XLenVT i))),
71 (!cast<Instruction>("MOPR"#i) GPR:$rs1)>;
74 foreach i = 0...7 in {
75 def : Pat<(XLenVT (riscv_moprr GPR:$rs1, GPR:$rs2, (XLenVT i))),
76 (!cast<Instruction>("MOPRR"#i) GPR:$rs1, GPR:$rs2)>;
79 } // Predicates = [HasStdExtZimop]