xref: /freebsd/contrib/llvm-project/llvm/lib/Target/RISCV/RISCVInstrFormats.td (revision 7fdf597e96a02165cfe22ff357b857d5fa15ed8a)
1//===-- RISCVInstrFormats.td - RISC-V Instruction Formats --*- 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//===----------------------------------------------------------------------===//
10//
11//  These instruction format definitions are structured to match the
12//  description in the RISC-V User-Level ISA specification as closely as
13//  possible. For instance, the specification describes instructions with the
14//  MSB (31st bit) on the left and the LSB (0th bit) on the right. This is
15//  reflected in the order of parameters to each instruction class.
16//
17//  One area of divergence is in the description of immediates. The
18//  specification describes immediate encoding in terms of bit-slicing
19//  operations on the logical value represented. The immediate argument to
20//  these instruction formats instead represents the bit sequence that will be
21//  inserted into the instruction. e.g. although JAL's immediate is logically
22//  a 21-bit value (where the LSB is always zero), we describe it as an imm20
23//  to match how it is encoded.
24//
25//===----------------------------------------------------------------------===//
26
27// Format specifies the encoding used by the instruction. This is used by
28// RISCVMCCodeEmitter to determine which form of fixup to use. These
29// definitions must be kept in-sync with RISCVBaseInfo.h.
30class InstFormat<bits<5> val> {
31  bits<5> Value = val;
32}
33def InstFormatPseudo : InstFormat<0>;
34def InstFormatR      : InstFormat<1>;
35def InstFormatR4     : InstFormat<2>;
36def InstFormatI      : InstFormat<3>;
37def InstFormatS      : InstFormat<4>;
38def InstFormatB      : InstFormat<5>;
39def InstFormatU      : InstFormat<6>;
40def InstFormatJ      : InstFormat<7>;
41def InstFormatCR     : InstFormat<8>;
42def InstFormatCI     : InstFormat<9>;
43def InstFormatCSS    : InstFormat<10>;
44def InstFormatCIW    : InstFormat<11>;
45def InstFormatCL     : InstFormat<12>;
46def InstFormatCS     : InstFormat<13>;
47def InstFormatCA     : InstFormat<14>;
48def InstFormatCB     : InstFormat<15>;
49def InstFormatCJ     : InstFormat<16>;
50def InstFormatCU     : InstFormat<17>;
51def InstFormatCLB    : InstFormat<18>;
52def InstFormatCLH    : InstFormat<19>;
53def InstFormatCSB    : InstFormat<20>;
54def InstFormatCSH    : InstFormat<21>;
55def InstFormatOther  : InstFormat<22>;
56
57class RISCVVConstraint<bits<3> val> {
58  bits<3> Value = val;
59}
60def NoConstraint  : RISCVVConstraint<0b000>;
61def VS2Constraint : RISCVVConstraint<0b001>;
62def VS1Constraint : RISCVVConstraint<0b010>;
63def VMConstraint  : RISCVVConstraint<0b100>;
64
65// Illegal instructions:
66//
67// * The destination vector register group for a masked vector instruction
68// cannot overlap the source mask register (v0), unless the destination vector
69// register is being written with a mask value (e.g., comparisons) or the
70// scalar result of a reduction.
71//
72// * Widening: The destination EEW is greater than the source EEW, the source
73// EMUL is at least 1. The destination vector register group cannot overlap
74// with the source vector register groups besides the highest-numbered part of
75// the destination register group.
76//
77// * Narrowing: The destination EEW is smaller than the source EEW. The
78// destination vector register group cannot overlap with the source vector
79// register groups besides the lowest-numbered part of the source register
80// group.
81//
82// * vmsbf.m/vmsif.m/vmsof.m: The destination register cannot overlap the
83// source register and, if masked, cannot overlap the mask register ('v0').
84//
85// * viota: The destination register cannot overlap the source register and,
86// if masked, cannot overlap the mask register ('v0').
87//
88// * v[f]slide[1]up: The destination vector register group for vslideup cannot
89// overlap the source vector register group.
90//
91// * vrgather: The destination vector register group cannot overlap with the
92// source vector register groups.
93//
94// * vcompress: The destination vector register group cannot overlap the
95// source vector register group or the source mask register
96def WidenV       : RISCVVConstraint<!or(VS2Constraint.Value,
97                                        VS1Constraint.Value,
98                                        VMConstraint.Value)>;
99def WidenW       : RISCVVConstraint<!or(VS1Constraint.Value,
100                                        VMConstraint.Value)>;
101def WidenCvt     : RISCVVConstraint<!or(VS2Constraint.Value,
102                                        VMConstraint.Value)>;
103def Iota         : RISCVVConstraint<!or(VS2Constraint.Value,
104                                        VMConstraint.Value)>;
105def SlideUp      : RISCVVConstraint<!or(VS2Constraint.Value,
106                                        VMConstraint.Value)>;
107def Vrgather     : RISCVVConstraint<!or(VS2Constraint.Value,
108                                        VS1Constraint.Value,
109                                        VMConstraint.Value)>;
110def Vcompress    : RISCVVConstraint<!or(VS2Constraint.Value,
111                                        VS1Constraint.Value)>;
112def Sha2Constraint : RISCVVConstraint<!or(VS2Constraint.Value,
113                                          VS1Constraint.Value)>;
114
115// The following opcode names match those given in Table 19.1 in the
116// RISC-V User-level ISA specification ("RISC-V base opcode map").
117class RISCVOpcode<string name, bits<7> val> {
118  string Name = name;
119  bits<7> Value = val;
120}
121def RISCVOpcodesList : GenericTable {
122  let FilterClass = "RISCVOpcode";
123  let Fields = [
124    "Name", "Value"
125  ];
126  let PrimaryKey = [ "Value" ];
127  let PrimaryKeyName = "lookupRISCVOpcodeByValue";
128}
129def lookupRISCVOpcodeByName : SearchIndex {
130  let Table = RISCVOpcodesList;
131  let Key = [ "Name" ];
132}
133def OPC_LOAD      : RISCVOpcode<"LOAD",      0b0000011>;
134def OPC_LOAD_FP   : RISCVOpcode<"LOAD_FP",   0b0000111>;
135def OPC_CUSTOM_0  : RISCVOpcode<"CUSTOM_0",  0b0001011>;
136def OPC_MISC_MEM  : RISCVOpcode<"MISC_MEM",  0b0001111>;
137def OPC_OP_IMM    : RISCVOpcode<"OP_IMM",    0b0010011>;
138def OPC_AUIPC     : RISCVOpcode<"AUIPC",     0b0010111>;
139def OPC_OP_IMM_32 : RISCVOpcode<"OP_IMM_32", 0b0011011>;
140def OPC_STORE     : RISCVOpcode<"STORE",     0b0100011>;
141def OPC_STORE_FP  : RISCVOpcode<"STORE_FP",  0b0100111>;
142def OPC_CUSTOM_1  : RISCVOpcode<"CUSTOM_1",  0b0101011>;
143def OPC_AMO       : RISCVOpcode<"AMO",       0b0101111>;
144def OPC_OP        : RISCVOpcode<"OP",        0b0110011>;
145def OPC_LUI       : RISCVOpcode<"LUI",       0b0110111>;
146def OPC_OP_32     : RISCVOpcode<"OP_32",     0b0111011>;
147def OPC_MADD      : RISCVOpcode<"MADD",      0b1000011>;
148def OPC_MSUB      : RISCVOpcode<"MSUB",      0b1000111>;
149def OPC_NMSUB     : RISCVOpcode<"NMSUB",     0b1001011>;
150def OPC_NMADD     : RISCVOpcode<"NMADD",     0b1001111>;
151def OPC_OP_FP     : RISCVOpcode<"OP_FP",     0b1010011>;
152def OPC_OP_V      : RISCVOpcode<"OP_V",      0b1010111>;
153def OPC_CUSTOM_2  : RISCVOpcode<"CUSTOM_2",  0b1011011>;
154def OPC_BRANCH    : RISCVOpcode<"BRANCH",    0b1100011>;
155def OPC_JALR      : RISCVOpcode<"JALR",      0b1100111>;
156def OPC_JAL       : RISCVOpcode<"JAL",       0b1101111>;
157def OPC_SYSTEM    : RISCVOpcode<"SYSTEM",    0b1110011>;
158def OPC_OP_VE     : RISCVOpcode<"OP_VE",     0b1110111>;
159def OPC_CUSTOM_3  : RISCVOpcode<"CUSTOM_3",  0b1111011>;
160
161class RVInstCommon<dag outs, dag ins, string opcodestr, string argstr,
162                   list<dag> pattern, InstFormat format> : Instruction {
163  let Namespace = "RISCV";
164
165  dag OutOperandList = outs;
166  dag InOperandList = ins;
167  let AsmString = opcodestr # !if(!empty(argstr), "", "\t" # argstr);
168  let Pattern = pattern;
169
170  let TSFlags{4-0} = format.Value;
171
172  // Defaults
173  RISCVVConstraint RVVConstraint = NoConstraint;
174  let TSFlags{7-5} = RVVConstraint.Value;
175
176  bits<3> VLMul = 0;
177  let TSFlags{10-8} = VLMul;
178
179  bit ForceTailAgnostic = false;
180  let TSFlags{11} = ForceTailAgnostic;
181
182  bit IsTiedPseudo = 0;
183  let TSFlags{12} = IsTiedPseudo;
184
185  bit HasSEWOp = 0;
186  let TSFlags{13} = HasSEWOp;
187
188  bit HasVLOp = 0;
189  let TSFlags{14} = HasVLOp;
190
191  bit HasVecPolicyOp = 0;
192  let TSFlags{15} = HasVecPolicyOp;
193
194  bit IsRVVWideningReduction = 0;
195  let TSFlags{16} = IsRVVWideningReduction;
196
197  bit UsesMaskPolicy = 0;
198  let TSFlags{17} = UsesMaskPolicy;
199
200  // Indicates that the result can be considered sign extended from bit 31. Some
201  // instructions with this flag aren't W instructions, but are either sign
202  // extended from a smaller size, always outputs a small integer, or put zeros
203  // in bits 63:31. Used by the SExtWRemoval pass.
204  bit IsSignExtendingOpW = 0;
205  let TSFlags{18} = IsSignExtendingOpW;
206
207  bit HasRoundModeOp = 0;
208  let TSFlags{19} =  HasRoundModeOp;
209
210  // This is only valid when HasRoundModeOp is set to 1. HasRoundModeOp is set
211  // to 1 for vector fixed-point or floating-point intrinsics. This bit is
212  // processed under pass 'RISCVInsertReadWriteCSR' pass to distinguish between
213  // fixed-point / floating-point instructions and emit appropriate read/write
214  // to the correct CSR.
215  bit UsesVXRM = 0;
216  let TSFlags{20} =  UsesVXRM;
217
218  // Indicates whther these instructions can partially overlap between source
219  // registers and destination registers according to the vector spec.
220  // 0 -> not a vector pseudo
221  // 1 -> default value for vector pseudos. not widening or narrowing.
222  // 2 -> narrowing case
223  // 3 -> widening case
224  bits<2> TargetOverlapConstraintType = 0;
225  let TSFlags{22-21} = TargetOverlapConstraintType;
226}
227
228class RVInst<dag outs, dag ins, string opcodestr, string argstr,
229             list<dag> pattern, InstFormat format>
230    : RVInstCommon<outs, ins, opcodestr, argstr, pattern, format> {
231  field bits<32> Inst;
232  // SoftFail is a field the disassembler can use to provide a way for
233  // instructions to not match without killing the whole decode process. It is
234  // mainly used for ARM, but Tablegen expects this field to exist or it fails
235  // to build the decode table.
236  field bits<32> SoftFail = 0;
237  let Size = 4;
238}
239
240// Pseudo instructions
241class Pseudo<dag outs, dag ins, list<dag> pattern, string opcodestr = "", string argstr = "">
242    : RVInst<outs, ins, opcodestr, argstr, pattern, InstFormatPseudo> {
243  let isPseudo = 1;
244  let isCodeGenOnly = 1;
245}
246
247class PseudoQuietFCMP<DAGOperand Ty>
248    : Pseudo<(outs GPR:$rd), (ins Ty:$rs1, Ty:$rs2), []> {
249  let hasSideEffects = 1;
250  let mayLoad = 0;
251  let mayStore = 0;
252}
253
254// Pseudo load instructions.
255class PseudoLoad<string opcodestr>
256    : Pseudo<(outs GPR:$rd), (ins bare_symbol:$addr), [], opcodestr, "$rd, $addr"> {
257  let hasSideEffects = 0;
258  let mayLoad = 1;
259  let mayStore = 0;
260  let isCodeGenOnly = 0;
261  let isAsmParserOnly = 1;
262}
263
264class PseudoFloatLoad<string opcodestr, RegisterClass rdty>
265    : Pseudo<(outs GPR:$tmp, rdty:$rd), (ins bare_symbol:$addr), [], opcodestr, "$rd, $addr, $tmp"> {
266  let hasSideEffects = 0;
267  let mayLoad = 1;
268  let mayStore = 0;
269  let isCodeGenOnly = 0;
270  let isAsmParserOnly = 1;
271}
272
273// Pseudo store instructions.
274class PseudoStore<string opcodestr, RegisterClass rsty = GPR>
275    : Pseudo<(outs GPR:$tmp), (ins rsty:$rs, bare_symbol:$addr), [], opcodestr, "$rs, $addr, $tmp"> {
276  let hasSideEffects = 0;
277  let mayLoad = 0;
278  let mayStore = 1;
279  let isCodeGenOnly = 0;
280  let isAsmParserOnly = 1;
281}
282
283// Instruction formats are listed in the order they appear in the RISC-V
284// instruction set manual (R, R4, I, S, B, U, J).
285
286// Common base class for R format instructions. Bits {31-25} should be set by
287// the subclasses.
288class RVInstRBase<bits<3> funct3, RISCVOpcode opcode, dag outs,
289                  dag ins, string opcodestr, string argstr>
290    : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> {
291  bits<5> rs2;
292  bits<5> rs1;
293  bits<5> rd;
294
295  let Inst{24-20} = rs2;
296  let Inst{19-15} = rs1;
297  let Inst{14-12} = funct3;
298  let Inst{11-7} = rd;
299  let Inst{6-0} = opcode.Value;
300}
301
302class RVInstR<bits<7> funct7, bits<3> funct3, RISCVOpcode opcode, dag outs,
303              dag ins, string opcodestr, string argstr>
304    : RVInstRBase<funct3, opcode, outs, ins, opcodestr, argstr> {
305  let Inst{31-25} = funct7;
306}
307
308class RVInstRAtomic<bits<5> funct5, bit aq, bit rl, bits<3> funct3,
309                    RISCVOpcode opcode, dag outs, dag ins, string opcodestr,
310                    string argstr>
311    : RVInstRBase<funct3, opcode, outs, ins, opcodestr, argstr> {
312  let Inst{31-27} = funct5;
313  let Inst{26} = aq;
314  let Inst{25} = rl;
315}
316
317class RVInstRFrm<bits<7> funct7, RISCVOpcode opcode, dag outs, dag ins,
318                 string opcodestr, string argstr>
319    : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> {
320  bits<5> rs2;
321  bits<5> rs1;
322  bits<3> frm;
323  bits<5> rd;
324
325  let Inst{31-25} = funct7;
326  let Inst{24-20} = rs2;
327  let Inst{19-15} = rs1;
328  let Inst{14-12} = frm;
329  let Inst{11-7} = rd;
330  let Inst{6-0} = opcode.Value;
331}
332
333class RVInstR4<bits<2> funct2, bits<3> funct3, RISCVOpcode opcode, dag outs,
334               dag ins, string opcodestr, string argstr>
335    : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR4> {
336  bits<5> rs3;
337  bits<5> rs2;
338  bits<5> rs1;
339  bits<5> rd;
340
341  let Inst{31-27} = rs3;
342  let Inst{26-25} = funct2;
343  let Inst{24-20} = rs2;
344  let Inst{19-15} = rs1;
345  let Inst{14-12} = funct3;
346  let Inst{11-7} = rd;
347  let Inst{6-0} = opcode.Value;
348}
349
350class RVInstR4Frm<bits<2> funct2, RISCVOpcode opcode, dag outs, dag ins,
351                  string opcodestr, string argstr>
352    : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR4> {
353  bits<5> rs3;
354  bits<5> rs2;
355  bits<5> rs1;
356  bits<3> frm;
357  bits<5> rd;
358
359  let Inst{31-27} = rs3;
360  let Inst{26-25} = funct2;
361  let Inst{24-20} = rs2;
362  let Inst{19-15} = rs1;
363  let Inst{14-12} = frm;
364  let Inst{11-7} = rd;
365  let Inst{6-0} = opcode.Value;
366}
367
368// Common base class for I format instructions. Bits {31-20} should be set by
369// the subclasses.
370class RVInstIBase<bits<3> funct3, RISCVOpcode opcode, dag outs, dag ins,
371                  string opcodestr, string argstr>
372    : RVInst<outs, ins, opcodestr, argstr, [], InstFormatI> {
373  bits<5> rs1;
374  bits<5> rd;
375
376  let Inst{19-15} = rs1;
377  let Inst{14-12} = funct3;
378  let Inst{11-7} = rd;
379  let Inst{6-0} = opcode.Value;
380}
381
382class RVInstI<bits<3> funct3, RISCVOpcode opcode, dag outs, dag ins,
383              string opcodestr, string argstr>
384    : RVInstIBase<funct3, opcode, outs, ins, opcodestr, argstr> {
385  bits<12> imm12;
386
387  let Inst{31-20} = imm12;
388}
389
390class RVInstIShift<bits<5> imm11_7, bits<3> funct3, RISCVOpcode opcode,
391                   dag outs, dag ins, string opcodestr, string argstr>
392    : RVInstIBase<funct3, opcode, outs, ins, opcodestr, argstr> {
393  bits<6> shamt;
394
395  let Inst{31-27} = imm11_7;
396  let Inst{26} = 0;
397  let Inst{25-20} = shamt;
398}
399
400class RVInstIShiftW<bits<7> imm11_5, bits<3> funct3, RISCVOpcode opcode,
401                    dag outs, dag ins, string opcodestr, string argstr>
402    : RVInstIBase<funct3, opcode, outs, ins, opcodestr, argstr> {
403  bits<5> shamt;
404
405  let Inst{31-25} = imm11_5;
406  let Inst{24-20} = shamt;
407}
408
409class RVInstIUnary<bits<12> imm12, bits<3> funct3, RISCVOpcode opcode,
410                   dag outs, dag ins, string opcodestr, string argstr>
411    : RVInstIBase<funct3, opcode, outs, ins, opcodestr, argstr> {
412  let Inst{31-20} = imm12;
413}
414
415class RVInstS<bits<3> funct3, RISCVOpcode opcode, dag outs, dag ins,
416              string opcodestr, string argstr>
417    : RVInst<outs, ins, opcodestr, argstr, [], InstFormatS> {
418  bits<12> imm12;
419  bits<5> rs2;
420  bits<5> rs1;
421
422  let Inst{31-25} = imm12{11-5};
423  let Inst{24-20} = rs2;
424  let Inst{19-15} = rs1;
425  let Inst{14-12} = funct3;
426  let Inst{11-7} = imm12{4-0};
427  let Inst{6-0} = opcode.Value;
428}
429
430class RVInstB<bits<3> funct3, RISCVOpcode opcode, dag outs, dag ins,
431              string opcodestr, string argstr>
432    : RVInst<outs, ins, opcodestr, argstr, [], InstFormatB> {
433  bits<12> imm12;
434  bits<5> rs2;
435  bits<5> rs1;
436
437  let Inst{31} = imm12{11};
438  let Inst{30-25} = imm12{9-4};
439  let Inst{24-20} = rs2;
440  let Inst{19-15} = rs1;
441  let Inst{14-12} = funct3;
442  let Inst{11-8} = imm12{3-0};
443  let Inst{7} = imm12{10};
444  let Inst{6-0} = opcode.Value;
445}
446
447class RVInstU<RISCVOpcode opcode, dag outs, dag ins, string opcodestr,
448              string argstr>
449    : RVInst<outs, ins, opcodestr, argstr, [], InstFormatU> {
450  bits<20> imm20;
451  bits<5> rd;
452
453  let Inst{31-12} = imm20;
454  let Inst{11-7} = rd;
455  let Inst{6-0} = opcode.Value;
456}
457
458class RVInstJ<RISCVOpcode opcode, dag outs, dag ins, string opcodestr,
459              string argstr>
460    : RVInst<outs, ins, opcodestr, argstr, [], InstFormatJ> {
461  bits<20> imm20;
462  bits<5> rd;
463
464  let Inst{31} = imm20{19};
465  let Inst{30-21} = imm20{9-0};
466  let Inst{20} = imm20{10};
467  let Inst{19-12} = imm20{18-11};
468  let Inst{11-7} = rd;
469  let Inst{6-0} = opcode.Value;
470}
471
472//===----------------------------------------------------------------------===//
473// Instruction classes for .insn directives
474//===----------------------------------------------------------------------===//
475
476class DirectiveInsnR<dag outs, dag ins, string argstr>
477  : RVInst<outs, ins, "", "", [], InstFormatR> {
478  bits<7> opcode;
479  bits<7> funct7;
480  bits<3> funct3;
481
482  bits<5> rs2;
483  bits<5> rs1;
484  bits<5> rd;
485
486  let Inst{31-25} = funct7;
487  let Inst{24-20} = rs2;
488  let Inst{19-15} = rs1;
489  let Inst{14-12} = funct3;
490  let Inst{11-7} = rd;
491  let Inst{6-0} = opcode;
492
493  let AsmString = ".insn r " # argstr;
494}
495
496class DirectiveInsnR4<dag outs, dag ins, string argstr>
497  : RVInst<outs, ins, "", "", [], InstFormatR4> {
498  bits<7> opcode;
499  bits<2> funct2;
500  bits<3> funct3;
501
502  bits<5> rs3;
503  bits<5> rs2;
504  bits<5> rs1;
505  bits<5> rd;
506
507  let Inst{31-27} = rs3;
508  let Inst{26-25} = funct2;
509  let Inst{24-20} = rs2;
510  let Inst{19-15} = rs1;
511  let Inst{14-12} = funct3;
512  let Inst{11-7} = rd;
513  let Inst{6-0} = opcode;
514
515  let AsmString = ".insn r4 " # argstr;
516}
517
518class DirectiveInsnI<dag outs, dag ins, string argstr>
519  : RVInst<outs, ins, "", "", [], InstFormatI> {
520  bits<7> opcode;
521  bits<3> funct3;
522
523  bits<12> imm12;
524  bits<5> rs1;
525  bits<5> rd;
526
527  let Inst{31-20} = imm12;
528  let Inst{19-15} = rs1;
529  let Inst{14-12} = funct3;
530  let Inst{11-7} = rd;
531  let Inst{6-0} = opcode;
532
533  let AsmString = ".insn i " # argstr;
534}
535
536class DirectiveInsnS<dag outs, dag ins, string argstr>
537  : RVInst<outs, ins, "", "", [], InstFormatS> {
538  bits<7> opcode;
539  bits<3> funct3;
540
541  bits<12> imm12;
542  bits<5> rs2;
543  bits<5> rs1;
544
545  let Inst{31-25} = imm12{11-5};
546  let Inst{24-20} = rs2;
547  let Inst{19-15} = rs1;
548  let Inst{14-12} = funct3;
549  let Inst{11-7} = imm12{4-0};
550  let Inst{6-0} = opcode;
551
552  let AsmString = ".insn s " # argstr;
553}
554
555class DirectiveInsnB<dag outs, dag ins, string argstr>
556  : RVInst<outs, ins, "", "", [], InstFormatB> {
557  bits<7> opcode;
558  bits<3> funct3;
559
560  bits<12> imm12;
561  bits<5> rs2;
562  bits<5> rs1;
563
564  let Inst{31} = imm12{11};
565  let Inst{30-25} = imm12{9-4};
566  let Inst{24-20} = rs2;
567  let Inst{19-15} = rs1;
568  let Inst{14-12} = funct3;
569  let Inst{11-8} = imm12{3-0};
570  let Inst{7} = imm12{10};
571  let Inst{6-0} = opcode;
572
573  let AsmString = ".insn b " # argstr;
574}
575
576class DirectiveInsnU<dag outs, dag ins, string argstr>
577  : RVInst<outs, ins, "", "", [], InstFormatU> {
578  bits<7> opcode;
579
580  bits<20> imm20;
581  bits<5> rd;
582
583  let Inst{31-12} = imm20;
584  let Inst{11-7} = rd;
585  let Inst{6-0} = opcode;
586
587  let AsmString = ".insn u " # argstr;
588}
589
590class DirectiveInsnJ<dag outs, dag ins, string argstr>
591  : RVInst<outs, ins, "", "", [], InstFormatJ> {
592  bits<7> opcode;
593
594  bits<20> imm20;
595  bits<5> rd;
596
597  let Inst{31-12} = imm20;
598  let Inst{11-7} = rd;
599  let Inst{6-0} = opcode;
600
601  let AsmString = ".insn j " # argstr;
602}
603