RISCVInstrFormats.td 18 KB

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