1 //===-- RISCVInstrFormatsV.td - RISCV V Instruction Formats --*- 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 V extension instruction formats.
11 //===----------------------------------------------------------------------===//
13 class RISCVVFormat<bits<3> val> {
16 def OPIVV : RISCVVFormat<0b000>;
17 def OPFVV : RISCVVFormat<0b001>;
18 def OPMVV : RISCVVFormat<0b010>;
19 def OPIVI : RISCVVFormat<0b011>;
20 def OPIVX : RISCVVFormat<0b100>;
21 def OPFVF : RISCVVFormat<0b101>;
22 def OPMVX : RISCVVFormat<0b110>;
24 class RISCVMOP<bits<2> val> {
27 def MOPLDUnitStride : RISCVMOP<0b00>;
28 def MOPLDIndexedUnord : RISCVMOP<0b01>;
29 def MOPLDStrided : RISCVMOP<0b10>;
30 def MOPLDIndexedOrder : RISCVMOP<0b11>;
32 def MOPSTUnitStride : RISCVMOP<0b00>;
33 def MOPSTIndexedUnord : RISCVMOP<0b01>;
34 def MOPSTStrided : RISCVMOP<0b10>;
35 def MOPSTIndexedOrder : RISCVMOP<0b11>;
37 class RISCVLSUMOP<bits<5> val> {
40 def LUMOPUnitStride : RISCVLSUMOP<0b00000>;
41 def LUMOPUnitStrideMask : RISCVLSUMOP<0b01011>;
42 def LUMOPUnitStrideWholeReg : RISCVLSUMOP<0b01000>;
43 def LUMOPUnitStrideFF: RISCVLSUMOP<0b10000>;
44 def SUMOPUnitStride : RISCVLSUMOP<0b00000>;
45 def SUMOPUnitStrideMask : RISCVLSUMOP<0b01011>;
46 def SUMOPUnitStrideWholeReg : RISCVLSUMOP<0b01000>;
48 class RISCVAMOOP<bits<5> val> {
51 def AMOOPVamoSwap : RISCVAMOOP<0b00001>;
52 def AMOOPVamoAdd : RISCVAMOOP<0b00000>;
53 def AMOOPVamoXor : RISCVAMOOP<0b00100>;
54 def AMOOPVamoAnd : RISCVAMOOP<0b01100>;
55 def AMOOPVamoOr : RISCVAMOOP<0b01000>;
56 def AMOOPVamoMin : RISCVAMOOP<0b10000>;
57 def AMOOPVamoMax : RISCVAMOOP<0b10100>;
58 def AMOOPVamoMinu : RISCVAMOOP<0b11000>;
59 def AMOOPVamoMaxu : RISCVAMOOP<0b11100>;
61 class RISCVWidth<bits<4> val> {
64 def LSWidth8 : RISCVWidth<0b0000>;
65 def LSWidth16 : RISCVWidth<0b0101>;
66 def LSWidth32 : RISCVWidth<0b0110>;
67 def LSWidth64 : RISCVWidth<0b0111>;
69 class RVInstSetiVLi<dag outs, dag ins, string opcodestr, string argstr>
70 : RVInst<outs, ins, opcodestr, argstr, [], InstFormatI> {
77 let Inst{29-20} = vtypei{9-0};
78 let Inst{19-15} = uimm;
79 let Inst{14-12} = 0b111;
81 let Opcode = OPC_OP_V.Value;
83 let Defs = [VTYPE, VL];
86 class RVInstSetVLi<dag outs, dag ins, string opcodestr, string argstr>
87 : RVInst<outs, ins, opcodestr, argstr, [], InstFormatI> {
93 let Inst{30-20} = vtypei;
94 let Inst{19-15} = rs1;
95 let Inst{14-12} = 0b111;
97 let Opcode = OPC_OP_V.Value;
99 let Defs = [VTYPE, VL];
102 class RVInstSetVL<dag outs, dag ins, string opcodestr, string argstr>
103 : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> {
109 let Inst{30-25} = 0b000000;
110 let Inst{24-20} = rs2;
111 let Inst{19-15} = rs1;
112 let Inst{14-12} = 0b111;
114 let Opcode = OPC_OP_V.Value;
116 let Defs = [VTYPE, VL];
119 class RVInstVV<bits<6> funct6, RISCVVFormat opv, dag outs, dag ins,
120 string opcodestr, string argstr>
121 : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> {
127 let Inst{31-26} = funct6;
129 let Inst{24-20} = vs2;
130 let Inst{19-15} = vs1;
131 let Inst{14-12} = opv.Value;
133 let Opcode = OPC_OP_V.Value;
135 let Uses = [VTYPE, VL];
136 let RVVConstraint = VMConstraint;
139 class RVInstVX<bits<6> funct6, RISCVVFormat opv, dag outs, dag ins,
140 string opcodestr, string argstr>
141 : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> {
147 let Inst{31-26} = funct6;
149 let Inst{24-20} = vs2;
150 let Inst{19-15} = rs1;
151 let Inst{14-12} = opv.Value;
153 let Opcode = OPC_OP_V.Value;
155 let Uses = [VTYPE, VL];
156 let RVVConstraint = VMConstraint;
159 class RVInstV2<bits<6> funct6, bits<5> vs2, RISCVVFormat opv, dag outs, dag ins,
160 string opcodestr, string argstr>
161 : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> {
166 let Inst{31-26} = funct6;
168 let Inst{24-20} = vs2;
169 let Inst{19-15} = rs1;
170 let Inst{14-12} = opv.Value;
172 let Opcode = OPC_OP_V.Value;
174 let Uses = [VTYPE, VL];
175 let RVVConstraint = VMConstraint;
178 class RVInstIVI<bits<6> funct6, dag outs, dag ins, string opcodestr,
180 : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> {
186 let Inst{31-26} = funct6;
188 let Inst{24-20} = vs2;
189 let Inst{19-15} = imm;
190 let Inst{14-12} = 0b011;
192 let Opcode = OPC_OP_V.Value;
194 let Uses = [VTYPE, VL];
195 let RVVConstraint = VMConstraint;
198 class RVInstV<bits<6> funct6, bits<5> vs1, RISCVVFormat opv, dag outs,
199 dag ins, string opcodestr, string argstr>
200 : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> {
205 let Inst{31-26} = funct6;
207 let Inst{24-20} = vs2;
208 let Inst{19-15} = vs1;
209 let Inst{14-12} = opv.Value;
211 let Opcode = OPC_OP_V.Value;
213 let Uses = [VTYPE, VL];
214 let RVVConstraint = VMConstraint;
217 class RVInstVLU<bits<3> nf, bit mew, RISCVLSUMOP lumop,
218 bits<3> width, dag outs, dag ins, string opcodestr,
220 : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> {
225 let Inst{31-29} = nf;
227 let Inst{27-26} = MOPLDUnitStride.Value;
229 let Inst{24-20} = lumop.Value;
230 let Inst{19-15} = rs1;
231 let Inst{14-12} = width;
233 let Opcode = OPC_LOAD_FP.Value;
235 let Uses = [VTYPE, VL];
236 let RVVConstraint = VMConstraint;
239 class RVInstVLS<bits<3> nf, bit mew, bits<3> width,
240 dag outs, dag ins, string opcodestr, string argstr>
241 : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> {
247 let Inst{31-29} = nf;
249 let Inst{27-26} = MOPLDStrided.Value;
251 let Inst{24-20} = rs2;
252 let Inst{19-15} = rs1;
253 let Inst{14-12} = width;
255 let Opcode = OPC_LOAD_FP.Value;
257 let Uses = [VTYPE, VL];
258 let RVVConstraint = VMConstraint;
261 class RVInstVLX<bits<3> nf, bit mew, RISCVMOP mop, bits<3> width,
262 dag outs, dag ins, string opcodestr, string argstr>
263 : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> {
269 let Inst{31-29} = nf;
271 let Inst{27-26} = mop.Value;
273 let Inst{24-20} = vs2;
274 let Inst{19-15} = rs1;
275 let Inst{14-12} = width;
277 let Opcode = OPC_LOAD_FP.Value;
279 let Uses = [VTYPE, VL];
280 let RVVConstraint = VMConstraint;
283 class RVInstVSU<bits<3> nf, bit mew, RISCVLSUMOP sumop,
284 bits<3> width, dag outs, dag ins, string opcodestr,
286 : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> {
291 let Inst{31-29} = nf;
293 let Inst{27-26} = MOPSTUnitStride.Value;
295 let Inst{24-20} = sumop.Value;
296 let Inst{19-15} = rs1;
297 let Inst{14-12} = width;
298 let Inst{11-7} = vs3;
299 let Opcode = OPC_STORE_FP.Value;
301 let Uses = [VTYPE, VL];
304 class RVInstVSS<bits<3> nf, bit mew, bits<3> width,
305 dag outs, dag ins, string opcodestr, string argstr>
306 : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> {
312 let Inst{31-29} = nf;
314 let Inst{27-26} = MOPSTStrided.Value;
316 let Inst{24-20} = rs2;
317 let Inst{19-15} = rs1;
318 let Inst{14-12} = width;
319 let Inst{11-7} = vs3;
320 let Opcode = OPC_STORE_FP.Value;
322 let Uses = [VTYPE, VL];
325 class RVInstVSX<bits<3> nf, bit mew, RISCVMOP mop, bits<3> width,
326 dag outs, dag ins, string opcodestr, string argstr>
327 : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> {
333 let Inst{31-29} = nf;
335 let Inst{27-26} = mop.Value;
337 let Inst{24-20} = vs2;
338 let Inst{19-15} = rs1;
339 let Inst{14-12} = width;
340 let Inst{11-7} = vs3;
341 let Opcode = OPC_STORE_FP.Value;
343 let Uses = [VTYPE, VL];
346 class RVInstVAMO<RISCVAMOOP amoop, bits<3> width, dag outs,
347 dag ins, string opcodestr, string argstr>
348 : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> {
354 let Inst{31-27} = amoop.Value;
357 let Inst{24-20} = vs2;
358 let Inst{19-15} = rs1;
359 let Inst{14-12} = width;
360 let Opcode = OPC_AMO.Value;
362 let Uses = [VTYPE, VL];