[RISCV] Rename Mips instruction records to start with MIPS_. NFC (#125170)
[llvm-project.git] / llvm / lib / Target / RISCV / RISCVInstrInfoXMips.td
blobf53a887f62d4641b530f873cca4cefecdf6a1005
1 //===-- RISCVInstrInfoXMips.td -----------------------------*- tablegen -*-===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file describes the vendor extensions defined by MIPS.
11 //===----------------------------------------------------------------------===//
13 //===----------------------------------------------------------------------===//
14 // Operand definitions.
15 //===----------------------------------------------------------------------===//
17 // A 7-bit unsigned immediate where the least significant three bits are zero.
18 def uimm7_lsb000 : RISCVOp,
19                    ImmLeaf<XLenVT, [{return isShiftedUInt<4, 3>(Imm);}]> {
20   let ParserMatchClass = UImmAsmOperand<7, "Lsb000">;
21   let EncoderMethod = "getImmOpValue";
22   let DecoderMethod = "decodeUImmOperand<7>";
23   let OperandType = "OPERAND_UIMM7_LSB000";
24   let MCOperandPredicate = [{
25     int64_t Imm;
26     if (!MCOp.evaluateAsConstantImm(Imm))
27       return false;
28     return isShiftedUInt<4, 3>(Imm);
29   }];
32 //===----------------------------------------------------------------------===//
33 // MIPS custom instruction formats
34 //===----------------------------------------------------------------------===//
36 // Load double pair format.
37 class LDPFormat<dag outs, dag ins, string opcodestr, string argstr>
38     : RVInst<outs, ins, opcodestr, argstr, [], InstFormatI> {
39   bits<7> imm7;
40   bits<5> rs1;
41   bits<5> rd1;
42   bits<5> rd2;
44   let Inst{31-27} = rd2;
45   let Inst{26-23} = imm7{6-3};
46   let Inst{22-20} = 0b000;
47   let Inst{19-15} = rs1;
48   let Inst{14-12} = 0b100;
49   let Inst{11-7} = rd1;
50   let Inst{6-0} = OPC_CUSTOM_0.Value;
53 // Load word pair format.
54 class LWPFormat<dag outs, dag ins, string opcodestr, string argstr>
55     : RVInst<outs, ins, opcodestr, argstr, [], InstFormatI> {
56   bits<7> imm7;
57   bits<5> rs1;
58   bits<5> rd1;
59   bits<5> rd2;
61   let Inst{31-27} = rd2;
62   let Inst{26-22} = imm7{6-2};
63   let Inst{21-20} = 0b01;
64   let Inst{19-15} = rs1;
65   let Inst{14-12} = 0b100;
66   let Inst{11-7} = rd1;
67   let Inst{6-0} = OPC_CUSTOM_0.Value;
70 // Store double pair format.
71 class SDPFormat<dag outs, dag ins, string opcodestr, string argstr>
72     : RVInst<outs, ins, opcodestr, argstr, [], InstFormatI> {
73   bits<7> imm7;
74   bits<5> rs3;
75   bits<5> rs2;
76   bits<5> rs1;
78   let Inst{31-27} = rs3;
79   let Inst{26-25} = imm7{6-5};
80   let Inst{24-20} = rs2;
81   let Inst{19-15} = rs1;
82   let Inst{14-12} = 0b101;
83   let Inst{11-10} = imm7{4-3};
84   let Inst{9-7} = 0b000;
85   let Inst{6-0} = OPC_CUSTOM_0.Value;
88 // Store word pair format.
89 class SWPFormat<dag outs, dag ins, string opcodestr, string argstr>
90     : RVInst<outs, ins, opcodestr, argstr, [], InstFormatI> {
91   bits<7> imm7;
92   bits<5> rs3;
93   bits<5> rs2;
94   bits<5> rs1;
96   let Inst{31-27} = rs3;
97   let Inst{26-25} = imm7{6-5};
98   let Inst{24-20} = rs2;
99   let Inst{19-15} = rs1;
100   let Inst{14-12} = 0b101;
101   let Inst{11-9} = imm7{4-2};
102   let Inst{8-7} = 0b01;
103   let Inst{6-0} = OPC_CUSTOM_0.Value;
106 //===----------------------------------------------------------------------===//
107 // MIPS extensions
108 //===----------------------------------------------------------------------===//
110 let Predicates = [HasVendorXMIPSCMove], hasSideEffects = 0, mayLoad = 0, mayStore = 0,
111                  DecoderNamespace = "Xmipscmove" in {
112 def MIPS_CCMOV : RVInstR4<0b11, 0b011, OPC_CUSTOM_0, (outs GPR:$rd),
113                           (ins GPR:$rs1, GPR:$rs2, GPR:$rs3),
114                           "mips.ccmov", "$rd, $rs2, $rs1, $rs3">,
115                  Sched<[]>;
118 let Predicates = [UseCCMovInsn] in {
119 def : Pat<(select (XLenVT (setne (XLenVT GPR:$rs2), (XLenVT 0))),
120                   (XLenVT GPR:$rs1), (XLenVT GPR:$rs3)),
121           (MIPS_CCMOV GPR:$rs1, GPR:$rs2, GPR:$rs3)>;
122 def : Pat<(select (XLenVT (setne (XLenVT GPR:$x), (XLenVT simm12_plus1:$y))),
123                   (XLenVT GPR:$rs1), (XLenVT GPR:$rs3)),
124           (MIPS_CCMOV GPR:$rs1, (ADDI GPR:$x, (NegImm simm12_plus1:$y)), GPR:$rs3)>;
125 def : Pat<(select (XLenVT (setne (XLenVT GPR:$x), (XLenVT GPR:$y))),
126                   (XLenVT GPR:$rs1), (XLenVT GPR:$rs3)),
127           (MIPS_CCMOV GPR:$rs1, (XOR GPR:$x, GPR:$y), GPR:$rs3)>;
128 def : Pat<(select (XLenVT (seteq (XLenVT GPR:$rs2), (XLenVT 0))),
129                   (XLenVT GPR:$rs3), (XLenVT GPR:$rs1)),
130           (MIPS_CCMOV GPR:$rs1, GPR:$rs2, GPR:$rs3)>;
131 def : Pat<(select (XLenVT (seteq (XLenVT GPR:$x), (XLenVT simm12_plus1:$y))),
132                   (XLenVT GPR:$rs3), (XLenVT GPR:$rs1)),
133           (MIPS_CCMOV GPR:$rs1, (ADDI GPR:$x, (NegImm simm12_plus1:$y)), GPR:$rs3)>;
134 def : Pat<(select (XLenVT (seteq (XLenVT GPR:$x), (XLenVT GPR:$y))),
135                   (XLenVT GPR:$rs3), (XLenVT GPR:$rs1)),
136           (MIPS_CCMOV GPR:$rs1, (XOR GPR:$x, GPR:$y), GPR:$rs3)>;
137 def : Pat<(select (XLenVT GPR:$rs2), (XLenVT GPR:$rs1), (XLenVT GPR:$rs3)),
138           (MIPS_CCMOV GPR:$rs1, GPR:$rs2, GPR:$rs3)>;
141 let Predicates = [HasVendorXMIPSLSP], hasSideEffects = 0,
142                  DecoderNamespace = "Xmipslsp" in {
143 let mayLoad = 1, mayStore = 0 in {
144 def MIPS_LWP : LWPFormat<(outs GPR:$rd1, GPR:$rd2), (ins GPR:$rs1, uimm7_lsb00:$imm7),
145                          "mips.lwp", "$rd1, $rd2, ${imm7}(${rs1})">,
146                Sched<[WriteLDW, WriteLDW, ReadMemBase]>;
147 def MIPS_LDP : LDPFormat<(outs GPR:$rd1, GPR:$rd2), (ins GPR:$rs1, uimm7_lsb000:$imm7),
148                          "mips.ldp", "$rd1, $rd2, ${imm7}(${rs1})">,
149                Sched<[WriteLDD, WriteLDD, ReadMemBase]>;
150 } // mayLoad = 1, mayStore = 0
152 let mayLoad = 0, mayStore = 1 in {
153 def MIPS_SWP : SWPFormat<(outs), (ins GPR:$rs2, GPR:$rs3, GPR:$rs1, uimm7_lsb00:$imm7),
154                          "mips.swp", "$rs2, $rs3, ${imm7}(${rs1})">,
155                Sched<[WriteSTW, ReadStoreData, ReadStoreData, ReadMemBase]>;
156 def MIPS_SDP : SDPFormat<(outs), (ins GPR:$rs2, GPR:$rs3, GPR:$rs1, uimm7_lsb000:$imm7),
157                          "mips.sdp", "$rs2, $rs3, ${imm7}(${rs1})">,
158                Sched<[WriteSTD, ReadStoreData, ReadStoreData, ReadMemBase]>;
159 } // mayLoad = 0, mayStore = 1
160 } // Predicates = [HasVendorXMIPSLSP], hasSideEffects = 0, DecoderNamespace = "Xmipslsp"