opcode-tile_64.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248
  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 tilegx_bundle_bits;
  7. enum
  8. {
  9. TILEGX_MAX_OPERANDS = 4 /* bfexts */
  10. };
  11. typedef enum
  12. {
  13. TILEGX_OPC_BPT,
  14. TILEGX_OPC_INFO,
  15. TILEGX_OPC_INFOL,
  16. TILEGX_OPC_MOVE,
  17. TILEGX_OPC_MOVEI,
  18. TILEGX_OPC_MOVELI,
  19. TILEGX_OPC_PREFETCH,
  20. TILEGX_OPC_PREFETCH_ADD_L1,
  21. TILEGX_OPC_PREFETCH_ADD_L1_FAULT,
  22. TILEGX_OPC_PREFETCH_ADD_L2,
  23. TILEGX_OPC_PREFETCH_ADD_L2_FAULT,
  24. TILEGX_OPC_PREFETCH_ADD_L3,
  25. TILEGX_OPC_PREFETCH_ADD_L3_FAULT,
  26. TILEGX_OPC_PREFETCH_L1,
  27. TILEGX_OPC_PREFETCH_L1_FAULT,
  28. TILEGX_OPC_PREFETCH_L2,
  29. TILEGX_OPC_PREFETCH_L2_FAULT,
  30. TILEGX_OPC_PREFETCH_L3,
  31. TILEGX_OPC_PREFETCH_L3_FAULT,
  32. TILEGX_OPC_RAISE,
  33. TILEGX_OPC_ADD,
  34. TILEGX_OPC_ADDI,
  35. TILEGX_OPC_ADDLI,
  36. TILEGX_OPC_ADDX,
  37. TILEGX_OPC_ADDXI,
  38. TILEGX_OPC_ADDXLI,
  39. TILEGX_OPC_ADDXSC,
  40. TILEGX_OPC_AND,
  41. TILEGX_OPC_ANDI,
  42. TILEGX_OPC_BEQZ,
  43. TILEGX_OPC_BEQZT,
  44. TILEGX_OPC_BFEXTS,
  45. TILEGX_OPC_BFEXTU,
  46. TILEGX_OPC_BFINS,
  47. TILEGX_OPC_BGEZ,
  48. TILEGX_OPC_BGEZT,
  49. TILEGX_OPC_BGTZ,
  50. TILEGX_OPC_BGTZT,
  51. TILEGX_OPC_BLBC,
  52. TILEGX_OPC_BLBCT,
  53. TILEGX_OPC_BLBS,
  54. TILEGX_OPC_BLBST,
  55. TILEGX_OPC_BLEZ,
  56. TILEGX_OPC_BLEZT,
  57. TILEGX_OPC_BLTZ,
  58. TILEGX_OPC_BLTZT,
  59. TILEGX_OPC_BNEZ,
  60. TILEGX_OPC_BNEZT,
  61. TILEGX_OPC_CLZ,
  62. TILEGX_OPC_CMOVEQZ,
  63. TILEGX_OPC_CMOVNEZ,
  64. TILEGX_OPC_CMPEQ,
  65. TILEGX_OPC_CMPEQI,
  66. TILEGX_OPC_CMPEXCH,
  67. TILEGX_OPC_CMPEXCH4,
  68. TILEGX_OPC_CMPLES,
  69. TILEGX_OPC_CMPLEU,
  70. TILEGX_OPC_CMPLTS,
  71. TILEGX_OPC_CMPLTSI,
  72. TILEGX_OPC_CMPLTU,
  73. TILEGX_OPC_CMPLTUI,
  74. TILEGX_OPC_CMPNE,
  75. TILEGX_OPC_CMUL,
  76. TILEGX_OPC_CMULA,
  77. TILEGX_OPC_CMULAF,
  78. TILEGX_OPC_CMULF,
  79. TILEGX_OPC_CMULFR,
  80. TILEGX_OPC_CMULH,
  81. TILEGX_OPC_CMULHR,
  82. TILEGX_OPC_CRC32_32,
  83. TILEGX_OPC_CRC32_8,
  84. TILEGX_OPC_CTZ,
  85. TILEGX_OPC_DBLALIGN,
  86. TILEGX_OPC_DBLALIGN2,
  87. TILEGX_OPC_DBLALIGN4,
  88. TILEGX_OPC_DBLALIGN6,
  89. TILEGX_OPC_DRAIN,
  90. TILEGX_OPC_DTLBPR,
  91. TILEGX_OPC_EXCH,
  92. TILEGX_OPC_EXCH4,
  93. TILEGX_OPC_FDOUBLE_ADD_FLAGS,
  94. TILEGX_OPC_FDOUBLE_ADDSUB,
  95. TILEGX_OPC_FDOUBLE_MUL_FLAGS,
  96. TILEGX_OPC_FDOUBLE_PACK1,
  97. TILEGX_OPC_FDOUBLE_PACK2,
  98. TILEGX_OPC_FDOUBLE_SUB_FLAGS,
  99. TILEGX_OPC_FDOUBLE_UNPACK_MAX,
  100. TILEGX_OPC_FDOUBLE_UNPACK_MIN,
  101. TILEGX_OPC_FETCHADD,
  102. TILEGX_OPC_FETCHADD4,
  103. TILEGX_OPC_FETCHADDGEZ,
  104. TILEGX_OPC_FETCHADDGEZ4,
  105. TILEGX_OPC_FETCHAND,
  106. TILEGX_OPC_FETCHAND4,
  107. TILEGX_OPC_FETCHOR,
  108. TILEGX_OPC_FETCHOR4,
  109. TILEGX_OPC_FINV,
  110. TILEGX_OPC_FLUSH,
  111. TILEGX_OPC_FLUSHWB,
  112. TILEGX_OPC_FNOP,
  113. TILEGX_OPC_FSINGLE_ADD1,
  114. TILEGX_OPC_FSINGLE_ADDSUB2,
  115. TILEGX_OPC_FSINGLE_MUL1,
  116. TILEGX_OPC_FSINGLE_MUL2,
  117. TILEGX_OPC_FSINGLE_PACK1,
  118. TILEGX_OPC_FSINGLE_PACK2,
  119. TILEGX_OPC_FSINGLE_SUB1,
  120. TILEGX_OPC_ICOH,
  121. TILEGX_OPC_ILL,
  122. TILEGX_OPC_INV,
  123. TILEGX_OPC_IRET,
  124. TILEGX_OPC_J,
  125. TILEGX_OPC_JAL,
  126. TILEGX_OPC_JALR,
  127. TILEGX_OPC_JALRP,
  128. TILEGX_OPC_JR,
  129. TILEGX_OPC_JRP,
  130. TILEGX_OPC_LD,
  131. TILEGX_OPC_LD1S,
  132. TILEGX_OPC_LD1S_ADD,
  133. TILEGX_OPC_LD1U,
  134. TILEGX_OPC_LD1U_ADD,
  135. TILEGX_OPC_LD2S,
  136. TILEGX_OPC_LD2S_ADD,
  137. TILEGX_OPC_LD2U,
  138. TILEGX_OPC_LD2U_ADD,
  139. TILEGX_OPC_LD4S,
  140. TILEGX_OPC_LD4S_ADD,
  141. TILEGX_OPC_LD4U,
  142. TILEGX_OPC_LD4U_ADD,
  143. TILEGX_OPC_LD_ADD,
  144. TILEGX_OPC_LDNA,
  145. TILEGX_OPC_LDNA_ADD,
  146. TILEGX_OPC_LDNT,
  147. TILEGX_OPC_LDNT1S,
  148. TILEGX_OPC_LDNT1S_ADD,
  149. TILEGX_OPC_LDNT1U,
  150. TILEGX_OPC_LDNT1U_ADD,
  151. TILEGX_OPC_LDNT2S,
  152. TILEGX_OPC_LDNT2S_ADD,
  153. TILEGX_OPC_LDNT2U,
  154. TILEGX_OPC_LDNT2U_ADD,
  155. TILEGX_OPC_LDNT4S,
  156. TILEGX_OPC_LDNT4S_ADD,
  157. TILEGX_OPC_LDNT4U,
  158. TILEGX_OPC_LDNT4U_ADD,
  159. TILEGX_OPC_LDNT_ADD,
  160. TILEGX_OPC_LNK,
  161. TILEGX_OPC_MF,
  162. TILEGX_OPC_MFSPR,
  163. TILEGX_OPC_MM,
  164. TILEGX_OPC_MNZ,
  165. TILEGX_OPC_MTSPR,
  166. TILEGX_OPC_MUL_HS_HS,
  167. TILEGX_OPC_MUL_HS_HU,
  168. TILEGX_OPC_MUL_HS_LS,
  169. TILEGX_OPC_MUL_HS_LU,
  170. TILEGX_OPC_MUL_HU_HU,
  171. TILEGX_OPC_MUL_HU_LS,
  172. TILEGX_OPC_MUL_HU_LU,
  173. TILEGX_OPC_MUL_LS_LS,
  174. TILEGX_OPC_MUL_LS_LU,
  175. TILEGX_OPC_MUL_LU_LU,
  176. TILEGX_OPC_MULA_HS_HS,
  177. TILEGX_OPC_MULA_HS_HU,
  178. TILEGX_OPC_MULA_HS_LS,
  179. TILEGX_OPC_MULA_HS_LU,
  180. TILEGX_OPC_MULA_HU_HU,
  181. TILEGX_OPC_MULA_HU_LS,
  182. TILEGX_OPC_MULA_HU_LU,
  183. TILEGX_OPC_MULA_LS_LS,
  184. TILEGX_OPC_MULA_LS_LU,
  185. TILEGX_OPC_MULA_LU_LU,
  186. TILEGX_OPC_MULAX,
  187. TILEGX_OPC_MULX,
  188. TILEGX_OPC_MZ,
  189. TILEGX_OPC_NAP,
  190. TILEGX_OPC_NOP,
  191. TILEGX_OPC_NOR,
  192. TILEGX_OPC_OR,
  193. TILEGX_OPC_ORI,
  194. TILEGX_OPC_PCNT,
  195. TILEGX_OPC_REVBITS,
  196. TILEGX_OPC_REVBYTES,
  197. TILEGX_OPC_ROTL,
  198. TILEGX_OPC_ROTLI,
  199. TILEGX_OPC_SHL,
  200. TILEGX_OPC_SHL16INSLI,
  201. TILEGX_OPC_SHL1ADD,
  202. TILEGX_OPC_SHL1ADDX,
  203. TILEGX_OPC_SHL2ADD,
  204. TILEGX_OPC_SHL2ADDX,
  205. TILEGX_OPC_SHL3ADD,
  206. TILEGX_OPC_SHL3ADDX,
  207. TILEGX_OPC_SHLI,
  208. TILEGX_OPC_SHLX,
  209. TILEGX_OPC_SHLXI,
  210. TILEGX_OPC_SHRS,
  211. TILEGX_OPC_SHRSI,
  212. TILEGX_OPC_SHRU,
  213. TILEGX_OPC_SHRUI,
  214. TILEGX_OPC_SHRUX,
  215. TILEGX_OPC_SHRUXI,
  216. TILEGX_OPC_SHUFFLEBYTES,
  217. TILEGX_OPC_ST,
  218. TILEGX_OPC_ST1,
  219. TILEGX_OPC_ST1_ADD,
  220. TILEGX_OPC_ST2,
  221. TILEGX_OPC_ST2_ADD,
  222. TILEGX_OPC_ST4,
  223. TILEGX_OPC_ST4_ADD,
  224. TILEGX_OPC_ST_ADD,
  225. TILEGX_OPC_STNT,
  226. TILEGX_OPC_STNT1,
  227. TILEGX_OPC_STNT1_ADD,
  228. TILEGX_OPC_STNT2,
  229. TILEGX_OPC_STNT2_ADD,
  230. TILEGX_OPC_STNT4,
  231. TILEGX_OPC_STNT4_ADD,
  232. TILEGX_OPC_STNT_ADD,
  233. TILEGX_OPC_SUB,
  234. TILEGX_OPC_SUBX,
  235. TILEGX_OPC_SUBXSC,
  236. TILEGX_OPC_SWINT0,
  237. TILEGX_OPC_SWINT1,
  238. TILEGX_OPC_SWINT2,
  239. TILEGX_OPC_SWINT3,
  240. TILEGX_OPC_TBLIDXB0,
  241. TILEGX_OPC_TBLIDXB1,
  242. TILEGX_OPC_TBLIDXB2,
  243. TILEGX_OPC_TBLIDXB3,
  244. TILEGX_OPC_V1ADD,
  245. TILEGX_OPC_V1ADDI,
  246. TILEGX_OPC_V1ADDUC,
  247. TILEGX_OPC_V1ADIFFU,
  248. TILEGX_OPC_V1AVGU,
  249. TILEGX_OPC_V1CMPEQ,
  250. TILEGX_OPC_V1CMPEQI,
  251. TILEGX_OPC_V1CMPLES,
  252. TILEGX_OPC_V1CMPLEU,
  253. TILEGX_OPC_V1CMPLTS,
  254. TILEGX_OPC_V1CMPLTSI,
  255. TILEGX_OPC_V1CMPLTU,
  256. TILEGX_OPC_V1CMPLTUI,
  257. TILEGX_OPC_V1CMPNE,
  258. TILEGX_OPC_V1DDOTPU,
  259. TILEGX_OPC_V1DDOTPUA,
  260. TILEGX_OPC_V1DDOTPUS,
  261. TILEGX_OPC_V1DDOTPUSA,
  262. TILEGX_OPC_V1DOTP,
  263. TILEGX_OPC_V1DOTPA,
  264. TILEGX_OPC_V1DOTPU,
  265. TILEGX_OPC_V1DOTPUA,
  266. TILEGX_OPC_V1DOTPUS,
  267. TILEGX_OPC_V1DOTPUSA,
  268. TILEGX_OPC_V1INT_H,
  269. TILEGX_OPC_V1INT_L,
  270. TILEGX_OPC_V1MAXU,
  271. TILEGX_OPC_V1MAXUI,
  272. TILEGX_OPC_V1MINU,
  273. TILEGX_OPC_V1MINUI,
  274. TILEGX_OPC_V1MNZ,
  275. TILEGX_OPC_V1MULTU,
  276. TILEGX_OPC_V1MULU,
  277. TILEGX_OPC_V1MULUS,
  278. TILEGX_OPC_V1MZ,
  279. TILEGX_OPC_V1SADAU,
  280. TILEGX_OPC_V1SADU,
  281. TILEGX_OPC_V1SHL,
  282. TILEGX_OPC_V1SHLI,
  283. TILEGX_OPC_V1SHRS,
  284. TILEGX_OPC_V1SHRSI,
  285. TILEGX_OPC_V1SHRU,
  286. TILEGX_OPC_V1SHRUI,
  287. TILEGX_OPC_V1SUB,
  288. TILEGX_OPC_V1SUBUC,
  289. TILEGX_OPC_V2ADD,
  290. TILEGX_OPC_V2ADDI,
  291. TILEGX_OPC_V2ADDSC,
  292. TILEGX_OPC_V2ADIFFS,
  293. TILEGX_OPC_V2AVGS,
  294. TILEGX_OPC_V2CMPEQ,
  295. TILEGX_OPC_V2CMPEQI,
  296. TILEGX_OPC_V2CMPLES,
  297. TILEGX_OPC_V2CMPLEU,
  298. TILEGX_OPC_V2CMPLTS,
  299. TILEGX_OPC_V2CMPLTSI,
  300. TILEGX_OPC_V2CMPLTU,
  301. TILEGX_OPC_V2CMPLTUI,
  302. TILEGX_OPC_V2CMPNE,
  303. TILEGX_OPC_V2DOTP,
  304. TILEGX_OPC_V2DOTPA,
  305. TILEGX_OPC_V2INT_H,
  306. TILEGX_OPC_V2INT_L,
  307. TILEGX_OPC_V2MAXS,
  308. TILEGX_OPC_V2MAXSI,
  309. TILEGX_OPC_V2MINS,
  310. TILEGX_OPC_V2MINSI,
  311. TILEGX_OPC_V2MNZ,
  312. TILEGX_OPC_V2MULFSC,
  313. TILEGX_OPC_V2MULS,
  314. TILEGX_OPC_V2MULTS,
  315. TILEGX_OPC_V2MZ,
  316. TILEGX_OPC_V2PACKH,
  317. TILEGX_OPC_V2PACKL,
  318. TILEGX_OPC_V2PACKUC,
  319. TILEGX_OPC_V2SADAS,
  320. TILEGX_OPC_V2SADAU,
  321. TILEGX_OPC_V2SADS,
  322. TILEGX_OPC_V2SADU,
  323. TILEGX_OPC_V2SHL,
  324. TILEGX_OPC_V2SHLI,
  325. TILEGX_OPC_V2SHLSC,
  326. TILEGX_OPC_V2SHRS,
  327. TILEGX_OPC_V2SHRSI,
  328. TILEGX_OPC_V2SHRU,
  329. TILEGX_OPC_V2SHRUI,
  330. TILEGX_OPC_V2SUB,
  331. TILEGX_OPC_V2SUBSC,
  332. TILEGX_OPC_V4ADD,
  333. TILEGX_OPC_V4ADDSC,
  334. TILEGX_OPC_V4INT_H,
  335. TILEGX_OPC_V4INT_L,
  336. TILEGX_OPC_V4PACKSC,
  337. TILEGX_OPC_V4SHL,
  338. TILEGX_OPC_V4SHLSC,
  339. TILEGX_OPC_V4SHRS,
  340. TILEGX_OPC_V4SHRU,
  341. TILEGX_OPC_V4SUB,
  342. TILEGX_OPC_V4SUBSC,
  343. TILEGX_OPC_WH64,
  344. TILEGX_OPC_XOR,
  345. TILEGX_OPC_XORI,
  346. TILEGX_OPC_NONE
  347. } tilegx_mnemonic;
  348. /* 64-bit pattern for a { bpt ; nop } bundle. */
  349. #define TILEGX_BPT_BUNDLE 0x286a44ae51485000ULL
  350. #define TILE_ELF_MACHINE_CODE EM_TILE64
  351. #define TILE_ELF_NAME "elf32-tile64"
  352. static __inline unsigned int
  353. get_BFEnd_X0(tilegx_bundle_bits num)
  354. {
  355. const unsigned int n = (unsigned int)num;
  356. return (((n >> 12)) & 0x3f);
  357. }
  358. static __inline unsigned int
  359. get_BFOpcodeExtension_X0(tilegx_bundle_bits num)
  360. {
  361. const unsigned int n = (unsigned int)num;
  362. return (((n >> 24)) & 0xf);
  363. }
  364. static __inline unsigned int
  365. get_BFStart_X0(tilegx_bundle_bits num)
  366. {
  367. const unsigned int n = (unsigned int)num;
  368. return (((n >> 18)) & 0x3f);
  369. }
  370. static __inline unsigned int
  371. get_BrOff_X1(tilegx_bundle_bits n)
  372. {
  373. return (((unsigned int)(n >> 31)) & 0x0000003f) |
  374. (((unsigned int)(n >> 37)) & 0x0001ffc0);
  375. }
  376. static __inline unsigned int
  377. get_BrType_X1(tilegx_bundle_bits n)
  378. {
  379. return (((unsigned int)(n >> 54)) & 0x1f);
  380. }
  381. static __inline unsigned int
  382. get_Dest_Imm8_X1(tilegx_bundle_bits n)
  383. {
  384. return (((unsigned int)(n >> 31)) & 0x0000003f) |
  385. (((unsigned int)(n >> 43)) & 0x000000c0);
  386. }
  387. static __inline unsigned int
  388. get_Dest_X0(tilegx_bundle_bits num)
  389. {
  390. const unsigned int n = (unsigned int)num;
  391. return (((n >> 0)) & 0x3f);
  392. }
  393. static __inline unsigned int
  394. get_Dest_X1(tilegx_bundle_bits n)
  395. {
  396. return (((unsigned int)(n >> 31)) & 0x3f);
  397. }
  398. static __inline unsigned int
  399. get_Dest_Y0(tilegx_bundle_bits num)
  400. {
  401. const unsigned int n = (unsigned int)num;
  402. return (((n >> 0)) & 0x3f);
  403. }
  404. static __inline unsigned int
  405. get_Dest_Y1(tilegx_bundle_bits n)
  406. {
  407. return (((unsigned int)(n >> 31)) & 0x3f);
  408. }
  409. static __inline unsigned int
  410. get_Imm16_X0(tilegx_bundle_bits num)
  411. {
  412. const unsigned int n = (unsigned int)num;
  413. return (((n >> 12)) & 0xffff);
  414. }
  415. static __inline unsigned int
  416. get_Imm16_X1(tilegx_bundle_bits n)
  417. {
  418. return (((unsigned int)(n >> 43)) & 0xffff);
  419. }
  420. static __inline unsigned int
  421. get_Imm8OpcodeExtension_X0(tilegx_bundle_bits num)
  422. {
  423. const unsigned int n = (unsigned int)num;
  424. return (((n >> 20)) & 0xff);
  425. }
  426. static __inline unsigned int
  427. get_Imm8OpcodeExtension_X1(tilegx_bundle_bits n)
  428. {
  429. return (((unsigned int)(n >> 51)) & 0xff);
  430. }
  431. static __inline unsigned int
  432. get_Imm8_X0(tilegx_bundle_bits num)
  433. {
  434. const unsigned int n = (unsigned int)num;
  435. return (((n >> 12)) & 0xff);
  436. }
  437. static __inline unsigned int
  438. get_Imm8_X1(tilegx_bundle_bits n)
  439. {
  440. return (((unsigned int)(n >> 43)) & 0xff);
  441. }
  442. static __inline unsigned int
  443. get_Imm8_Y0(tilegx_bundle_bits num)
  444. {
  445. const unsigned int n = (unsigned int)num;
  446. return (((n >> 12)) & 0xff);
  447. }
  448. static __inline unsigned int
  449. get_Imm8_Y1(tilegx_bundle_bits n)
  450. {
  451. return (((unsigned int)(n >> 43)) & 0xff);
  452. }
  453. static __inline unsigned int
  454. get_JumpOff_X1(tilegx_bundle_bits n)
  455. {
  456. return (((unsigned int)(n >> 31)) & 0x7ffffff);
  457. }
  458. static __inline unsigned int
  459. get_JumpOpcodeExtension_X1(tilegx_bundle_bits n)
  460. {
  461. return (((unsigned int)(n >> 58)) & 0x1);
  462. }
  463. static __inline unsigned int
  464. get_MF_Imm14_X1(tilegx_bundle_bits n)
  465. {
  466. return (((unsigned int)(n >> 37)) & 0x3fff);
  467. }
  468. static __inline unsigned int
  469. get_MT_Imm14_X1(tilegx_bundle_bits n)
  470. {
  471. return (((unsigned int)(n >> 31)) & 0x0000003f) |
  472. (((unsigned int)(n >> 37)) & 0x00003fc0);
  473. }
  474. static __inline unsigned int
  475. get_Mode(tilegx_bundle_bits n)
  476. {
  477. return (((unsigned int)(n >> 62)) & 0x3);
  478. }
  479. static __inline unsigned int
  480. get_Opcode_X0(tilegx_bundle_bits num)
  481. {
  482. const unsigned int n = (unsigned int)num;
  483. return (((n >> 28)) & 0x7);
  484. }
  485. static __inline unsigned int
  486. get_Opcode_X1(tilegx_bundle_bits n)
  487. {
  488. return (((unsigned int)(n >> 59)) & 0x7);
  489. }
  490. static __inline unsigned int
  491. get_Opcode_Y0(tilegx_bundle_bits num)
  492. {
  493. const unsigned int n = (unsigned int)num;
  494. return (((n >> 27)) & 0xf);
  495. }
  496. static __inline unsigned int
  497. get_Opcode_Y1(tilegx_bundle_bits n)
  498. {
  499. return (((unsigned int)(n >> 58)) & 0xf);
  500. }
  501. static __inline unsigned int
  502. get_Opcode_Y2(tilegx_bundle_bits n)
  503. {
  504. return (((n >> 26)) & 0x00000001) |
  505. (((unsigned int)(n >> 56)) & 0x00000002);
  506. }
  507. static __inline unsigned int
  508. get_RRROpcodeExtension_X0(tilegx_bundle_bits num)
  509. {
  510. const unsigned int n = (unsigned int)num;
  511. return (((n >> 18)) & 0x3ff);
  512. }
  513. static __inline unsigned int
  514. get_RRROpcodeExtension_X1(tilegx_bundle_bits n)
  515. {
  516. return (((unsigned int)(n >> 49)) & 0x3ff);
  517. }
  518. static __inline unsigned int
  519. get_RRROpcodeExtension_Y0(tilegx_bundle_bits num)
  520. {
  521. const unsigned int n = (unsigned int)num;
  522. return (((n >> 18)) & 0x3);
  523. }
  524. static __inline unsigned int
  525. get_RRROpcodeExtension_Y1(tilegx_bundle_bits n)
  526. {
  527. return (((unsigned int)(n >> 49)) & 0x3);
  528. }
  529. static __inline unsigned int
  530. get_ShAmt_X0(tilegx_bundle_bits num)
  531. {
  532. const unsigned int n = (unsigned int)num;
  533. return (((n >> 12)) & 0x3f);
  534. }
  535. static __inline unsigned int
  536. get_ShAmt_X1(tilegx_bundle_bits n)
  537. {
  538. return (((unsigned int)(n >> 43)) & 0x3f);
  539. }
  540. static __inline unsigned int
  541. get_ShAmt_Y0(tilegx_bundle_bits num)
  542. {
  543. const unsigned int n = (unsigned int)num;
  544. return (((n >> 12)) & 0x3f);
  545. }
  546. static __inline unsigned int
  547. get_ShAmt_Y1(tilegx_bundle_bits n)
  548. {
  549. return (((unsigned int)(n >> 43)) & 0x3f);
  550. }
  551. static __inline unsigned int
  552. get_ShiftOpcodeExtension_X0(tilegx_bundle_bits num)
  553. {
  554. const unsigned int n = (unsigned int)num;
  555. return (((n >> 18)) & 0x3ff);
  556. }
  557. static __inline unsigned int
  558. get_ShiftOpcodeExtension_X1(tilegx_bundle_bits n)
  559. {
  560. return (((unsigned int)(n >> 49)) & 0x3ff);
  561. }
  562. static __inline unsigned int
  563. get_ShiftOpcodeExtension_Y0(tilegx_bundle_bits num)
  564. {
  565. const unsigned int n = (unsigned int)num;
  566. return (((n >> 18)) & 0x3);
  567. }
  568. static __inline unsigned int
  569. get_ShiftOpcodeExtension_Y1(tilegx_bundle_bits n)
  570. {
  571. return (((unsigned int)(n >> 49)) & 0x3);
  572. }
  573. static __inline unsigned int
  574. get_SrcA_X0(tilegx_bundle_bits num)
  575. {
  576. const unsigned int n = (unsigned int)num;
  577. return (((n >> 6)) & 0x3f);
  578. }
  579. static __inline unsigned int
  580. get_SrcA_X1(tilegx_bundle_bits n)
  581. {
  582. return (((unsigned int)(n >> 37)) & 0x3f);
  583. }
  584. static __inline unsigned int
  585. get_SrcA_Y0(tilegx_bundle_bits num)
  586. {
  587. const unsigned int n = (unsigned int)num;
  588. return (((n >> 6)) & 0x3f);
  589. }
  590. static __inline unsigned int
  591. get_SrcA_Y1(tilegx_bundle_bits n)
  592. {
  593. return (((unsigned int)(n >> 37)) & 0x3f);
  594. }
  595. static __inline unsigned int
  596. get_SrcA_Y2(tilegx_bundle_bits num)
  597. {
  598. const unsigned int n = (unsigned int)num;
  599. return (((n >> 20)) & 0x3f);
  600. }
  601. static __inline unsigned int
  602. get_SrcBDest_Y2(tilegx_bundle_bits n)
  603. {
  604. return (((unsigned int)(n >> 51)) & 0x3f);
  605. }
  606. static __inline unsigned int
  607. get_SrcB_X0(tilegx_bundle_bits num)
  608. {
  609. const unsigned int n = (unsigned int)num;
  610. return (((n >> 12)) & 0x3f);
  611. }
  612. static __inline unsigned int
  613. get_SrcB_X1(tilegx_bundle_bits n)
  614. {
  615. return (((unsigned int)(n >> 43)) & 0x3f);
  616. }
  617. static __inline unsigned int
  618. get_SrcB_Y0(tilegx_bundle_bits num)
  619. {
  620. const unsigned int n = (unsigned int)num;
  621. return (((n >> 12)) & 0x3f);
  622. }
  623. static __inline unsigned int
  624. get_SrcB_Y1(tilegx_bundle_bits n)
  625. {
  626. return (((unsigned int)(n >> 43)) & 0x3f);
  627. }
  628. static __inline unsigned int
  629. get_UnaryOpcodeExtension_X0(tilegx_bundle_bits num)
  630. {
  631. const unsigned int n = (unsigned int)num;
  632. return (((n >> 12)) & 0x3f);
  633. }
  634. static __inline unsigned int
  635. get_UnaryOpcodeExtension_X1(tilegx_bundle_bits n)
  636. {
  637. return (((unsigned int)(n >> 43)) & 0x3f);
  638. }
  639. static __inline unsigned int
  640. get_UnaryOpcodeExtension_Y0(tilegx_bundle_bits num)
  641. {
  642. const unsigned int n = (unsigned int)num;
  643. return (((n >> 12)) & 0x3f);
  644. }
  645. static __inline unsigned int
  646. get_UnaryOpcodeExtension_Y1(tilegx_bundle_bits n)
  647. {
  648. return (((unsigned int)(n >> 43)) & 0x3f);
  649. }
  650. static __inline int
  651. sign_extend(int n, int num_bits)
  652. {
  653. int shift = (int)(sizeof(int) * 8 - num_bits);
  654. return (n << shift) >> shift;
  655. }
  656. static __inline tilegx_bundle_bits
  657. create_BFEnd_X0(int num)
  658. {
  659. const unsigned int n = (unsigned int)num;
  660. return ((n & 0x3f) << 12);
  661. }
  662. static __inline tilegx_bundle_bits
  663. create_BFOpcodeExtension_X0(int num)
  664. {
  665. const unsigned int n = (unsigned int)num;
  666. return ((n & 0xf) << 24);
  667. }
  668. static __inline tilegx_bundle_bits
  669. create_BFStart_X0(int num)
  670. {
  671. const unsigned int n = (unsigned int)num;
  672. return ((n & 0x3f) << 18);
  673. }
  674. static __inline tilegx_bundle_bits
  675. create_BrOff_X1(int num)
  676. {
  677. const unsigned int n = (unsigned int)num;
  678. return (((tilegx_bundle_bits)(n & 0x0000003f)) << 31) |
  679. (((tilegx_bundle_bits)(n & 0x0001ffc0)) << 37);
  680. }
  681. static __inline tilegx_bundle_bits
  682. create_BrType_X1(int num)
  683. {
  684. const unsigned int n = (unsigned int)num;
  685. return (((tilegx_bundle_bits)(n & 0x1f)) << 54);
  686. }
  687. static __inline tilegx_bundle_bits
  688. create_Dest_Imm8_X1(int num)
  689. {
  690. const unsigned int n = (unsigned int)num;
  691. return (((tilegx_bundle_bits)(n & 0x0000003f)) << 31) |
  692. (((tilegx_bundle_bits)(n & 0x000000c0)) << 43);
  693. }
  694. static __inline tilegx_bundle_bits
  695. create_Dest_X0(int num)
  696. {
  697. const unsigned int n = (unsigned int)num;
  698. return ((n & 0x3f) << 0);
  699. }
  700. static __inline tilegx_bundle_bits
  701. create_Dest_X1(int num)
  702. {
  703. const unsigned int n = (unsigned int)num;
  704. return (((tilegx_bundle_bits)(n & 0x3f)) << 31);
  705. }
  706. static __inline tilegx_bundle_bits
  707. create_Dest_Y0(int num)
  708. {
  709. const unsigned int n = (unsigned int)num;
  710. return ((n & 0x3f) << 0);
  711. }
  712. static __inline tilegx_bundle_bits
  713. create_Dest_Y1(int num)
  714. {
  715. const unsigned int n = (unsigned int)num;
  716. return (((tilegx_bundle_bits)(n & 0x3f)) << 31);
  717. }
  718. static __inline tilegx_bundle_bits
  719. create_Imm16_X0(int num)
  720. {
  721. const unsigned int n = (unsigned int)num;
  722. return ((n & 0xffff) << 12);
  723. }
  724. static __inline tilegx_bundle_bits
  725. create_Imm16_X1(int num)
  726. {
  727. const unsigned int n = (unsigned int)num;
  728. return (((tilegx_bundle_bits)(n & 0xffff)) << 43);
  729. }
  730. static __inline tilegx_bundle_bits
  731. create_Imm8OpcodeExtension_X0(int num)
  732. {
  733. const unsigned int n = (unsigned int)num;
  734. return ((n & 0xff) << 20);
  735. }
  736. static __inline tilegx_bundle_bits
  737. create_Imm8OpcodeExtension_X1(int num)
  738. {
  739. const unsigned int n = (unsigned int)num;
  740. return (((tilegx_bundle_bits)(n & 0xff)) << 51);
  741. }
  742. static __inline tilegx_bundle_bits
  743. create_Imm8_X0(int num)
  744. {
  745. const unsigned int n = (unsigned int)num;
  746. return ((n & 0xff) << 12);
  747. }
  748. static __inline tilegx_bundle_bits
  749. create_Imm8_X1(int num)
  750. {
  751. const unsigned int n = (unsigned int)num;
  752. return (((tilegx_bundle_bits)(n & 0xff)) << 43);
  753. }
  754. static __inline tilegx_bundle_bits
  755. create_Imm8_Y0(int num)
  756. {
  757. const unsigned int n = (unsigned int)num;
  758. return ((n & 0xff) << 12);
  759. }
  760. static __inline tilegx_bundle_bits
  761. create_Imm8_Y1(int num)
  762. {
  763. const unsigned int n = (unsigned int)num;
  764. return (((tilegx_bundle_bits)(n & 0xff)) << 43);
  765. }
  766. static __inline tilegx_bundle_bits
  767. create_JumpOff_X1(int num)
  768. {
  769. const unsigned int n = (unsigned int)num;
  770. return (((tilegx_bundle_bits)(n & 0x7ffffff)) << 31);
  771. }
  772. static __inline tilegx_bundle_bits
  773. create_JumpOpcodeExtension_X1(int num)
  774. {
  775. const unsigned int n = (unsigned int)num;
  776. return (((tilegx_bundle_bits)(n & 0x1)) << 58);
  777. }
  778. static __inline tilegx_bundle_bits
  779. create_MF_Imm14_X1(int num)
  780. {
  781. const unsigned int n = (unsigned int)num;
  782. return (((tilegx_bundle_bits)(n & 0x3fff)) << 37);
  783. }
  784. static __inline tilegx_bundle_bits
  785. create_MT_Imm14_X1(int num)
  786. {
  787. const unsigned int n = (unsigned int)num;
  788. return (((tilegx_bundle_bits)(n & 0x0000003f)) << 31) |
  789. (((tilegx_bundle_bits)(n & 0x00003fc0)) << 37);
  790. }
  791. static __inline tilegx_bundle_bits
  792. create_Mode(int num)
  793. {
  794. const unsigned int n = (unsigned int)num;
  795. return (((tilegx_bundle_bits)(n & 0x3)) << 62);
  796. }
  797. static __inline tilegx_bundle_bits
  798. create_Opcode_X0(int num)
  799. {
  800. const unsigned int n = (unsigned int)num;
  801. return ((n & 0x7) << 28);
  802. }
  803. static __inline tilegx_bundle_bits
  804. create_Opcode_X1(int num)
  805. {
  806. const unsigned int n = (unsigned int)num;
  807. return (((tilegx_bundle_bits)(n & 0x7)) << 59);
  808. }
  809. static __inline tilegx_bundle_bits
  810. create_Opcode_Y0(int num)
  811. {
  812. const unsigned int n = (unsigned int)num;
  813. return ((n & 0xf) << 27);
  814. }
  815. static __inline tilegx_bundle_bits
  816. create_Opcode_Y1(int num)
  817. {
  818. const unsigned int n = (unsigned int)num;
  819. return (((tilegx_bundle_bits)(n & 0xf)) << 58);
  820. }
  821. static __inline tilegx_bundle_bits
  822. create_Opcode_Y2(int num)
  823. {
  824. const unsigned int n = (unsigned int)num;
  825. return ((n & 0x00000001) << 26) |
  826. (((tilegx_bundle_bits)(n & 0x00000002)) << 56);
  827. }
  828. static __inline tilegx_bundle_bits
  829. create_RRROpcodeExtension_X0(int num)
  830. {
  831. const unsigned int n = (unsigned int)num;
  832. return ((n & 0x3ff) << 18);
  833. }
  834. static __inline tilegx_bundle_bits
  835. create_RRROpcodeExtension_X1(int num)
  836. {
  837. const unsigned int n = (unsigned int)num;
  838. return (((tilegx_bundle_bits)(n & 0x3ff)) << 49);
  839. }
  840. static __inline tilegx_bundle_bits
  841. create_RRROpcodeExtension_Y0(int num)
  842. {
  843. const unsigned int n = (unsigned int)num;
  844. return ((n & 0x3) << 18);
  845. }
  846. static __inline tilegx_bundle_bits
  847. create_RRROpcodeExtension_Y1(int num)
  848. {
  849. const unsigned int n = (unsigned int)num;
  850. return (((tilegx_bundle_bits)(n & 0x3)) << 49);
  851. }
  852. static __inline tilegx_bundle_bits
  853. create_ShAmt_X0(int num)
  854. {
  855. const unsigned int n = (unsigned int)num;
  856. return ((n & 0x3f) << 12);
  857. }
  858. static __inline tilegx_bundle_bits
  859. create_ShAmt_X1(int num)
  860. {
  861. const unsigned int n = (unsigned int)num;
  862. return (((tilegx_bundle_bits)(n & 0x3f)) << 43);
  863. }
  864. static __inline tilegx_bundle_bits
  865. create_ShAmt_Y0(int num)
  866. {
  867. const unsigned int n = (unsigned int)num;
  868. return ((n & 0x3f) << 12);
  869. }
  870. static __inline tilegx_bundle_bits
  871. create_ShAmt_Y1(int num)
  872. {
  873. const unsigned int n = (unsigned int)num;
  874. return (((tilegx_bundle_bits)(n & 0x3f)) << 43);
  875. }
  876. static __inline tilegx_bundle_bits
  877. create_ShiftOpcodeExtension_X0(int num)
  878. {
  879. const unsigned int n = (unsigned int)num;
  880. return ((n & 0x3ff) << 18);
  881. }
  882. static __inline tilegx_bundle_bits
  883. create_ShiftOpcodeExtension_X1(int num)
  884. {
  885. const unsigned int n = (unsigned int)num;
  886. return (((tilegx_bundle_bits)(n & 0x3ff)) << 49);
  887. }
  888. static __inline tilegx_bundle_bits
  889. create_ShiftOpcodeExtension_Y0(int num)
  890. {
  891. const unsigned int n = (unsigned int)num;
  892. return ((n & 0x3) << 18);
  893. }
  894. static __inline tilegx_bundle_bits
  895. create_ShiftOpcodeExtension_Y1(int num)
  896. {
  897. const unsigned int n = (unsigned int)num;
  898. return (((tilegx_bundle_bits)(n & 0x3)) << 49);
  899. }
  900. static __inline tilegx_bundle_bits
  901. create_SrcA_X0(int num)
  902. {
  903. const unsigned int n = (unsigned int)num;
  904. return ((n & 0x3f) << 6);
  905. }
  906. static __inline tilegx_bundle_bits
  907. create_SrcA_X1(int num)
  908. {
  909. const unsigned int n = (unsigned int)num;
  910. return (((tilegx_bundle_bits)(n & 0x3f)) << 37);
  911. }
  912. static __inline tilegx_bundle_bits
  913. create_SrcA_Y0(int num)
  914. {
  915. const unsigned int n = (unsigned int)num;
  916. return ((n & 0x3f) << 6);
  917. }
  918. static __inline tilegx_bundle_bits
  919. create_SrcA_Y1(int num)
  920. {
  921. const unsigned int n = (unsigned int)num;
  922. return (((tilegx_bundle_bits)(n & 0x3f)) << 37);
  923. }
  924. static __inline tilegx_bundle_bits
  925. create_SrcA_Y2(int num)
  926. {
  927. const unsigned int n = (unsigned int)num;
  928. return ((n & 0x3f) << 20);
  929. }
  930. static __inline tilegx_bundle_bits
  931. create_SrcBDest_Y2(int num)
  932. {
  933. const unsigned int n = (unsigned int)num;
  934. return (((tilegx_bundle_bits)(n & 0x3f)) << 51);
  935. }
  936. static __inline tilegx_bundle_bits
  937. create_SrcB_X0(int num)
  938. {
  939. const unsigned int n = (unsigned int)num;
  940. return ((n & 0x3f) << 12);
  941. }
  942. static __inline tilegx_bundle_bits
  943. create_SrcB_X1(int num)
  944. {
  945. const unsigned int n = (unsigned int)num;
  946. return (((tilegx_bundle_bits)(n & 0x3f)) << 43);
  947. }
  948. static __inline tilegx_bundle_bits
  949. create_SrcB_Y0(int num)
  950. {
  951. const unsigned int n = (unsigned int)num;
  952. return ((n & 0x3f) << 12);
  953. }
  954. static __inline tilegx_bundle_bits
  955. create_SrcB_Y1(int num)
  956. {
  957. const unsigned int n = (unsigned int)num;
  958. return (((tilegx_bundle_bits)(n & 0x3f)) << 43);
  959. }
  960. static __inline tilegx_bundle_bits
  961. create_UnaryOpcodeExtension_X0(int num)
  962. {
  963. const unsigned int n = (unsigned int)num;
  964. return ((n & 0x3f) << 12);
  965. }
  966. static __inline tilegx_bundle_bits
  967. create_UnaryOpcodeExtension_X1(int num)
  968. {
  969. const unsigned int n = (unsigned int)num;
  970. return (((tilegx_bundle_bits)(n & 0x3f)) << 43);
  971. }
  972. static __inline tilegx_bundle_bits
  973. create_UnaryOpcodeExtension_Y0(int num)
  974. {
  975. const unsigned int n = (unsigned int)num;
  976. return ((n & 0x3f) << 12);
  977. }
  978. static __inline tilegx_bundle_bits
  979. create_UnaryOpcodeExtension_Y1(int num)
  980. {
  981. const unsigned int n = (unsigned int)num;
  982. return (((tilegx_bundle_bits)(n & 0x3f)) << 43);
  983. }
  984. typedef enum
  985. {
  986. TILEGX_PIPELINE_X0,
  987. TILEGX_PIPELINE_X1,
  988. TILEGX_PIPELINE_Y0,
  989. TILEGX_PIPELINE_Y1,
  990. TILEGX_PIPELINE_Y2,
  991. } tilegx_pipeline;
  992. #define tilegx_is_x_pipeline(p) ((int)(p) <= (int)TILEGX_PIPELINE_X1)
  993. typedef enum
  994. {
  995. TILEGX_OP_TYPE_REGISTER,
  996. TILEGX_OP_TYPE_IMMEDIATE,
  997. TILEGX_OP_TYPE_ADDRESS,
  998. TILEGX_OP_TYPE_SPR
  999. } tilegx_operand_type;
  1000. /* These are the bits that determine if a bundle is in the X encoding. */
  1001. #define TILEGX_BUNDLE_MODE_MASK ((tilegx_bundle_bits)3 << 62)
  1002. enum
  1003. {
  1004. /* Maximum number of instructions in a bundle (2 for X, 3 for Y). */
  1005. TILEGX_MAX_INSTRUCTIONS_PER_BUNDLE = 3,
  1006. /* How many different pipeline encodings are there? X0, X1, Y0, Y1, Y2. */
  1007. TILEGX_NUM_PIPELINE_ENCODINGS = 5,
  1008. /* Log base 2 of TILEGX_BUNDLE_SIZE_IN_BYTES. */
  1009. TILEGX_LOG2_BUNDLE_SIZE_IN_BYTES = 3,
  1010. /* Instructions take this many bytes. */
  1011. TILEGX_BUNDLE_SIZE_IN_BYTES = 1 << TILEGX_LOG2_BUNDLE_SIZE_IN_BYTES,
  1012. /* Log base 2 of TILEGX_BUNDLE_ALIGNMENT_IN_BYTES. */
  1013. TILEGX_LOG2_BUNDLE_ALIGNMENT_IN_BYTES = 3,
  1014. /* Bundles should be aligned modulo this number of bytes. */
  1015. TILEGX_BUNDLE_ALIGNMENT_IN_BYTES =
  1016. (1 << TILEGX_LOG2_BUNDLE_ALIGNMENT_IN_BYTES),
  1017. /* Number of registers (some are magic, such as network I/O). */
  1018. TILEGX_NUM_REGISTERS = 64,
  1019. };
  1020. struct tilegx_operand
  1021. {
  1022. /* Is this operand a register, immediate or address? */
  1023. tilegx_operand_type type;
  1024. /* The default relocation type for this operand. */
  1025. signed int default_reloc : 16;
  1026. /* How many bits is this value? (used for range checking) */
  1027. unsigned int num_bits : 5;
  1028. /* Is the value signed? (used for range checking) */
  1029. unsigned int is_signed : 1;
  1030. /* Is this operand a source register? */
  1031. unsigned int is_src_reg : 1;
  1032. /* Is this operand written? (i.e. is it a destination register) */
  1033. unsigned int is_dest_reg : 1;
  1034. /* Is this operand PC-relative? */
  1035. unsigned int is_pc_relative : 1;
  1036. /* By how many bits do we right shift the value before inserting? */
  1037. unsigned int rightshift : 2;
  1038. /* Return the bits for this operand to be ORed into an existing bundle. */
  1039. tilegx_bundle_bits (*insert) (int op);
  1040. /* Extract this operand and return it. */
  1041. unsigned int (*extract) (tilegx_bundle_bits bundle);
  1042. };
  1043. extern const struct tilegx_operand tilegx_operands[];
  1044. /* One finite-state machine per pipe for rapid instruction decoding. */
  1045. extern const unsigned short * const
  1046. tilegx_bundle_decoder_fsms[TILEGX_NUM_PIPELINE_ENCODINGS];
  1047. struct tilegx_opcode
  1048. {
  1049. /* The opcode mnemonic, e.g. "add" */
  1050. const char *name;
  1051. /* The enum value for this mnemonic. */
  1052. tilegx_mnemonic mnemonic;
  1053. /* A bit mask of which of the five pipes this instruction
  1054. is compatible with:
  1055. X0 0x01
  1056. X1 0x02
  1057. Y0 0x04
  1058. Y1 0x08
  1059. Y2 0x10 */
  1060. unsigned char pipes;
  1061. /* How many operands are there? */
  1062. unsigned char num_operands;
  1063. /* Which register does this write implicitly, or TREG_ZERO if none? */
  1064. unsigned char implicitly_written_register;
  1065. /* Can this be bundled with other instructions (almost always true). */
  1066. unsigned char can_bundle;
  1067. /* The description of the operands. Each of these is an
  1068. * index into the tilegx_operands[] table. */
  1069. unsigned char operands[TILEGX_NUM_PIPELINE_ENCODINGS][TILEGX_MAX_OPERANDS];
  1070. };
  1071. extern const struct tilegx_opcode tilegx_opcodes[];
  1072. /* Used for non-textual disassembly into structs. */
  1073. struct tilegx_decoded_instruction
  1074. {
  1075. const struct tilegx_opcode *opcode;
  1076. const struct tilegx_operand *operands[TILEGX_MAX_OPERANDS];
  1077. long long operand_values[TILEGX_MAX_OPERANDS];
  1078. };
  1079. /* Disassemble a bundle into a struct for machine processing. */
  1080. extern int parse_insn_tilegx(tilegx_bundle_bits bits,
  1081. unsigned long long pc,
  1082. struct tilegx_decoded_instruction
  1083. decoded[TILEGX_MAX_INSTRUCTIONS_PER_BUNDLE]);
  1084. #endif /* opcode_tilegx_h */