tic6x.h 24 KB

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