@@ -47,13 +47,13 @@ class LDPFormat<dag outs, dag ins, string opcodestr, string argstr>
4747 bits<5> rd1;
4848 bits<5> rd2;
4949
50- let Inst{31- 27} = rd2;
51- let Inst{26- 23} = imm7{6- 3};
52- let Inst{22- 20} = 0b000;
53- let Inst{19- 15} = rs1;
54- let Inst{14- 12} = 0b100;
55- let Inst{11- 7} = rd1;
56- let Inst{6- 0} = OPC_CUSTOM_0.Value;
50+ let Inst{31 - 27} = rd2;
51+ let Inst{26 - 23} = imm7{6 - 3};
52+ let Inst{22 - 20} = 0b000;
53+ let Inst{19 - 15} = rs1;
54+ let Inst{14 - 12} = 0b100;
55+ let Inst{11 - 7} = rd1;
56+ let Inst{6 - 0} = OPC_CUSTOM_0.Value;
5757}
5858
5959// Load word pair format.
@@ -64,13 +64,13 @@ class LWPFormat<dag outs, dag ins, string opcodestr, string argstr>
6464 bits<5> rd1;
6565 bits<5> rd2;
6666
67- let Inst{31- 27} = rd2;
68- let Inst{26- 22} = imm7{6- 2};
69- let Inst{21- 20} = 0b01;
70- let Inst{19- 15} = rs1;
71- let Inst{14- 12} = 0b100;
72- let Inst{11- 7} = rd1;
73- let Inst{6- 0} = OPC_CUSTOM_0.Value;
67+ let Inst{31 - 27} = rd2;
68+ let Inst{26 - 22} = imm7{6 - 2};
69+ let Inst{21 - 20} = 0b01;
70+ let Inst{19 - 15} = rs1;
71+ let Inst{14 - 12} = 0b100;
72+ let Inst{11 - 7} = rd1;
73+ let Inst{6 - 0} = OPC_CUSTOM_0.Value;
7474}
7575
7676// Store double pair format.
@@ -81,14 +81,14 @@ class SDPFormat<dag outs, dag ins, string opcodestr, string argstr>
8181 bits<5> rs2;
8282 bits<5> rs1;
8383
84- let Inst{31- 27} = rs3;
85- let Inst{26- 25} = imm7{6- 5};
86- let Inst{24- 20} = rs2;
87- let Inst{19- 15} = rs1;
88- let Inst{14- 12} = 0b101;
89- let Inst{11- 10} = imm7{4- 3};
90- let Inst{9- 7} = 0b000;
91- let Inst{6- 0} = OPC_CUSTOM_0.Value;
84+ let Inst{31 - 27} = rs3;
85+ let Inst{26 - 25} = imm7{6 - 5};
86+ let Inst{24 - 20} = rs2;
87+ let Inst{19 - 15} = rs1;
88+ let Inst{14 - 12} = 0b101;
89+ let Inst{11 - 10} = imm7{4 - 3};
90+ let Inst{9 - 7} = 0b000;
91+ let Inst{6 - 0} = OPC_CUSTOM_0.Value;
9292}
9393
9494// Store word pair format.
@@ -99,89 +99,167 @@ class SWPFormat<dag outs, dag ins, string opcodestr, string argstr>
9999 bits<5> rs2;
100100 bits<5> rs1;
101101
102- let Inst{31- 27} = rs3;
103- let Inst{26- 25} = imm7{6- 5};
104- let Inst{24- 20} = rs2;
105- let Inst{19- 15} = rs1;
106- let Inst{14- 12} = 0b101;
107- let Inst{11- 9} = imm7{4- 2};
108- let Inst{8- 7} = 0b01;
109- let Inst{6- 0} = OPC_CUSTOM_0.Value;
102+ let Inst{31 - 27} = rs3;
103+ let Inst{26 - 25} = imm7{6 - 5};
104+ let Inst{24 - 20} = rs2;
105+ let Inst{19 - 15} = rs1;
106+ let Inst{14 - 12} = 0b101;
107+ let Inst{11 - 9} = imm7{4 - 2};
108+ let Inst{8 - 7} = 0b01;
109+ let Inst{6 - 0} = OPC_CUSTOM_0.Value;
110110}
111111
112112// Prefetch format.
113- let hasSideEffects = 0, mayLoad = 1, mayStore = 1 in
114- class Mips_prefetch_ri<dag outs, dag ins, string opcodestr, string argstr>
113+ let hasSideEffects = 0, mayLoad = 1,
114+ mayStore = 1 in class
115+ Mips_prefetch_ri<dag outs, dag ins, string opcodestr, string argstr>
115116 : RVInst<outs, ins, opcodestr, argstr, [], InstFormatI> {
116117 bits<9> imm9;
117118 bits<5> rs1;
118119 bits<5> hint;
119120
120- let Inst{31-29} = 0b000;
121- let Inst{28-20} = imm9;
122- let Inst{19-15} = rs1;
123- let Inst{14-12} = 0b000;
124- let Inst{11-7} = hint;
125- let Inst{6-0} = OPC_CUSTOM_0.Value;
121+ let Inst{31 - 29} = 0b000;
122+ let Inst{28 - 20} = imm9;
123+ let Inst{19 - 15} = rs1;
124+ let Inst{14 - 12} = 0b000;
125+ let Inst{11 - 7} = hint;
126+ let Inst{6 - 0} = OPC_CUSTOM_0.Value;
127+ }
128+
129+ // MIPS Ext Insns
130+ let hasSideEffects = 1, mayLoad = 0,
131+ mayStore = 0 in class MIPSExtInst_ri<bits<6> shimm5, string opcodestr>
132+ : RVInstIShift<0b00000, 0b001, OPC_OP_IMM, (outs), (ins), opcodestr, ""> {
133+ let shamt = shimm5;
134+ let rd = 0;
135+ let rs1 = 0;
126136}
127137
128138//===----------------------------------------------------------------------===//
129139// MIPS extensions
130140//===----------------------------------------------------------------------===//
131- let Predicates = [HasVendorXMIPSCBOP] ,DecoderNamespace = "Xmipscbop" in {
132- def MIPS_PREF : Mips_prefetch_ri<(outs), (ins GPR:$rs1, uimm9:$imm9, uimm5:$hint),
133- "mips.pref", "$hint, ${imm9}(${rs1})">,
134- Sched<[]>;
141+ let Predicates = [HasVendorXMIPSCBOP], DecoderNamespace = "XMIPS" in {
142+ def MIPS_PREF : Mips_prefetch_ri<(outs),
143+ (ins GPR
144+ : $rs1, uimm9
145+ : $imm9, uimm5
146+ : $hint),
147+ "mips.pref", "$hint, ${imm9}(${rs1})">,
148+ Sched<[]>;
149+ }
150+
151+ let Predicates = [HasVendorXMIPSEXECTL], DecoderNamespace = "XMIPS" in {
152+ def MIPS_EHB : MIPSExtInst_ri<0b000011, "mips.ehb">;
153+ def MIPS_IHB : MIPSExtInst_ri<0b000001, "mips.ihb">;
154+ def MIPS_PAUSE : MIPSExtInst_ri<0b000101, "mips.pause">;
135155}
136156
137157let Predicates = [HasVendorXMIPSCBOP] in {
138158 // Prefetch Data Write.
139- def : Pat<(prefetch (AddrRegImm9 (XLenVT GPR:$rs1), uimm9:$imm9),
159+ def : Pat<(prefetch(AddrRegImm9(XLenVT GPR
160+ : $rs1),
161+ uimm9
162+ : $imm9),
140163 (i32 1), timm, (i32 1)),
141- (MIPS_PREF GPR:$rs1, uimm9:$imm9, 9)>;
164+ (MIPS_PREF GPR
165+ : $rs1, uimm9
166+ : $imm9, 9)>;
142167 // Prefetch Data Read.
143- def : Pat<(prefetch (AddrRegImm9 (XLenVT GPR:$rs1), uimm9:$imm9),
168+ def : Pat<(prefetch(AddrRegImm9(XLenVT GPR
169+ : $rs1),
170+ uimm9
171+ : $imm9),
144172 (i32 0), timm, (i32 1)),
145- (MIPS_PREF GPR:$rs1, uimm9:$imm9, 8)>;
173+ (MIPS_PREF GPR
174+ : $rs1, uimm9
175+ : $imm9, 8)>;
146176}
147177
148- let Predicates = [HasVendorXMIPSCMov], hasSideEffects = 0, mayLoad = 0, mayStore = 0,
149- DecoderNamespace = "Xmipscmov" in {
150- def MIPS_CCMOV : RVInstR4<0b11, 0b011, OPC_CUSTOM_0, (outs GPR:$rd),
151- (ins GPR:$rs1, GPR:$rs2, GPR:$rs3),
152- "mips.ccmov", "$rd, $rs2, $rs1, $rs3">,
153- Sched<[]>;
178+ let Predicates = [HasVendorXMIPSCMov], hasSideEffects = 0, mayLoad = 0,
179+ mayStore = 0, DecoderNamespace = "XMIPS" in {
180+ def MIPS_CCMOV : RVInstR4<0b11, 0b011, OPC_CUSTOM_0,
181+ (outs GPR
182+ : $rd),
183+ (ins GPR
184+ : $rs1, GPR
185+ : $rs2, GPR
186+ : $rs3),
187+ "mips.ccmov", "$rd, $rs2, $rs1, $rs3">,
188+ Sched<[]>;
154189}
155190
156191let Predicates = [UseCCMovInsn] in {
157- def : Pat<(select (riscv_setne (XLenVT GPR:$rs2)),
158- (XLenVT GPR:$rs1), (XLenVT GPR:$rs3)),
159- (MIPS_CCMOV GPR:$rs1, GPR:$rs2, GPR:$rs3)>;
160- def : Pat<(select (riscv_seteq (XLenVT GPR:$rs2)),
161- (XLenVT GPR:$rs3), (XLenVT GPR:$rs1)),
162- (MIPS_CCMOV GPR:$rs1, GPR:$rs2, GPR:$rs3)>;
163-
164- def : Pat<(select (XLenVT GPR:$rs2), (XLenVT GPR:$rs1), (XLenVT GPR:$rs3)),
165- (MIPS_CCMOV GPR:$rs1, GPR:$rs2, GPR:$rs3)>;
192+ def : Pat<(select(riscv_setne(XLenVT GPR
193+ : $rs2)),
194+ (XLenVT GPR
195+ : $rs1),
196+ (XLenVT GPR
197+ : $rs3)),
198+ (MIPS_CCMOV GPR
199+ : $rs1, GPR
200+ : $rs2, GPR
201+ : $rs3)>;
202+ def : Pat<(select(riscv_seteq(XLenVT GPR
203+ : $rs2)),
204+ (XLenVT GPR
205+ : $rs3),
206+ (XLenVT GPR
207+ : $rs1)),
208+ (MIPS_CCMOV GPR
209+ : $rs1, GPR
210+ : $rs2, GPR
211+ : $rs3)>;
212+
213+ def : Pat<(select(XLenVT GPR
214+ : $rs2),
215+ (XLenVT GPR
216+ : $rs1),
217+ (XLenVT GPR
218+ : $rs3)),
219+ (MIPS_CCMOV GPR
220+ : $rs1, GPR
221+ : $rs2, GPR
222+ : $rs3)>;
166223}
167224
168225let Predicates = [HasVendorXMIPSLSP], hasSideEffects = 0,
169- DecoderNamespace = "Xmipslsp" in {
170- let mayLoad = 1, mayStore = 0 in {
171- def MIPS_LWP : LWPFormat<(outs GPR:$rd1, GPR:$rd2), (ins GPR:$rs1, uimm7_lsb00:$imm7),
172- "mips.lwp", "$rd1, $rd2, ${imm7}(${rs1})">,
173- Sched<[WriteLDW, WriteLDW, ReadMemBase]>;
174- def MIPS_LDP : LDPFormat<(outs GPR:$rd1, GPR:$rd2), (ins GPR:$rs1, uimm7_lsb000:$imm7),
175- "mips.ldp", "$rd1, $rd2, ${imm7}(${rs1})">,
176- Sched<[WriteLDD, WriteLDD, ReadMemBase]>;
177- } // mayLoad = 1, mayStore = 0
178-
179- let mayLoad = 0, mayStore = 1 in {
180- def MIPS_SWP : SWPFormat<(outs), (ins GPR:$rs2, GPR:$rs3, GPR:$rs1, uimm7_lsb00:$imm7),
181- "mips.swp", "$rs2, $rs3, ${imm7}(${rs1})">,
182- Sched<[WriteSTW, ReadStoreData, ReadStoreData, ReadMemBase]>;
183- def MIPS_SDP : SDPFormat<(outs), (ins GPR:$rs2, GPR:$rs3, GPR:$rs1, uimm7_lsb000:$imm7),
184- "mips.sdp", "$rs2, $rs3, ${imm7}(${rs1})">,
185- Sched<[WriteSTD, ReadStoreData, ReadStoreData, ReadMemBase]>;
186- } // mayLoad = 0, mayStore = 1
187- } // Predicates = [HasVendorXMIPSLSP], hasSideEffects = 0, DecoderNamespace = "Xmipslsp"
226+ DecoderNamespace = "XMIPS" in {
227+ let mayLoad = 1, mayStore = 0 in {
228+ def MIPS_LWP : LWPFormat<(outs GPR
229+ : $rd1, GPR
230+ : $rd2),
231+ (ins GPR
232+ : $rs1, uimm7_lsb00
233+ : $imm7),
234+ "mips.lwp", "$rd1, $rd2, ${imm7}(${rs1})">,
235+ Sched<[WriteLDW, WriteLDW, ReadMemBase]>;
236+ def MIPS_LDP : LDPFormat<(outs GPR
237+ : $rd1, GPR
238+ : $rd2),
239+ (ins GPR
240+ : $rs1, uimm7_lsb000
241+ : $imm7),
242+ "mips.ldp", "$rd1, $rd2, ${imm7}(${rs1})">,
243+ Sched<[WriteLDD, WriteLDD, ReadMemBase]>;
244+ } // mayLoad = 1, mayStore = 0
245+
246+ let mayLoad = 0, mayStore = 1 in {
247+ def MIPS_SWP : SWPFormat<(outs),
248+ (ins GPR
249+ : $rs2, GPR
250+ : $rs3, GPR
251+ : $rs1, uimm7_lsb00
252+ : $imm7),
253+ "mips.swp", "$rs2, $rs3, ${imm7}(${rs1})">,
254+ Sched<[WriteSTW, ReadStoreData, ReadStoreData, ReadMemBase]>;
255+ def MIPS_SDP : SDPFormat<(outs),
256+ (ins GPR
257+ : $rs2, GPR
258+ : $rs3, GPR
259+ : $rs1, uimm7_lsb000
260+ : $imm7),
261+ "mips.sdp", "$rs2, $rs3, ${imm7}(${rs1})">,
262+ Sched<[WriteSTD, ReadStoreData, ReadStoreData, ReadMemBase]>;
263+ } // mayLoad = 0, mayStore = 1
264+ } // Predicates = [HasVendorXMIPSLSP], hasSideEffects = 0, DecoderNamespace =
265+ // "XMIPS"
0 commit comments