RISCVInstrFormatsV.td 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. //===-- RISCVInstrFormatsV.td - RISCV 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. // This file describes the RISC-V V extension instruction formats.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. class RISCVVFormat<bits<3> val> {
  13. bits<3> Value = val;
  14. }
  15. def OPIVV : RISCVVFormat<0b000>;
  16. def OPFVV : RISCVVFormat<0b001>;
  17. def OPMVV : RISCVVFormat<0b010>;
  18. def OPIVI : RISCVVFormat<0b011>;
  19. def OPIVX : RISCVVFormat<0b100>;
  20. def OPFVF : RISCVVFormat<0b101>;
  21. def OPMVX : RISCVVFormat<0b110>;
  22. def OPCFG : RISCVVFormat<0b111>;
  23. class RISCVMOP<bits<2> val> {
  24. bits<2> Value = val;
  25. }
  26. def MOPLDUnitStride : RISCVMOP<0b00>;
  27. def MOPLDIndexedUnord : RISCVMOP<0b01>;
  28. def MOPLDStrided : RISCVMOP<0b10>;
  29. def MOPLDIndexedOrder : RISCVMOP<0b11>;
  30. def MOPSTUnitStride : RISCVMOP<0b00>;
  31. def MOPSTIndexedUnord : RISCVMOP<0b01>;
  32. def MOPSTStrided : RISCVMOP<0b10>;
  33. def MOPSTIndexedOrder : RISCVMOP<0b11>;
  34. class RISCVLSUMOP<bits<5> val> {
  35. bits<5> Value = val;
  36. }
  37. def LUMOPUnitStride : RISCVLSUMOP<0b00000>;
  38. def LUMOPUnitStrideMask : RISCVLSUMOP<0b01011>;
  39. def LUMOPUnitStrideWholeReg : RISCVLSUMOP<0b01000>;
  40. def LUMOPUnitStrideFF: RISCVLSUMOP<0b10000>;
  41. def SUMOPUnitStride : RISCVLSUMOP<0b00000>;
  42. def SUMOPUnitStrideMask : RISCVLSUMOP<0b01011>;
  43. def SUMOPUnitStrideWholeReg : RISCVLSUMOP<0b01000>;
  44. class RISCVWidth<bits<4> val> {
  45. bits<4> Value = val;
  46. }
  47. def LSWidth8 : RISCVWidth<0b0000>;
  48. def LSWidth16 : RISCVWidth<0b0101>;
  49. def LSWidth32 : RISCVWidth<0b0110>;
  50. def LSWidth64 : RISCVWidth<0b0111>;
  51. class RVInstSetiVLi<dag outs, dag ins, string opcodestr, string argstr>
  52. : RVInst<outs, ins, opcodestr, argstr, [], InstFormatI> {
  53. bits<5> uimm;
  54. bits<5> rd;
  55. bits<10> vtypei;
  56. let Inst{31} = 1;
  57. let Inst{30} = 1;
  58. let Inst{29-20} = vtypei{9-0};
  59. let Inst{19-15} = uimm;
  60. let Inst{14-12} = OPCFG.Value;
  61. let Inst{11-7} = rd;
  62. let Opcode = OPC_OP_V.Value;
  63. let Defs = [VTYPE, VL];
  64. }
  65. class RVInstSetVLi<dag outs, dag ins, string opcodestr, string argstr>
  66. : RVInst<outs, ins, opcodestr, argstr, [], InstFormatI> {
  67. bits<5> rs1;
  68. bits<5> rd;
  69. bits<11> vtypei;
  70. let Inst{31} = 0;
  71. let Inst{30-20} = vtypei;
  72. let Inst{19-15} = rs1;
  73. let Inst{14-12} = OPCFG.Value;
  74. let Inst{11-7} = rd;
  75. let Opcode = OPC_OP_V.Value;
  76. let Defs = [VTYPE, VL];
  77. }
  78. class RVInstSetVL<dag outs, dag ins, string opcodestr, string argstr>
  79. : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> {
  80. bits<5> rs2;
  81. bits<5> rs1;
  82. bits<5> rd;
  83. let Inst{31} = 1;
  84. let Inst{30-25} = 0b000000;
  85. let Inst{24-20} = rs2;
  86. let Inst{19-15} = rs1;
  87. let Inst{14-12} = OPCFG.Value;
  88. let Inst{11-7} = rd;
  89. let Opcode = OPC_OP_V.Value;
  90. let Defs = [VTYPE, VL];
  91. }
  92. class RVInstVV<bits<6> funct6, RISCVVFormat opv, dag outs, dag ins,
  93. string opcodestr, string argstr>
  94. : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> {
  95. bits<5> vs2;
  96. bits<5> vs1;
  97. bits<5> vd;
  98. bit vm;
  99. let Inst{31-26} = funct6;
  100. let Inst{25} = vm;
  101. let Inst{24-20} = vs2;
  102. let Inst{19-15} = vs1;
  103. let Inst{14-12} = opv.Value;
  104. let Inst{11-7} = vd;
  105. let Opcode = OPC_OP_V.Value;
  106. let Uses = [VTYPE, VL];
  107. let RVVConstraint = VMConstraint;
  108. }
  109. class RVInstVX<bits<6> funct6, RISCVVFormat opv, dag outs, dag ins,
  110. string opcodestr, string argstr>
  111. : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> {
  112. bits<5> vs2;
  113. bits<5> rs1;
  114. bits<5> vd;
  115. bit vm;
  116. let Inst{31-26} = funct6;
  117. let Inst{25} = vm;
  118. let Inst{24-20} = vs2;
  119. let Inst{19-15} = rs1;
  120. let Inst{14-12} = opv.Value;
  121. let Inst{11-7} = vd;
  122. let Opcode = OPC_OP_V.Value;
  123. let Uses = [VTYPE, VL];
  124. let RVVConstraint = VMConstraint;
  125. }
  126. class RVInstV2<bits<6> funct6, bits<5> vs2, RISCVVFormat opv, dag outs, dag ins,
  127. string opcodestr, string argstr>
  128. : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> {
  129. bits<5> rs1;
  130. bits<5> vd;
  131. bit vm;
  132. let Inst{31-26} = funct6;
  133. let Inst{25} = vm;
  134. let Inst{24-20} = vs2;
  135. let Inst{19-15} = rs1;
  136. let Inst{14-12} = opv.Value;
  137. let Inst{11-7} = vd;
  138. let Opcode = OPC_OP_V.Value;
  139. let Uses = [VTYPE, VL];
  140. let RVVConstraint = VMConstraint;
  141. }
  142. class RVInstIVI<bits<6> funct6, dag outs, dag ins, string opcodestr,
  143. string argstr>
  144. : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> {
  145. bits<5> vs2;
  146. bits<5> imm;
  147. bits<5> vd;
  148. bit vm;
  149. let Inst{31-26} = funct6;
  150. let Inst{25} = vm;
  151. let Inst{24-20} = vs2;
  152. let Inst{19-15} = imm;
  153. let Inst{14-12} = OPIVI.Value;
  154. let Inst{11-7} = vd;
  155. let Opcode = OPC_OP_V.Value;
  156. let Uses = [VTYPE, VL];
  157. let RVVConstraint = VMConstraint;
  158. }
  159. class RVInstV<bits<6> funct6, bits<5> vs1, RISCVVFormat opv, dag outs,
  160. dag ins, string opcodestr, string argstr>
  161. : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> {
  162. bits<5> vs2;
  163. bits<5> vd;
  164. bit vm;
  165. let Inst{31-26} = funct6;
  166. let Inst{25} = vm;
  167. let Inst{24-20} = vs2;
  168. let Inst{19-15} = vs1;
  169. let Inst{14-12} = opv.Value;
  170. let Inst{11-7} = vd;
  171. let Opcode = OPC_OP_V.Value;
  172. let Uses = [VTYPE, VL];
  173. let RVVConstraint = VMConstraint;
  174. }
  175. class RVInstVLU<bits<3> nf, bit mew, RISCVLSUMOP lumop,
  176. bits<3> width, dag outs, dag ins, string opcodestr,
  177. string argstr>
  178. : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> {
  179. bits<5> rs1;
  180. bits<5> vd;
  181. bit vm;
  182. let Inst{31-29} = nf;
  183. let Inst{28} = mew;
  184. let Inst{27-26} = MOPLDUnitStride.Value;
  185. let Inst{25} = vm;
  186. let Inst{24-20} = lumop.Value;
  187. let Inst{19-15} = rs1;
  188. let Inst{14-12} = width;
  189. let Inst{11-7} = vd;
  190. let Opcode = OPC_LOAD_FP.Value;
  191. let Uses = [VTYPE, VL];
  192. let RVVConstraint = VMConstraint;
  193. }
  194. class RVInstVLS<bits<3> nf, bit mew, bits<3> width,
  195. dag outs, dag ins, string opcodestr, string argstr>
  196. : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> {
  197. bits<5> rs2;
  198. bits<5> rs1;
  199. bits<5> vd;
  200. bit vm;
  201. let Inst{31-29} = nf;
  202. let Inst{28} = mew;
  203. let Inst{27-26} = MOPLDStrided.Value;
  204. let Inst{25} = vm;
  205. let Inst{24-20} = rs2;
  206. let Inst{19-15} = rs1;
  207. let Inst{14-12} = width;
  208. let Inst{11-7} = vd;
  209. let Opcode = OPC_LOAD_FP.Value;
  210. let Uses = [VTYPE, VL];
  211. let RVVConstraint = VMConstraint;
  212. }
  213. class RVInstVLX<bits<3> nf, bit mew, RISCVMOP mop, bits<3> width,
  214. dag outs, dag ins, string opcodestr, string argstr>
  215. : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> {
  216. bits<5> vs2;
  217. bits<5> rs1;
  218. bits<5> vd;
  219. bit vm;
  220. let Inst{31-29} = nf;
  221. let Inst{28} = mew;
  222. let Inst{27-26} = mop.Value;
  223. let Inst{25} = vm;
  224. let Inst{24-20} = vs2;
  225. let Inst{19-15} = rs1;
  226. let Inst{14-12} = width;
  227. let Inst{11-7} = vd;
  228. let Opcode = OPC_LOAD_FP.Value;
  229. let Uses = [VTYPE, VL];
  230. let RVVConstraint = VMConstraint;
  231. }
  232. class RVInstVSU<bits<3> nf, bit mew, RISCVLSUMOP sumop,
  233. bits<3> width, dag outs, dag ins, string opcodestr,
  234. string argstr>
  235. : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> {
  236. bits<5> rs1;
  237. bits<5> vs3;
  238. bit vm;
  239. let Inst{31-29} = nf;
  240. let Inst{28} = mew;
  241. let Inst{27-26} = MOPSTUnitStride.Value;
  242. let Inst{25} = vm;
  243. let Inst{24-20} = sumop.Value;
  244. let Inst{19-15} = rs1;
  245. let Inst{14-12} = width;
  246. let Inst{11-7} = vs3;
  247. let Opcode = OPC_STORE_FP.Value;
  248. let Uses = [VTYPE, VL];
  249. }
  250. class RVInstVSS<bits<3> nf, bit mew, bits<3> width,
  251. dag outs, dag ins, string opcodestr, string argstr>
  252. : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> {
  253. bits<5> rs2;
  254. bits<5> rs1;
  255. bits<5> vs3;
  256. bit vm;
  257. let Inst{31-29} = nf;
  258. let Inst{28} = mew;
  259. let Inst{27-26} = MOPSTStrided.Value;
  260. let Inst{25} = vm;
  261. let Inst{24-20} = rs2;
  262. let Inst{19-15} = rs1;
  263. let Inst{14-12} = width;
  264. let Inst{11-7} = vs3;
  265. let Opcode = OPC_STORE_FP.Value;
  266. let Uses = [VTYPE, VL];
  267. }
  268. class RVInstVSX<bits<3> nf, bit mew, RISCVMOP mop, bits<3> width,
  269. dag outs, dag ins, string opcodestr, string argstr>
  270. : RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> {
  271. bits<5> vs2;
  272. bits<5> rs1;
  273. bits<5> vs3;
  274. bit vm;
  275. let Inst{31-29} = nf;
  276. let Inst{28} = mew;
  277. let Inst{27-26} = mop.Value;
  278. let Inst{25} = vm;
  279. let Inst{24-20} = vs2;
  280. let Inst{19-15} = rs1;
  281. let Inst{14-12} = width;
  282. let Inst{11-7} = vs3;
  283. let Opcode = OPC_STORE_FP.Value;
  284. let Uses = [VTYPE, VL];
  285. }