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<3> val> {
27 def MOPLDUnitStrideU : RISCVMOP<0b000>;
28 def MOPLDStridedU : RISCVMOP<0b010>;
29 def MOPLDIndexedU : RISCVMOP<0b011>;
30 def MOPLDUnitStrideS : RISCVMOP<0b100>;
31 def MOPLDStridedS : RISCVMOP<0b110>;
32 def MOPLDIndexedS : RISCVMOP<0b111>;
34 def MOPSTUnitStride : RISCVMOP<0b000>;
35 def MOPSTStrided : RISCVMOP<0b010>;
36 def MOPSTIndexedOrder: RISCVMOP<0b011>;
37 def MOPSTIndexedUnOrd: RISCVMOP<0b111>;
39 class RISCVLSUMOP<bits<5> val> {
42 def LUMOPUnitStride : RISCVLSUMOP<0b00000>;
43 def LUMOPUnitStrideWholeReg : RISCVLSUMOP<0b01000>;
44 def LUMOPUnitStrideFF: RISCVLSUMOP<0b10000>;
45 def SUMOPUnitStride : RISCVLSUMOP<0b00000>;
46 def SUMOPUnitStrideWholeReg : RISCVLSUMOP<0b01000>;
48 class RISCVWidth<bits<3> val> {
51 def LSWidthVByte : RISCVWidth<0b000>;
52 def LSWidthVHalf : RISCVWidth<0b101>;
53 def LSWidthVWord : RISCVWidth<0b110>;
54 def LSWidthVSEW : RISCVWidth<0b111>;
56 class RVInstSetVLi<dag outs, dag ins, string opcodestr, string argstr>
57 : RVInst<outs, ins, opcodestr, argstr, [], InstFormatI> {
63 let Inst{30-20} = vtypei;
64 let Inst{19-15} = rs1;
65 let Inst{14-12} = 0b111;
67 let Opcode = OPC_OP_V.Value;
69 let Defs = [VTYPE, VL];
72 class RVInstSetVL<dag outs, dag ins, string opcodestr, string argstr>
73 : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> {
79 let Inst{30-25} = 0b000000;
80 let Inst{24-20} = rs2;
81 let Inst{19-15} = rs1;
82 let Inst{14-12} = 0b111;
84 let Opcode = OPC_OP_V.Value;
86 let Defs = [VTYPE, VL];
89 class RVInstVV<bits<6> funct6, RISCVVFormat opv, dag outs, dag ins,
90 string opcodestr, string argstr>
91 : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> {
97 let Inst{31-26} = funct6;
99 let Inst{24-20} = vs2;
100 let Inst{19-15} = vs1;
101 let Inst{14-12} = opv.Value;
103 let Opcode = OPC_OP_V.Value;
105 let Uses = [VTYPE, VL];
108 class RVInstVX<bits<6> funct6, RISCVVFormat opv, dag outs, dag ins,
109 string opcodestr, string argstr>
110 : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> {
116 let Inst{31-26} = funct6;
118 let Inst{24-20} = vs2;
119 let Inst{19-15} = rs1;
120 let Inst{14-12} = opv.Value;
122 let Opcode = OPC_OP_V.Value;
124 let Uses = [VTYPE, VL];
127 class RVInstV2<bits<6> funct6, bits<5> vs2, RISCVVFormat opv, dag outs, dag ins,
128 string opcodestr, string argstr>
129 : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> {
134 let Inst{31-26} = funct6;
136 let Inst{24-20} = vs2;
137 let Inst{19-15} = rs1;
138 let Inst{14-12} = opv.Value;
140 let Opcode = OPC_OP_V.Value;
142 let Uses = [VTYPE, VL];
145 class RVInstIVI<bits<6> funct6, dag outs, dag ins, string opcodestr,
147 : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> {
153 let Inst{31-26} = funct6;
155 let Inst{24-20} = vs2;
156 let Inst{19-15} = imm;
157 let Inst{14-12} = 0b011;
159 let Opcode = OPC_OP_V.Value;
161 let Uses = [VTYPE, VL];
164 class RVInstV<bits<6> funct6, bits<5> vs1, RISCVVFormat opv, dag outs,
165 dag ins, string opcodestr, string argstr>
166 : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> {
171 let Inst{31-26} = funct6;
173 let Inst{24-20} = vs2;
174 let Inst{19-15} = vs1;
175 let Inst{14-12} = opv.Value;
177 let Opcode = OPC_OP_V.Value;
179 let Uses = [VTYPE, VL];
182 class RVInstVLU<bits<3> nf, RISCVMOP mop, RISCVLSUMOP lumop,
183 RISCVWidth width, dag outs, dag ins, string opcodestr,
185 : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> {
190 let Inst{31-29} = nf;
191 let Inst{28-26} = mop.Value;
193 let Inst{24-20} = lumop.Value;
194 let Inst{19-15} = rs1;
195 let Inst{14-12} = width.Value;
197 let Opcode = OPC_LOAD_FP.Value;
199 let Uses = [VTYPE, VL];
202 class RVInstVLS<bits<3> nf, RISCVMOP mop, RISCVWidth width,
203 dag outs, dag ins, string opcodestr, string argstr>
204 : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> {
210 let Inst{31-29} = nf;
211 let Inst{28-26} = mop.Value;
213 let Inst{24-20} = rs2;
214 let Inst{19-15} = rs1;
215 let Inst{14-12} = width.Value;
217 let Opcode = OPC_LOAD_FP.Value;
219 let Uses = [VTYPE, VL];
222 class RVInstVLX<bits<3> nf, RISCVMOP mop, RISCVWidth width,
223 dag outs, dag ins, string opcodestr, string argstr>
224 : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> {
230 let Inst{31-29} = nf;
231 let Inst{28-26} = mop.Value;
233 let Inst{24-20} = vs2;
234 let Inst{19-15} = rs1;
235 let Inst{14-12} = width.Value;
237 let Opcode = OPC_LOAD_FP.Value;
239 let Uses = [VTYPE, VL];
242 class RVInstVSU<bits<3> nf, RISCVMOP mop, RISCVLSUMOP sumop,
243 RISCVWidth width, dag outs, dag ins, string opcodestr,
245 : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> {
250 let Inst{31-29} = nf;
251 let Inst{28-26} = mop.Value;
253 let Inst{24-20} = sumop.Value;
254 let Inst{19-15} = rs1;
255 let Inst{14-12} = width.Value;
256 let Inst{11-7} = vs3;
257 let Opcode = OPC_STORE_FP.Value;
259 let Uses = [VTYPE, VL];
262 class RVInstVSS<bits<3> nf, RISCVMOP mop, RISCVWidth width,
263 dag outs, dag ins, string opcodestr, string argstr>
264 : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> {
270 let Inst{31-29} = nf;
271 let Inst{28-26} = mop.Value;
273 let Inst{24-20} = rs2;
274 let Inst{19-15} = rs1;
275 let Inst{14-12} = width.Value;
276 let Inst{11-7} = vs3;
277 let Opcode = OPC_STORE_FP.Value;
279 let Uses = [VTYPE, VL];
282 class RVInstVSX<bits<3> nf, RISCVMOP mop, RISCVWidth width,
283 dag outs, dag ins, string opcodestr, string argstr>
284 : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> {
290 let Inst{31-29} = nf;
291 let Inst{28-26} = mop.Value;
293 let Inst{24-20} = vs2;
294 let Inst{19-15} = rs1;
295 let Inst{14-12} = width.Value;
296 let Inst{11-7} = vs3;
297 let Opcode = OPC_STORE_FP.Value;
299 let Uses = [VTYPE, VL];