1*06c3fb27SDimitry Andric//===-- RISCVInstrFormatsC.td - RISC-V C Instruction Formats -*- tablegen -*-=// 20b57cec5SDimitry Andric// 30b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric// 70b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric// 90b57cec5SDimitry Andric// This file describes the RISC-V C extension instruction formats. 100b57cec5SDimitry Andric// 110b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 120b57cec5SDimitry Andric 130b57cec5SDimitry Andricclass RVInst16<dag outs, dag ins, string opcodestr, string argstr, 140b57cec5SDimitry Andric list<dag> pattern, InstFormat format> 15*06c3fb27SDimitry Andric : RVInstCommon<outs, ins, opcodestr, argstr, pattern, format> { 160b57cec5SDimitry Andric field bits<16> Inst; 170b57cec5SDimitry Andric // SoftFail is a field the disassembler can use to provide a way for 180b57cec5SDimitry Andric // instructions to not match without killing the whole decode process. It is 190b57cec5SDimitry Andric // mainly used for ARM, but Tablegen expects this field to exist or it fails 200b57cec5SDimitry Andric // to build the decode table. 210b57cec5SDimitry Andric field bits<16> SoftFail = 0; 220b57cec5SDimitry Andric let Size = 2; 230b57cec5SDimitry Andric} 240b57cec5SDimitry Andric 250b57cec5SDimitry Andricclass RVInst16CR<bits<4> funct4, bits<2> opcode, dag outs, dag ins, 260b57cec5SDimitry Andric string opcodestr, string argstr> 270b57cec5SDimitry Andric : RVInst16<outs, ins, opcodestr, argstr, [], InstFormatCR> { 280b57cec5SDimitry Andric bits<5> rs1; 290b57cec5SDimitry Andric bits<5> rs2; 300b57cec5SDimitry Andric 310b57cec5SDimitry Andric let Inst{15-12} = funct4; 320b57cec5SDimitry Andric let Inst{11-7} = rs1; 330b57cec5SDimitry Andric let Inst{6-2} = rs2; 340b57cec5SDimitry Andric let Inst{1-0} = opcode; 350b57cec5SDimitry Andric} 360b57cec5SDimitry Andric 370b57cec5SDimitry Andric// The immediate value encoding differs for each instruction, so each subclass 380b57cec5SDimitry Andric// is responsible for setting the appropriate bits in the Inst field. 390b57cec5SDimitry Andric// The bits Inst{6-2} must be set for each instruction. 400b57cec5SDimitry Andricclass RVInst16CI<bits<3> funct3, bits<2> opcode, dag outs, dag ins, 410b57cec5SDimitry Andric string opcodestr, string argstr> 420b57cec5SDimitry Andric : RVInst16<outs, ins, opcodestr, argstr, [], InstFormatCI> { 430b57cec5SDimitry Andric bits<10> imm; 440b57cec5SDimitry Andric bits<5> rd; 450b57cec5SDimitry Andric 460b57cec5SDimitry Andric let Inst{15-13} = funct3; 470b57cec5SDimitry Andric let Inst{12} = imm{5}; 480b57cec5SDimitry Andric let Inst{11-7} = rd; 490b57cec5SDimitry Andric let Inst{1-0} = opcode; 500b57cec5SDimitry Andric} 510b57cec5SDimitry Andric 520b57cec5SDimitry Andric// The immediate value encoding differs for each instruction, so each subclass 530b57cec5SDimitry Andric// is responsible for setting the appropriate bits in the Inst field. 540b57cec5SDimitry Andric// The bits Inst{12-7} must be set for each instruction. 550b57cec5SDimitry Andricclass RVInst16CSS<bits<3> funct3, bits<2> opcode, dag outs, dag ins, 560b57cec5SDimitry Andric string opcodestr, string argstr> 570b57cec5SDimitry Andric : RVInst16<outs, ins, opcodestr, argstr, [], InstFormatCSS> { 580b57cec5SDimitry Andric bits<10> imm; 590b57cec5SDimitry Andric bits<5> rs2; 600b57cec5SDimitry Andric bits<5> rs1; 610b57cec5SDimitry Andric 620b57cec5SDimitry Andric let Inst{15-13} = funct3; 630b57cec5SDimitry Andric let Inst{6-2} = rs2; 640b57cec5SDimitry Andric let Inst{1-0} = opcode; 650b57cec5SDimitry Andric} 660b57cec5SDimitry Andric 670b57cec5SDimitry Andricclass RVInst16CIW<bits<3> funct3, bits<2> opcode, dag outs, dag ins, 680b57cec5SDimitry Andric string opcodestr, string argstr> 690b57cec5SDimitry Andric : RVInst16<outs, ins, opcodestr, argstr, [], InstFormatCIW> { 700b57cec5SDimitry Andric bits<10> imm; 710b57cec5SDimitry Andric bits<3> rd; 720b57cec5SDimitry Andric 730b57cec5SDimitry Andric let Inst{15-13} = funct3; 740b57cec5SDimitry Andric let Inst{4-2} = rd; 750b57cec5SDimitry Andric let Inst{1-0} = opcode; 760b57cec5SDimitry Andric} 770b57cec5SDimitry Andric 780b57cec5SDimitry Andric// The immediate value encoding differs for each instruction, so each subclass 790b57cec5SDimitry Andric// is responsible for setting the appropriate bits in the Inst field. 800b57cec5SDimitry Andric// The bits Inst{12-10} and Inst{6-5} must be set for each instruction. 810b57cec5SDimitry Andricclass RVInst16CL<bits<3> funct3, bits<2> opcode, dag outs, dag ins, 820b57cec5SDimitry Andric string opcodestr, string argstr> 830b57cec5SDimitry Andric : RVInst16<outs, ins, opcodestr, argstr, [], InstFormatCL> { 840b57cec5SDimitry Andric bits<3> rd; 850b57cec5SDimitry Andric bits<3> rs1; 860b57cec5SDimitry Andric 870b57cec5SDimitry Andric let Inst{15-13} = funct3; 880b57cec5SDimitry Andric let Inst{9-7} = rs1; 890b57cec5SDimitry Andric let Inst{4-2} = rd; 900b57cec5SDimitry Andric let Inst{1-0} = opcode; 910b57cec5SDimitry Andric} 920b57cec5SDimitry Andric 930b57cec5SDimitry Andric// The immediate value encoding differs for each instruction, so each subclass 940b57cec5SDimitry Andric// is responsible for setting the appropriate bits in the Inst field. 950b57cec5SDimitry Andric// The bits Inst{12-10} and Inst{6-5} must be set for each instruction. 960b57cec5SDimitry Andricclass RVInst16CS<bits<3> funct3, bits<2> opcode, dag outs, dag ins, 970b57cec5SDimitry Andric string opcodestr, string argstr> 980b57cec5SDimitry Andric : RVInst16<outs, ins, opcodestr, argstr, [], InstFormatCS> { 990b57cec5SDimitry Andric bits<3> rs2; 1000b57cec5SDimitry Andric bits<3> rs1; 1010b57cec5SDimitry Andric 1020b57cec5SDimitry Andric let Inst{15-13} = funct3; 1030b57cec5SDimitry Andric let Inst{9-7} = rs1; 1040b57cec5SDimitry Andric let Inst{4-2} = rs2; 1050b57cec5SDimitry Andric let Inst{1-0} = opcode; 1060b57cec5SDimitry Andric} 1070b57cec5SDimitry Andric 1080b57cec5SDimitry Andricclass RVInst16CA<bits<6> funct6, bits<2> funct2, bits<2> opcode, dag outs, 1090b57cec5SDimitry Andric dag ins, string opcodestr, string argstr> 1100b57cec5SDimitry Andric : RVInst16<outs, ins, opcodestr, argstr, [], InstFormatCA> { 1110b57cec5SDimitry Andric bits<3> rs2; 1120b57cec5SDimitry Andric bits<3> rs1; 1130b57cec5SDimitry Andric 1140b57cec5SDimitry Andric let Inst{15-10} = funct6; 1150b57cec5SDimitry Andric let Inst{9-7} = rs1; 1160b57cec5SDimitry Andric let Inst{6-5} = funct2; 1170b57cec5SDimitry Andric let Inst{4-2} = rs2; 1180b57cec5SDimitry Andric let Inst{1-0} = opcode; 1190b57cec5SDimitry Andric} 1200b57cec5SDimitry Andric 1210b57cec5SDimitry Andricclass RVInst16CB<bits<3> funct3, bits<2> opcode, dag outs, dag ins, 1220b57cec5SDimitry Andric string opcodestr, string argstr> 1230b57cec5SDimitry Andric : RVInst16<outs, ins, opcodestr, argstr, [], InstFormatCB> { 1240b57cec5SDimitry Andric bits<9> imm; 1250b57cec5SDimitry Andric bits<3> rs1; 1260b57cec5SDimitry Andric 1270b57cec5SDimitry Andric let Inst{15-13} = funct3; 1280b57cec5SDimitry Andric let Inst{9-7} = rs1; 1290b57cec5SDimitry Andric let Inst{1-0} = opcode; 1300b57cec5SDimitry Andric} 1310b57cec5SDimitry Andric 1320b57cec5SDimitry Andricclass RVInst16CJ<bits<3> funct3, bits<2> opcode, dag outs, dag ins, 1330b57cec5SDimitry Andric string opcodestr, string argstr> 1340b57cec5SDimitry Andric : RVInst16<outs, ins, opcodestr, argstr, [], InstFormatCJ> { 1350b57cec5SDimitry Andric bits<11> offset; 1360b57cec5SDimitry Andric 1370b57cec5SDimitry Andric let Inst{15-13} = funct3; 1380b57cec5SDimitry Andric let Inst{12} = offset{10}; 1390b57cec5SDimitry Andric let Inst{11} = offset{3}; 1400b57cec5SDimitry Andric let Inst{10-9} = offset{8-7}; 1410b57cec5SDimitry Andric let Inst{8} = offset{9}; 1420b57cec5SDimitry Andric let Inst{7} = offset{5}; 1430b57cec5SDimitry Andric let Inst{6} = offset{6}; 1440b57cec5SDimitry Andric let Inst{5-3} = offset{2-0}; 1450b57cec5SDimitry Andric let Inst{2} = offset{4}; 1460b57cec5SDimitry Andric let Inst{1-0} = opcode; 1470b57cec5SDimitry Andric} 148*06c3fb27SDimitry Andric 149*06c3fb27SDimitry Andricclass RVInst16CU<bits<6> funct6, bits<5> funct5, bits<2> opcode, dag outs, 150*06c3fb27SDimitry Andric dag ins, string opcodestr, string argstr> 151*06c3fb27SDimitry Andric : RVInst16<outs, ins, opcodestr, argstr, [], InstFormatCU>{ 152*06c3fb27SDimitry Andric bits<3> rd; 153*06c3fb27SDimitry Andric 154*06c3fb27SDimitry Andric let Inst{15-10} = funct6; 155*06c3fb27SDimitry Andric let Inst{9-7} = rd; 156*06c3fb27SDimitry Andric let Inst{6-2} = funct5; 157*06c3fb27SDimitry Andric let Inst{1-0} = opcode; 158*06c3fb27SDimitry Andric} 159*06c3fb27SDimitry Andric 160*06c3fb27SDimitry Andric// The immediate value encoding differs for each instruction, so each subclass 161*06c3fb27SDimitry Andric// is responsible for setting the appropriate bits in the Inst field. 162*06c3fb27SDimitry Andric// The bits Inst{6-5} must be set for each instruction. 163*06c3fb27SDimitry Andricclass RVInst16CLB<bits<6> funct6, bits<2> opcode, dag outs, dag ins, 164*06c3fb27SDimitry Andric string opcodestr, string argstr> 165*06c3fb27SDimitry Andric : RVInst16<outs, ins, opcodestr, argstr, [], InstFormatCLB> { 166*06c3fb27SDimitry Andric bits<3> rd; 167*06c3fb27SDimitry Andric bits<3> rs1; 168*06c3fb27SDimitry Andric 169*06c3fb27SDimitry Andric let Inst{15-10} = funct6; 170*06c3fb27SDimitry Andric let Inst{9-7} = rs1; 171*06c3fb27SDimitry Andric let Inst{4-2} = rd; 172*06c3fb27SDimitry Andric let Inst{1-0} = opcode; 173*06c3fb27SDimitry Andric} 174*06c3fb27SDimitry Andric 175*06c3fb27SDimitry Andric// The immediate value encoding differs for each instruction, so each subclass 176*06c3fb27SDimitry Andric// is responsible for setting the appropriate bits in the Inst field. 177*06c3fb27SDimitry Andric// The bits Inst{5} must be set for each instruction. 178*06c3fb27SDimitry Andricclass RVInst16CLH<bits<6> funct6, bit funct1, bits<2> opcode, dag outs, 179*06c3fb27SDimitry Andric dag ins, string opcodestr, string argstr> 180*06c3fb27SDimitry Andric : RVInst16<outs, ins, opcodestr, argstr, [], InstFormatCLH> { 181*06c3fb27SDimitry Andric bits<3> rd; 182*06c3fb27SDimitry Andric bits<3> rs1; 183*06c3fb27SDimitry Andric 184*06c3fb27SDimitry Andric let Inst{15-10} = funct6; 185*06c3fb27SDimitry Andric let Inst{9-7} = rs1; 186*06c3fb27SDimitry Andric let Inst{6} = funct1; 187*06c3fb27SDimitry Andric let Inst{4-2} = rd; 188*06c3fb27SDimitry Andric let Inst{1-0} = opcode; 189*06c3fb27SDimitry Andric} 190*06c3fb27SDimitry Andric 191*06c3fb27SDimitry Andric// The immediate value encoding differs for each instruction, so each subclass 192*06c3fb27SDimitry Andric// is responsible for setting the appropriate bits in the Inst field. 193*06c3fb27SDimitry Andric// The bits Inst{6-5} must be set for each instruction. 194*06c3fb27SDimitry Andricclass RVInst16CSB<bits<6> funct6, bits<2> opcode, dag outs, dag ins, 195*06c3fb27SDimitry Andric string opcodestr, string argstr> 196*06c3fb27SDimitry Andric : RVInst16<outs, ins, opcodestr, argstr, [], InstFormatCSB> { 197*06c3fb27SDimitry Andric bits<3> rs2; 198*06c3fb27SDimitry Andric bits<3> rs1; 199*06c3fb27SDimitry Andric 200*06c3fb27SDimitry Andric let Inst{15-10} = funct6; 201*06c3fb27SDimitry Andric let Inst{9-7} = rs1; 202*06c3fb27SDimitry Andric let Inst{4-2} = rs2; 203*06c3fb27SDimitry Andric let Inst{1-0} = opcode; 204*06c3fb27SDimitry Andric} 205*06c3fb27SDimitry Andric 206*06c3fb27SDimitry Andric// The immediate value encoding differs for each instruction, so each subclass 207*06c3fb27SDimitry Andric// is responsible for setting the appropriate bits in the Inst field. 208*06c3fb27SDimitry Andric// The bits Inst{5} must be set for each instruction. 209*06c3fb27SDimitry Andricclass RVInst16CSH<bits<6> funct6, bit funct1, bits<2> opcode, dag outs, 210*06c3fb27SDimitry Andric dag ins, string opcodestr, string argstr> 211*06c3fb27SDimitry Andric : RVInst16<outs, ins, opcodestr, argstr, [], InstFormatCSH> { 212*06c3fb27SDimitry Andric bits<3> rs2; 213*06c3fb27SDimitry Andric bits<3> rs1; 214*06c3fb27SDimitry Andric 215*06c3fb27SDimitry Andric let Inst{15-10} = funct6; 216*06c3fb27SDimitry Andric let Inst{9-7} = rs1; 217*06c3fb27SDimitry Andric let Inst{6} = funct1; 218*06c3fb27SDimitry Andric let Inst{4-2} = rs2; 219*06c3fb27SDimitry Andric let Inst{1-0} = opcode; 220*06c3fb27SDimitry Andric} 221*06c3fb27SDimitry Andric 222*06c3fb27SDimitry Andric//===----------------------------------------------------------------------===// 223*06c3fb27SDimitry Andric// Instruction classes for .insn directives 224*06c3fb27SDimitry Andric//===----------------------------------------------------------------------===// 225*06c3fb27SDimitry Andric 226*06c3fb27SDimitry Andricclass DirectiveInsnCR<dag outs, dag ins, string argstr> 227*06c3fb27SDimitry Andric : RVInst16<outs, ins, "", "", [], InstFormatCR> { 228*06c3fb27SDimitry Andric bits<2> opcode; 229*06c3fb27SDimitry Andric bits<4> funct4; 230*06c3fb27SDimitry Andric 231*06c3fb27SDimitry Andric bits<5> rs2; 232*06c3fb27SDimitry Andric bits<5> rd; 233*06c3fb27SDimitry Andric 234*06c3fb27SDimitry Andric let Inst{15-12} = funct4; 235*06c3fb27SDimitry Andric let Inst{11-7} = rd; 236*06c3fb27SDimitry Andric let Inst{6-2} = rs2; 237*06c3fb27SDimitry Andric let Inst{1-0} = opcode; 238*06c3fb27SDimitry Andric 239*06c3fb27SDimitry Andric let AsmString = ".insn cr " # argstr; 240*06c3fb27SDimitry Andric} 241*06c3fb27SDimitry Andric 242*06c3fb27SDimitry Andricclass DirectiveInsnCI<dag outs, dag ins, string argstr> 243*06c3fb27SDimitry Andric : RVInst16<outs, ins, "", "", [], InstFormatCI> { 244*06c3fb27SDimitry Andric bits<2> opcode; 245*06c3fb27SDimitry Andric bits<3> funct3; 246*06c3fb27SDimitry Andric 247*06c3fb27SDimitry Andric bits<6> imm6; 248*06c3fb27SDimitry Andric bits<5> rd; 249*06c3fb27SDimitry Andric 250*06c3fb27SDimitry Andric let Inst{15-13} = funct3; 251*06c3fb27SDimitry Andric let Inst{12} = imm6{5}; 252*06c3fb27SDimitry Andric let Inst{11-7} = rd; 253*06c3fb27SDimitry Andric let Inst{6-2} = imm6{4-0}; 254*06c3fb27SDimitry Andric let Inst{1-0} = opcode; 255*06c3fb27SDimitry Andric 256*06c3fb27SDimitry Andric let AsmString = ".insn ci " # argstr; 257*06c3fb27SDimitry Andric} 258*06c3fb27SDimitry Andric 259*06c3fb27SDimitry Andricclass DirectiveInsnCIW<dag outs, dag ins, string argstr> 260*06c3fb27SDimitry Andric : RVInst16<outs, ins, "", "", [], InstFormatCIW> { 261*06c3fb27SDimitry Andric bits<2> opcode; 262*06c3fb27SDimitry Andric bits<3> funct3; 263*06c3fb27SDimitry Andric 264*06c3fb27SDimitry Andric bits<8> imm8; 265*06c3fb27SDimitry Andric bits<3> rd; 266*06c3fb27SDimitry Andric 267*06c3fb27SDimitry Andric let Inst{15-13} = funct3; 268*06c3fb27SDimitry Andric let Inst{12-5} = imm8; 269*06c3fb27SDimitry Andric let Inst{4-2} = rd; 270*06c3fb27SDimitry Andric let Inst{1-0} = opcode; 271*06c3fb27SDimitry Andric 272*06c3fb27SDimitry Andric let AsmString = ".insn ciw " # argstr; 273*06c3fb27SDimitry Andric} 274*06c3fb27SDimitry Andric 275*06c3fb27SDimitry Andricclass DirectiveInsnCSS<dag outs, dag ins, string argstr> 276*06c3fb27SDimitry Andric : RVInst16<outs, ins, "", "", [], InstFormatCSS> { 277*06c3fb27SDimitry Andric bits<2> opcode; 278*06c3fb27SDimitry Andric bits<3> funct3; 279*06c3fb27SDimitry Andric 280*06c3fb27SDimitry Andric bits<6> imm6; 281*06c3fb27SDimitry Andric bits<5> rs2; 282*06c3fb27SDimitry Andric 283*06c3fb27SDimitry Andric let Inst{15-13} = funct3; 284*06c3fb27SDimitry Andric let Inst{12-7} = imm6; 285*06c3fb27SDimitry Andric let Inst{6-2} = rs2; 286*06c3fb27SDimitry Andric let Inst{1-0} = opcode; 287*06c3fb27SDimitry Andric 288*06c3fb27SDimitry Andric let AsmString = ".insn css " # argstr; 289*06c3fb27SDimitry Andric} 290*06c3fb27SDimitry Andric 291*06c3fb27SDimitry Andricclass DirectiveInsnCL<dag outs, dag ins, string argstr> 292*06c3fb27SDimitry Andric : RVInst16<outs, ins, "", "", [], InstFormatCL> { 293*06c3fb27SDimitry Andric bits<2> opcode; 294*06c3fb27SDimitry Andric bits<3> funct3; 295*06c3fb27SDimitry Andric 296*06c3fb27SDimitry Andric bits<5> imm5; 297*06c3fb27SDimitry Andric bits<3> rd; 298*06c3fb27SDimitry Andric bits<3> rs1; 299*06c3fb27SDimitry Andric 300*06c3fb27SDimitry Andric let Inst{15-13} = funct3; 301*06c3fb27SDimitry Andric let Inst{12-10} = imm5{4-2}; 302*06c3fb27SDimitry Andric let Inst{9-7} = rs1; 303*06c3fb27SDimitry Andric let Inst{6-5} = imm5{1-0}; 304*06c3fb27SDimitry Andric let Inst{4-2} = rd; 305*06c3fb27SDimitry Andric let Inst{1-0} = opcode; 306*06c3fb27SDimitry Andric 307*06c3fb27SDimitry Andric let AsmString = ".insn cl " # argstr; 308*06c3fb27SDimitry Andric} 309*06c3fb27SDimitry Andric 310*06c3fb27SDimitry Andricclass DirectiveInsnCS<dag outs, dag ins, string argstr> 311*06c3fb27SDimitry Andric : RVInst16<outs, ins, "", "", [], InstFormatCS> { 312*06c3fb27SDimitry Andric bits<2> opcode; 313*06c3fb27SDimitry Andric bits<3> funct3; 314*06c3fb27SDimitry Andric 315*06c3fb27SDimitry Andric bits<5> imm5; 316*06c3fb27SDimitry Andric bits<3> rs2; 317*06c3fb27SDimitry Andric bits<3> rs1; 318*06c3fb27SDimitry Andric 319*06c3fb27SDimitry Andric let Inst{15-13} = funct3; 320*06c3fb27SDimitry Andric let Inst{12-10} = imm5{4-2}; 321*06c3fb27SDimitry Andric let Inst{9-7} = rs1; 322*06c3fb27SDimitry Andric let Inst{6-5} = imm5{1-0}; 323*06c3fb27SDimitry Andric let Inst{4-2} = rs2; 324*06c3fb27SDimitry Andric let Inst{1-0} = opcode; 325*06c3fb27SDimitry Andric 326*06c3fb27SDimitry Andric let AsmString = ".insn cs " # argstr; 327*06c3fb27SDimitry Andric} 328*06c3fb27SDimitry Andric 329*06c3fb27SDimitry Andricclass DirectiveInsnCA<dag outs, dag ins, string argstr> 330*06c3fb27SDimitry Andric : RVInst16<outs, ins, "", "", [], InstFormatCA> { 331*06c3fb27SDimitry Andric bits<2> opcode; 332*06c3fb27SDimitry Andric bits<6> funct6; 333*06c3fb27SDimitry Andric bits<2> funct2; 334*06c3fb27SDimitry Andric 335*06c3fb27SDimitry Andric bits<3> rd; 336*06c3fb27SDimitry Andric bits<3> rs2; 337*06c3fb27SDimitry Andric 338*06c3fb27SDimitry Andric let Inst{15-10} = funct6; 339*06c3fb27SDimitry Andric let Inst{9-7} = rd; 340*06c3fb27SDimitry Andric let Inst{6-5} = funct2; 341*06c3fb27SDimitry Andric let Inst{4-2} = rs2; 342*06c3fb27SDimitry Andric let Inst{1-0} = opcode; 343*06c3fb27SDimitry Andric 344*06c3fb27SDimitry Andric let AsmString = ".insn ca " # argstr; 345*06c3fb27SDimitry Andric} 346*06c3fb27SDimitry Andric 347*06c3fb27SDimitry Andricclass DirectiveInsnCB<dag outs, dag ins, string argstr> 348*06c3fb27SDimitry Andric : RVInst16<outs, ins, "", "", [], InstFormatCB> { 349*06c3fb27SDimitry Andric bits<2> opcode; 350*06c3fb27SDimitry Andric bits<3> funct3; 351*06c3fb27SDimitry Andric 352*06c3fb27SDimitry Andric bits<8> imm8; 353*06c3fb27SDimitry Andric bits<3> rs1; 354*06c3fb27SDimitry Andric 355*06c3fb27SDimitry Andric let Inst{15-13} = funct3; 356*06c3fb27SDimitry Andric let Inst{12} = imm8{7}; 357*06c3fb27SDimitry Andric let Inst{11-10} = imm8{3-2}; 358*06c3fb27SDimitry Andric let Inst{9-7} = rs1; 359*06c3fb27SDimitry Andric let Inst{6-5} = imm8{6-5}; 360*06c3fb27SDimitry Andric let Inst{4-3} = imm8{1-0}; 361*06c3fb27SDimitry Andric let Inst{2} = imm8{4}; 362*06c3fb27SDimitry Andric let Inst{1-0} = opcode; 363*06c3fb27SDimitry Andric 364*06c3fb27SDimitry Andric let AsmString = ".insn cb " # argstr; 365*06c3fb27SDimitry Andric} 366*06c3fb27SDimitry Andric 367*06c3fb27SDimitry Andricclass DirectiveInsnCJ<dag outs, dag ins, string argstr> 368*06c3fb27SDimitry Andric : RVInst16<outs, ins, "", "", [], InstFormatCJ> { 369*06c3fb27SDimitry Andric bits<2> opcode; 370*06c3fb27SDimitry Andric bits<3> funct3; 371*06c3fb27SDimitry Andric 372*06c3fb27SDimitry Andric bits<11> imm11; 373*06c3fb27SDimitry Andric 374*06c3fb27SDimitry Andric let Inst{15-13} = funct3; 375*06c3fb27SDimitry Andric let Inst{12} = imm11{10}; 376*06c3fb27SDimitry Andric let Inst{11} = imm11{3}; 377*06c3fb27SDimitry Andric let Inst{10-9} = imm11{8-7}; 378*06c3fb27SDimitry Andric let Inst{8} = imm11{9}; 379*06c3fb27SDimitry Andric let Inst{7} = imm11{5}; 380*06c3fb27SDimitry Andric let Inst{6} = imm11{6}; 381*06c3fb27SDimitry Andric let Inst{5-3} = imm11{2-0}; 382*06c3fb27SDimitry Andric let Inst{2} = imm11{4}; 383*06c3fb27SDimitry Andric let Inst{1-0} = opcode; 384*06c3fb27SDimitry Andric 385*06c3fb27SDimitry Andric let AsmString = ".insn cj " # argstr; 386*06c3fb27SDimitry Andric} 387