inst.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899
  1. /*
  2. * Format of an instruction in memory.
  3. *
  4. * This file is subject to the terms and conditions of the GNU General Public
  5. * License. See the file "COPYING" in the main directory of this archive
  6. * for more details.
  7. *
  8. * Copyright (C) 1996, 2000 by Ralf Baechle
  9. * Copyright (C) 2006 by Thiemo Seufer
  10. * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved.
  11. */
  12. #ifndef _UAPI_ASM_INST_H
  13. #define _UAPI_ASM_INST_H
  14. /*
  15. * Major opcodes; before MIPS IV cop1x was called cop3.
  16. */
  17. enum major_op {
  18. spec_op, bcond_op, j_op, jal_op,
  19. beq_op, bne_op, blez_op, bgtz_op,
  20. addi_op, addiu_op, slti_op, sltiu_op,
  21. andi_op, ori_op, xori_op, lui_op,
  22. cop0_op, cop1_op, cop2_op, cop1x_op,
  23. beql_op, bnel_op, blezl_op, bgtzl_op,
  24. daddi_op, daddiu_op, ldl_op, ldr_op,
  25. spec2_op, jalx_op, mdmx_op, spec3_op,
  26. lb_op, lh_op, lwl_op, lw_op,
  27. lbu_op, lhu_op, lwr_op, lwu_op,
  28. sb_op, sh_op, swl_op, sw_op,
  29. sdl_op, sdr_op, swr_op, cache_op,
  30. ll_op, lwc1_op, lwc2_op, pref_op,
  31. lld_op, ldc1_op, ldc2_op, ld_op,
  32. sc_op, swc1_op, swc2_op, major_3b_op,
  33. scd_op, sdc1_op, sdc2_op, sd_op
  34. };
  35. /*
  36. * func field of spec opcode.
  37. */
  38. enum spec_op {
  39. sll_op, movc_op, srl_op, sra_op,
  40. sllv_op, pmon_op, srlv_op, srav_op,
  41. jr_op, jalr_op, movz_op, movn_op,
  42. syscall_op, break_op, spim_op, sync_op,
  43. mfhi_op, mthi_op, mflo_op, mtlo_op,
  44. dsllv_op, spec2_unused_op, dsrlv_op, dsrav_op,
  45. mult_op, multu_op, div_op, divu_op,
  46. dmult_op, dmultu_op, ddiv_op, ddivu_op,
  47. add_op, addu_op, sub_op, subu_op,
  48. and_op, or_op, xor_op, nor_op,
  49. spec3_unused_op, spec4_unused_op, slt_op, sltu_op,
  50. dadd_op, daddu_op, dsub_op, dsubu_op,
  51. tge_op, tgeu_op, tlt_op, tltu_op,
  52. teq_op, spec5_unused_op, tne_op, spec6_unused_op,
  53. dsll_op, spec7_unused_op, dsrl_op, dsra_op,
  54. dsll32_op, spec8_unused_op, dsrl32_op, dsra32_op
  55. };
  56. /*
  57. * func field of spec2 opcode.
  58. */
  59. enum spec2_op {
  60. madd_op, maddu_op, mul_op, spec2_3_unused_op,
  61. msub_op, msubu_op, /* more unused ops */
  62. clz_op = 0x20, clo_op,
  63. dclz_op = 0x24, dclo_op,
  64. sdbpp_op = 0x3f
  65. };
  66. /*
  67. * func field of spec3 opcode.
  68. */
  69. enum spec3_op {
  70. ext_op, dextm_op, dextu_op, dext_op,
  71. ins_op, dinsm_op, dinsu_op, dins_op,
  72. lx_op = 0x0a,
  73. bshfl_op = 0x20,
  74. dbshfl_op = 0x24,
  75. rdhwr_op = 0x3b
  76. };
  77. /*
  78. * rt field of bcond opcodes.
  79. */
  80. enum rt_op {
  81. bltz_op, bgez_op, bltzl_op, bgezl_op,
  82. spimi_op, unused_rt_op_0x05, unused_rt_op_0x06, unused_rt_op_0x07,
  83. tgei_op, tgeiu_op, tlti_op, tltiu_op,
  84. teqi_op, unused_0x0d_rt_op, tnei_op, unused_0x0f_rt_op,
  85. bltzal_op, bgezal_op, bltzall_op, bgezall_op,
  86. rt_op_0x14, rt_op_0x15, rt_op_0x16, rt_op_0x17,
  87. rt_op_0x18, rt_op_0x19, rt_op_0x1a, rt_op_0x1b,
  88. bposge32_op, rt_op_0x1d, rt_op_0x1e, rt_op_0x1f
  89. };
  90. /*
  91. * rs field of cop opcodes.
  92. */
  93. enum cop_op {
  94. mfc_op = 0x00, dmfc_op = 0x01,
  95. cfc_op = 0x02, mfhc_op = 0x03,
  96. mtc_op = 0x04, dmtc_op = 0x05,
  97. ctc_op = 0x06, mthc_op = 0x07,
  98. bc_op = 0x08, cop_op = 0x10,
  99. copm_op = 0x18
  100. };
  101. /*
  102. * rt field of cop.bc_op opcodes
  103. */
  104. enum bcop_op {
  105. bcf_op, bct_op, bcfl_op, bctl_op
  106. };
  107. /*
  108. * func field of cop0 coi opcodes.
  109. */
  110. enum cop0_coi_func {
  111. tlbr_op = 0x01, tlbwi_op = 0x02,
  112. tlbwr_op = 0x06, tlbp_op = 0x08,
  113. rfe_op = 0x10, eret_op = 0x18
  114. };
  115. /*
  116. * func field of cop0 com opcodes.
  117. */
  118. enum cop0_com_func {
  119. tlbr1_op = 0x01, tlbw_op = 0x02,
  120. tlbp1_op = 0x08, dctr_op = 0x09,
  121. dctw_op = 0x0a
  122. };
  123. /*
  124. * fmt field of cop1 opcodes.
  125. */
  126. enum cop1_fmt {
  127. s_fmt, d_fmt, e_fmt, q_fmt,
  128. w_fmt, l_fmt
  129. };
  130. /*
  131. * func field of cop1 instructions using d, s or w format.
  132. */
  133. enum cop1_sdw_func {
  134. fadd_op = 0x00, fsub_op = 0x01,
  135. fmul_op = 0x02, fdiv_op = 0x03,
  136. fsqrt_op = 0x04, fabs_op = 0x05,
  137. fmov_op = 0x06, fneg_op = 0x07,
  138. froundl_op = 0x08, ftruncl_op = 0x09,
  139. fceill_op = 0x0a, ffloorl_op = 0x0b,
  140. fround_op = 0x0c, ftrunc_op = 0x0d,
  141. fceil_op = 0x0e, ffloor_op = 0x0f,
  142. fmovc_op = 0x11, fmovz_op = 0x12,
  143. fmovn_op = 0x13, frecip_op = 0x15,
  144. frsqrt_op = 0x16, fcvts_op = 0x20,
  145. fcvtd_op = 0x21, fcvte_op = 0x22,
  146. fcvtw_op = 0x24, fcvtl_op = 0x25,
  147. fcmp_op = 0x30
  148. };
  149. /*
  150. * func field of cop1x opcodes (MIPS IV).
  151. */
  152. enum cop1x_func {
  153. lwxc1_op = 0x00, ldxc1_op = 0x01,
  154. swxc1_op = 0x08, sdxc1_op = 0x09,
  155. pfetch_op = 0x0f, madd_s_op = 0x20,
  156. madd_d_op = 0x21, madd_e_op = 0x22,
  157. msub_s_op = 0x28, msub_d_op = 0x29,
  158. msub_e_op = 0x2a, nmadd_s_op = 0x30,
  159. nmadd_d_op = 0x31, nmadd_e_op = 0x32,
  160. nmsub_s_op = 0x38, nmsub_d_op = 0x39,
  161. nmsub_e_op = 0x3a
  162. };
  163. /*
  164. * func field for mad opcodes (MIPS IV).
  165. */
  166. enum mad_func {
  167. madd_fp_op = 0x08, msub_fp_op = 0x0a,
  168. nmadd_fp_op = 0x0c, nmsub_fp_op = 0x0e
  169. };
  170. /*
  171. * func field for special3 lx opcodes (Cavium Octeon).
  172. */
  173. enum lx_func {
  174. lwx_op = 0x00,
  175. lhx_op = 0x04,
  176. lbux_op = 0x06,
  177. ldx_op = 0x08,
  178. lwux_op = 0x10,
  179. lhux_op = 0x14,
  180. lbx_op = 0x16,
  181. };
  182. /*
  183. * (microMIPS) Major opcodes.
  184. */
  185. enum mm_major_op {
  186. mm_pool32a_op, mm_pool16a_op, mm_lbu16_op, mm_move16_op,
  187. mm_addi32_op, mm_lbu32_op, mm_sb32_op, mm_lb32_op,
  188. mm_pool32b_op, mm_pool16b_op, mm_lhu16_op, mm_andi16_op,
  189. mm_addiu32_op, mm_lhu32_op, mm_sh32_op, mm_lh32_op,
  190. mm_pool32i_op, mm_pool16c_op, mm_lwsp16_op, mm_pool16d_op,
  191. mm_ori32_op, mm_pool32f_op, mm_reserved1_op, mm_reserved2_op,
  192. mm_pool32c_op, mm_lwgp16_op, mm_lw16_op, mm_pool16e_op,
  193. mm_xori32_op, mm_jals32_op, mm_addiupc_op, mm_reserved3_op,
  194. mm_reserved4_op, mm_pool16f_op, mm_sb16_op, mm_beqz16_op,
  195. mm_slti32_op, mm_beq32_op, mm_swc132_op, mm_lwc132_op,
  196. mm_reserved5_op, mm_reserved6_op, mm_sh16_op, mm_bnez16_op,
  197. mm_sltiu32_op, mm_bne32_op, mm_sdc132_op, mm_ldc132_op,
  198. mm_reserved7_op, mm_reserved8_op, mm_swsp16_op, mm_b16_op,
  199. mm_andi32_op, mm_j32_op, mm_sd32_op, mm_ld32_op,
  200. mm_reserved11_op, mm_reserved12_op, mm_sw16_op, mm_li16_op,
  201. mm_jalx32_op, mm_jal32_op, mm_sw32_op, mm_lw32_op,
  202. };
  203. /*
  204. * (microMIPS) POOL32I minor opcodes.
  205. */
  206. enum mm_32i_minor_op {
  207. mm_bltz_op, mm_bltzal_op, mm_bgez_op, mm_bgezal_op,
  208. mm_blez_op, mm_bnezc_op, mm_bgtz_op, mm_beqzc_op,
  209. mm_tlti_op, mm_tgei_op, mm_tltiu_op, mm_tgeiu_op,
  210. mm_tnei_op, mm_lui_op, mm_teqi_op, mm_reserved13_op,
  211. mm_synci_op, mm_bltzals_op, mm_reserved14_op, mm_bgezals_op,
  212. mm_bc2f_op, mm_bc2t_op, mm_reserved15_op, mm_reserved16_op,
  213. mm_reserved17_op, mm_reserved18_op, mm_bposge64_op, mm_bposge32_op,
  214. mm_bc1f_op, mm_bc1t_op, mm_reserved19_op, mm_reserved20_op,
  215. mm_bc1any2f_op, mm_bc1any2t_op, mm_bc1any4f_op, mm_bc1any4t_op,
  216. };
  217. /*
  218. * (microMIPS) POOL32A minor opcodes.
  219. */
  220. enum mm_32a_minor_op {
  221. mm_sll32_op = 0x000,
  222. mm_ins_op = 0x00c,
  223. mm_ext_op = 0x02c,
  224. mm_pool32axf_op = 0x03c,
  225. mm_srl32_op = 0x040,
  226. mm_sra_op = 0x080,
  227. mm_rotr_op = 0x0c0,
  228. mm_lwxs_op = 0x118,
  229. mm_addu32_op = 0x150,
  230. mm_subu32_op = 0x1d0,
  231. mm_and_op = 0x250,
  232. mm_or32_op = 0x290,
  233. mm_xor32_op = 0x310,
  234. };
  235. /*
  236. * (microMIPS) POOL32B functions.
  237. */
  238. enum mm_32b_func {
  239. mm_lwc2_func = 0x0,
  240. mm_lwp_func = 0x1,
  241. mm_ldc2_func = 0x2,
  242. mm_ldp_func = 0x4,
  243. mm_lwm32_func = 0x5,
  244. mm_cache_func = 0x6,
  245. mm_ldm_func = 0x7,
  246. mm_swc2_func = 0x8,
  247. mm_swp_func = 0x9,
  248. mm_sdc2_func = 0xa,
  249. mm_sdp_func = 0xc,
  250. mm_swm32_func = 0xd,
  251. mm_sdm_func = 0xf,
  252. };
  253. /*
  254. * (microMIPS) POOL32C functions.
  255. */
  256. enum mm_32c_func {
  257. mm_pref_func = 0x2,
  258. mm_ll_func = 0x3,
  259. mm_swr_func = 0x9,
  260. mm_sc_func = 0xb,
  261. mm_lwu_func = 0xe,
  262. };
  263. /*
  264. * (microMIPS) POOL32AXF minor opcodes.
  265. */
  266. enum mm_32axf_minor_op {
  267. mm_mfc0_op = 0x003,
  268. mm_mtc0_op = 0x00b,
  269. mm_tlbp_op = 0x00d,
  270. mm_jalr_op = 0x03c,
  271. mm_tlbr_op = 0x04d,
  272. mm_jalrhb_op = 0x07c,
  273. mm_tlbwi_op = 0x08d,
  274. mm_tlbwr_op = 0x0cd,
  275. mm_jalrs_op = 0x13c,
  276. mm_jalrshb_op = 0x17c,
  277. mm_syscall_op = 0x22d,
  278. mm_eret_op = 0x3cd,
  279. };
  280. /*
  281. * (microMIPS) POOL32F minor opcodes.
  282. */
  283. enum mm_32f_minor_op {
  284. mm_32f_00_op = 0x00,
  285. mm_32f_01_op = 0x01,
  286. mm_32f_02_op = 0x02,
  287. mm_32f_10_op = 0x08,
  288. mm_32f_11_op = 0x09,
  289. mm_32f_12_op = 0x0a,
  290. mm_32f_20_op = 0x10,
  291. mm_32f_30_op = 0x18,
  292. mm_32f_40_op = 0x20,
  293. mm_32f_41_op = 0x21,
  294. mm_32f_42_op = 0x22,
  295. mm_32f_50_op = 0x28,
  296. mm_32f_51_op = 0x29,
  297. mm_32f_52_op = 0x2a,
  298. mm_32f_60_op = 0x30,
  299. mm_32f_70_op = 0x38,
  300. mm_32f_73_op = 0x3b,
  301. mm_32f_74_op = 0x3c,
  302. };
  303. /*
  304. * (microMIPS) POOL32F secondary minor opcodes.
  305. */
  306. enum mm_32f_10_minor_op {
  307. mm_lwxc1_op = 0x1,
  308. mm_swxc1_op,
  309. mm_ldxc1_op,
  310. mm_sdxc1_op,
  311. mm_luxc1_op,
  312. mm_suxc1_op,
  313. };
  314. enum mm_32f_func {
  315. mm_lwxc1_func = 0x048,
  316. mm_swxc1_func = 0x088,
  317. mm_ldxc1_func = 0x0c8,
  318. mm_sdxc1_func = 0x108,
  319. };
  320. /*
  321. * (microMIPS) POOL32F secondary minor opcodes.
  322. */
  323. enum mm_32f_40_minor_op {
  324. mm_fmovf_op,
  325. mm_fmovt_op,
  326. };
  327. /*
  328. * (microMIPS) POOL32F secondary minor opcodes.
  329. */
  330. enum mm_32f_60_minor_op {
  331. mm_fadd_op,
  332. mm_fsub_op,
  333. mm_fmul_op,
  334. mm_fdiv_op,
  335. };
  336. /*
  337. * (microMIPS) POOL32F secondary minor opcodes.
  338. */
  339. enum mm_32f_70_minor_op {
  340. mm_fmovn_op,
  341. mm_fmovz_op,
  342. };
  343. /*
  344. * (microMIPS) POOL32FXF secondary minor opcodes for POOL32F.
  345. */
  346. enum mm_32f_73_minor_op {
  347. mm_fmov0_op = 0x01,
  348. mm_fcvtl_op = 0x04,
  349. mm_movf0_op = 0x05,
  350. mm_frsqrt_op = 0x08,
  351. mm_ffloorl_op = 0x0c,
  352. mm_fabs0_op = 0x0d,
  353. mm_fcvtw_op = 0x24,
  354. mm_movt0_op = 0x25,
  355. mm_fsqrt_op = 0x28,
  356. mm_ffloorw_op = 0x2c,
  357. mm_fneg0_op = 0x2d,
  358. mm_cfc1_op = 0x40,
  359. mm_frecip_op = 0x48,
  360. mm_fceill_op = 0x4c,
  361. mm_fcvtd0_op = 0x4d,
  362. mm_ctc1_op = 0x60,
  363. mm_fceilw_op = 0x6c,
  364. mm_fcvts0_op = 0x6d,
  365. mm_mfc1_op = 0x80,
  366. mm_fmov1_op = 0x81,
  367. mm_movf1_op = 0x85,
  368. mm_ftruncl_op = 0x8c,
  369. mm_fabs1_op = 0x8d,
  370. mm_mtc1_op = 0xa0,
  371. mm_movt1_op = 0xa5,
  372. mm_ftruncw_op = 0xac,
  373. mm_fneg1_op = 0xad,
  374. mm_mfhc1_op = 0xc0,
  375. mm_froundl_op = 0xcc,
  376. mm_fcvtd1_op = 0xcd,
  377. mm_mthc1_op = 0xe0,
  378. mm_froundw_op = 0xec,
  379. mm_fcvts1_op = 0xed,
  380. };
  381. /*
  382. * (microMIPS) POOL16C minor opcodes.
  383. */
  384. enum mm_16c_minor_op {
  385. mm_lwm16_op = 0x04,
  386. mm_swm16_op = 0x05,
  387. mm_jr16_op = 0x0c,
  388. mm_jrc_op = 0x0d,
  389. mm_jalr16_op = 0x0e,
  390. mm_jalrs16_op = 0x0f,
  391. mm_jraddiusp_op = 0x18,
  392. };
  393. /*
  394. * (microMIPS) POOL16D minor opcodes.
  395. */
  396. enum mm_16d_minor_op {
  397. mm_addius5_func,
  398. mm_addiusp_func,
  399. };
  400. /*
  401. * (MIPS16e) opcodes.
  402. */
  403. enum MIPS16e_ops {
  404. MIPS16e_jal_op = 003,
  405. MIPS16e_ld_op = 007,
  406. MIPS16e_i8_op = 014,
  407. MIPS16e_sd_op = 017,
  408. MIPS16e_lb_op = 020,
  409. MIPS16e_lh_op = 021,
  410. MIPS16e_lwsp_op = 022,
  411. MIPS16e_lw_op = 023,
  412. MIPS16e_lbu_op = 024,
  413. MIPS16e_lhu_op = 025,
  414. MIPS16e_lwpc_op = 026,
  415. MIPS16e_lwu_op = 027,
  416. MIPS16e_sb_op = 030,
  417. MIPS16e_sh_op = 031,
  418. MIPS16e_swsp_op = 032,
  419. MIPS16e_sw_op = 033,
  420. MIPS16e_rr_op = 035,
  421. MIPS16e_extend_op = 036,
  422. MIPS16e_i64_op = 037,
  423. };
  424. enum MIPS16e_i64_func {
  425. MIPS16e_ldsp_func,
  426. MIPS16e_sdsp_func,
  427. MIPS16e_sdrasp_func,
  428. MIPS16e_dadjsp_func,
  429. MIPS16e_ldpc_func,
  430. };
  431. enum MIPS16e_rr_func {
  432. MIPS16e_jr_func,
  433. };
  434. enum MIPS6e_i8_func {
  435. MIPS16e_swrasp_func = 02,
  436. };
  437. /*
  438. * (microMIPS & MIPS16e) NOP instruction.
  439. */
  440. #define MM_NOP16 0x0c00
  441. /*
  442. * Damn ... bitfields depend from byteorder :-(
  443. */
  444. #ifdef __MIPSEB__
  445. #define BITFIELD_FIELD(field, more) \
  446. field; \
  447. more
  448. #elif defined(__MIPSEL__)
  449. #define BITFIELD_FIELD(field, more) \
  450. more \
  451. field;
  452. #else /* !defined (__MIPSEB__) && !defined (__MIPSEL__) */
  453. #error "MIPS but neither __MIPSEL__ nor __MIPSEB__?"
  454. #endif
  455. struct j_format {
  456. BITFIELD_FIELD(unsigned int opcode : 6, /* Jump format */
  457. BITFIELD_FIELD(unsigned int target : 26,
  458. ;))
  459. };
  460. struct i_format { /* signed immediate format */
  461. BITFIELD_FIELD(unsigned int opcode : 6,
  462. BITFIELD_FIELD(unsigned int rs : 5,
  463. BITFIELD_FIELD(unsigned int rt : 5,
  464. BITFIELD_FIELD(signed int simmediate : 16,
  465. ;))))
  466. };
  467. struct u_format { /* unsigned immediate format */
  468. BITFIELD_FIELD(unsigned int opcode : 6,
  469. BITFIELD_FIELD(unsigned int rs : 5,
  470. BITFIELD_FIELD(unsigned int rt : 5,
  471. BITFIELD_FIELD(unsigned int uimmediate : 16,
  472. ;))))
  473. };
  474. struct c_format { /* Cache (>= R6000) format */
  475. BITFIELD_FIELD(unsigned int opcode : 6,
  476. BITFIELD_FIELD(unsigned int rs : 5,
  477. BITFIELD_FIELD(unsigned int c_op : 3,
  478. BITFIELD_FIELD(unsigned int cache : 2,
  479. BITFIELD_FIELD(unsigned int simmediate : 16,
  480. ;)))))
  481. };
  482. struct r_format { /* Register format */
  483. BITFIELD_FIELD(unsigned int opcode : 6,
  484. BITFIELD_FIELD(unsigned int rs : 5,
  485. BITFIELD_FIELD(unsigned int rt : 5,
  486. BITFIELD_FIELD(unsigned int rd : 5,
  487. BITFIELD_FIELD(unsigned int re : 5,
  488. BITFIELD_FIELD(unsigned int func : 6,
  489. ;))))))
  490. };
  491. struct p_format { /* Performance counter format (R10000) */
  492. BITFIELD_FIELD(unsigned int opcode : 6,
  493. BITFIELD_FIELD(unsigned int rs : 5,
  494. BITFIELD_FIELD(unsigned int rt : 5,
  495. BITFIELD_FIELD(unsigned int rd : 5,
  496. BITFIELD_FIELD(unsigned int re : 5,
  497. BITFIELD_FIELD(unsigned int func : 6,
  498. ;))))))
  499. };
  500. struct f_format { /* FPU register format */
  501. BITFIELD_FIELD(unsigned int opcode : 6,
  502. BITFIELD_FIELD(unsigned int : 1,
  503. BITFIELD_FIELD(unsigned int fmt : 4,
  504. BITFIELD_FIELD(unsigned int rt : 5,
  505. BITFIELD_FIELD(unsigned int rd : 5,
  506. BITFIELD_FIELD(unsigned int re : 5,
  507. BITFIELD_FIELD(unsigned int func : 6,
  508. ;)))))))
  509. };
  510. struct ma_format { /* FPU multiply and add format (MIPS IV) */
  511. BITFIELD_FIELD(unsigned int opcode : 6,
  512. BITFIELD_FIELD(unsigned int fr : 5,
  513. BITFIELD_FIELD(unsigned int ft : 5,
  514. BITFIELD_FIELD(unsigned int fs : 5,
  515. BITFIELD_FIELD(unsigned int fd : 5,
  516. BITFIELD_FIELD(unsigned int func : 4,
  517. BITFIELD_FIELD(unsigned int fmt : 2,
  518. ;)))))))
  519. };
  520. struct b_format { /* BREAK and SYSCALL */
  521. BITFIELD_FIELD(unsigned int opcode : 6,
  522. BITFIELD_FIELD(unsigned int code : 20,
  523. BITFIELD_FIELD(unsigned int func : 6,
  524. ;)))
  525. };
  526. struct ps_format { /* MIPS-3D / paired single format */
  527. BITFIELD_FIELD(unsigned int opcode : 6,
  528. BITFIELD_FIELD(unsigned int rs : 5,
  529. BITFIELD_FIELD(unsigned int ft : 5,
  530. BITFIELD_FIELD(unsigned int fs : 5,
  531. BITFIELD_FIELD(unsigned int fd : 5,
  532. BITFIELD_FIELD(unsigned int func : 6,
  533. ;))))))
  534. };
  535. struct v_format { /* MDMX vector format */
  536. BITFIELD_FIELD(unsigned int opcode : 6,
  537. BITFIELD_FIELD(unsigned int sel : 4,
  538. BITFIELD_FIELD(unsigned int fmt : 1,
  539. BITFIELD_FIELD(unsigned int vt : 5,
  540. BITFIELD_FIELD(unsigned int vs : 5,
  541. BITFIELD_FIELD(unsigned int vd : 5,
  542. BITFIELD_FIELD(unsigned int func : 6,
  543. ;)))))))
  544. };
  545. /*
  546. * microMIPS instruction formats (32-bit length)
  547. *
  548. * NOTE:
  549. * Parenthesis denote whether the format is a microMIPS instruction or
  550. * if it is MIPS32 instruction re-encoded for use in the microMIPS ASE.
  551. */
  552. struct fb_format { /* FPU branch format (MIPS32) */
  553. BITFIELD_FIELD(unsigned int opcode : 6,
  554. BITFIELD_FIELD(unsigned int bc : 5,
  555. BITFIELD_FIELD(unsigned int cc : 3,
  556. BITFIELD_FIELD(unsigned int flag : 2,
  557. BITFIELD_FIELD(signed int simmediate : 16,
  558. ;)))))
  559. };
  560. struct fp0_format { /* FPU multiply and add format (MIPS32) */
  561. BITFIELD_FIELD(unsigned int opcode : 6,
  562. BITFIELD_FIELD(unsigned int fmt : 5,
  563. BITFIELD_FIELD(unsigned int ft : 5,
  564. BITFIELD_FIELD(unsigned int fs : 5,
  565. BITFIELD_FIELD(unsigned int fd : 5,
  566. BITFIELD_FIELD(unsigned int func : 6,
  567. ;))))))
  568. };
  569. struct mm_fp0_format { /* FPU multipy and add format (microMIPS) */
  570. BITFIELD_FIELD(unsigned int opcode : 6,
  571. BITFIELD_FIELD(unsigned int ft : 5,
  572. BITFIELD_FIELD(unsigned int fs : 5,
  573. BITFIELD_FIELD(unsigned int fd : 5,
  574. BITFIELD_FIELD(unsigned int fmt : 3,
  575. BITFIELD_FIELD(unsigned int op : 2,
  576. BITFIELD_FIELD(unsigned int func : 6,
  577. ;)))))))
  578. };
  579. struct fp1_format { /* FPU mfc1 and cfc1 format (MIPS32) */
  580. BITFIELD_FIELD(unsigned int opcode : 6,
  581. BITFIELD_FIELD(unsigned int op : 5,
  582. BITFIELD_FIELD(unsigned int rt : 5,
  583. BITFIELD_FIELD(unsigned int fs : 5,
  584. BITFIELD_FIELD(unsigned int fd : 5,
  585. BITFIELD_FIELD(unsigned int func : 6,
  586. ;))))))
  587. };
  588. struct mm_fp1_format { /* FPU mfc1 and cfc1 format (microMIPS) */
  589. BITFIELD_FIELD(unsigned int opcode : 6,
  590. BITFIELD_FIELD(unsigned int rt : 5,
  591. BITFIELD_FIELD(unsigned int fs : 5,
  592. BITFIELD_FIELD(unsigned int fmt : 2,
  593. BITFIELD_FIELD(unsigned int op : 8,
  594. BITFIELD_FIELD(unsigned int func : 6,
  595. ;))))))
  596. };
  597. struct mm_fp2_format { /* FPU movt and movf format (microMIPS) */
  598. BITFIELD_FIELD(unsigned int opcode : 6,
  599. BITFIELD_FIELD(unsigned int fd : 5,
  600. BITFIELD_FIELD(unsigned int fs : 5,
  601. BITFIELD_FIELD(unsigned int cc : 3,
  602. BITFIELD_FIELD(unsigned int zero : 2,
  603. BITFIELD_FIELD(unsigned int fmt : 2,
  604. BITFIELD_FIELD(unsigned int op : 3,
  605. BITFIELD_FIELD(unsigned int func : 6,
  606. ;))))))))
  607. };
  608. struct mm_fp3_format { /* FPU abs and neg format (microMIPS) */
  609. BITFIELD_FIELD(unsigned int opcode : 6,
  610. BITFIELD_FIELD(unsigned int rt : 5,
  611. BITFIELD_FIELD(unsigned int fs : 5,
  612. BITFIELD_FIELD(unsigned int fmt : 3,
  613. BITFIELD_FIELD(unsigned int op : 7,
  614. BITFIELD_FIELD(unsigned int func : 6,
  615. ;))))))
  616. };
  617. struct mm_fp4_format { /* FPU c.cond format (microMIPS) */
  618. BITFIELD_FIELD(unsigned int opcode : 6,
  619. BITFIELD_FIELD(unsigned int rt : 5,
  620. BITFIELD_FIELD(unsigned int fs : 5,
  621. BITFIELD_FIELD(unsigned int cc : 3,
  622. BITFIELD_FIELD(unsigned int fmt : 3,
  623. BITFIELD_FIELD(unsigned int cond : 4,
  624. BITFIELD_FIELD(unsigned int func : 6,
  625. ;)))))))
  626. };
  627. struct mm_fp5_format { /* FPU lwxc1 and swxc1 format (microMIPS) */
  628. BITFIELD_FIELD(unsigned int opcode : 6,
  629. BITFIELD_FIELD(unsigned int index : 5,
  630. BITFIELD_FIELD(unsigned int base : 5,
  631. BITFIELD_FIELD(unsigned int fd : 5,
  632. BITFIELD_FIELD(unsigned int op : 5,
  633. BITFIELD_FIELD(unsigned int func : 6,
  634. ;))))))
  635. };
  636. struct fp6_format { /* FPU madd and msub format (MIPS IV) */
  637. BITFIELD_FIELD(unsigned int opcode : 6,
  638. BITFIELD_FIELD(unsigned int fr : 5,
  639. BITFIELD_FIELD(unsigned int ft : 5,
  640. BITFIELD_FIELD(unsigned int fs : 5,
  641. BITFIELD_FIELD(unsigned int fd : 5,
  642. BITFIELD_FIELD(unsigned int func : 6,
  643. ;))))))
  644. };
  645. struct mm_fp6_format { /* FPU madd and msub format (microMIPS) */
  646. BITFIELD_FIELD(unsigned int opcode : 6,
  647. BITFIELD_FIELD(unsigned int ft : 5,
  648. BITFIELD_FIELD(unsigned int fs : 5,
  649. BITFIELD_FIELD(unsigned int fd : 5,
  650. BITFIELD_FIELD(unsigned int fr : 5,
  651. BITFIELD_FIELD(unsigned int func : 6,
  652. ;))))))
  653. };
  654. struct mm_i_format { /* Immediate format (microMIPS) */
  655. BITFIELD_FIELD(unsigned int opcode : 6,
  656. BITFIELD_FIELD(unsigned int rt : 5,
  657. BITFIELD_FIELD(unsigned int rs : 5,
  658. BITFIELD_FIELD(signed int simmediate : 16,
  659. ;))))
  660. };
  661. struct mm_m_format { /* Multi-word load/store format (microMIPS) */
  662. BITFIELD_FIELD(unsigned int opcode : 6,
  663. BITFIELD_FIELD(unsigned int rd : 5,
  664. BITFIELD_FIELD(unsigned int base : 5,
  665. BITFIELD_FIELD(unsigned int func : 4,
  666. BITFIELD_FIELD(signed int simmediate : 12,
  667. ;)))))
  668. };
  669. struct mm_x_format { /* Scaled indexed load format (microMIPS) */
  670. BITFIELD_FIELD(unsigned int opcode : 6,
  671. BITFIELD_FIELD(unsigned int index : 5,
  672. BITFIELD_FIELD(unsigned int base : 5,
  673. BITFIELD_FIELD(unsigned int rd : 5,
  674. BITFIELD_FIELD(unsigned int func : 11,
  675. ;)))))
  676. };
  677. /*
  678. * microMIPS instruction formats (16-bit length)
  679. */
  680. struct mm_b0_format { /* Unconditional branch format (microMIPS) */
  681. BITFIELD_FIELD(unsigned int opcode : 6,
  682. BITFIELD_FIELD(signed int simmediate : 10,
  683. BITFIELD_FIELD(unsigned int : 16, /* Ignored */
  684. ;)))
  685. };
  686. struct mm_b1_format { /* Conditional branch format (microMIPS) */
  687. BITFIELD_FIELD(unsigned int opcode : 6,
  688. BITFIELD_FIELD(unsigned int rs : 3,
  689. BITFIELD_FIELD(signed int simmediate : 7,
  690. BITFIELD_FIELD(unsigned int : 16, /* Ignored */
  691. ;))))
  692. };
  693. struct mm16_m_format { /* Multi-word load/store format */
  694. BITFIELD_FIELD(unsigned int opcode : 6,
  695. BITFIELD_FIELD(unsigned int func : 4,
  696. BITFIELD_FIELD(unsigned int rlist : 2,
  697. BITFIELD_FIELD(unsigned int imm : 4,
  698. BITFIELD_FIELD(unsigned int : 16, /* Ignored */
  699. ;)))))
  700. };
  701. struct mm16_rb_format { /* Signed immediate format */
  702. BITFIELD_FIELD(unsigned int opcode : 6,
  703. BITFIELD_FIELD(unsigned int rt : 3,
  704. BITFIELD_FIELD(unsigned int base : 3,
  705. BITFIELD_FIELD(signed int simmediate : 4,
  706. BITFIELD_FIELD(unsigned int : 16, /* Ignored */
  707. ;)))))
  708. };
  709. struct mm16_r3_format { /* Load from global pointer format */
  710. BITFIELD_FIELD(unsigned int opcode : 6,
  711. BITFIELD_FIELD(unsigned int rt : 3,
  712. BITFIELD_FIELD(signed int simmediate : 7,
  713. BITFIELD_FIELD(unsigned int : 16, /* Ignored */
  714. ;))))
  715. };
  716. struct mm16_r5_format { /* Load/store from stack pointer format */
  717. BITFIELD_FIELD(unsigned int opcode : 6,
  718. BITFIELD_FIELD(unsigned int rt : 5,
  719. BITFIELD_FIELD(signed int simmediate : 5,
  720. BITFIELD_FIELD(unsigned int : 16, /* Ignored */
  721. ;))))
  722. };
  723. /*
  724. * MIPS16e instruction formats (16-bit length)
  725. */
  726. struct m16e_rr {
  727. BITFIELD_FIELD(unsigned int opcode : 5,
  728. BITFIELD_FIELD(unsigned int rx : 3,
  729. BITFIELD_FIELD(unsigned int nd : 1,
  730. BITFIELD_FIELD(unsigned int l : 1,
  731. BITFIELD_FIELD(unsigned int ra : 1,
  732. BITFIELD_FIELD(unsigned int func : 5,
  733. ;))))))
  734. };
  735. struct m16e_jal {
  736. BITFIELD_FIELD(unsigned int opcode : 5,
  737. BITFIELD_FIELD(unsigned int x : 1,
  738. BITFIELD_FIELD(unsigned int imm20_16 : 5,
  739. BITFIELD_FIELD(signed int imm25_21 : 5,
  740. ;))))
  741. };
  742. struct m16e_i64 {
  743. BITFIELD_FIELD(unsigned int opcode : 5,
  744. BITFIELD_FIELD(unsigned int func : 3,
  745. BITFIELD_FIELD(unsigned int imm : 8,
  746. ;)))
  747. };
  748. struct m16e_ri64 {
  749. BITFIELD_FIELD(unsigned int opcode : 5,
  750. BITFIELD_FIELD(unsigned int func : 3,
  751. BITFIELD_FIELD(unsigned int ry : 3,
  752. BITFIELD_FIELD(unsigned int imm : 5,
  753. ;))))
  754. };
  755. struct m16e_ri {
  756. BITFIELD_FIELD(unsigned int opcode : 5,
  757. BITFIELD_FIELD(unsigned int rx : 3,
  758. BITFIELD_FIELD(unsigned int imm : 8,
  759. ;)))
  760. };
  761. struct m16e_rri {
  762. BITFIELD_FIELD(unsigned int opcode : 5,
  763. BITFIELD_FIELD(unsigned int rx : 3,
  764. BITFIELD_FIELD(unsigned int ry : 3,
  765. BITFIELD_FIELD(unsigned int imm : 5,
  766. ;))))
  767. };
  768. struct m16e_i8 {
  769. BITFIELD_FIELD(unsigned int opcode : 5,
  770. BITFIELD_FIELD(unsigned int func : 3,
  771. BITFIELD_FIELD(unsigned int imm : 8,
  772. ;)))
  773. };
  774. union mips_instruction {
  775. unsigned int word;
  776. unsigned short halfword[2];
  777. unsigned char byte[4];
  778. struct j_format j_format;
  779. struct i_format i_format;
  780. struct u_format u_format;
  781. struct c_format c_format;
  782. struct r_format r_format;
  783. struct p_format p_format;
  784. struct f_format f_format;
  785. struct ma_format ma_format;
  786. struct b_format b_format;
  787. struct ps_format ps_format;
  788. struct v_format v_format;
  789. struct fb_format fb_format;
  790. struct fp0_format fp0_format;
  791. struct mm_fp0_format mm_fp0_format;
  792. struct fp1_format fp1_format;
  793. struct mm_fp1_format mm_fp1_format;
  794. struct mm_fp2_format mm_fp2_format;
  795. struct mm_fp3_format mm_fp3_format;
  796. struct mm_fp4_format mm_fp4_format;
  797. struct mm_fp5_format mm_fp5_format;
  798. struct fp6_format fp6_format;
  799. struct mm_fp6_format mm_fp6_format;
  800. struct mm_i_format mm_i_format;
  801. struct mm_m_format mm_m_format;
  802. struct mm_x_format mm_x_format;
  803. struct mm_b0_format mm_b0_format;
  804. struct mm_b1_format mm_b1_format;
  805. struct mm16_m_format mm16_m_format ;
  806. struct mm16_rb_format mm16_rb_format;
  807. struct mm16_r3_format mm16_r3_format;
  808. struct mm16_r5_format mm16_r5_format;
  809. };
  810. union mips16e_instruction {
  811. unsigned int full : 16;
  812. struct m16e_rr rr;
  813. struct m16e_jal jal;
  814. struct m16e_i64 i64;
  815. struct m16e_ri64 ri64;
  816. struct m16e_ri ri;
  817. struct m16e_rri rri;
  818. struct m16e_i8 i8;
  819. };
  820. #endif /* _UAPI_ASM_INST_H */