tms320c64x.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. /* Capstone Disassembly Engine */
  2. /* TMS320C64x Backend by Fotis Loukos <me@fotisl.com> 2016 */
  3. #ifndef CAPSTONE_TMS320C64X_H
  4. #define CAPSTONE_TMS320C64X_H
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8. #include <stdint.h>
  9. #include "platform.h"
  10. #ifdef _MSC_VER
  11. #pragma warning(disable:4201)
  12. #endif
  13. typedef enum tms320c64x_op_type {
  14. TMS320C64X_OP_INVALID = 0, ///< = CS_OP_INVALID (Uninitialized).
  15. TMS320C64X_OP_REG, ///< = CS_OP_REG (Register operand).
  16. TMS320C64X_OP_IMM, ///< = CS_OP_IMM (Immediate operand).
  17. TMS320C64X_OP_MEM, ///< = CS_OP_MEM (Memory operand).
  18. TMS320C64X_OP_REGPAIR = 64, ///< Register pair for double word ops
  19. } tms320c64x_op_type;
  20. typedef enum tms320c64x_mem_disp {
  21. TMS320C64X_MEM_DISP_INVALID = 0,
  22. TMS320C64X_MEM_DISP_CONSTANT,
  23. TMS320C64X_MEM_DISP_REGISTER,
  24. } tms320c64x_mem_disp;
  25. typedef enum tms320c64x_mem_dir {
  26. TMS320C64X_MEM_DIR_INVALID = 0,
  27. TMS320C64X_MEM_DIR_FW,
  28. TMS320C64X_MEM_DIR_BW,
  29. } tms320c64x_mem_dir;
  30. typedef enum tms320c64x_mem_mod {
  31. TMS320C64X_MEM_MOD_INVALID = 0,
  32. TMS320C64X_MEM_MOD_NO,
  33. TMS320C64X_MEM_MOD_PRE,
  34. TMS320C64X_MEM_MOD_POST,
  35. } tms320c64x_mem_mod;
  36. typedef struct tms320c64x_op_mem {
  37. unsigned int base; ///< base register
  38. unsigned int disp; ///< displacement/offset value
  39. unsigned int unit; ///< unit of base and offset register
  40. unsigned int scaled; ///< offset scaled
  41. unsigned int disptype; ///< displacement type
  42. unsigned int direction; ///< direction
  43. unsigned int modify; ///< modification
  44. } tms320c64x_op_mem;
  45. typedef struct cs_tms320c64x_op {
  46. tms320c64x_op_type type; ///< operand type
  47. union {
  48. unsigned int reg; ///< register value for REG operand or first register for REGPAIR operand
  49. int32_t imm; ///< immediate value for IMM operand
  50. tms320c64x_op_mem mem; ///< base/disp value for MEM operand
  51. };
  52. } cs_tms320c64x_op;
  53. typedef struct cs_tms320c64x {
  54. uint8_t op_count;
  55. cs_tms320c64x_op operands[8]; ///< operands for this instruction.
  56. struct {
  57. unsigned int reg;
  58. unsigned int zero;
  59. } condition;
  60. struct {
  61. unsigned int unit;
  62. unsigned int side;
  63. unsigned int crosspath;
  64. } funit;
  65. unsigned int parallel;
  66. } cs_tms320c64x;
  67. typedef enum tms320c64x_reg {
  68. TMS320C64X_REG_INVALID = 0,
  69. TMS320C64X_REG_AMR,
  70. TMS320C64X_REG_CSR,
  71. TMS320C64X_REG_DIER,
  72. TMS320C64X_REG_DNUM,
  73. TMS320C64X_REG_ECR,
  74. TMS320C64X_REG_GFPGFR,
  75. TMS320C64X_REG_GPLYA,
  76. TMS320C64X_REG_GPLYB,
  77. TMS320C64X_REG_ICR,
  78. TMS320C64X_REG_IER,
  79. TMS320C64X_REG_IERR,
  80. TMS320C64X_REG_ILC,
  81. TMS320C64X_REG_IRP,
  82. TMS320C64X_REG_ISR,
  83. TMS320C64X_REG_ISTP,
  84. TMS320C64X_REG_ITSR,
  85. TMS320C64X_REG_NRP,
  86. TMS320C64X_REG_NTSR,
  87. TMS320C64X_REG_REP,
  88. TMS320C64X_REG_RILC,
  89. TMS320C64X_REG_SSR,
  90. TMS320C64X_REG_TSCH,
  91. TMS320C64X_REG_TSCL,
  92. TMS320C64X_REG_TSR,
  93. TMS320C64X_REG_A0,
  94. TMS320C64X_REG_A1,
  95. TMS320C64X_REG_A2,
  96. TMS320C64X_REG_A3,
  97. TMS320C64X_REG_A4,
  98. TMS320C64X_REG_A5,
  99. TMS320C64X_REG_A6,
  100. TMS320C64X_REG_A7,
  101. TMS320C64X_REG_A8,
  102. TMS320C64X_REG_A9,
  103. TMS320C64X_REG_A10,
  104. TMS320C64X_REG_A11,
  105. TMS320C64X_REG_A12,
  106. TMS320C64X_REG_A13,
  107. TMS320C64X_REG_A14,
  108. TMS320C64X_REG_A15,
  109. TMS320C64X_REG_A16,
  110. TMS320C64X_REG_A17,
  111. TMS320C64X_REG_A18,
  112. TMS320C64X_REG_A19,
  113. TMS320C64X_REG_A20,
  114. TMS320C64X_REG_A21,
  115. TMS320C64X_REG_A22,
  116. TMS320C64X_REG_A23,
  117. TMS320C64X_REG_A24,
  118. TMS320C64X_REG_A25,
  119. TMS320C64X_REG_A26,
  120. TMS320C64X_REG_A27,
  121. TMS320C64X_REG_A28,
  122. TMS320C64X_REG_A29,
  123. TMS320C64X_REG_A30,
  124. TMS320C64X_REG_A31,
  125. TMS320C64X_REG_B0,
  126. TMS320C64X_REG_B1,
  127. TMS320C64X_REG_B2,
  128. TMS320C64X_REG_B3,
  129. TMS320C64X_REG_B4,
  130. TMS320C64X_REG_B5,
  131. TMS320C64X_REG_B6,
  132. TMS320C64X_REG_B7,
  133. TMS320C64X_REG_B8,
  134. TMS320C64X_REG_B9,
  135. TMS320C64X_REG_B10,
  136. TMS320C64X_REG_B11,
  137. TMS320C64X_REG_B12,
  138. TMS320C64X_REG_B13,
  139. TMS320C64X_REG_B14,
  140. TMS320C64X_REG_B15,
  141. TMS320C64X_REG_B16,
  142. TMS320C64X_REG_B17,
  143. TMS320C64X_REG_B18,
  144. TMS320C64X_REG_B19,
  145. TMS320C64X_REG_B20,
  146. TMS320C64X_REG_B21,
  147. TMS320C64X_REG_B22,
  148. TMS320C64X_REG_B23,
  149. TMS320C64X_REG_B24,
  150. TMS320C64X_REG_B25,
  151. TMS320C64X_REG_B26,
  152. TMS320C64X_REG_B27,
  153. TMS320C64X_REG_B28,
  154. TMS320C64X_REG_B29,
  155. TMS320C64X_REG_B30,
  156. TMS320C64X_REG_B31,
  157. TMS320C64X_REG_PCE1,
  158. TMS320C64X_REG_ENDING, // <-- mark the end of the list of registers
  159. // Alias registers
  160. TMS320C64X_REG_EFR = TMS320C64X_REG_ECR,
  161. TMS320C64X_REG_IFR = TMS320C64X_REG_ISR,
  162. } tms320c64x_reg;
  163. typedef enum tms320c64x_insn {
  164. TMS320C64X_INS_INVALID = 0,
  165. TMS320C64X_INS_ABS,
  166. TMS320C64X_INS_ABS2,
  167. TMS320C64X_INS_ADD,
  168. TMS320C64X_INS_ADD2,
  169. TMS320C64X_INS_ADD4,
  170. TMS320C64X_INS_ADDAB,
  171. TMS320C64X_INS_ADDAD,
  172. TMS320C64X_INS_ADDAH,
  173. TMS320C64X_INS_ADDAW,
  174. TMS320C64X_INS_ADDK,
  175. TMS320C64X_INS_ADDKPC,
  176. TMS320C64X_INS_ADDU,
  177. TMS320C64X_INS_AND,
  178. TMS320C64X_INS_ANDN,
  179. TMS320C64X_INS_AVG2,
  180. TMS320C64X_INS_AVGU4,
  181. TMS320C64X_INS_B,
  182. TMS320C64X_INS_BDEC,
  183. TMS320C64X_INS_BITC4,
  184. TMS320C64X_INS_BNOP,
  185. TMS320C64X_INS_BPOS,
  186. TMS320C64X_INS_CLR,
  187. TMS320C64X_INS_CMPEQ,
  188. TMS320C64X_INS_CMPEQ2,
  189. TMS320C64X_INS_CMPEQ4,
  190. TMS320C64X_INS_CMPGT,
  191. TMS320C64X_INS_CMPGT2,
  192. TMS320C64X_INS_CMPGTU4,
  193. TMS320C64X_INS_CMPLT,
  194. TMS320C64X_INS_CMPLTU,
  195. TMS320C64X_INS_DEAL,
  196. TMS320C64X_INS_DOTP2,
  197. TMS320C64X_INS_DOTPN2,
  198. TMS320C64X_INS_DOTPNRSU2,
  199. TMS320C64X_INS_DOTPRSU2,
  200. TMS320C64X_INS_DOTPSU4,
  201. TMS320C64X_INS_DOTPU4,
  202. TMS320C64X_INS_EXT,
  203. TMS320C64X_INS_EXTU,
  204. TMS320C64X_INS_GMPGTU,
  205. TMS320C64X_INS_GMPY4,
  206. TMS320C64X_INS_LDB,
  207. TMS320C64X_INS_LDBU,
  208. TMS320C64X_INS_LDDW,
  209. TMS320C64X_INS_LDH,
  210. TMS320C64X_INS_LDHU,
  211. TMS320C64X_INS_LDNDW,
  212. TMS320C64X_INS_LDNW,
  213. TMS320C64X_INS_LDW,
  214. TMS320C64X_INS_LMBD,
  215. TMS320C64X_INS_MAX2,
  216. TMS320C64X_INS_MAXU4,
  217. TMS320C64X_INS_MIN2,
  218. TMS320C64X_INS_MINU4,
  219. TMS320C64X_INS_MPY,
  220. TMS320C64X_INS_MPY2,
  221. TMS320C64X_INS_MPYH,
  222. TMS320C64X_INS_MPYHI,
  223. TMS320C64X_INS_MPYHIR,
  224. TMS320C64X_INS_MPYHL,
  225. TMS320C64X_INS_MPYHLU,
  226. TMS320C64X_INS_MPYHSLU,
  227. TMS320C64X_INS_MPYHSU,
  228. TMS320C64X_INS_MPYHU,
  229. TMS320C64X_INS_MPYHULS,
  230. TMS320C64X_INS_MPYHUS,
  231. TMS320C64X_INS_MPYLH,
  232. TMS320C64X_INS_MPYLHU,
  233. TMS320C64X_INS_MPYLI,
  234. TMS320C64X_INS_MPYLIR,
  235. TMS320C64X_INS_MPYLSHU,
  236. TMS320C64X_INS_MPYLUHS,
  237. TMS320C64X_INS_MPYSU,
  238. TMS320C64X_INS_MPYSU4,
  239. TMS320C64X_INS_MPYU,
  240. TMS320C64X_INS_MPYU4,
  241. TMS320C64X_INS_MPYUS,
  242. TMS320C64X_INS_MVC,
  243. TMS320C64X_INS_MVD,
  244. TMS320C64X_INS_MVK,
  245. TMS320C64X_INS_MVKL,
  246. TMS320C64X_INS_MVKLH,
  247. TMS320C64X_INS_NOP,
  248. TMS320C64X_INS_NORM,
  249. TMS320C64X_INS_OR,
  250. TMS320C64X_INS_PACK2,
  251. TMS320C64X_INS_PACKH2,
  252. TMS320C64X_INS_PACKH4,
  253. TMS320C64X_INS_PACKHL2,
  254. TMS320C64X_INS_PACKL4,
  255. TMS320C64X_INS_PACKLH2,
  256. TMS320C64X_INS_ROTL,
  257. TMS320C64X_INS_SADD,
  258. TMS320C64X_INS_SADD2,
  259. TMS320C64X_INS_SADDU4,
  260. TMS320C64X_INS_SADDUS2,
  261. TMS320C64X_INS_SAT,
  262. TMS320C64X_INS_SET,
  263. TMS320C64X_INS_SHFL,
  264. TMS320C64X_INS_SHL,
  265. TMS320C64X_INS_SHLMB,
  266. TMS320C64X_INS_SHR,
  267. TMS320C64X_INS_SHR2,
  268. TMS320C64X_INS_SHRMB,
  269. TMS320C64X_INS_SHRU,
  270. TMS320C64X_INS_SHRU2,
  271. TMS320C64X_INS_SMPY,
  272. TMS320C64X_INS_SMPY2,
  273. TMS320C64X_INS_SMPYH,
  274. TMS320C64X_INS_SMPYHL,
  275. TMS320C64X_INS_SMPYLH,
  276. TMS320C64X_INS_SPACK2,
  277. TMS320C64X_INS_SPACKU4,
  278. TMS320C64X_INS_SSHL,
  279. TMS320C64X_INS_SSHVL,
  280. TMS320C64X_INS_SSHVR,
  281. TMS320C64X_INS_SSUB,
  282. TMS320C64X_INS_STB,
  283. TMS320C64X_INS_STDW,
  284. TMS320C64X_INS_STH,
  285. TMS320C64X_INS_STNDW,
  286. TMS320C64X_INS_STNW,
  287. TMS320C64X_INS_STW,
  288. TMS320C64X_INS_SUB,
  289. TMS320C64X_INS_SUB2,
  290. TMS320C64X_INS_SUB4,
  291. TMS320C64X_INS_SUBAB,
  292. TMS320C64X_INS_SUBABS4,
  293. TMS320C64X_INS_SUBAH,
  294. TMS320C64X_INS_SUBAW,
  295. TMS320C64X_INS_SUBC,
  296. TMS320C64X_INS_SUBU,
  297. TMS320C64X_INS_SWAP4,
  298. TMS320C64X_INS_UNPKHU4,
  299. TMS320C64X_INS_UNPKLU4,
  300. TMS320C64X_INS_XOR,
  301. TMS320C64X_INS_XPND2,
  302. TMS320C64X_INS_XPND4,
  303. // Aliases
  304. TMS320C64X_INS_IDLE,
  305. TMS320C64X_INS_MV,
  306. TMS320C64X_INS_NEG,
  307. TMS320C64X_INS_NOT,
  308. TMS320C64X_INS_SWAP2,
  309. TMS320C64X_INS_ZERO,
  310. TMS320C64X_INS_ENDING, // <-- mark the end of the list of instructions
  311. } tms320c64x_insn;
  312. typedef enum tms320c64x_insn_group {
  313. TMS320C64X_GRP_INVALID = 0, ///< = CS_GRP_INVALID
  314. TMS320C64X_GRP_JUMP, ///< = CS_GRP_JUMP
  315. TMS320C64X_GRP_FUNIT_D = 128,
  316. TMS320C64X_GRP_FUNIT_L,
  317. TMS320C64X_GRP_FUNIT_M,
  318. TMS320C64X_GRP_FUNIT_S,
  319. TMS320C64X_GRP_FUNIT_NO,
  320. TMS320C64X_GRP_ENDING, // <-- mark the end of the list of groups
  321. } tms320c64x_insn_group;
  322. typedef enum tms320c64x_funit {
  323. TMS320C64X_FUNIT_INVALID = 0,
  324. TMS320C64X_FUNIT_D,
  325. TMS320C64X_FUNIT_L,
  326. TMS320C64X_FUNIT_M,
  327. TMS320C64X_FUNIT_S,
  328. TMS320C64X_FUNIT_NO
  329. } tms320c64x_funit;
  330. #ifdef __cplusplus
  331. }
  332. #endif
  333. #endif