inst.go 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  1. // Code generated by parse_opcodes -go; DO NOT EDIT.
  2. package riscv
  3. import "github.com/twitchyliquid64/golang-asm/obj"
  4. type inst struct {
  5. opcode uint32
  6. funct3 uint32
  7. rs2 uint32
  8. csr int64
  9. funct7 uint32
  10. }
  11. func encode(a obj.As) *inst {
  12. switch a {
  13. case ABEQ:
  14. return &inst{0x63, 0x0, 0x0, 0, 0x0}
  15. case ABNE:
  16. return &inst{0x63, 0x1, 0x0, 0, 0x0}
  17. case ABLT:
  18. return &inst{0x63, 0x4, 0x0, 0, 0x0}
  19. case ABGE:
  20. return &inst{0x63, 0x5, 0x0, 0, 0x0}
  21. case ABLTU:
  22. return &inst{0x63, 0x6, 0x0, 0, 0x0}
  23. case ABGEU:
  24. return &inst{0x63, 0x7, 0x0, 0, 0x0}
  25. case AJALR:
  26. return &inst{0x67, 0x0, 0x0, 0, 0x0}
  27. case AJAL:
  28. return &inst{0x6f, 0x0, 0x0, 0, 0x0}
  29. case ALUI:
  30. return &inst{0x37, 0x0, 0x0, 0, 0x0}
  31. case AAUIPC:
  32. return &inst{0x17, 0x0, 0x0, 0, 0x0}
  33. case AADDI:
  34. return &inst{0x13, 0x0, 0x0, 0, 0x0}
  35. case ASLLI:
  36. return &inst{0x13, 0x1, 0x0, 0, 0x0}
  37. case ASLTI:
  38. return &inst{0x13, 0x2, 0x0, 0, 0x0}
  39. case ASLTIU:
  40. return &inst{0x13, 0x3, 0x0, 0, 0x0}
  41. case AXORI:
  42. return &inst{0x13, 0x4, 0x0, 0, 0x0}
  43. case ASRLI:
  44. return &inst{0x13, 0x5, 0x0, 0, 0x0}
  45. case ASRAI:
  46. return &inst{0x13, 0x5, 0x0, 1024, 0x20}
  47. case AORI:
  48. return &inst{0x13, 0x6, 0x0, 0, 0x0}
  49. case AANDI:
  50. return &inst{0x13, 0x7, 0x0, 0, 0x0}
  51. case AADD:
  52. return &inst{0x33, 0x0, 0x0, 0, 0x0}
  53. case ASUB:
  54. return &inst{0x33, 0x0, 0x0, 1024, 0x20}
  55. case ASLL:
  56. return &inst{0x33, 0x1, 0x0, 0, 0x0}
  57. case ASLT:
  58. return &inst{0x33, 0x2, 0x0, 0, 0x0}
  59. case ASLTU:
  60. return &inst{0x33, 0x3, 0x0, 0, 0x0}
  61. case AXOR:
  62. return &inst{0x33, 0x4, 0x0, 0, 0x0}
  63. case ASRL:
  64. return &inst{0x33, 0x5, 0x0, 0, 0x0}
  65. case ASRA:
  66. return &inst{0x33, 0x5, 0x0, 1024, 0x20}
  67. case AOR:
  68. return &inst{0x33, 0x6, 0x0, 0, 0x0}
  69. case AAND:
  70. return &inst{0x33, 0x7, 0x0, 0, 0x0}
  71. case AADDIW:
  72. return &inst{0x1b, 0x0, 0x0, 0, 0x0}
  73. case ASLLIW:
  74. return &inst{0x1b, 0x1, 0x0, 0, 0x0}
  75. case ASRLIW:
  76. return &inst{0x1b, 0x5, 0x0, 0, 0x0}
  77. case ASRAIW:
  78. return &inst{0x1b, 0x5, 0x0, 1024, 0x20}
  79. case AADDW:
  80. return &inst{0x3b, 0x0, 0x0, 0, 0x0}
  81. case ASUBW:
  82. return &inst{0x3b, 0x0, 0x0, 1024, 0x20}
  83. case ASLLW:
  84. return &inst{0x3b, 0x1, 0x0, 0, 0x0}
  85. case ASRLW:
  86. return &inst{0x3b, 0x5, 0x0, 0, 0x0}
  87. case ASRAW:
  88. return &inst{0x3b, 0x5, 0x0, 1024, 0x20}
  89. case ALB:
  90. return &inst{0x3, 0x0, 0x0, 0, 0x0}
  91. case ALH:
  92. return &inst{0x3, 0x1, 0x0, 0, 0x0}
  93. case ALW:
  94. return &inst{0x3, 0x2, 0x0, 0, 0x0}
  95. case ALD:
  96. return &inst{0x3, 0x3, 0x0, 0, 0x0}
  97. case ALBU:
  98. return &inst{0x3, 0x4, 0x0, 0, 0x0}
  99. case ALHU:
  100. return &inst{0x3, 0x5, 0x0, 0, 0x0}
  101. case ALWU:
  102. return &inst{0x3, 0x6, 0x0, 0, 0x0}
  103. case ASB:
  104. return &inst{0x23, 0x0, 0x0, 0, 0x0}
  105. case ASH:
  106. return &inst{0x23, 0x1, 0x0, 0, 0x0}
  107. case ASW:
  108. return &inst{0x23, 0x2, 0x0, 0, 0x0}
  109. case ASD:
  110. return &inst{0x23, 0x3, 0x0, 0, 0x0}
  111. case AFENCE:
  112. return &inst{0xf, 0x0, 0x0, 0, 0x0}
  113. case AFENCEI:
  114. return &inst{0xf, 0x1, 0x0, 0, 0x0}
  115. case AMUL:
  116. return &inst{0x33, 0x0, 0x0, 32, 0x1}
  117. case AMULH:
  118. return &inst{0x33, 0x1, 0x0, 32, 0x1}
  119. case AMULHSU:
  120. return &inst{0x33, 0x2, 0x0, 32, 0x1}
  121. case AMULHU:
  122. return &inst{0x33, 0x3, 0x0, 32, 0x1}
  123. case ADIV:
  124. return &inst{0x33, 0x4, 0x0, 32, 0x1}
  125. case ADIVU:
  126. return &inst{0x33, 0x5, 0x0, 32, 0x1}
  127. case AREM:
  128. return &inst{0x33, 0x6, 0x0, 32, 0x1}
  129. case AREMU:
  130. return &inst{0x33, 0x7, 0x0, 32, 0x1}
  131. case AMULW:
  132. return &inst{0x3b, 0x0, 0x0, 32, 0x1}
  133. case ADIVW:
  134. return &inst{0x3b, 0x4, 0x0, 32, 0x1}
  135. case ADIVUW:
  136. return &inst{0x3b, 0x5, 0x0, 32, 0x1}
  137. case AREMW:
  138. return &inst{0x3b, 0x6, 0x0, 32, 0x1}
  139. case AREMUW:
  140. return &inst{0x3b, 0x7, 0x0, 32, 0x1}
  141. case AAMOADDW:
  142. return &inst{0x2f, 0x2, 0x0, 0, 0x0}
  143. case AAMOXORW:
  144. return &inst{0x2f, 0x2, 0x0, 512, 0x10}
  145. case AAMOORW:
  146. return &inst{0x2f, 0x2, 0x0, 1024, 0x20}
  147. case AAMOANDW:
  148. return &inst{0x2f, 0x2, 0x0, 1536, 0x30}
  149. case AAMOMINW:
  150. return &inst{0x2f, 0x2, 0x0, -2048, 0x40}
  151. case AAMOMAXW:
  152. return &inst{0x2f, 0x2, 0x0, -1536, 0x50}
  153. case AAMOMINUW:
  154. return &inst{0x2f, 0x2, 0x0, -1024, 0x60}
  155. case AAMOMAXUW:
  156. return &inst{0x2f, 0x2, 0x0, -512, 0x70}
  157. case AAMOSWAPW:
  158. return &inst{0x2f, 0x2, 0x0, 128, 0x4}
  159. case ALRW:
  160. return &inst{0x2f, 0x2, 0x0, 256, 0x8}
  161. case ASCW:
  162. return &inst{0x2f, 0x2, 0x0, 384, 0xc}
  163. case AAMOADDD:
  164. return &inst{0x2f, 0x3, 0x0, 0, 0x0}
  165. case AAMOXORD:
  166. return &inst{0x2f, 0x3, 0x0, 512, 0x10}
  167. case AAMOORD:
  168. return &inst{0x2f, 0x3, 0x0, 1024, 0x20}
  169. case AAMOANDD:
  170. return &inst{0x2f, 0x3, 0x0, 1536, 0x30}
  171. case AAMOMIND:
  172. return &inst{0x2f, 0x3, 0x0, -2048, 0x40}
  173. case AAMOMAXD:
  174. return &inst{0x2f, 0x3, 0x0, -1536, 0x50}
  175. case AAMOMINUD:
  176. return &inst{0x2f, 0x3, 0x0, -1024, 0x60}
  177. case AAMOMAXUD:
  178. return &inst{0x2f, 0x3, 0x0, -512, 0x70}
  179. case AAMOSWAPD:
  180. return &inst{0x2f, 0x3, 0x0, 128, 0x4}
  181. case ALRD:
  182. return &inst{0x2f, 0x3, 0x0, 256, 0x8}
  183. case ASCD:
  184. return &inst{0x2f, 0x3, 0x0, 384, 0xc}
  185. case AECALL:
  186. return &inst{0x73, 0x0, 0x0, 0, 0x0}
  187. case AEBREAK:
  188. return &inst{0x73, 0x0, 0x1, 1, 0x0}
  189. case AURET:
  190. return &inst{0x73, 0x0, 0x2, 2, 0x0}
  191. case ASRET:
  192. return &inst{0x73, 0x0, 0x2, 258, 0x8}
  193. case AMRET:
  194. return &inst{0x73, 0x0, 0x2, 770, 0x18}
  195. case ADRET:
  196. return &inst{0x73, 0x0, 0x12, 1970, 0x3d}
  197. case ASFENCEVMA:
  198. return &inst{0x73, 0x0, 0x0, 288, 0x9}
  199. case AWFI:
  200. return &inst{0x73, 0x0, 0x5, 261, 0x8}
  201. case ACSRRW:
  202. return &inst{0x73, 0x1, 0x0, 0, 0x0}
  203. case ACSRRS:
  204. return &inst{0x73, 0x2, 0x0, 0, 0x0}
  205. case ACSRRC:
  206. return &inst{0x73, 0x3, 0x0, 0, 0x0}
  207. case ACSRRWI:
  208. return &inst{0x73, 0x5, 0x0, 0, 0x0}
  209. case ACSRRSI:
  210. return &inst{0x73, 0x6, 0x0, 0, 0x0}
  211. case ACSRRCI:
  212. return &inst{0x73, 0x7, 0x0, 0, 0x0}
  213. case AHFENCEVVMA:
  214. return &inst{0x73, 0x0, 0x0, 544, 0x11}
  215. case AHFENCEGVMA:
  216. return &inst{0x73, 0x0, 0x0, 1568, 0x31}
  217. case AFADDS:
  218. return &inst{0x53, 0x0, 0x0, 0, 0x0}
  219. case AFSUBS:
  220. return &inst{0x53, 0x0, 0x0, 128, 0x4}
  221. case AFMULS:
  222. return &inst{0x53, 0x0, 0x0, 256, 0x8}
  223. case AFDIVS:
  224. return &inst{0x53, 0x0, 0x0, 384, 0xc}
  225. case AFSGNJS:
  226. return &inst{0x53, 0x0, 0x0, 512, 0x10}
  227. case AFSGNJNS:
  228. return &inst{0x53, 0x1, 0x0, 512, 0x10}
  229. case AFSGNJXS:
  230. return &inst{0x53, 0x2, 0x0, 512, 0x10}
  231. case AFMINS:
  232. return &inst{0x53, 0x0, 0x0, 640, 0x14}
  233. case AFMAXS:
  234. return &inst{0x53, 0x1, 0x0, 640, 0x14}
  235. case AFSQRTS:
  236. return &inst{0x53, 0x0, 0x0, 1408, 0x2c}
  237. case AFADDD:
  238. return &inst{0x53, 0x0, 0x0, 32, 0x1}
  239. case AFSUBD:
  240. return &inst{0x53, 0x0, 0x0, 160, 0x5}
  241. case AFMULD:
  242. return &inst{0x53, 0x0, 0x0, 288, 0x9}
  243. case AFDIVD:
  244. return &inst{0x53, 0x0, 0x0, 416, 0xd}
  245. case AFSGNJD:
  246. return &inst{0x53, 0x0, 0x0, 544, 0x11}
  247. case AFSGNJND:
  248. return &inst{0x53, 0x1, 0x0, 544, 0x11}
  249. case AFSGNJXD:
  250. return &inst{0x53, 0x2, 0x0, 544, 0x11}
  251. case AFMIND:
  252. return &inst{0x53, 0x0, 0x0, 672, 0x15}
  253. case AFMAXD:
  254. return &inst{0x53, 0x1, 0x0, 672, 0x15}
  255. case AFCVTSD:
  256. return &inst{0x53, 0x0, 0x1, 1025, 0x20}
  257. case AFCVTDS:
  258. return &inst{0x53, 0x0, 0x0, 1056, 0x21}
  259. case AFSQRTD:
  260. return &inst{0x53, 0x0, 0x0, 1440, 0x2d}
  261. case AFADDQ:
  262. return &inst{0x53, 0x0, 0x0, 96, 0x3}
  263. case AFSUBQ:
  264. return &inst{0x53, 0x0, 0x0, 224, 0x7}
  265. case AFMULQ:
  266. return &inst{0x53, 0x0, 0x0, 352, 0xb}
  267. case AFDIVQ:
  268. return &inst{0x53, 0x0, 0x0, 480, 0xf}
  269. case AFSGNJQ:
  270. return &inst{0x53, 0x0, 0x0, 608, 0x13}
  271. case AFSGNJNQ:
  272. return &inst{0x53, 0x1, 0x0, 608, 0x13}
  273. case AFSGNJXQ:
  274. return &inst{0x53, 0x2, 0x0, 608, 0x13}
  275. case AFMINQ:
  276. return &inst{0x53, 0x0, 0x0, 736, 0x17}
  277. case AFMAXQ:
  278. return &inst{0x53, 0x1, 0x0, 736, 0x17}
  279. case AFCVTSQ:
  280. return &inst{0x53, 0x0, 0x3, 1027, 0x20}
  281. case AFCVTQS:
  282. return &inst{0x53, 0x0, 0x0, 1120, 0x23}
  283. case AFCVTDQ:
  284. return &inst{0x53, 0x0, 0x3, 1059, 0x21}
  285. case AFCVTQD:
  286. return &inst{0x53, 0x0, 0x1, 1121, 0x23}
  287. case AFSQRTQ:
  288. return &inst{0x53, 0x0, 0x0, 1504, 0x2f}
  289. case AFLES:
  290. return &inst{0x53, 0x0, 0x0, -1536, 0x50}
  291. case AFLTS:
  292. return &inst{0x53, 0x1, 0x0, -1536, 0x50}
  293. case AFEQS:
  294. return &inst{0x53, 0x2, 0x0, -1536, 0x50}
  295. case AFLED:
  296. return &inst{0x53, 0x0, 0x0, -1504, 0x51}
  297. case AFLTD:
  298. return &inst{0x53, 0x1, 0x0, -1504, 0x51}
  299. case AFEQD:
  300. return &inst{0x53, 0x2, 0x0, -1504, 0x51}
  301. case AFLEQ:
  302. return &inst{0x53, 0x0, 0x0, -1440, 0x53}
  303. case AFLTQ:
  304. return &inst{0x53, 0x1, 0x0, -1440, 0x53}
  305. case AFEQQ:
  306. return &inst{0x53, 0x2, 0x0, -1440, 0x53}
  307. case AFCVTWS:
  308. return &inst{0x53, 0x0, 0x0, -1024, 0x60}
  309. case AFCVTWUS:
  310. return &inst{0x53, 0x0, 0x1, -1023, 0x60}
  311. case AFCVTLS:
  312. return &inst{0x53, 0x0, 0x2, -1022, 0x60}
  313. case AFCVTLUS:
  314. return &inst{0x53, 0x0, 0x3, -1021, 0x60}
  315. case AFMVXW:
  316. return &inst{0x53, 0x0, 0x0, -512, 0x70}
  317. case AFCLASSS:
  318. return &inst{0x53, 0x1, 0x0, -512, 0x70}
  319. case AFCVTWD:
  320. return &inst{0x53, 0x0, 0x0, -992, 0x61}
  321. case AFCVTWUD:
  322. return &inst{0x53, 0x0, 0x1, -991, 0x61}
  323. case AFCVTLD:
  324. return &inst{0x53, 0x0, 0x2, -990, 0x61}
  325. case AFCVTLUD:
  326. return &inst{0x53, 0x0, 0x3, -989, 0x61}
  327. case AFMVXD:
  328. return &inst{0x53, 0x0, 0x0, -480, 0x71}
  329. case AFCLASSD:
  330. return &inst{0x53, 0x1, 0x0, -480, 0x71}
  331. case AFCVTWQ:
  332. return &inst{0x53, 0x0, 0x0, -928, 0x63}
  333. case AFCVTWUQ:
  334. return &inst{0x53, 0x0, 0x1, -927, 0x63}
  335. case AFCVTLQ:
  336. return &inst{0x53, 0x0, 0x2, -926, 0x63}
  337. case AFCVTLUQ:
  338. return &inst{0x53, 0x0, 0x3, -925, 0x63}
  339. case AFMVXQ:
  340. return &inst{0x53, 0x0, 0x0, -416, 0x73}
  341. case AFCLASSQ:
  342. return &inst{0x53, 0x1, 0x0, -416, 0x73}
  343. case AFCVTSW:
  344. return &inst{0x53, 0x0, 0x0, -768, 0x68}
  345. case AFCVTSWU:
  346. return &inst{0x53, 0x0, 0x1, -767, 0x68}
  347. case AFCVTSL:
  348. return &inst{0x53, 0x0, 0x2, -766, 0x68}
  349. case AFCVTSLU:
  350. return &inst{0x53, 0x0, 0x3, -765, 0x68}
  351. case AFMVWX:
  352. return &inst{0x53, 0x0, 0x0, -256, 0x78}
  353. case AFCVTDW:
  354. return &inst{0x53, 0x0, 0x0, -736, 0x69}
  355. case AFCVTDWU:
  356. return &inst{0x53, 0x0, 0x1, -735, 0x69}
  357. case AFCVTDL:
  358. return &inst{0x53, 0x0, 0x2, -734, 0x69}
  359. case AFCVTDLU:
  360. return &inst{0x53, 0x0, 0x3, -733, 0x69}
  361. case AFMVDX:
  362. return &inst{0x53, 0x0, 0x0, -224, 0x79}
  363. case AFCVTQW:
  364. return &inst{0x53, 0x0, 0x0, -672, 0x6b}
  365. case AFCVTQWU:
  366. return &inst{0x53, 0x0, 0x1, -671, 0x6b}
  367. case AFCVTQL:
  368. return &inst{0x53, 0x0, 0x2, -670, 0x6b}
  369. case AFCVTQLU:
  370. return &inst{0x53, 0x0, 0x3, -669, 0x6b}
  371. case AFMVQX:
  372. return &inst{0x53, 0x0, 0x0, -160, 0x7b}
  373. case AFLW:
  374. return &inst{0x7, 0x2, 0x0, 0, 0x0}
  375. case AFLD:
  376. return &inst{0x7, 0x3, 0x0, 0, 0x0}
  377. case AFLQ:
  378. return &inst{0x7, 0x4, 0x0, 0, 0x0}
  379. case AFSW:
  380. return &inst{0x27, 0x2, 0x0, 0, 0x0}
  381. case AFSD:
  382. return &inst{0x27, 0x3, 0x0, 0, 0x0}
  383. case AFSQ:
  384. return &inst{0x27, 0x4, 0x0, 0, 0x0}
  385. case AFMADDS:
  386. return &inst{0x43, 0x0, 0x0, 0, 0x0}
  387. case AFMSUBS:
  388. return &inst{0x47, 0x0, 0x0, 0, 0x0}
  389. case AFNMSUBS:
  390. return &inst{0x4b, 0x0, 0x0, 0, 0x0}
  391. case AFNMADDS:
  392. return &inst{0x4f, 0x0, 0x0, 0, 0x0}
  393. case AFMADDD:
  394. return &inst{0x43, 0x0, 0x0, 32, 0x1}
  395. case AFMSUBD:
  396. return &inst{0x47, 0x0, 0x0, 32, 0x1}
  397. case AFNMSUBD:
  398. return &inst{0x4b, 0x0, 0x0, 32, 0x1}
  399. case AFNMADDD:
  400. return &inst{0x4f, 0x0, 0x0, 32, 0x1}
  401. case AFMADDQ:
  402. return &inst{0x43, 0x0, 0x0, 96, 0x3}
  403. case AFMSUBQ:
  404. return &inst{0x47, 0x0, 0x0, 96, 0x3}
  405. case AFNMSUBQ:
  406. return &inst{0x4b, 0x0, 0x0, 96, 0x3}
  407. case AFNMADDQ:
  408. return &inst{0x4f, 0x0, 0x0, 96, 0x3}
  409. case ASLLIRV32:
  410. return &inst{0x13, 0x1, 0x0, 0, 0x0}
  411. case ASRLIRV32:
  412. return &inst{0x13, 0x5, 0x0, 0, 0x0}
  413. case ASRAIRV32:
  414. return &inst{0x13, 0x5, 0x0, 1024, 0x20}
  415. case AFRFLAGS:
  416. return &inst{0x73, 0x2, 0x1, 1, 0x0}
  417. case AFSFLAGS:
  418. return &inst{0x73, 0x1, 0x1, 1, 0x0}
  419. case AFSFLAGSI:
  420. return &inst{0x73, 0x5, 0x1, 1, 0x0}
  421. case AFRRM:
  422. return &inst{0x73, 0x2, 0x2, 2, 0x0}
  423. case AFSRM:
  424. return &inst{0x73, 0x1, 0x2, 2, 0x0}
  425. case AFSRMI:
  426. return &inst{0x73, 0x5, 0x2, 2, 0x0}
  427. case AFSCSR:
  428. return &inst{0x73, 0x1, 0x3, 3, 0x0}
  429. case AFRCSR:
  430. return &inst{0x73, 0x2, 0x3, 3, 0x0}
  431. case ARDCYCLE:
  432. return &inst{0x73, 0x2, 0x0, -1024, 0x60}
  433. case ARDTIME:
  434. return &inst{0x73, 0x2, 0x1, -1023, 0x60}
  435. case ARDINSTRET:
  436. return &inst{0x73, 0x2, 0x2, -1022, 0x60}
  437. case ARDCYCLEH:
  438. return &inst{0x73, 0x2, 0x0, -896, 0x64}
  439. case ARDTIMEH:
  440. return &inst{0x73, 0x2, 0x1, -895, 0x64}
  441. case ARDINSTRETH:
  442. return &inst{0x73, 0x2, 0x2, -894, 0x64}
  443. case ASCALL:
  444. return &inst{0x73, 0x0, 0x0, 0, 0x0}
  445. case ASBREAK:
  446. return &inst{0x73, 0x0, 0x1, 1, 0x0}
  447. case AFMVXS:
  448. return &inst{0x53, 0x0, 0x0, -512, 0x70}
  449. case AFMVSX:
  450. return &inst{0x53, 0x0, 0x0, -256, 0x78}
  451. case AFENCETSO:
  452. return &inst{0xf, 0x0, 0x13, -1997, 0x41}
  453. }
  454. return nil
  455. }