tile-desc_64.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  1. /* TILE-Gx opcode information.
  2. *
  3. * Copyright 2011 Tilera Corporation. All Rights Reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * as published by the Free Software Foundation, version 2.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  12. * NON INFRINGEMENT. See the GNU General Public License for
  13. * more details.
  14. *
  15. *
  16. *
  17. *
  18. *
  19. */
  20. #ifndef opcode_tile_h
  21. #define opcode_tile_h
  22. #include <arch/opcode.h>
  23. enum
  24. {
  25. TILEGX_MAX_OPERANDS = 4 /* bfexts */
  26. };
  27. typedef enum
  28. {
  29. TILEGX_OPC_BPT,
  30. TILEGX_OPC_INFO,
  31. TILEGX_OPC_INFOL,
  32. TILEGX_OPC_MOVE,
  33. TILEGX_OPC_MOVEI,
  34. TILEGX_OPC_MOVELI,
  35. TILEGX_OPC_PREFETCH,
  36. TILEGX_OPC_PREFETCH_ADD_L1,
  37. TILEGX_OPC_PREFETCH_ADD_L1_FAULT,
  38. TILEGX_OPC_PREFETCH_ADD_L2,
  39. TILEGX_OPC_PREFETCH_ADD_L2_FAULT,
  40. TILEGX_OPC_PREFETCH_ADD_L3,
  41. TILEGX_OPC_PREFETCH_ADD_L3_FAULT,
  42. TILEGX_OPC_PREFETCH_L1,
  43. TILEGX_OPC_PREFETCH_L1_FAULT,
  44. TILEGX_OPC_PREFETCH_L2,
  45. TILEGX_OPC_PREFETCH_L2_FAULT,
  46. TILEGX_OPC_PREFETCH_L3,
  47. TILEGX_OPC_PREFETCH_L3_FAULT,
  48. TILEGX_OPC_RAISE,
  49. TILEGX_OPC_ADD,
  50. TILEGX_OPC_ADDI,
  51. TILEGX_OPC_ADDLI,
  52. TILEGX_OPC_ADDX,
  53. TILEGX_OPC_ADDXI,
  54. TILEGX_OPC_ADDXLI,
  55. TILEGX_OPC_ADDXSC,
  56. TILEGX_OPC_AND,
  57. TILEGX_OPC_ANDI,
  58. TILEGX_OPC_BEQZ,
  59. TILEGX_OPC_BEQZT,
  60. TILEGX_OPC_BFEXTS,
  61. TILEGX_OPC_BFEXTU,
  62. TILEGX_OPC_BFINS,
  63. TILEGX_OPC_BGEZ,
  64. TILEGX_OPC_BGEZT,
  65. TILEGX_OPC_BGTZ,
  66. TILEGX_OPC_BGTZT,
  67. TILEGX_OPC_BLBC,
  68. TILEGX_OPC_BLBCT,
  69. TILEGX_OPC_BLBS,
  70. TILEGX_OPC_BLBST,
  71. TILEGX_OPC_BLEZ,
  72. TILEGX_OPC_BLEZT,
  73. TILEGX_OPC_BLTZ,
  74. TILEGX_OPC_BLTZT,
  75. TILEGX_OPC_BNEZ,
  76. TILEGX_OPC_BNEZT,
  77. TILEGX_OPC_CLZ,
  78. TILEGX_OPC_CMOVEQZ,
  79. TILEGX_OPC_CMOVNEZ,
  80. TILEGX_OPC_CMPEQ,
  81. TILEGX_OPC_CMPEQI,
  82. TILEGX_OPC_CMPEXCH,
  83. TILEGX_OPC_CMPEXCH4,
  84. TILEGX_OPC_CMPLES,
  85. TILEGX_OPC_CMPLEU,
  86. TILEGX_OPC_CMPLTS,
  87. TILEGX_OPC_CMPLTSI,
  88. TILEGX_OPC_CMPLTU,
  89. TILEGX_OPC_CMPLTUI,
  90. TILEGX_OPC_CMPNE,
  91. TILEGX_OPC_CMUL,
  92. TILEGX_OPC_CMULA,
  93. TILEGX_OPC_CMULAF,
  94. TILEGX_OPC_CMULF,
  95. TILEGX_OPC_CMULFR,
  96. TILEGX_OPC_CMULH,
  97. TILEGX_OPC_CMULHR,
  98. TILEGX_OPC_CRC32_32,
  99. TILEGX_OPC_CRC32_8,
  100. TILEGX_OPC_CTZ,
  101. TILEGX_OPC_DBLALIGN,
  102. TILEGX_OPC_DBLALIGN2,
  103. TILEGX_OPC_DBLALIGN4,
  104. TILEGX_OPC_DBLALIGN6,
  105. TILEGX_OPC_DRAIN,
  106. TILEGX_OPC_DTLBPR,
  107. TILEGX_OPC_EXCH,
  108. TILEGX_OPC_EXCH4,
  109. TILEGX_OPC_FDOUBLE_ADD_FLAGS,
  110. TILEGX_OPC_FDOUBLE_ADDSUB,
  111. TILEGX_OPC_FDOUBLE_MUL_FLAGS,
  112. TILEGX_OPC_FDOUBLE_PACK1,
  113. TILEGX_OPC_FDOUBLE_PACK2,
  114. TILEGX_OPC_FDOUBLE_SUB_FLAGS,
  115. TILEGX_OPC_FDOUBLE_UNPACK_MAX,
  116. TILEGX_OPC_FDOUBLE_UNPACK_MIN,
  117. TILEGX_OPC_FETCHADD,
  118. TILEGX_OPC_FETCHADD4,
  119. TILEGX_OPC_FETCHADDGEZ,
  120. TILEGX_OPC_FETCHADDGEZ4,
  121. TILEGX_OPC_FETCHAND,
  122. TILEGX_OPC_FETCHAND4,
  123. TILEGX_OPC_FETCHOR,
  124. TILEGX_OPC_FETCHOR4,
  125. TILEGX_OPC_FINV,
  126. TILEGX_OPC_FLUSH,
  127. TILEGX_OPC_FLUSHWB,
  128. TILEGX_OPC_FNOP,
  129. TILEGX_OPC_FSINGLE_ADD1,
  130. TILEGX_OPC_FSINGLE_ADDSUB2,
  131. TILEGX_OPC_FSINGLE_MUL1,
  132. TILEGX_OPC_FSINGLE_MUL2,
  133. TILEGX_OPC_FSINGLE_PACK1,
  134. TILEGX_OPC_FSINGLE_PACK2,
  135. TILEGX_OPC_FSINGLE_SUB1,
  136. TILEGX_OPC_ICOH,
  137. TILEGX_OPC_ILL,
  138. TILEGX_OPC_INV,
  139. TILEGX_OPC_IRET,
  140. TILEGX_OPC_J,
  141. TILEGX_OPC_JAL,
  142. TILEGX_OPC_JALR,
  143. TILEGX_OPC_JALRP,
  144. TILEGX_OPC_JR,
  145. TILEGX_OPC_JRP,
  146. TILEGX_OPC_LD,
  147. TILEGX_OPC_LD1S,
  148. TILEGX_OPC_LD1S_ADD,
  149. TILEGX_OPC_LD1U,
  150. TILEGX_OPC_LD1U_ADD,
  151. TILEGX_OPC_LD2S,
  152. TILEGX_OPC_LD2S_ADD,
  153. TILEGX_OPC_LD2U,
  154. TILEGX_OPC_LD2U_ADD,
  155. TILEGX_OPC_LD4S,
  156. TILEGX_OPC_LD4S_ADD,
  157. TILEGX_OPC_LD4U,
  158. TILEGX_OPC_LD4U_ADD,
  159. TILEGX_OPC_LD_ADD,
  160. TILEGX_OPC_LDNA,
  161. TILEGX_OPC_LDNA_ADD,
  162. TILEGX_OPC_LDNT,
  163. TILEGX_OPC_LDNT1S,
  164. TILEGX_OPC_LDNT1S_ADD,
  165. TILEGX_OPC_LDNT1U,
  166. TILEGX_OPC_LDNT1U_ADD,
  167. TILEGX_OPC_LDNT2S,
  168. TILEGX_OPC_LDNT2S_ADD,
  169. TILEGX_OPC_LDNT2U,
  170. TILEGX_OPC_LDNT2U_ADD,
  171. TILEGX_OPC_LDNT4S,
  172. TILEGX_OPC_LDNT4S_ADD,
  173. TILEGX_OPC_LDNT4U,
  174. TILEGX_OPC_LDNT4U_ADD,
  175. TILEGX_OPC_LDNT_ADD,
  176. TILEGX_OPC_LNK,
  177. TILEGX_OPC_MF,
  178. TILEGX_OPC_MFSPR,
  179. TILEGX_OPC_MM,
  180. TILEGX_OPC_MNZ,
  181. TILEGX_OPC_MTSPR,
  182. TILEGX_OPC_MUL_HS_HS,
  183. TILEGX_OPC_MUL_HS_HU,
  184. TILEGX_OPC_MUL_HS_LS,
  185. TILEGX_OPC_MUL_HS_LU,
  186. TILEGX_OPC_MUL_HU_HU,
  187. TILEGX_OPC_MUL_HU_LS,
  188. TILEGX_OPC_MUL_HU_LU,
  189. TILEGX_OPC_MUL_LS_LS,
  190. TILEGX_OPC_MUL_LS_LU,
  191. TILEGX_OPC_MUL_LU_LU,
  192. TILEGX_OPC_MULA_HS_HS,
  193. TILEGX_OPC_MULA_HS_HU,
  194. TILEGX_OPC_MULA_HS_LS,
  195. TILEGX_OPC_MULA_HS_LU,
  196. TILEGX_OPC_MULA_HU_HU,
  197. TILEGX_OPC_MULA_HU_LS,
  198. TILEGX_OPC_MULA_HU_LU,
  199. TILEGX_OPC_MULA_LS_LS,
  200. TILEGX_OPC_MULA_LS_LU,
  201. TILEGX_OPC_MULA_LU_LU,
  202. TILEGX_OPC_MULAX,
  203. TILEGX_OPC_MULX,
  204. TILEGX_OPC_MZ,
  205. TILEGX_OPC_NAP,
  206. TILEGX_OPC_NOP,
  207. TILEGX_OPC_NOR,
  208. TILEGX_OPC_OR,
  209. TILEGX_OPC_ORI,
  210. TILEGX_OPC_PCNT,
  211. TILEGX_OPC_REVBITS,
  212. TILEGX_OPC_REVBYTES,
  213. TILEGX_OPC_ROTL,
  214. TILEGX_OPC_ROTLI,
  215. TILEGX_OPC_SHL,
  216. TILEGX_OPC_SHL16INSLI,
  217. TILEGX_OPC_SHL1ADD,
  218. TILEGX_OPC_SHL1ADDX,
  219. TILEGX_OPC_SHL2ADD,
  220. TILEGX_OPC_SHL2ADDX,
  221. TILEGX_OPC_SHL3ADD,
  222. TILEGX_OPC_SHL3ADDX,
  223. TILEGX_OPC_SHLI,
  224. TILEGX_OPC_SHLX,
  225. TILEGX_OPC_SHLXI,
  226. TILEGX_OPC_SHRS,
  227. TILEGX_OPC_SHRSI,
  228. TILEGX_OPC_SHRU,
  229. TILEGX_OPC_SHRUI,
  230. TILEGX_OPC_SHRUX,
  231. TILEGX_OPC_SHRUXI,
  232. TILEGX_OPC_SHUFFLEBYTES,
  233. TILEGX_OPC_ST,
  234. TILEGX_OPC_ST1,
  235. TILEGX_OPC_ST1_ADD,
  236. TILEGX_OPC_ST2,
  237. TILEGX_OPC_ST2_ADD,
  238. TILEGX_OPC_ST4,
  239. TILEGX_OPC_ST4_ADD,
  240. TILEGX_OPC_ST_ADD,
  241. TILEGX_OPC_STNT,
  242. TILEGX_OPC_STNT1,
  243. TILEGX_OPC_STNT1_ADD,
  244. TILEGX_OPC_STNT2,
  245. TILEGX_OPC_STNT2_ADD,
  246. TILEGX_OPC_STNT4,
  247. TILEGX_OPC_STNT4_ADD,
  248. TILEGX_OPC_STNT_ADD,
  249. TILEGX_OPC_SUB,
  250. TILEGX_OPC_SUBX,
  251. TILEGX_OPC_SUBXSC,
  252. TILEGX_OPC_SWINT0,
  253. TILEGX_OPC_SWINT1,
  254. TILEGX_OPC_SWINT2,
  255. TILEGX_OPC_SWINT3,
  256. TILEGX_OPC_TBLIDXB0,
  257. TILEGX_OPC_TBLIDXB1,
  258. TILEGX_OPC_TBLIDXB2,
  259. TILEGX_OPC_TBLIDXB3,
  260. TILEGX_OPC_V1ADD,
  261. TILEGX_OPC_V1ADDI,
  262. TILEGX_OPC_V1ADDUC,
  263. TILEGX_OPC_V1ADIFFU,
  264. TILEGX_OPC_V1AVGU,
  265. TILEGX_OPC_V1CMPEQ,
  266. TILEGX_OPC_V1CMPEQI,
  267. TILEGX_OPC_V1CMPLES,
  268. TILEGX_OPC_V1CMPLEU,
  269. TILEGX_OPC_V1CMPLTS,
  270. TILEGX_OPC_V1CMPLTSI,
  271. TILEGX_OPC_V1CMPLTU,
  272. TILEGX_OPC_V1CMPLTUI,
  273. TILEGX_OPC_V1CMPNE,
  274. TILEGX_OPC_V1DDOTPU,
  275. TILEGX_OPC_V1DDOTPUA,
  276. TILEGX_OPC_V1DDOTPUS,
  277. TILEGX_OPC_V1DDOTPUSA,
  278. TILEGX_OPC_V1DOTP,
  279. TILEGX_OPC_V1DOTPA,
  280. TILEGX_OPC_V1DOTPU,
  281. TILEGX_OPC_V1DOTPUA,
  282. TILEGX_OPC_V1DOTPUS,
  283. TILEGX_OPC_V1DOTPUSA,
  284. TILEGX_OPC_V1INT_H,
  285. TILEGX_OPC_V1INT_L,
  286. TILEGX_OPC_V1MAXU,
  287. TILEGX_OPC_V1MAXUI,
  288. TILEGX_OPC_V1MINU,
  289. TILEGX_OPC_V1MINUI,
  290. TILEGX_OPC_V1MNZ,
  291. TILEGX_OPC_V1MULTU,
  292. TILEGX_OPC_V1MULU,
  293. TILEGX_OPC_V1MULUS,
  294. TILEGX_OPC_V1MZ,
  295. TILEGX_OPC_V1SADAU,
  296. TILEGX_OPC_V1SADU,
  297. TILEGX_OPC_V1SHL,
  298. TILEGX_OPC_V1SHLI,
  299. TILEGX_OPC_V1SHRS,
  300. TILEGX_OPC_V1SHRSI,
  301. TILEGX_OPC_V1SHRU,
  302. TILEGX_OPC_V1SHRUI,
  303. TILEGX_OPC_V1SUB,
  304. TILEGX_OPC_V1SUBUC,
  305. TILEGX_OPC_V2ADD,
  306. TILEGX_OPC_V2ADDI,
  307. TILEGX_OPC_V2ADDSC,
  308. TILEGX_OPC_V2ADIFFS,
  309. TILEGX_OPC_V2AVGS,
  310. TILEGX_OPC_V2CMPEQ,
  311. TILEGX_OPC_V2CMPEQI,
  312. TILEGX_OPC_V2CMPLES,
  313. TILEGX_OPC_V2CMPLEU,
  314. TILEGX_OPC_V2CMPLTS,
  315. TILEGX_OPC_V2CMPLTSI,
  316. TILEGX_OPC_V2CMPLTU,
  317. TILEGX_OPC_V2CMPLTUI,
  318. TILEGX_OPC_V2CMPNE,
  319. TILEGX_OPC_V2DOTP,
  320. TILEGX_OPC_V2DOTPA,
  321. TILEGX_OPC_V2INT_H,
  322. TILEGX_OPC_V2INT_L,
  323. TILEGX_OPC_V2MAXS,
  324. TILEGX_OPC_V2MAXSI,
  325. TILEGX_OPC_V2MINS,
  326. TILEGX_OPC_V2MINSI,
  327. TILEGX_OPC_V2MNZ,
  328. TILEGX_OPC_V2MULFSC,
  329. TILEGX_OPC_V2MULS,
  330. TILEGX_OPC_V2MULTS,
  331. TILEGX_OPC_V2MZ,
  332. TILEGX_OPC_V2PACKH,
  333. TILEGX_OPC_V2PACKL,
  334. TILEGX_OPC_V2PACKUC,
  335. TILEGX_OPC_V2SADAS,
  336. TILEGX_OPC_V2SADAU,
  337. TILEGX_OPC_V2SADS,
  338. TILEGX_OPC_V2SADU,
  339. TILEGX_OPC_V2SHL,
  340. TILEGX_OPC_V2SHLI,
  341. TILEGX_OPC_V2SHLSC,
  342. TILEGX_OPC_V2SHRS,
  343. TILEGX_OPC_V2SHRSI,
  344. TILEGX_OPC_V2SHRU,
  345. TILEGX_OPC_V2SHRUI,
  346. TILEGX_OPC_V2SUB,
  347. TILEGX_OPC_V2SUBSC,
  348. TILEGX_OPC_V4ADD,
  349. TILEGX_OPC_V4ADDSC,
  350. TILEGX_OPC_V4INT_H,
  351. TILEGX_OPC_V4INT_L,
  352. TILEGX_OPC_V4PACKSC,
  353. TILEGX_OPC_V4SHL,
  354. TILEGX_OPC_V4SHLSC,
  355. TILEGX_OPC_V4SHRS,
  356. TILEGX_OPC_V4SHRU,
  357. TILEGX_OPC_V4SUB,
  358. TILEGX_OPC_V4SUBSC,
  359. TILEGX_OPC_WH64,
  360. TILEGX_OPC_XOR,
  361. TILEGX_OPC_XORI,
  362. TILEGX_OPC_NONE
  363. } tilegx_mnemonic;
  364. typedef enum
  365. {
  366. TILEGX_PIPELINE_X0,
  367. TILEGX_PIPELINE_X1,
  368. TILEGX_PIPELINE_Y0,
  369. TILEGX_PIPELINE_Y1,
  370. TILEGX_PIPELINE_Y2,
  371. } tilegx_pipeline;
  372. #define tilegx_is_x_pipeline(p) ((int)(p) <= (int)TILEGX_PIPELINE_X1)
  373. typedef enum
  374. {
  375. TILEGX_OP_TYPE_REGISTER,
  376. TILEGX_OP_TYPE_IMMEDIATE,
  377. TILEGX_OP_TYPE_ADDRESS,
  378. TILEGX_OP_TYPE_SPR
  379. } tilegx_operand_type;
  380. struct tilegx_operand
  381. {
  382. /* Is this operand a register, immediate or address? */
  383. tilegx_operand_type type;
  384. /* The default relocation type for this operand. */
  385. signed int default_reloc : 16;
  386. /* How many bits is this value? (used for range checking) */
  387. unsigned int num_bits : 5;
  388. /* Is the value signed? (used for range checking) */
  389. unsigned int is_signed : 1;
  390. /* Is this operand a source register? */
  391. unsigned int is_src_reg : 1;
  392. /* Is this operand written? (i.e. is it a destination register) */
  393. unsigned int is_dest_reg : 1;
  394. /* Is this operand PC-relative? */
  395. unsigned int is_pc_relative : 1;
  396. /* By how many bits do we right shift the value before inserting? */
  397. unsigned int rightshift : 2;
  398. /* Return the bits for this operand to be ORed into an existing bundle. */
  399. tilegx_bundle_bits (*insert) (int op);
  400. /* Extract this operand and return it. */
  401. unsigned int (*extract) (tilegx_bundle_bits bundle);
  402. };
  403. extern const struct tilegx_operand tilegx_operands[];
  404. /* One finite-state machine per pipe for rapid instruction decoding. */
  405. extern const unsigned short * const
  406. tilegx_bundle_decoder_fsms[TILEGX_NUM_PIPELINE_ENCODINGS];
  407. struct tilegx_opcode
  408. {
  409. /* The opcode mnemonic, e.g. "add" */
  410. const char *name;
  411. /* The enum value for this mnemonic. */
  412. tilegx_mnemonic mnemonic;
  413. /* A bit mask of which of the five pipes this instruction
  414. is compatible with:
  415. X0 0x01
  416. X1 0x02
  417. Y0 0x04
  418. Y1 0x08
  419. Y2 0x10 */
  420. unsigned char pipes;
  421. /* How many operands are there? */
  422. unsigned char num_operands;
  423. /* Which register does this write implicitly, or TREG_ZERO if none? */
  424. unsigned char implicitly_written_register;
  425. /* Can this be bundled with other instructions (almost always true). */
  426. unsigned char can_bundle;
  427. /* The description of the operands. Each of these is an
  428. * index into the tilegx_operands[] table. */
  429. unsigned char operands[TILEGX_NUM_PIPELINE_ENCODINGS][TILEGX_MAX_OPERANDS];
  430. };
  431. extern const struct tilegx_opcode tilegx_opcodes[];
  432. /* Used for non-textual disassembly into structs. */
  433. struct tilegx_decoded_instruction
  434. {
  435. const struct tilegx_opcode *opcode;
  436. const struct tilegx_operand *operands[TILEGX_MAX_OPERANDS];
  437. long long operand_values[TILEGX_MAX_OPERANDS];
  438. };
  439. /* Disassemble a bundle into a struct for machine processing. */
  440. extern int parse_insn_tilegx(tilegx_bundle_bits bits,
  441. unsigned long long pc,
  442. struct tilegx_decoded_instruction
  443. decoded[TILEGX_MAX_INSTRUCTIONS_PER_BUNDLE]);
  444. #endif /* opcode_tilegx_h */