1 //===-- RISCVInstrFormatsC.td - RISCV C Instruction Formats --*- tablegen -*-=//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file describes the RISC-V C extension instruction formats.
12 //===----------------------------------------------------------------------===//
14 class RVInst16<dag outs, dag ins, string opcodestr, string argstr,
15 list<dag> pattern, InstFormat format>
18 // SoftFail is a field the disassembler can use to provide a way for
19 // instructions to not match without killing the whole decode process. It is
20 // mainly used for ARM, but Tablegen expects this field to exist or it fails
21 // to build the decode table.
22 field bits<16> SoftFail = 0;
27 let Namespace = "RISCV";
29 dag OutOperandList = outs;
30 dag InOperandList = ins;
31 let AsmString = opcodestr # "\t" # argstr;
32 let Pattern = pattern;
34 let TSFlags{4-0} = format.Value;
37 class RVInst16CR<bits<4> funct4, bits<2> opcode, dag outs, dag ins,
38 string opcodestr, string argstr>
39 : RVInst16<outs, ins, opcodestr, argstr, [], InstFormatCR> {
43 let Inst{15-12} = funct4;
46 let Inst{1-0} = opcode;
49 // The immediate value encoding differs for each instruction, so each subclass
50 // is responsible for setting the appropriate bits in the Inst field.
51 // The bits Inst{6-2} must be set for each instruction.
52 class RVInst16CI<bits<3> funct3, bits<2> opcode, dag outs, dag ins,
53 string opcodestr, string argstr>
54 : RVInst16<outs, ins, opcodestr, argstr, [], InstFormatCI> {
59 let Inst{15-13} = funct3;
60 let Inst{12} = imm{5};
62 let Inst{1-0} = opcode;
65 // The immediate value encoding differs for each instruction, so each subclass
66 // is responsible for setting the appropriate bits in the Inst field.
67 // The bits Inst{12-7} must be set for each instruction.
68 class RVInst16CSS<bits<3> funct3, bits<2> opcode, dag outs, dag ins,
69 string opcodestr, string argstr>
70 : RVInst16<outs, ins, opcodestr, argstr, [], InstFormatCSS> {
75 let Inst{15-13} = funct3;
77 let Inst{1-0} = opcode;
80 class RVInst16CIW<bits<3> funct3, bits<2> opcode, dag outs, dag ins,
81 string opcodestr, string argstr>
82 : RVInst16<outs, ins, opcodestr, argstr, [], InstFormatCIW> {
86 let Inst{15-13} = funct3;
88 let Inst{1-0} = opcode;
91 // The immediate value encoding differs for each instruction, so each subclass
92 // is responsible for setting the appropriate bits in the Inst field.
93 // The bits Inst{12-10} and Inst{6-5} must be set for each instruction.
94 class RVInst16CL<bits<3> funct3, bits<2> opcode, dag outs, dag ins,
95 string opcodestr, string argstr>
96 : RVInst16<outs, ins, opcodestr, argstr, [], InstFormatCL> {
100 let Inst{15-13} = funct3;
103 let Inst{1-0} = opcode;
106 // The immediate value encoding differs for each instruction, so each subclass
107 // is responsible for setting the appropriate bits in the Inst field.
108 // The bits Inst{12-10} and Inst{6-5} must be set for each instruction.
109 class RVInst16CS<bits<3> funct3, bits<2> opcode, dag outs, dag ins,
110 string opcodestr, string argstr>
111 : RVInst16<outs, ins, opcodestr, argstr, [], InstFormatCS> {
115 let Inst{15-13} = funct3;
118 let Inst{1-0} = opcode;
121 class RVInst16CA<bits<6> funct6, bits<2> funct2, bits<2> opcode, dag outs,
122 dag ins, string opcodestr, string argstr>
123 : RVInst16<outs, ins, opcodestr, argstr, [], InstFormatCA> {
127 let Inst{15-10} = funct6;
129 let Inst{6-5} = funct2;
131 let Inst{1-0} = opcode;
134 class RVInst16CB<bits<3> funct3, bits<2> opcode, dag outs, dag ins,
135 string opcodestr, string argstr>
136 : RVInst16<outs, ins, opcodestr, argstr, [], InstFormatCB> {
140 let Inst{15-13} = funct3;
142 let Inst{1-0} = opcode;
145 class RVInst16CJ<bits<3> funct3, bits<2> opcode, dag outs, dag ins,
146 string opcodestr, string argstr>
147 : RVInst16<outs, ins, opcodestr, argstr, [], InstFormatCJ> {
150 let Inst{15-13} = funct3;
151 let Inst{12} = offset{10};
152 let Inst{11} = offset{3};
153 let Inst{10-9} = offset{8-7};
154 let Inst{8} = offset{9};
155 let Inst{7} = offset{5};
156 let Inst{6} = offset{6};
157 let Inst{5-3} = offset{2-0};
158 let Inst{2} = offset{4};
159 let Inst{1-0} = opcode;