opcode-tile_32.h 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513
  1. /* tile.h -- Header file for TILE opcode table
  2. Copyright (C) 2005 Free Software Foundation, Inc.
  3. Contributed by Tilera Corp. */
  4. #ifndef opcode_tile_h
  5. #define opcode_tile_h
  6. typedef unsigned long long tile_bundle_bits;
  7. enum
  8. {
  9. TILE_MAX_OPERANDS = 5 /* mm */
  10. };
  11. typedef enum
  12. {
  13. TILE_OPC_BPT,
  14. TILE_OPC_INFO,
  15. TILE_OPC_INFOL,
  16. TILE_OPC_J,
  17. TILE_OPC_JAL,
  18. TILE_OPC_MOVE,
  19. TILE_OPC_MOVE_SN,
  20. TILE_OPC_MOVEI,
  21. TILE_OPC_MOVEI_SN,
  22. TILE_OPC_MOVELI,
  23. TILE_OPC_MOVELI_SN,
  24. TILE_OPC_MOVELIS,
  25. TILE_OPC_PREFETCH,
  26. TILE_OPC_RAISE,
  27. TILE_OPC_ADD,
  28. TILE_OPC_ADD_SN,
  29. TILE_OPC_ADDB,
  30. TILE_OPC_ADDB_SN,
  31. TILE_OPC_ADDBS_U,
  32. TILE_OPC_ADDBS_U_SN,
  33. TILE_OPC_ADDH,
  34. TILE_OPC_ADDH_SN,
  35. TILE_OPC_ADDHS,
  36. TILE_OPC_ADDHS_SN,
  37. TILE_OPC_ADDI,
  38. TILE_OPC_ADDI_SN,
  39. TILE_OPC_ADDIB,
  40. TILE_OPC_ADDIB_SN,
  41. TILE_OPC_ADDIH,
  42. TILE_OPC_ADDIH_SN,
  43. TILE_OPC_ADDLI,
  44. TILE_OPC_ADDLI_SN,
  45. TILE_OPC_ADDLIS,
  46. TILE_OPC_ADDS,
  47. TILE_OPC_ADDS_SN,
  48. TILE_OPC_ADIFFB_U,
  49. TILE_OPC_ADIFFB_U_SN,
  50. TILE_OPC_ADIFFH,
  51. TILE_OPC_ADIFFH_SN,
  52. TILE_OPC_AND,
  53. TILE_OPC_AND_SN,
  54. TILE_OPC_ANDI,
  55. TILE_OPC_ANDI_SN,
  56. TILE_OPC_AULI,
  57. TILE_OPC_AVGB_U,
  58. TILE_OPC_AVGB_U_SN,
  59. TILE_OPC_AVGH,
  60. TILE_OPC_AVGH_SN,
  61. TILE_OPC_BBNS,
  62. TILE_OPC_BBNS_SN,
  63. TILE_OPC_BBNST,
  64. TILE_OPC_BBNST_SN,
  65. TILE_OPC_BBS,
  66. TILE_OPC_BBS_SN,
  67. TILE_OPC_BBST,
  68. TILE_OPC_BBST_SN,
  69. TILE_OPC_BGEZ,
  70. TILE_OPC_BGEZ_SN,
  71. TILE_OPC_BGEZT,
  72. TILE_OPC_BGEZT_SN,
  73. TILE_OPC_BGZ,
  74. TILE_OPC_BGZ_SN,
  75. TILE_OPC_BGZT,
  76. TILE_OPC_BGZT_SN,
  77. TILE_OPC_BITX,
  78. TILE_OPC_BITX_SN,
  79. TILE_OPC_BLEZ,
  80. TILE_OPC_BLEZ_SN,
  81. TILE_OPC_BLEZT,
  82. TILE_OPC_BLEZT_SN,
  83. TILE_OPC_BLZ,
  84. TILE_OPC_BLZ_SN,
  85. TILE_OPC_BLZT,
  86. TILE_OPC_BLZT_SN,
  87. TILE_OPC_BNZ,
  88. TILE_OPC_BNZ_SN,
  89. TILE_OPC_BNZT,
  90. TILE_OPC_BNZT_SN,
  91. TILE_OPC_BYTEX,
  92. TILE_OPC_BYTEX_SN,
  93. TILE_OPC_BZ,
  94. TILE_OPC_BZ_SN,
  95. TILE_OPC_BZT,
  96. TILE_OPC_BZT_SN,
  97. TILE_OPC_CLZ,
  98. TILE_OPC_CLZ_SN,
  99. TILE_OPC_CRC32_32,
  100. TILE_OPC_CRC32_32_SN,
  101. TILE_OPC_CRC32_8,
  102. TILE_OPC_CRC32_8_SN,
  103. TILE_OPC_CTZ,
  104. TILE_OPC_CTZ_SN,
  105. TILE_OPC_DRAIN,
  106. TILE_OPC_DTLBPR,
  107. TILE_OPC_DWORD_ALIGN,
  108. TILE_OPC_DWORD_ALIGN_SN,
  109. TILE_OPC_FINV,
  110. TILE_OPC_FLUSH,
  111. TILE_OPC_FNOP,
  112. TILE_OPC_ICOH,
  113. TILE_OPC_ILL,
  114. TILE_OPC_INTHB,
  115. TILE_OPC_INTHB_SN,
  116. TILE_OPC_INTHH,
  117. TILE_OPC_INTHH_SN,
  118. TILE_OPC_INTLB,
  119. TILE_OPC_INTLB_SN,
  120. TILE_OPC_INTLH,
  121. TILE_OPC_INTLH_SN,
  122. TILE_OPC_INV,
  123. TILE_OPC_IRET,
  124. TILE_OPC_JALB,
  125. TILE_OPC_JALF,
  126. TILE_OPC_JALR,
  127. TILE_OPC_JALRP,
  128. TILE_OPC_JB,
  129. TILE_OPC_JF,
  130. TILE_OPC_JR,
  131. TILE_OPC_JRP,
  132. TILE_OPC_LB,
  133. TILE_OPC_LB_SN,
  134. TILE_OPC_LB_U,
  135. TILE_OPC_LB_U_SN,
  136. TILE_OPC_LBADD,
  137. TILE_OPC_LBADD_SN,
  138. TILE_OPC_LBADD_U,
  139. TILE_OPC_LBADD_U_SN,
  140. TILE_OPC_LH,
  141. TILE_OPC_LH_SN,
  142. TILE_OPC_LH_U,
  143. TILE_OPC_LH_U_SN,
  144. TILE_OPC_LHADD,
  145. TILE_OPC_LHADD_SN,
  146. TILE_OPC_LHADD_U,
  147. TILE_OPC_LHADD_U_SN,
  148. TILE_OPC_LNK,
  149. TILE_OPC_LNK_SN,
  150. TILE_OPC_LW,
  151. TILE_OPC_LW_SN,
  152. TILE_OPC_LW_NA,
  153. TILE_OPC_LW_NA_SN,
  154. TILE_OPC_LWADD,
  155. TILE_OPC_LWADD_SN,
  156. TILE_OPC_LWADD_NA,
  157. TILE_OPC_LWADD_NA_SN,
  158. TILE_OPC_MAXB_U,
  159. TILE_OPC_MAXB_U_SN,
  160. TILE_OPC_MAXH,
  161. TILE_OPC_MAXH_SN,
  162. TILE_OPC_MAXIB_U,
  163. TILE_OPC_MAXIB_U_SN,
  164. TILE_OPC_MAXIH,
  165. TILE_OPC_MAXIH_SN,
  166. TILE_OPC_MF,
  167. TILE_OPC_MFSPR,
  168. TILE_OPC_MINB_U,
  169. TILE_OPC_MINB_U_SN,
  170. TILE_OPC_MINH,
  171. TILE_OPC_MINH_SN,
  172. TILE_OPC_MINIB_U,
  173. TILE_OPC_MINIB_U_SN,
  174. TILE_OPC_MINIH,
  175. TILE_OPC_MINIH_SN,
  176. TILE_OPC_MM,
  177. TILE_OPC_MNZ,
  178. TILE_OPC_MNZ_SN,
  179. TILE_OPC_MNZB,
  180. TILE_OPC_MNZB_SN,
  181. TILE_OPC_MNZH,
  182. TILE_OPC_MNZH_SN,
  183. TILE_OPC_MTSPR,
  184. TILE_OPC_MULHH_SS,
  185. TILE_OPC_MULHH_SS_SN,
  186. TILE_OPC_MULHH_SU,
  187. TILE_OPC_MULHH_SU_SN,
  188. TILE_OPC_MULHH_UU,
  189. TILE_OPC_MULHH_UU_SN,
  190. TILE_OPC_MULHHA_SS,
  191. TILE_OPC_MULHHA_SS_SN,
  192. TILE_OPC_MULHHA_SU,
  193. TILE_OPC_MULHHA_SU_SN,
  194. TILE_OPC_MULHHA_UU,
  195. TILE_OPC_MULHHA_UU_SN,
  196. TILE_OPC_MULHHSA_UU,
  197. TILE_OPC_MULHHSA_UU_SN,
  198. TILE_OPC_MULHL_SS,
  199. TILE_OPC_MULHL_SS_SN,
  200. TILE_OPC_MULHL_SU,
  201. TILE_OPC_MULHL_SU_SN,
  202. TILE_OPC_MULHL_US,
  203. TILE_OPC_MULHL_US_SN,
  204. TILE_OPC_MULHL_UU,
  205. TILE_OPC_MULHL_UU_SN,
  206. TILE_OPC_MULHLA_SS,
  207. TILE_OPC_MULHLA_SS_SN,
  208. TILE_OPC_MULHLA_SU,
  209. TILE_OPC_MULHLA_SU_SN,
  210. TILE_OPC_MULHLA_US,
  211. TILE_OPC_MULHLA_US_SN,
  212. TILE_OPC_MULHLA_UU,
  213. TILE_OPC_MULHLA_UU_SN,
  214. TILE_OPC_MULHLSA_UU,
  215. TILE_OPC_MULHLSA_UU_SN,
  216. TILE_OPC_MULLL_SS,
  217. TILE_OPC_MULLL_SS_SN,
  218. TILE_OPC_MULLL_SU,
  219. TILE_OPC_MULLL_SU_SN,
  220. TILE_OPC_MULLL_UU,
  221. TILE_OPC_MULLL_UU_SN,
  222. TILE_OPC_MULLLA_SS,
  223. TILE_OPC_MULLLA_SS_SN,
  224. TILE_OPC_MULLLA_SU,
  225. TILE_OPC_MULLLA_SU_SN,
  226. TILE_OPC_MULLLA_UU,
  227. TILE_OPC_MULLLA_UU_SN,
  228. TILE_OPC_MULLLSA_UU,
  229. TILE_OPC_MULLLSA_UU_SN,
  230. TILE_OPC_MVNZ,
  231. TILE_OPC_MVNZ_SN,
  232. TILE_OPC_MVZ,
  233. TILE_OPC_MVZ_SN,
  234. TILE_OPC_MZ,
  235. TILE_OPC_MZ_SN,
  236. TILE_OPC_MZB,
  237. TILE_OPC_MZB_SN,
  238. TILE_OPC_MZH,
  239. TILE_OPC_MZH_SN,
  240. TILE_OPC_NAP,
  241. TILE_OPC_NOP,
  242. TILE_OPC_NOR,
  243. TILE_OPC_NOR_SN,
  244. TILE_OPC_OR,
  245. TILE_OPC_OR_SN,
  246. TILE_OPC_ORI,
  247. TILE_OPC_ORI_SN,
  248. TILE_OPC_PACKBS_U,
  249. TILE_OPC_PACKBS_U_SN,
  250. TILE_OPC_PACKHB,
  251. TILE_OPC_PACKHB_SN,
  252. TILE_OPC_PACKHS,
  253. TILE_OPC_PACKHS_SN,
  254. TILE_OPC_PACKLB,
  255. TILE_OPC_PACKLB_SN,
  256. TILE_OPC_PCNT,
  257. TILE_OPC_PCNT_SN,
  258. TILE_OPC_RL,
  259. TILE_OPC_RL_SN,
  260. TILE_OPC_RLI,
  261. TILE_OPC_RLI_SN,
  262. TILE_OPC_S1A,
  263. TILE_OPC_S1A_SN,
  264. TILE_OPC_S2A,
  265. TILE_OPC_S2A_SN,
  266. TILE_OPC_S3A,
  267. TILE_OPC_S3A_SN,
  268. TILE_OPC_SADAB_U,
  269. TILE_OPC_SADAB_U_SN,
  270. TILE_OPC_SADAH,
  271. TILE_OPC_SADAH_SN,
  272. TILE_OPC_SADAH_U,
  273. TILE_OPC_SADAH_U_SN,
  274. TILE_OPC_SADB_U,
  275. TILE_OPC_SADB_U_SN,
  276. TILE_OPC_SADH,
  277. TILE_OPC_SADH_SN,
  278. TILE_OPC_SADH_U,
  279. TILE_OPC_SADH_U_SN,
  280. TILE_OPC_SB,
  281. TILE_OPC_SBADD,
  282. TILE_OPC_SEQ,
  283. TILE_OPC_SEQ_SN,
  284. TILE_OPC_SEQB,
  285. TILE_OPC_SEQB_SN,
  286. TILE_OPC_SEQH,
  287. TILE_OPC_SEQH_SN,
  288. TILE_OPC_SEQI,
  289. TILE_OPC_SEQI_SN,
  290. TILE_OPC_SEQIB,
  291. TILE_OPC_SEQIB_SN,
  292. TILE_OPC_SEQIH,
  293. TILE_OPC_SEQIH_SN,
  294. TILE_OPC_SH,
  295. TILE_OPC_SHADD,
  296. TILE_OPC_SHL,
  297. TILE_OPC_SHL_SN,
  298. TILE_OPC_SHLB,
  299. TILE_OPC_SHLB_SN,
  300. TILE_OPC_SHLH,
  301. TILE_OPC_SHLH_SN,
  302. TILE_OPC_SHLI,
  303. TILE_OPC_SHLI_SN,
  304. TILE_OPC_SHLIB,
  305. TILE_OPC_SHLIB_SN,
  306. TILE_OPC_SHLIH,
  307. TILE_OPC_SHLIH_SN,
  308. TILE_OPC_SHR,
  309. TILE_OPC_SHR_SN,
  310. TILE_OPC_SHRB,
  311. TILE_OPC_SHRB_SN,
  312. TILE_OPC_SHRH,
  313. TILE_OPC_SHRH_SN,
  314. TILE_OPC_SHRI,
  315. TILE_OPC_SHRI_SN,
  316. TILE_OPC_SHRIB,
  317. TILE_OPC_SHRIB_SN,
  318. TILE_OPC_SHRIH,
  319. TILE_OPC_SHRIH_SN,
  320. TILE_OPC_SLT,
  321. TILE_OPC_SLT_SN,
  322. TILE_OPC_SLT_U,
  323. TILE_OPC_SLT_U_SN,
  324. TILE_OPC_SLTB,
  325. TILE_OPC_SLTB_SN,
  326. TILE_OPC_SLTB_U,
  327. TILE_OPC_SLTB_U_SN,
  328. TILE_OPC_SLTE,
  329. TILE_OPC_SLTE_SN,
  330. TILE_OPC_SLTE_U,
  331. TILE_OPC_SLTE_U_SN,
  332. TILE_OPC_SLTEB,
  333. TILE_OPC_SLTEB_SN,
  334. TILE_OPC_SLTEB_U,
  335. TILE_OPC_SLTEB_U_SN,
  336. TILE_OPC_SLTEH,
  337. TILE_OPC_SLTEH_SN,
  338. TILE_OPC_SLTEH_U,
  339. TILE_OPC_SLTEH_U_SN,
  340. TILE_OPC_SLTH,
  341. TILE_OPC_SLTH_SN,
  342. TILE_OPC_SLTH_U,
  343. TILE_OPC_SLTH_U_SN,
  344. TILE_OPC_SLTI,
  345. TILE_OPC_SLTI_SN,
  346. TILE_OPC_SLTI_U,
  347. TILE_OPC_SLTI_U_SN,
  348. TILE_OPC_SLTIB,
  349. TILE_OPC_SLTIB_SN,
  350. TILE_OPC_SLTIB_U,
  351. TILE_OPC_SLTIB_U_SN,
  352. TILE_OPC_SLTIH,
  353. TILE_OPC_SLTIH_SN,
  354. TILE_OPC_SLTIH_U,
  355. TILE_OPC_SLTIH_U_SN,
  356. TILE_OPC_SNE,
  357. TILE_OPC_SNE_SN,
  358. TILE_OPC_SNEB,
  359. TILE_OPC_SNEB_SN,
  360. TILE_OPC_SNEH,
  361. TILE_OPC_SNEH_SN,
  362. TILE_OPC_SRA,
  363. TILE_OPC_SRA_SN,
  364. TILE_OPC_SRAB,
  365. TILE_OPC_SRAB_SN,
  366. TILE_OPC_SRAH,
  367. TILE_OPC_SRAH_SN,
  368. TILE_OPC_SRAI,
  369. TILE_OPC_SRAI_SN,
  370. TILE_OPC_SRAIB,
  371. TILE_OPC_SRAIB_SN,
  372. TILE_OPC_SRAIH,
  373. TILE_OPC_SRAIH_SN,
  374. TILE_OPC_SUB,
  375. TILE_OPC_SUB_SN,
  376. TILE_OPC_SUBB,
  377. TILE_OPC_SUBB_SN,
  378. TILE_OPC_SUBBS_U,
  379. TILE_OPC_SUBBS_U_SN,
  380. TILE_OPC_SUBH,
  381. TILE_OPC_SUBH_SN,
  382. TILE_OPC_SUBHS,
  383. TILE_OPC_SUBHS_SN,
  384. TILE_OPC_SUBS,
  385. TILE_OPC_SUBS_SN,
  386. TILE_OPC_SW,
  387. TILE_OPC_SWADD,
  388. TILE_OPC_SWINT0,
  389. TILE_OPC_SWINT1,
  390. TILE_OPC_SWINT2,
  391. TILE_OPC_SWINT3,
  392. TILE_OPC_TBLIDXB0,
  393. TILE_OPC_TBLIDXB0_SN,
  394. TILE_OPC_TBLIDXB1,
  395. TILE_OPC_TBLIDXB1_SN,
  396. TILE_OPC_TBLIDXB2,
  397. TILE_OPC_TBLIDXB2_SN,
  398. TILE_OPC_TBLIDXB3,
  399. TILE_OPC_TBLIDXB3_SN,
  400. TILE_OPC_TNS,
  401. TILE_OPC_TNS_SN,
  402. TILE_OPC_WH64,
  403. TILE_OPC_XOR,
  404. TILE_OPC_XOR_SN,
  405. TILE_OPC_XORI,
  406. TILE_OPC_XORI_SN,
  407. TILE_OPC_NONE
  408. } tile_mnemonic;
  409. /* 64-bit pattern for a { bpt ; nop } bundle. */
  410. #define TILE_BPT_BUNDLE 0x400b3cae70166000ULL
  411. #define TILE_ELF_MACHINE_CODE EM_TILEPRO
  412. #define TILE_ELF_NAME "elf32-tilepro"
  413. static __inline unsigned int
  414. get_BrOff_SN(tile_bundle_bits num)
  415. {
  416. const unsigned int n = (unsigned int)num;
  417. return (((n >> 0)) & 0x3ff);
  418. }
  419. static __inline unsigned int
  420. get_BrOff_X1(tile_bundle_bits n)
  421. {
  422. return (((unsigned int)(n >> 43)) & 0x00007fff) |
  423. (((unsigned int)(n >> 20)) & 0x00018000);
  424. }
  425. static __inline unsigned int
  426. get_BrType_X1(tile_bundle_bits n)
  427. {
  428. return (((unsigned int)(n >> 31)) & 0xf);
  429. }
  430. static __inline unsigned int
  431. get_Dest_Imm8_X1(tile_bundle_bits n)
  432. {
  433. return (((unsigned int)(n >> 31)) & 0x0000003f) |
  434. (((unsigned int)(n >> 43)) & 0x000000c0);
  435. }
  436. static __inline unsigned int
  437. get_Dest_SN(tile_bundle_bits num)
  438. {
  439. const unsigned int n = (unsigned int)num;
  440. return (((n >> 2)) & 0x3);
  441. }
  442. static __inline unsigned int
  443. get_Dest_X0(tile_bundle_bits num)
  444. {
  445. const unsigned int n = (unsigned int)num;
  446. return (((n >> 0)) & 0x3f);
  447. }
  448. static __inline unsigned int
  449. get_Dest_X1(tile_bundle_bits n)
  450. {
  451. return (((unsigned int)(n >> 31)) & 0x3f);
  452. }
  453. static __inline unsigned int
  454. get_Dest_Y0(tile_bundle_bits num)
  455. {
  456. const unsigned int n = (unsigned int)num;
  457. return (((n >> 0)) & 0x3f);
  458. }
  459. static __inline unsigned int
  460. get_Dest_Y1(tile_bundle_bits n)
  461. {
  462. return (((unsigned int)(n >> 31)) & 0x3f);
  463. }
  464. static __inline unsigned int
  465. get_Imm16_X0(tile_bundle_bits num)
  466. {
  467. const unsigned int n = (unsigned int)num;
  468. return (((n >> 12)) & 0xffff);
  469. }
  470. static __inline unsigned int
  471. get_Imm16_X1(tile_bundle_bits n)
  472. {
  473. return (((unsigned int)(n >> 43)) & 0xffff);
  474. }
  475. static __inline unsigned int
  476. get_Imm8_SN(tile_bundle_bits num)
  477. {
  478. const unsigned int n = (unsigned int)num;
  479. return (((n >> 0)) & 0xff);
  480. }
  481. static __inline unsigned int
  482. get_Imm8_X0(tile_bundle_bits num)
  483. {
  484. const unsigned int n = (unsigned int)num;
  485. return (((n >> 12)) & 0xff);
  486. }
  487. static __inline unsigned int
  488. get_Imm8_X1(tile_bundle_bits n)
  489. {
  490. return (((unsigned int)(n >> 43)) & 0xff);
  491. }
  492. static __inline unsigned int
  493. get_Imm8_Y0(tile_bundle_bits num)
  494. {
  495. const unsigned int n = (unsigned int)num;
  496. return (((n >> 12)) & 0xff);
  497. }
  498. static __inline unsigned int
  499. get_Imm8_Y1(tile_bundle_bits n)
  500. {
  501. return (((unsigned int)(n >> 43)) & 0xff);
  502. }
  503. static __inline unsigned int
  504. get_ImmOpcodeExtension_X0(tile_bundle_bits num)
  505. {
  506. const unsigned int n = (unsigned int)num;
  507. return (((n >> 20)) & 0x7f);
  508. }
  509. static __inline unsigned int
  510. get_ImmOpcodeExtension_X1(tile_bundle_bits n)
  511. {
  512. return (((unsigned int)(n >> 51)) & 0x7f);
  513. }
  514. static __inline unsigned int
  515. get_ImmRROpcodeExtension_SN(tile_bundle_bits num)
  516. {
  517. const unsigned int n = (unsigned int)num;
  518. return (((n >> 8)) & 0x3);
  519. }
  520. static __inline unsigned int
  521. get_JOffLong_X1(tile_bundle_bits n)
  522. {
  523. return (((unsigned int)(n >> 43)) & 0x00007fff) |
  524. (((unsigned int)(n >> 20)) & 0x00018000) |
  525. (((unsigned int)(n >> 14)) & 0x001e0000) |
  526. (((unsigned int)(n >> 16)) & 0x07e00000) |
  527. (((unsigned int)(n >> 31)) & 0x18000000);
  528. }
  529. static __inline unsigned int
  530. get_JOff_X1(tile_bundle_bits n)
  531. {
  532. return (((unsigned int)(n >> 43)) & 0x00007fff) |
  533. (((unsigned int)(n >> 20)) & 0x00018000) |
  534. (((unsigned int)(n >> 14)) & 0x001e0000) |
  535. (((unsigned int)(n >> 16)) & 0x07e00000) |
  536. (((unsigned int)(n >> 31)) & 0x08000000);
  537. }
  538. static __inline unsigned int
  539. get_MF_Imm15_X1(tile_bundle_bits n)
  540. {
  541. return (((unsigned int)(n >> 37)) & 0x00003fff) |
  542. (((unsigned int)(n >> 44)) & 0x00004000);
  543. }
  544. static __inline unsigned int
  545. get_MMEnd_X0(tile_bundle_bits num)
  546. {
  547. const unsigned int n = (unsigned int)num;
  548. return (((n >> 18)) & 0x1f);
  549. }
  550. static __inline unsigned int
  551. get_MMEnd_X1(tile_bundle_bits n)
  552. {
  553. return (((unsigned int)(n >> 49)) & 0x1f);
  554. }
  555. static __inline unsigned int
  556. get_MMStart_X0(tile_bundle_bits num)
  557. {
  558. const unsigned int n = (unsigned int)num;
  559. return (((n >> 23)) & 0x1f);
  560. }
  561. static __inline unsigned int
  562. get_MMStart_X1(tile_bundle_bits n)
  563. {
  564. return (((unsigned int)(n >> 54)) & 0x1f);
  565. }
  566. static __inline unsigned int
  567. get_MT_Imm15_X1(tile_bundle_bits n)
  568. {
  569. return (((unsigned int)(n >> 31)) & 0x0000003f) |
  570. (((unsigned int)(n >> 37)) & 0x00003fc0) |
  571. (((unsigned int)(n >> 44)) & 0x00004000);
  572. }
  573. static __inline unsigned int
  574. get_Mode(tile_bundle_bits n)
  575. {
  576. return (((unsigned int)(n >> 63)) & 0x1);
  577. }
  578. static __inline unsigned int
  579. get_NoRegOpcodeExtension_SN(tile_bundle_bits num)
  580. {
  581. const unsigned int n = (unsigned int)num;
  582. return (((n >> 0)) & 0xf);
  583. }
  584. static __inline unsigned int
  585. get_Opcode_SN(tile_bundle_bits num)
  586. {
  587. const unsigned int n = (unsigned int)num;
  588. return (((n >> 10)) & 0x3f);
  589. }
  590. static __inline unsigned int
  591. get_Opcode_X0(tile_bundle_bits num)
  592. {
  593. const unsigned int n = (unsigned int)num;
  594. return (((n >> 28)) & 0x7);
  595. }
  596. static __inline unsigned int
  597. get_Opcode_X1(tile_bundle_bits n)
  598. {
  599. return (((unsigned int)(n >> 59)) & 0xf);
  600. }
  601. static __inline unsigned int
  602. get_Opcode_Y0(tile_bundle_bits num)
  603. {
  604. const unsigned int n = (unsigned int)num;
  605. return (((n >> 27)) & 0xf);
  606. }
  607. static __inline unsigned int
  608. get_Opcode_Y1(tile_bundle_bits n)
  609. {
  610. return (((unsigned int)(n >> 59)) & 0xf);
  611. }
  612. static __inline unsigned int
  613. get_Opcode_Y2(tile_bundle_bits n)
  614. {
  615. return (((unsigned int)(n >> 56)) & 0x7);
  616. }
  617. static __inline unsigned int
  618. get_RROpcodeExtension_SN(tile_bundle_bits num)
  619. {
  620. const unsigned int n = (unsigned int)num;
  621. return (((n >> 4)) & 0xf);
  622. }
  623. static __inline unsigned int
  624. get_RRROpcodeExtension_X0(tile_bundle_bits num)
  625. {
  626. const unsigned int n = (unsigned int)num;
  627. return (((n >> 18)) & 0x1ff);
  628. }
  629. static __inline unsigned int
  630. get_RRROpcodeExtension_X1(tile_bundle_bits n)
  631. {
  632. return (((unsigned int)(n >> 49)) & 0x1ff);
  633. }
  634. static __inline unsigned int
  635. get_RRROpcodeExtension_Y0(tile_bundle_bits num)
  636. {
  637. const unsigned int n = (unsigned int)num;
  638. return (((n >> 18)) & 0x3);
  639. }
  640. static __inline unsigned int
  641. get_RRROpcodeExtension_Y1(tile_bundle_bits n)
  642. {
  643. return (((unsigned int)(n >> 49)) & 0x3);
  644. }
  645. static __inline unsigned int
  646. get_RouteOpcodeExtension_SN(tile_bundle_bits num)
  647. {
  648. const unsigned int n = (unsigned int)num;
  649. return (((n >> 0)) & 0x3ff);
  650. }
  651. static __inline unsigned int
  652. get_S_X0(tile_bundle_bits num)
  653. {
  654. const unsigned int n = (unsigned int)num;
  655. return (((n >> 27)) & 0x1);
  656. }
  657. static __inline unsigned int
  658. get_S_X1(tile_bundle_bits n)
  659. {
  660. return (((unsigned int)(n >> 58)) & 0x1);
  661. }
  662. static __inline unsigned int
  663. get_ShAmt_X0(tile_bundle_bits num)
  664. {
  665. const unsigned int n = (unsigned int)num;
  666. return (((n >> 12)) & 0x1f);
  667. }
  668. static __inline unsigned int
  669. get_ShAmt_X1(tile_bundle_bits n)
  670. {
  671. return (((unsigned int)(n >> 43)) & 0x1f);
  672. }
  673. static __inline unsigned int
  674. get_ShAmt_Y0(tile_bundle_bits num)
  675. {
  676. const unsigned int n = (unsigned int)num;
  677. return (((n >> 12)) & 0x1f);
  678. }
  679. static __inline unsigned int
  680. get_ShAmt_Y1(tile_bundle_bits n)
  681. {
  682. return (((unsigned int)(n >> 43)) & 0x1f);
  683. }
  684. static __inline unsigned int
  685. get_SrcA_X0(tile_bundle_bits num)
  686. {
  687. const unsigned int n = (unsigned int)num;
  688. return (((n >> 6)) & 0x3f);
  689. }
  690. static __inline unsigned int
  691. get_SrcA_X1(tile_bundle_bits n)
  692. {
  693. return (((unsigned int)(n >> 37)) & 0x3f);
  694. }
  695. static __inline unsigned int
  696. get_SrcA_Y0(tile_bundle_bits num)
  697. {
  698. const unsigned int n = (unsigned int)num;
  699. return (((n >> 6)) & 0x3f);
  700. }
  701. static __inline unsigned int
  702. get_SrcA_Y1(tile_bundle_bits n)
  703. {
  704. return (((unsigned int)(n >> 37)) & 0x3f);
  705. }
  706. static __inline unsigned int
  707. get_SrcA_Y2(tile_bundle_bits n)
  708. {
  709. return (((n >> 26)) & 0x00000001) |
  710. (((unsigned int)(n >> 50)) & 0x0000003e);
  711. }
  712. static __inline unsigned int
  713. get_SrcBDest_Y2(tile_bundle_bits num)
  714. {
  715. const unsigned int n = (unsigned int)num;
  716. return (((n >> 20)) & 0x3f);
  717. }
  718. static __inline unsigned int
  719. get_SrcB_X0(tile_bundle_bits num)
  720. {
  721. const unsigned int n = (unsigned int)num;
  722. return (((n >> 12)) & 0x3f);
  723. }
  724. static __inline unsigned int
  725. get_SrcB_X1(tile_bundle_bits n)
  726. {
  727. return (((unsigned int)(n >> 43)) & 0x3f);
  728. }
  729. static __inline unsigned int
  730. get_SrcB_Y0(tile_bundle_bits num)
  731. {
  732. const unsigned int n = (unsigned int)num;
  733. return (((n >> 12)) & 0x3f);
  734. }
  735. static __inline unsigned int
  736. get_SrcB_Y1(tile_bundle_bits n)
  737. {
  738. return (((unsigned int)(n >> 43)) & 0x3f);
  739. }
  740. static __inline unsigned int
  741. get_Src_SN(tile_bundle_bits num)
  742. {
  743. const unsigned int n = (unsigned int)num;
  744. return (((n >> 0)) & 0x3);
  745. }
  746. static __inline unsigned int
  747. get_UnOpcodeExtension_X0(tile_bundle_bits num)
  748. {
  749. const unsigned int n = (unsigned int)num;
  750. return (((n >> 12)) & 0x1f);
  751. }
  752. static __inline unsigned int
  753. get_UnOpcodeExtension_X1(tile_bundle_bits n)
  754. {
  755. return (((unsigned int)(n >> 43)) & 0x1f);
  756. }
  757. static __inline unsigned int
  758. get_UnOpcodeExtension_Y0(tile_bundle_bits num)
  759. {
  760. const unsigned int n = (unsigned int)num;
  761. return (((n >> 12)) & 0x1f);
  762. }
  763. static __inline unsigned int
  764. get_UnOpcodeExtension_Y1(tile_bundle_bits n)
  765. {
  766. return (((unsigned int)(n >> 43)) & 0x1f);
  767. }
  768. static __inline unsigned int
  769. get_UnShOpcodeExtension_X0(tile_bundle_bits num)
  770. {
  771. const unsigned int n = (unsigned int)num;
  772. return (((n >> 17)) & 0x3ff);
  773. }
  774. static __inline unsigned int
  775. get_UnShOpcodeExtension_X1(tile_bundle_bits n)
  776. {
  777. return (((unsigned int)(n >> 48)) & 0x3ff);
  778. }
  779. static __inline unsigned int
  780. get_UnShOpcodeExtension_Y0(tile_bundle_bits num)
  781. {
  782. const unsigned int n = (unsigned int)num;
  783. return (((n >> 17)) & 0x7);
  784. }
  785. static __inline unsigned int
  786. get_UnShOpcodeExtension_Y1(tile_bundle_bits n)
  787. {
  788. return (((unsigned int)(n >> 48)) & 0x7);
  789. }
  790. static __inline int
  791. sign_extend(int n, int num_bits)
  792. {
  793. int shift = (int)(sizeof(int) * 8 - num_bits);
  794. return (n << shift) >> shift;
  795. }
  796. static __inline tile_bundle_bits
  797. create_BrOff_SN(int num)
  798. {
  799. const unsigned int n = (unsigned int)num;
  800. return ((n & 0x3ff) << 0);
  801. }
  802. static __inline tile_bundle_bits
  803. create_BrOff_X1(int num)
  804. {
  805. const unsigned int n = (unsigned int)num;
  806. return (((tile_bundle_bits)(n & 0x00007fff)) << 43) |
  807. (((tile_bundle_bits)(n & 0x00018000)) << 20);
  808. }
  809. static __inline tile_bundle_bits
  810. create_BrType_X1(int num)
  811. {
  812. const unsigned int n = (unsigned int)num;
  813. return (((tile_bundle_bits)(n & 0xf)) << 31);
  814. }
  815. static __inline tile_bundle_bits
  816. create_Dest_Imm8_X1(int num)
  817. {
  818. const unsigned int n = (unsigned int)num;
  819. return (((tile_bundle_bits)(n & 0x0000003f)) << 31) |
  820. (((tile_bundle_bits)(n & 0x000000c0)) << 43);
  821. }
  822. static __inline tile_bundle_bits
  823. create_Dest_SN(int num)
  824. {
  825. const unsigned int n = (unsigned int)num;
  826. return ((n & 0x3) << 2);
  827. }
  828. static __inline tile_bundle_bits
  829. create_Dest_X0(int num)
  830. {
  831. const unsigned int n = (unsigned int)num;
  832. return ((n & 0x3f) << 0);
  833. }
  834. static __inline tile_bundle_bits
  835. create_Dest_X1(int num)
  836. {
  837. const unsigned int n = (unsigned int)num;
  838. return (((tile_bundle_bits)(n & 0x3f)) << 31);
  839. }
  840. static __inline tile_bundle_bits
  841. create_Dest_Y0(int num)
  842. {
  843. const unsigned int n = (unsigned int)num;
  844. return ((n & 0x3f) << 0);
  845. }
  846. static __inline tile_bundle_bits
  847. create_Dest_Y1(int num)
  848. {
  849. const unsigned int n = (unsigned int)num;
  850. return (((tile_bundle_bits)(n & 0x3f)) << 31);
  851. }
  852. static __inline tile_bundle_bits
  853. create_Imm16_X0(int num)
  854. {
  855. const unsigned int n = (unsigned int)num;
  856. return ((n & 0xffff) << 12);
  857. }
  858. static __inline tile_bundle_bits
  859. create_Imm16_X1(int num)
  860. {
  861. const unsigned int n = (unsigned int)num;
  862. return (((tile_bundle_bits)(n & 0xffff)) << 43);
  863. }
  864. static __inline tile_bundle_bits
  865. create_Imm8_SN(int num)
  866. {
  867. const unsigned int n = (unsigned int)num;
  868. return ((n & 0xff) << 0);
  869. }
  870. static __inline tile_bundle_bits
  871. create_Imm8_X0(int num)
  872. {
  873. const unsigned int n = (unsigned int)num;
  874. return ((n & 0xff) << 12);
  875. }
  876. static __inline tile_bundle_bits
  877. create_Imm8_X1(int num)
  878. {
  879. const unsigned int n = (unsigned int)num;
  880. return (((tile_bundle_bits)(n & 0xff)) << 43);
  881. }
  882. static __inline tile_bundle_bits
  883. create_Imm8_Y0(int num)
  884. {
  885. const unsigned int n = (unsigned int)num;
  886. return ((n & 0xff) << 12);
  887. }
  888. static __inline tile_bundle_bits
  889. create_Imm8_Y1(int num)
  890. {
  891. const unsigned int n = (unsigned int)num;
  892. return (((tile_bundle_bits)(n & 0xff)) << 43);
  893. }
  894. static __inline tile_bundle_bits
  895. create_ImmOpcodeExtension_X0(int num)
  896. {
  897. const unsigned int n = (unsigned int)num;
  898. return ((n & 0x7f) << 20);
  899. }
  900. static __inline tile_bundle_bits
  901. create_ImmOpcodeExtension_X1(int num)
  902. {
  903. const unsigned int n = (unsigned int)num;
  904. return (((tile_bundle_bits)(n & 0x7f)) << 51);
  905. }
  906. static __inline tile_bundle_bits
  907. create_ImmRROpcodeExtension_SN(int num)
  908. {
  909. const unsigned int n = (unsigned int)num;
  910. return ((n & 0x3) << 8);
  911. }
  912. static __inline tile_bundle_bits
  913. create_JOffLong_X1(int num)
  914. {
  915. const unsigned int n = (unsigned int)num;
  916. return (((tile_bundle_bits)(n & 0x00007fff)) << 43) |
  917. (((tile_bundle_bits)(n & 0x00018000)) << 20) |
  918. (((tile_bundle_bits)(n & 0x001e0000)) << 14) |
  919. (((tile_bundle_bits)(n & 0x07e00000)) << 16) |
  920. (((tile_bundle_bits)(n & 0x18000000)) << 31);
  921. }
  922. static __inline tile_bundle_bits
  923. create_JOff_X1(int num)
  924. {
  925. const unsigned int n = (unsigned int)num;
  926. return (((tile_bundle_bits)(n & 0x00007fff)) << 43) |
  927. (((tile_bundle_bits)(n & 0x00018000)) << 20) |
  928. (((tile_bundle_bits)(n & 0x001e0000)) << 14) |
  929. (((tile_bundle_bits)(n & 0x07e00000)) << 16) |
  930. (((tile_bundle_bits)(n & 0x08000000)) << 31);
  931. }
  932. static __inline tile_bundle_bits
  933. create_MF_Imm15_X1(int num)
  934. {
  935. const unsigned int n = (unsigned int)num;
  936. return (((tile_bundle_bits)(n & 0x00003fff)) << 37) |
  937. (((tile_bundle_bits)(n & 0x00004000)) << 44);
  938. }
  939. static __inline tile_bundle_bits
  940. create_MMEnd_X0(int num)
  941. {
  942. const unsigned int n = (unsigned int)num;
  943. return ((n & 0x1f) << 18);
  944. }
  945. static __inline tile_bundle_bits
  946. create_MMEnd_X1(int num)
  947. {
  948. const unsigned int n = (unsigned int)num;
  949. return (((tile_bundle_bits)(n & 0x1f)) << 49);
  950. }
  951. static __inline tile_bundle_bits
  952. create_MMStart_X0(int num)
  953. {
  954. const unsigned int n = (unsigned int)num;
  955. return ((n & 0x1f) << 23);
  956. }
  957. static __inline tile_bundle_bits
  958. create_MMStart_X1(int num)
  959. {
  960. const unsigned int n = (unsigned int)num;
  961. return (((tile_bundle_bits)(n & 0x1f)) << 54);
  962. }
  963. static __inline tile_bundle_bits
  964. create_MT_Imm15_X1(int num)
  965. {
  966. const unsigned int n = (unsigned int)num;
  967. return (((tile_bundle_bits)(n & 0x0000003f)) << 31) |
  968. (((tile_bundle_bits)(n & 0x00003fc0)) << 37) |
  969. (((tile_bundle_bits)(n & 0x00004000)) << 44);
  970. }
  971. static __inline tile_bundle_bits
  972. create_Mode(int num)
  973. {
  974. const unsigned int n = (unsigned int)num;
  975. return (((tile_bundle_bits)(n & 0x1)) << 63);
  976. }
  977. static __inline tile_bundle_bits
  978. create_NoRegOpcodeExtension_SN(int num)
  979. {
  980. const unsigned int n = (unsigned int)num;
  981. return ((n & 0xf) << 0);
  982. }
  983. static __inline tile_bundle_bits
  984. create_Opcode_SN(int num)
  985. {
  986. const unsigned int n = (unsigned int)num;
  987. return ((n & 0x3f) << 10);
  988. }
  989. static __inline tile_bundle_bits
  990. create_Opcode_X0(int num)
  991. {
  992. const unsigned int n = (unsigned int)num;
  993. return ((n & 0x7) << 28);
  994. }
  995. static __inline tile_bundle_bits
  996. create_Opcode_X1(int num)
  997. {
  998. const unsigned int n = (unsigned int)num;
  999. return (((tile_bundle_bits)(n & 0xf)) << 59);
  1000. }
  1001. static __inline tile_bundle_bits
  1002. create_Opcode_Y0(int num)
  1003. {
  1004. const unsigned int n = (unsigned int)num;
  1005. return ((n & 0xf) << 27);
  1006. }
  1007. static __inline tile_bundle_bits
  1008. create_Opcode_Y1(int num)
  1009. {
  1010. const unsigned int n = (unsigned int)num;
  1011. return (((tile_bundle_bits)(n & 0xf)) << 59);
  1012. }
  1013. static __inline tile_bundle_bits
  1014. create_Opcode_Y2(int num)
  1015. {
  1016. const unsigned int n = (unsigned int)num;
  1017. return (((tile_bundle_bits)(n & 0x7)) << 56);
  1018. }
  1019. static __inline tile_bundle_bits
  1020. create_RROpcodeExtension_SN(int num)
  1021. {
  1022. const unsigned int n = (unsigned int)num;
  1023. return ((n & 0xf) << 4);
  1024. }
  1025. static __inline tile_bundle_bits
  1026. create_RRROpcodeExtension_X0(int num)
  1027. {
  1028. const unsigned int n = (unsigned int)num;
  1029. return ((n & 0x1ff) << 18);
  1030. }
  1031. static __inline tile_bundle_bits
  1032. create_RRROpcodeExtension_X1(int num)
  1033. {
  1034. const unsigned int n = (unsigned int)num;
  1035. return (((tile_bundle_bits)(n & 0x1ff)) << 49);
  1036. }
  1037. static __inline tile_bundle_bits
  1038. create_RRROpcodeExtension_Y0(int num)
  1039. {
  1040. const unsigned int n = (unsigned int)num;
  1041. return ((n & 0x3) << 18);
  1042. }
  1043. static __inline tile_bundle_bits
  1044. create_RRROpcodeExtension_Y1(int num)
  1045. {
  1046. const unsigned int n = (unsigned int)num;
  1047. return (((tile_bundle_bits)(n & 0x3)) << 49);
  1048. }
  1049. static __inline tile_bundle_bits
  1050. create_RouteOpcodeExtension_SN(int num)
  1051. {
  1052. const unsigned int n = (unsigned int)num;
  1053. return ((n & 0x3ff) << 0);
  1054. }
  1055. static __inline tile_bundle_bits
  1056. create_S_X0(int num)
  1057. {
  1058. const unsigned int n = (unsigned int)num;
  1059. return ((n & 0x1) << 27);
  1060. }
  1061. static __inline tile_bundle_bits
  1062. create_S_X1(int num)
  1063. {
  1064. const unsigned int n = (unsigned int)num;
  1065. return (((tile_bundle_bits)(n & 0x1)) << 58);
  1066. }
  1067. static __inline tile_bundle_bits
  1068. create_ShAmt_X0(int num)
  1069. {
  1070. const unsigned int n = (unsigned int)num;
  1071. return ((n & 0x1f) << 12);
  1072. }
  1073. static __inline tile_bundle_bits
  1074. create_ShAmt_X1(int num)
  1075. {
  1076. const unsigned int n = (unsigned int)num;
  1077. return (((tile_bundle_bits)(n & 0x1f)) << 43);
  1078. }
  1079. static __inline tile_bundle_bits
  1080. create_ShAmt_Y0(int num)
  1081. {
  1082. const unsigned int n = (unsigned int)num;
  1083. return ((n & 0x1f) << 12);
  1084. }
  1085. static __inline tile_bundle_bits
  1086. create_ShAmt_Y1(int num)
  1087. {
  1088. const unsigned int n = (unsigned int)num;
  1089. return (((tile_bundle_bits)(n & 0x1f)) << 43);
  1090. }
  1091. static __inline tile_bundle_bits
  1092. create_SrcA_X0(int num)
  1093. {
  1094. const unsigned int n = (unsigned int)num;
  1095. return ((n & 0x3f) << 6);
  1096. }
  1097. static __inline tile_bundle_bits
  1098. create_SrcA_X1(int num)
  1099. {
  1100. const unsigned int n = (unsigned int)num;
  1101. return (((tile_bundle_bits)(n & 0x3f)) << 37);
  1102. }
  1103. static __inline tile_bundle_bits
  1104. create_SrcA_Y0(int num)
  1105. {
  1106. const unsigned int n = (unsigned int)num;
  1107. return ((n & 0x3f) << 6);
  1108. }
  1109. static __inline tile_bundle_bits
  1110. create_SrcA_Y1(int num)
  1111. {
  1112. const unsigned int n = (unsigned int)num;
  1113. return (((tile_bundle_bits)(n & 0x3f)) << 37);
  1114. }
  1115. static __inline tile_bundle_bits
  1116. create_SrcA_Y2(int num)
  1117. {
  1118. const unsigned int n = (unsigned int)num;
  1119. return ((n & 0x00000001) << 26) |
  1120. (((tile_bundle_bits)(n & 0x0000003e)) << 50);
  1121. }
  1122. static __inline tile_bundle_bits
  1123. create_SrcBDest_Y2(int num)
  1124. {
  1125. const unsigned int n = (unsigned int)num;
  1126. return ((n & 0x3f) << 20);
  1127. }
  1128. static __inline tile_bundle_bits
  1129. create_SrcB_X0(int num)
  1130. {
  1131. const unsigned int n = (unsigned int)num;
  1132. return ((n & 0x3f) << 12);
  1133. }
  1134. static __inline tile_bundle_bits
  1135. create_SrcB_X1(int num)
  1136. {
  1137. const unsigned int n = (unsigned int)num;
  1138. return (((tile_bundle_bits)(n & 0x3f)) << 43);
  1139. }
  1140. static __inline tile_bundle_bits
  1141. create_SrcB_Y0(int num)
  1142. {
  1143. const unsigned int n = (unsigned int)num;
  1144. return ((n & 0x3f) << 12);
  1145. }
  1146. static __inline tile_bundle_bits
  1147. create_SrcB_Y1(int num)
  1148. {
  1149. const unsigned int n = (unsigned int)num;
  1150. return (((tile_bundle_bits)(n & 0x3f)) << 43);
  1151. }
  1152. static __inline tile_bundle_bits
  1153. create_Src_SN(int num)
  1154. {
  1155. const unsigned int n = (unsigned int)num;
  1156. return ((n & 0x3) << 0);
  1157. }
  1158. static __inline tile_bundle_bits
  1159. create_UnOpcodeExtension_X0(int num)
  1160. {
  1161. const unsigned int n = (unsigned int)num;
  1162. return ((n & 0x1f) << 12);
  1163. }
  1164. static __inline tile_bundle_bits
  1165. create_UnOpcodeExtension_X1(int num)
  1166. {
  1167. const unsigned int n = (unsigned int)num;
  1168. return (((tile_bundle_bits)(n & 0x1f)) << 43);
  1169. }
  1170. static __inline tile_bundle_bits
  1171. create_UnOpcodeExtension_Y0(int num)
  1172. {
  1173. const unsigned int n = (unsigned int)num;
  1174. return ((n & 0x1f) << 12);
  1175. }
  1176. static __inline tile_bundle_bits
  1177. create_UnOpcodeExtension_Y1(int num)
  1178. {
  1179. const unsigned int n = (unsigned int)num;
  1180. return (((tile_bundle_bits)(n & 0x1f)) << 43);
  1181. }
  1182. static __inline tile_bundle_bits
  1183. create_UnShOpcodeExtension_X0(int num)
  1184. {
  1185. const unsigned int n = (unsigned int)num;
  1186. return ((n & 0x3ff) << 17);
  1187. }
  1188. static __inline tile_bundle_bits
  1189. create_UnShOpcodeExtension_X1(int num)
  1190. {
  1191. const unsigned int n = (unsigned int)num;
  1192. return (((tile_bundle_bits)(n & 0x3ff)) << 48);
  1193. }
  1194. static __inline tile_bundle_bits
  1195. create_UnShOpcodeExtension_Y0(int num)
  1196. {
  1197. const unsigned int n = (unsigned int)num;
  1198. return ((n & 0x7) << 17);
  1199. }
  1200. static __inline tile_bundle_bits
  1201. create_UnShOpcodeExtension_Y1(int num)
  1202. {
  1203. const unsigned int n = (unsigned int)num;
  1204. return (((tile_bundle_bits)(n & 0x7)) << 48);
  1205. }
  1206. typedef enum
  1207. {
  1208. TILE_PIPELINE_X0,
  1209. TILE_PIPELINE_X1,
  1210. TILE_PIPELINE_Y0,
  1211. TILE_PIPELINE_Y1,
  1212. TILE_PIPELINE_Y2,
  1213. } tile_pipeline;
  1214. #define tile_is_x_pipeline(p) ((int)(p) <= (int)TILE_PIPELINE_X1)
  1215. typedef enum
  1216. {
  1217. TILE_OP_TYPE_REGISTER,
  1218. TILE_OP_TYPE_IMMEDIATE,
  1219. TILE_OP_TYPE_ADDRESS,
  1220. TILE_OP_TYPE_SPR
  1221. } tile_operand_type;
  1222. /* This is the bit that determines if a bundle is in the Y encoding. */
  1223. #define TILE_BUNDLE_Y_ENCODING_MASK ((tile_bundle_bits)1 << 63)
  1224. enum
  1225. {
  1226. /* Maximum number of instructions in a bundle (2 for X, 3 for Y). */
  1227. TILE_MAX_INSTRUCTIONS_PER_BUNDLE = 3,
  1228. /* How many different pipeline encodings are there? X0, X1, Y0, Y1, Y2. */
  1229. TILE_NUM_PIPELINE_ENCODINGS = 5,
  1230. /* Log base 2 of TILE_BUNDLE_SIZE_IN_BYTES. */
  1231. TILE_LOG2_BUNDLE_SIZE_IN_BYTES = 3,
  1232. /* Instructions take this many bytes. */
  1233. TILE_BUNDLE_SIZE_IN_BYTES = 1 << TILE_LOG2_BUNDLE_SIZE_IN_BYTES,
  1234. /* Log base 2 of TILE_BUNDLE_ALIGNMENT_IN_BYTES. */
  1235. TILE_LOG2_BUNDLE_ALIGNMENT_IN_BYTES = 3,
  1236. /* Bundles should be aligned modulo this number of bytes. */
  1237. TILE_BUNDLE_ALIGNMENT_IN_BYTES =
  1238. (1 << TILE_LOG2_BUNDLE_ALIGNMENT_IN_BYTES),
  1239. /* Log base 2 of TILE_SN_INSTRUCTION_SIZE_IN_BYTES. */
  1240. TILE_LOG2_SN_INSTRUCTION_SIZE_IN_BYTES = 1,
  1241. /* Static network instructions take this many bytes. */
  1242. TILE_SN_INSTRUCTION_SIZE_IN_BYTES =
  1243. (1 << TILE_LOG2_SN_INSTRUCTION_SIZE_IN_BYTES),
  1244. /* Number of registers (some are magic, such as network I/O). */
  1245. TILE_NUM_REGISTERS = 64,
  1246. /* Number of static network registers. */
  1247. TILE_NUM_SN_REGISTERS = 4
  1248. };
  1249. struct tile_operand
  1250. {
  1251. /* Is this operand a register, immediate or address? */
  1252. tile_operand_type type;
  1253. /* The default relocation type for this operand. */
  1254. signed int default_reloc : 16;
  1255. /* How many bits is this value? (used for range checking) */
  1256. unsigned int num_bits : 5;
  1257. /* Is the value signed? (used for range checking) */
  1258. unsigned int is_signed : 1;
  1259. /* Is this operand a source register? */
  1260. unsigned int is_src_reg : 1;
  1261. /* Is this operand written? (i.e. is it a destination register) */
  1262. unsigned int is_dest_reg : 1;
  1263. /* Is this operand PC-relative? */
  1264. unsigned int is_pc_relative : 1;
  1265. /* By how many bits do we right shift the value before inserting? */
  1266. unsigned int rightshift : 2;
  1267. /* Return the bits for this operand to be ORed into an existing bundle. */
  1268. tile_bundle_bits (*insert) (int op);
  1269. /* Extract this operand and return it. */
  1270. unsigned int (*extract) (tile_bundle_bits bundle);
  1271. };
  1272. extern const struct tile_operand tile_operands[];
  1273. /* One finite-state machine per pipe for rapid instruction decoding. */
  1274. extern const unsigned short * const
  1275. tile_bundle_decoder_fsms[TILE_NUM_PIPELINE_ENCODINGS];
  1276. struct tile_opcode
  1277. {
  1278. /* The opcode mnemonic, e.g. "add" */
  1279. const char *name;
  1280. /* The enum value for this mnemonic. */
  1281. tile_mnemonic mnemonic;
  1282. /* A bit mask of which of the five pipes this instruction
  1283. is compatible with:
  1284. X0 0x01
  1285. X1 0x02
  1286. Y0 0x04
  1287. Y1 0x08
  1288. Y2 0x10 */
  1289. unsigned char pipes;
  1290. /* How many operands are there? */
  1291. unsigned char num_operands;
  1292. /* Which register does this write implicitly, or TREG_ZERO if none? */
  1293. unsigned char implicitly_written_register;
  1294. /* Can this be bundled with other instructions (almost always true). */
  1295. unsigned char can_bundle;
  1296. /* The description of the operands. Each of these is an
  1297. * index into the tile_operands[] table. */
  1298. unsigned char operands[TILE_NUM_PIPELINE_ENCODINGS][TILE_MAX_OPERANDS];
  1299. };
  1300. extern const struct tile_opcode tile_opcodes[];
  1301. /* Used for non-textual disassembly into structs. */
  1302. struct tile_decoded_instruction
  1303. {
  1304. const struct tile_opcode *opcode;
  1305. const struct tile_operand *operands[TILE_MAX_OPERANDS];
  1306. int operand_values[TILE_MAX_OPERANDS];
  1307. };
  1308. /* Disassemble a bundle into a struct for machine processing. */
  1309. extern int parse_insn_tile(tile_bundle_bits bits,
  1310. unsigned int pc,
  1311. struct tile_decoded_instruction
  1312. decoded[TILE_MAX_INSTRUCTIONS_PER_BUNDLE]);
  1313. /* Given a set of bundle bits and a specific pipe, returns which
  1314. * instruction the bundle contains in that pipe.
  1315. */
  1316. extern const struct tile_opcode *
  1317. find_opcode(tile_bundle_bits bits, tile_pipeline pipe);
  1318. #endif /* opcode_tile_h */