tic6x.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726
  1. /* TI C6X opcode information.
  2. Copyright (C) 2010-2022 Free Software Foundation, Inc.
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
  14. MA 02110-1301, USA. */
  15. #ifndef OPCODE_TIC6X_H
  16. #define OPCODE_TIC6X_H
  17. #include "bfd.h"
  18. #include "symcat.h"
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22. /* A field in an instruction format. The names are based on those
  23. used in the architecture manuals. */
  24. typedef enum
  25. {
  26. tic6x_field_baseR,
  27. tic6x_field_cc,
  28. tic6x_field_creg,
  29. tic6x_field_cst,
  30. tic6x_field_csta,
  31. tic6x_field_cstb,
  32. tic6x_field_dst,
  33. tic6x_field_dstms,
  34. tic6x_field_dw,
  35. tic6x_field_fstgfcyc,
  36. tic6x_field_h,
  37. tic6x_field_ii,
  38. tic6x_field_mask,
  39. tic6x_field_mode,
  40. tic6x_field_n,
  41. tic6x_field_na,
  42. tic6x_field_offsetR,
  43. tic6x_field_op,
  44. tic6x_field_p,
  45. tic6x_field_ptr,
  46. tic6x_field_r,
  47. tic6x_field_s,
  48. tic6x_field_sc,
  49. tic6x_field_src,
  50. tic6x_field_src1,
  51. tic6x_field_src2,
  52. tic6x_field_srcdst,
  53. tic6x_field_srcms,
  54. tic6x_field_sn,
  55. tic6x_field_sz,
  56. tic6x_field_unit,
  57. tic6x_field_t,
  58. tic6x_field_x,
  59. tic6x_field_y,
  60. tic6x_field_z
  61. } tic6x_insn_field_id;
  62. typedef struct
  63. {
  64. /* The least-significant bit position in the field. */
  65. unsigned short low_pos;
  66. /* The number of bits in the field. */
  67. unsigned short width;
  68. /* The position of the bitfield in the field. */
  69. unsigned short pos;
  70. } tic6x_bitfield;
  71. /* Maximum number of subfields in composite field. */
  72. #define TIC6X_MAX_BITFIELDS 4
  73. typedef struct
  74. {
  75. /* The name used to reference the field. */
  76. tic6x_insn_field_id field_id;
  77. unsigned int num_bitfields;
  78. tic6x_bitfield bitfields[TIC6X_MAX_BITFIELDS];
  79. } tic6x_insn_field;
  80. /* Maximum number of variable fields in an instruction format. */
  81. #define TIC6X_MAX_INSN_FIELDS 11
  82. /* A particular instruction format. */
  83. typedef struct
  84. {
  85. /* How many bits in the instruction. */
  86. unsigned int num_bits;
  87. /* Constant bits in the instruction. */
  88. unsigned int cst_bits;
  89. /* Mask matching those bits. */
  90. unsigned int mask;
  91. /* The number of instruction fields. */
  92. unsigned int num_fields;
  93. /* Descriptions of instruction fields. */
  94. tic6x_insn_field fields[TIC6X_MAX_INSN_FIELDS];
  95. } tic6x_insn_format;
  96. /* An index into the table of instruction formats. */
  97. typedef enum
  98. {
  99. #define FMT(name, num_bits, cst_bits, mask, fields) \
  100. CONCAT2(tic6x_insn_format_, name),
  101. #include "tic6x-insn-formats.h"
  102. #undef FMT
  103. tic6x_insn_format_max
  104. } tic6x_insn_format_id;
  105. /* The table itself. */
  106. extern const tic6x_insn_format tic6x_insn_format_table[tic6x_insn_format_max];
  107. /* If instruction format FMT has a field FIELD, return a pointer to
  108. the description of that field; otherwise return NULL. */
  109. const tic6x_insn_field *tic6x_field_from_fmt (const tic6x_insn_format *fmt,
  110. tic6x_insn_field_id field);
  111. /* Description of a field (in an instruction format) whose value is
  112. fixed, or constrained to be in a particular range, in a particular
  113. opcode. */
  114. typedef struct
  115. {
  116. /* The name of the field. */
  117. tic6x_insn_field_id field_id;
  118. /* The least value of the field in this instruction. */
  119. unsigned int min_val;
  120. /* The greatest value of the field in this instruction. */
  121. unsigned int max_val;
  122. } tic6x_fixed_field;
  123. /* Pseudo opcode fields position for compact instructions
  124. If 16 bits instruction detected, the opcode is enriched
  125. [DSZ/3][BR][SAT][opcode] */
  126. #define TIC6X_COMPACT_SAT_POS 16
  127. #define TIC6X_COMPACT_BR_POS 17
  128. #define TIC6X_COMPACT_DSZ_POS 18
  129. /* Bit-masks for defining instructions present on some subset of
  130. processors; each indicates an instruction present on that processor
  131. and those that are supersets of it. The options passed to the
  132. assembler determine a bit-mask ANDed with the bit-mask indicating
  133. when the instruction was added to determine whether the instruction
  134. is enabled. */
  135. #define TIC6X_INSN_C62X 0x0001
  136. #define TIC6X_INSN_C64X 0x0002
  137. #define TIC6X_INSN_C64XP 0x0004
  138. #define TIC6X_INSN_C67X 0x0008
  139. #define TIC6X_INSN_C67XP 0x0010
  140. #define TIC6X_INSN_C674X 0x0020
  141. /* Flags with further information about an opcode table entry. */
  142. /* Only used by the assembler, not the disassembler. */
  143. #define TIC6X_FLAG_MACRO 0x0001
  144. /* Must be first in its execute packet. */
  145. #define TIC6X_FLAG_FIRST 0x0002
  146. /* Multi-cycle NOP (not used for the NOP n instruction itself, which
  147. is only a multicycle NOP if n > 1). */
  148. #define TIC6X_FLAG_MCNOP 0x0004
  149. /* Cannot be in parallel with a multi-cycle NOP. */
  150. #define TIC6X_FLAG_NO_MCNOP 0x0008
  151. /* Load instruction. */
  152. #define TIC6X_FLAG_LOAD 0x0010
  153. /* Store instruction. */
  154. #define TIC6X_FLAG_STORE 0x0020
  155. /* Unaligned memory operation. */
  156. #define TIC6X_FLAG_UNALIGNED 0x0040
  157. /* Only on side B. */
  158. #define TIC6X_FLAG_SIDE_B_ONLY 0x0080
  159. /* Only on data path T2. */
  160. #define TIC6X_FLAG_SIDE_T2_ONLY 0x0100
  161. /* Does not support cross paths. */
  162. #define TIC6X_FLAG_NO_CROSS 0x0200
  163. /* Annotate this branch instruction as a call. */
  164. #define TIC6X_FLAG_CALL 0x0400
  165. /* Annotate this branch instruction as a return. */
  166. #define TIC6X_FLAG_RETURN 0x0800
  167. /* This instruction starts a software pipelined loop. */
  168. #define TIC6X_FLAG_SPLOOP 0x1000
  169. /* This instruction ends a software pipelined loop. */
  170. #define TIC6X_FLAG_SPKERNEL 0x2000
  171. /* This instruction takes a list of functional units as parameters;
  172. although described as having one parameter, the number may be 0 to
  173. 8. */
  174. #define TIC6X_FLAG_SPMASK 0x4000
  175. /* When more than one opcode matches the assembly source, prefer the
  176. one with the highest value for this bit-field. If two opcode table
  177. entries can match the same syntactic form, they must have different
  178. values here. */
  179. #define TIC6X_PREFER_VAL(n) (((n) & 0x8000) >> 15)
  180. #define TIC6X_FLAG_PREFER(n) ((n) << 15)
  181. /* 16 bits opcode is predicated by register a0 (s = 0) or b0 (s = 1) */
  182. #define TIC6X_FLAG_INSN16_SPRED 0x00100000
  183. /* 16 bits opcode ignores RS bit of fetch packet header */
  184. #define TIC6X_FLAG_INSN16_NORS 0x00200000
  185. /* 16 bits opcode only on side B */
  186. #define TIC6X_FLAG_INSN16_BSIDE 0x00400000
  187. /* 16 bits opcode ptr reg is b15 */
  188. #define TIC6X_FLAG_INSN16_B15PTR 0x00800000
  189. /* 16 bits opcode memory access modes */
  190. #define TIC6X_INSN16_MEM_MODE(n) ((n) << 16)
  191. #define TIC6X_INSN16_MEM_MODE_VAL(n) (((n) & 0x000F0000) >> 16)
  192. #define TIC6X_MEM_MODE_NEGATIVE 0
  193. #define TIC6X_MEM_MODE_POSITIVE 1
  194. #define TIC6X_MEM_MODE_REG_NEGATIVE 4
  195. #define TIC6X_MEM_MODE_REG_POSITIVE 5
  196. #define TIC6X_MEM_MODE_PREDECR 8
  197. #define TIC6X_MEM_MODE_PREINCR 9
  198. #define TIC6X_MEM_MODE_POSTDECR 10
  199. #define TIC6X_MEM_MODE_POSTINCR 11
  200. #define TIC6X_FLAG_INSN16_MEM_MODE(mode) TIC6X_INSN16_MEM_MODE(TIC6X_MEM_MODE_##mode)
  201. #define TIC6X_NUM_PREFER 2
  202. /* Maximum number of fixed fields for a particular opcode. */
  203. #define TIC6X_MAX_FIXED_FIELDS 4
  204. /* Maximum number of operands in the opcode table for a particular
  205. opcode. */
  206. #define TIC6X_MAX_OPERANDS 4
  207. /* Maximum number of operands in the source code for a particular
  208. opcode (different from the number in the opcode table for SPMASK
  209. and SPMASKR). */
  210. #define TIC6X_MAX_SOURCE_OPERANDS 8
  211. /* Maximum number of variable fields for a particular opcode. */
  212. #define TIC6X_MAX_VAR_FIELDS 7
  213. /* Which functional units an opcode uses. This only describes the
  214. basic choice of D, L, M, S or no functional unit; other fields are
  215. used to describe further restrictions (instructions only operating
  216. on one side), use of cross paths and load/store instructions using
  217. one side for the address and the other side for the source or
  218. destination register. */
  219. typedef enum
  220. {
  221. tic6x_func_unit_d,
  222. tic6x_func_unit_l,
  223. tic6x_func_unit_m,
  224. tic6x_func_unit_s,
  225. tic6x_func_unit_nfu
  226. } tic6x_func_unit_base;
  227. /* Possible forms of source operand. */
  228. typedef enum
  229. {
  230. /* An assembly-time constant. */
  231. tic6x_operand_asm_const,
  232. /* A link-time constant. */
  233. tic6x_operand_link_const,
  234. /* A register, from the same side as the functional unit
  235. selected. */
  236. tic6x_operand_reg,
  237. /* A register, from the same side as the functional unit
  238. selected that ignore RS header bit */
  239. tic6x_operand_reg_nors,
  240. /* A register, from the b side */
  241. tic6x_operand_reg_bside,
  242. /* A register, from the b side and from the low register set */
  243. tic6x_operand_reg_bside_nors,
  244. /* A register, that is from the other side if a cross path is
  245. used. */
  246. tic6x_operand_xreg,
  247. /* A register, that is from the side of the data path
  248. selected. */
  249. tic6x_operand_dreg,
  250. /* An address register usable with 15-bit offsets (B14 or B15).
  251. This is from the same side as the functional unit if a cross
  252. path is not used, and the other side if a cross path is
  253. used. */
  254. tic6x_operand_areg,
  255. /* The B15 register */
  256. tic6x_operand_b15reg,
  257. /* A register coded as an offset from either A16 or B16 depending
  258. on the value of the t bit. */
  259. tic6x_operand_treg,
  260. /* A register (A0 or B0), from the same side as the
  261. functional unit selected. */
  262. tic6x_operand_zreg,
  263. /* A return address register (A3 or B3), from the same side as the
  264. functional unit selected. */
  265. tic6x_operand_retreg,
  266. /* A register pair, from the same side as the functional unit
  267. selected. */
  268. tic6x_operand_regpair,
  269. /* A register pair, that is from the other side if a cross path is
  270. used. */
  271. tic6x_operand_xregpair,
  272. /* A register pair, from the side of the data path selected. */
  273. tic6x_operand_dregpair,
  274. /* A register pair coded as an offset from either A16 or B16 depending
  275. on the value of the t bit. */
  276. tic6x_operand_tregpair,
  277. /* The literal string "irp" (case-insensitive). */
  278. tic6x_operand_irp,
  279. /* The literal string "nrp" (case-insensitive). */
  280. tic6x_operand_nrp,
  281. /* The literal string "ilc" (case-insensitive). */
  282. tic6x_operand_ilc,
  283. /* A control register. */
  284. tic6x_operand_ctrl,
  285. /* A memory reference (base and offset registers from the side of
  286. the functional unit selected), using either unsigned 5-bit
  287. constant or register offset, if any offset; register offsets
  288. cannot use unscaled () syntax. */
  289. tic6x_operand_mem_short,
  290. /* A memory reference (base and offset registers from the side of
  291. the functional unit selected), using either unsigned 5-bit
  292. constant or register offset, if any offset; register offsets
  293. can use unscaled () syntax (for LDNDW and STNDW). */
  294. tic6x_operand_mem_ndw,
  295. /* A memory reference using 15-bit link-time constant offset
  296. relative to B14 or B15. */
  297. tic6x_operand_mem_long,
  298. /* A memory reference that only dereferences a register with no
  299. further adjustments (*REG), that register being from the side
  300. of the functional unit selected. */
  301. tic6x_operand_mem_deref,
  302. /* A functional unit name or a list thereof (for SPMASK and
  303. SPMASKR). */
  304. tic6x_operand_func_unit,
  305. /* Hardwired constant '5' in Sbu8 Scs10 and Sbu8c 16 bits
  306. instruction formats - spru732j.pdf Appendix F.4 */
  307. tic6x_operand_hw_const_minus_1,
  308. tic6x_operand_hw_const_0,
  309. tic6x_operand_hw_const_1,
  310. tic6x_operand_hw_const_5,
  311. tic6x_operand_hw_const_16,
  312. tic6x_operand_hw_const_24,
  313. tic6x_operand_hw_const_31
  314. } tic6x_operand_form;
  315. /* Whether something is, or can be, read or written. */
  316. typedef enum
  317. {
  318. tic6x_rw_none,
  319. tic6x_rw_read,
  320. tic6x_rw_write,
  321. tic6x_rw_read_write
  322. } tic6x_rw;
  323. /* Description of a source operand and how it is used. */
  324. typedef struct
  325. {
  326. /* The syntactic form of the operand. */
  327. tic6x_operand_form form;
  328. /* For non-constant operands, the size in bytes (1, 2, 4, 5 or
  329. 8). Ignored for constant operands. */
  330. unsigned int size;
  331. /* Whether the operand is read, written or both. In addition to the
  332. operations described here, address registers are read on cycle 1
  333. regardless of when the memory operand is read or written, and may
  334. be modified as described by the addressing mode, and control
  335. registers may be implicitly read by some instructions. There are
  336. also some special cases not fully described by this
  337. structure.
  338. - For mpydp, the low part of src2 is read on cycles 1 and 3 but
  339. not 2, and the high part on cycles 2 and 4 but not 3.
  340. - The swap2 pseudo-operation maps to packlh2, reading the first
  341. operand of swap2 twice. */
  342. tic6x_rw rw;
  343. /* The first and last cycles (1 for E1, etc.) at which the operand,
  344. or the low part for two-register operands, is read or
  345. written. */
  346. unsigned short low_first;
  347. unsigned short low_last;
  348. /* Likewise, for the high part. */
  349. unsigned short high_first;
  350. unsigned short high_last;
  351. } tic6x_operand_info;
  352. /* Ways of converting an operand or functional unit specifier to a
  353. field value. */
  354. typedef enum
  355. {
  356. /* Store an unsigned assembly-time constant (which must fit) in
  357. the field. */
  358. tic6x_coding_ucst,
  359. /* Store a signed constant (which must fit) in the field. This
  360. may be used both for assembly-time constants and for link-time
  361. constants. */
  362. tic6x_coding_scst,
  363. /* Subtract one from an unsigned assembly-time constant (which
  364. must be strictly positive before the subtraction) and store the
  365. value (which must fit) in the field. */
  366. tic6x_coding_ucst_minus_one,
  367. /* Negate a signed assembly-time constant, and store the result of
  368. negation (which must fit) in the field. Used only for
  369. pseudo-operations. */
  370. tic6x_coding_scst_negate,
  371. /* Store an unsigned link-time constant, implicitly DP-relative
  372. and counting in bytes, in the field. For expression operands,
  373. assembly-time constants are encoded as-is. For memory
  374. reference operands, the offset is encoded as-is if [] syntax is
  375. used and shifted if () is used. */
  376. tic6x_coding_ulcst_dpr_byte,
  377. /* Store an unsigned link-time constant, implicitly DP-relative
  378. and counting in half-words, in the field. For expression
  379. operands, assembly-time constants are encoded as-is. For
  380. memory reference operands, the offset is encoded as-is if []
  381. syntax is used and shifted if () is used. */
  382. tic6x_coding_ulcst_dpr_half,
  383. /* Store an unsigned link-time constant, implicitly DP-relative
  384. and counting in words, in the field. For expression operands,
  385. assembly-time constants are encoded as-is. For memory
  386. reference operands, the offset is encoded as-is if [] syntax is
  387. used and shifted if () is used. */
  388. tic6x_coding_ulcst_dpr_word,
  389. /* Store the low 16 bits of a link-time constant in the field;
  390. considered unsigned for disassembly. */
  391. tic6x_coding_lcst_low16,
  392. /* Store the high 16 bits of a link-time constant in the field;
  393. considered unsigned for disassembly. */
  394. tic6x_coding_lcst_high16,
  395. /* Store a signed PC-relative value (address of label minus
  396. address of fetch packet containing the current instruction,
  397. counted in words) in the field. */
  398. tic6x_coding_pcrel,
  399. /* Likewise, but counting in half-words if in a header-based fetch
  400. packet. */
  401. tic6x_coding_pcrel_half,
  402. /* Store an unsigned PC-relative value used in compact insn */
  403. tic6x_coding_pcrel_half_unsigned,
  404. /* Encode the register number (even number for a register pair) in
  405. the field. When applied to a memory reference, encode the base
  406. register. */
  407. tic6x_coding_reg,
  408. /* Encode the register-pair's lsb (even register) for instructions
  409. that use src1 as port for loading lsb of double-precision
  410. operand value (absdp, dpint, dpsp, dptrunc, rcpdp, rsqrdp). */
  411. tic6x_coding_regpair_lsb,
  412. /* Encode the register-pair's msb (odd register), see above. */
  413. tic6x_coding_regpair_msb,
  414. /* Store 0 for register B14, 1 for register B15. When applied to
  415. a memory reference, encode the base register. */
  416. tic6x_coding_areg,
  417. /* Compact instruction offset base register */
  418. tic6x_coding_reg_ptr,
  419. /* Store the low part of a control register address. */
  420. tic6x_coding_crlo,
  421. /* Store the high part of a control register address. */
  422. tic6x_coding_crhi,
  423. /* Encode the even register number for a register pair, shifted
  424. right by one bit. */
  425. tic6x_coding_reg_shift,
  426. /* Store either the offset register or the 5-bit unsigned offset
  427. for a memory reference. If an offset uses the unscaled ()
  428. form, which is only permitted with constants, it is scaled
  429. according to the access size of the operand before being
  430. stored. */
  431. tic6x_coding_mem_offset,
  432. /* Store either the offset register or the 5-bit unsigned offset
  433. for a memory reference, but with no scaling applied to the
  434. offset (for nonaligned doubleword operations). */
  435. tic6x_coding_mem_offset_noscale,
  436. /* Store the addressing mode for a memory reference. */
  437. tic6x_coding_mem_mode,
  438. /* Store whether a memory reference is scaled. */
  439. tic6x_coding_scaled,
  440. /* Store the stage in an SPKERNEL instruction in the upper part of
  441. the field. */
  442. tic6x_coding_fstg,
  443. /* Store the cycle in an SPKERNEL instruction in the lower part of
  444. the field. */
  445. tic6x_coding_fcyc,
  446. /* Store the mask bits for functional units in the field in an
  447. SPMASK or SPMASKR instruction. */
  448. tic6x_coding_spmask,
  449. /* Store the number of a register that is unused, or minimally
  450. used, in this execute packet. The number must be the same for
  451. all uses of this coding in a single instruction, but may be
  452. different for different instructions in the execute packet.
  453. This is for the "zero" pseudo-operation. This is not safe when
  454. reads may occur from instructions in previous execute packets;
  455. in such cases the programmer or compiler should use explicit
  456. "sub" instructions for those cases of "zero" that cannot be
  457. implemented as "mvk" for the processor specified. */
  458. tic6x_coding_reg_unused,
  459. /* Store 1 if the functional unit used is on side B, 0 for side
  460. A. */
  461. tic6x_coding_fu,
  462. /* Store 1 if the data path used (source register for store,
  463. destination for load) is on side B, 0 for side A. */
  464. tic6x_coding_data_fu,
  465. /* Store 1 if the cross path is being used, 0 otherwise. */
  466. tic6x_coding_xpath,
  467. /* L3i constant coding */
  468. tic6x_coding_scst_l3i,
  469. /* S3i constant coding */
  470. tic6x_coding_cst_s3i,
  471. /* mem offset minus 1 */
  472. tic6x_coding_mem_offset_minus_one,
  473. /* non aligned mem offset minus 1 */
  474. tic6x_coding_mem_offset_minus_one_noscale,
  475. tic6x_coding_rside
  476. } tic6x_coding_method;
  477. /* How to generate the value of a particular field. */
  478. typedef struct
  479. {
  480. /* The name of the field. */
  481. tic6x_insn_field_id field_id;
  482. /* How it is encoded. */
  483. tic6x_coding_method coding_method;
  484. /* Source operand number, if any. */
  485. unsigned int operand_num;
  486. } tic6x_coding_field;
  487. /* Types of instruction for pipeline purposes. The type determines
  488. functional unit and cross path latency (when the same functional
  489. unit can be used by other instructions, when the same cross path
  490. can be used by other instructions). */
  491. typedef enum
  492. {
  493. tic6x_pipeline_nop,
  494. tic6x_pipeline_1cycle,
  495. tic6x_pipeline_1616_m,
  496. tic6x_pipeline_store,
  497. tic6x_pipeline_mul_ext,
  498. tic6x_pipeline_load,
  499. tic6x_pipeline_branch,
  500. tic6x_pipeline_2cycle_dp,
  501. tic6x_pipeline_4cycle,
  502. tic6x_pipeline_intdp,
  503. tic6x_pipeline_dpcmp,
  504. tic6x_pipeline_addsubdp,
  505. tic6x_pipeline_mpyi,
  506. tic6x_pipeline_mpyid,
  507. tic6x_pipeline_mpydp,
  508. tic6x_pipeline_mpyspdp,
  509. tic6x_pipeline_mpysp2dp
  510. } tic6x_pipeline_type;
  511. /* Description of a control register. */
  512. typedef struct
  513. {
  514. /* The name of the register. */
  515. const char *name;
  516. /* Which ISA variants include this control register. */
  517. unsigned short isa_variants;
  518. /* Whether it can be read, written or both (in supervisor mode).
  519. Some registers use the same address, but different names, for
  520. reading and writing. */
  521. tic6x_rw rw;
  522. /* crlo value for this register. */
  523. unsigned int crlo;
  524. /* Mask that, ANDed with the crhi value in the instruction, must be
  525. 0. 0 is always generated when generating code. */
  526. unsigned int crhi_mask;
  527. } tic6x_ctrl;
  528. /* An index into the table of control registers. */
  529. typedef enum
  530. {
  531. #define CTRL(name, isa, rw, crlo, crhi_mask) \
  532. CONCAT2(tic6x_ctrl_,name),
  533. #include "tic6x-control-registers.h"
  534. #undef CTRL
  535. tic6x_ctrl_max
  536. } tic6x_ctrl_id;
  537. /* The table itself. */
  538. extern const tic6x_ctrl tic6x_ctrl_table[tic6x_ctrl_max];
  539. /* An entry in the opcode table. */
  540. typedef struct
  541. {
  542. /* The name of the instruction. */
  543. const char *name;
  544. /* Functional unit used by this instruction (basic information). */
  545. tic6x_func_unit_base func_unit;
  546. /* The format of this instruction. */
  547. tic6x_insn_format_id format;
  548. /* The pipeline type of this instruction. */
  549. tic6x_pipeline_type type;
  550. /* Which ISA variants include this instruction. */
  551. unsigned short isa_variants;
  552. /* Flags for this instruction. */
  553. unsigned int flags;
  554. /* Number of fixed fields, or fields with restricted value ranges,
  555. for this instruction. */
  556. unsigned int num_fixed_fields;
  557. /* Values of fields fixed for this instruction. */
  558. tic6x_fixed_field fixed_fields[TIC6X_MAX_FIXED_FIELDS];
  559. /* The number of operands in the source form of this
  560. instruction. */
  561. unsigned int num_operands;
  562. /* Information about individual operands. */
  563. tic6x_operand_info operand_info[TIC6X_MAX_OPERANDS];
  564. /* The number of variable fields for this instruction with encoding
  565. instructions explicitly given. */
  566. unsigned int num_variable_fields;
  567. /* How fields (other than ones with fixed value) are computed from
  568. the source operands and functional unit specifiers. In addition
  569. to fields specified here:
  570. - creg, if present, is set from the predicate, along with z which
  571. must be present if creg is present.
  572. - p, if present (on all non-compact instructions), is set from
  573. the parallel bars.
  574. */
  575. tic6x_coding_field variable_fields[TIC6X_MAX_VAR_FIELDS];
  576. } tic6x_opcode;
  577. /* An index into the table of opcodes. */
  578. typedef enum
  579. {
  580. #define INSN(name, func_unit, format, type, isa, flags, fixed, ops, var) \
  581. CONCAT6(tic6x_opcode_,name,_,func_unit,_,format),
  582. #define INSNE(name, e, func_unit, format, type, isa, flags, fixed, ops, var) \
  583. CONCAT4(tic6x_opcode_,name,_,e),
  584. #define INSNU(name, func_unit, format, type, isa, flags, fixed, ops, var) \
  585. CONCAT6(tic6x_opcode_,name,_,func_unit,_,format),
  586. #define INSNUE(name, e, func_unit, format, type, isa, flags, fixed, ops, var) \
  587. CONCAT6(tic6x_opcode_,name,_,func_unit,_,e),
  588. #include "tic6x-opcode-table.h"
  589. #undef INSN
  590. #undef INSNE
  591. #undef INSNU
  592. #undef INSNUE
  593. tic6x_opcode_max
  594. } tic6x_opcode_id;
  595. /* The table itself. */
  596. extern const tic6x_opcode tic6x_opcode_table[tic6x_opcode_max];
  597. /* A linked list of opcodes. */
  598. typedef struct tic6x_opcode_list_tag
  599. {
  600. tic6x_opcode_id id;
  601. struct tic6x_opcode_list_tag *next;
  602. } tic6x_opcode_list;
  603. /* The information from a fetch packet header. */
  604. typedef struct
  605. {
  606. /* The header itself. */
  607. unsigned int header;
  608. /* Whether each word uses compact instructions. */
  609. bool word_compact[7];
  610. /* Whether loads are protected. */
  611. bool prot;
  612. /* Whether instructions use the high register set. */
  613. bool rs;
  614. /* Data size. */
  615. unsigned int dsz;
  616. /* Whether compact instructions in the S unit are decoded as
  617. branches. */
  618. bool br;
  619. /* Whether compact instructions saturate. */
  620. bool sat;
  621. /* P-bits. */
  622. bool p_bits[14];
  623. } tic6x_fetch_packet_header;
  624. #ifdef __cplusplus
  625. }
  626. #endif
  627. #endif /* OPCODE_TIC6X_H */