visium.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. /* Opcode table header for Visium.
  2. Copyright (C) 2003-2015 Free Software Foundation, Inc.
  3. This file is part of GDB, GAS, and GNU binutils.
  4. GDB, GAS and the GNU binutils are free software; you can redistribute
  5. them and/or modify them under the terms of the GNU General Public
  6. License as published by the Free Software Foundation; either version 3,
  7. or (at your option) any later version.
  8. GDB, GAS, and the GNU binutils are distributed in the hope that they
  9. will be useful, but WITHOUT ANY WARRANTY; without even the implied
  10. warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
  11. the GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this file; see the file COPYING3. If not, write to the Free
  14. Software Foundation, 51 Franklin Street - Fifth Floor, Boston,
  15. MA 02110-1301, USA. */
  16. enum visium_opcode_arch_val
  17. {
  18. VISIUM_OPCODE_ARCH_DEF = 0,
  19. VISIUM_OPCODE_ARCH_GR5,
  20. VISIUM_OPCODE_ARCH_GR6,
  21. VISIUM_OPCODE_ARCH_BAD
  22. };
  23. /* The highest architecture in the table. */
  24. #define VISIUM_OPCODE_ARCH_MAX (VISIUM_OPCODE_ARCH_BAD - 1)
  25. /* Given an enum visium_opcode_arch_val, return the bitmask to use in
  26. insn encoding/decoding. */
  27. #define VISIUM_OPCODE_ARCH_MASK(arch) (1 << (arch))
  28. /* Some defines to make life easy. */
  29. #define MASK_DEF VISIUM_OPCODE_ARCH_MASK (VISIUM_OPCODE_ARCH_DEF)
  30. #define MASK_GR5 VISIUM_OPCODE_ARCH_MASK (VISIUM_OPCODE_ARCH_GR5)
  31. #define MASK_GR6 VISIUM_OPCODE_ARCH_MASK (VISIUM_OPCODE_ARCH_GR6)
  32. /* Bit masks of architectures supporting the insn. */
  33. #define def (MASK_DEF | MASK_GR5 | MASK_GR6)
  34. #define gr5 (MASK_GR5 | MASK_GR6)
  35. #define gr6 (MASK_GR6)
  36. /* The condition code field is not used (zero) for most instructions.
  37. BRR and BRA make normal use of it. Floating point instructions use
  38. it as a sub-opcode. */
  39. #define CC_MASK (0xf << 27)
  40. /* It seems a shame not to use these bits in a class 0 instruction,
  41. since they could be used to extend the range of the branch. */
  42. #define CLASS0_UNUSED_MASK (0x1f << 16)
  43. /* For class 1 instructions the following bit is unused. */
  44. #define CLASS1_UNUSED_MASK (1 << 9)
  45. /* For class 1 instructions this field gives the index for a write
  46. instruction, the specific operation for an EAM instruction, or
  47. the floating point destination register for a floating point
  48. instruction. */
  49. #define CLASS1_INDEX_MASK (0x1f << 10)
  50. /* For class 3 instructions the following field gives the destination
  51. general register. */
  52. #define CLASS3_DEST_MASK (0x1f << 10)
  53. /* For class 1 and class 3 instructions the following bit selects an
  54. EAM write/read rather than a memory write/read. */
  55. #define EAM_SELECT_MASK (1 << 15)
  56. /* Floating point instructions are distinguished from general EAM
  57. instructions by the following bit. */
  58. #define FP_SELECT_MASK (1 << 3)
  59. /* For both class 1 and class 3 the following fields give, where
  60. appropriate the srcA and srcB registers whether floating point
  61. or general. */
  62. #define SRCA_MASK (0x1f << 16)
  63. #define SRCB_MASK (0x1f << 4)
  64. /* The class 3 interrupt bit. It turns a BRA into a SYS1, and an
  65. RFLAG into a SYS2. This bit should not be set in the user's
  66. class 3 instructions. This bit is also used in class 3
  67. to distinguish between floating point and other EAM operations.
  68. (see FP_SELECT_MASK). */
  69. #define CLASS3_INT (1 << 3)
  70. /* Class 3 shift instructions use this bit to indicate that the
  71. srcB field is a 5 bit immediate shift count rather than a
  72. register number. */
  73. #define CLASS3_SOURCEB_IMMED (1 << 9)
  74. #define BMD 0x02630004
  75. #define BMI 0x82230004
  76. #define DSI 0x82800004
  77. #define ENI 0x02a00004
  78. #define RFI 0x82fe01d4
  79. struct reg_entry
  80. {
  81. char *name;
  82. unsigned char code;
  83. };
  84. static const struct reg_entry gen_reg_table[] =
  85. {
  86. {"fp", 0x16},
  87. {"r0", 0x0},
  88. {"r1", 0x1},
  89. {"r10", 0xA},
  90. {"r11", 0xB},
  91. {"r12", 0xC},
  92. {"r13", 0xD},
  93. {"r14", 0xE},
  94. {"r15", 0xF},
  95. {"r16", 0x10},
  96. {"r17", 0x11},
  97. {"r18", 0x12},
  98. {"r19", 0x13},
  99. {"r2", 0x2},
  100. {"r20", 0x14},
  101. {"r21", 0x15},
  102. {"r22", 0x16},
  103. {"r23", 0x17},
  104. {"r24", 0x18},
  105. {"r25", 0x19},
  106. {"r26", 0x1a},
  107. {"r27", 0x1b},
  108. {"r28", 0x1c},
  109. {"r29", 0x1d},
  110. {"r3", 0x3},
  111. {"r30", 0x1e},
  112. {"r31", 0x1f},
  113. {"r4", 0x4},
  114. {"r5", 0x5},
  115. {"r6", 0x6},
  116. {"r7", 0x7},
  117. {"r8", 0x8},
  118. {"r9", 0x9},
  119. {"sp", 0x17},
  120. };
  121. static const struct reg_entry fp_reg_table[] =
  122. {
  123. {"f0", 0x0},
  124. {"f1", 0x1},
  125. {"f10", 0xa},
  126. {"f11", 0xb},
  127. {"f12", 0xc},
  128. {"f13", 0xd},
  129. {"f14", 0xe},
  130. {"f15", 0xf},
  131. {"f2", 0x2},
  132. {"f3", 0x3},
  133. {"f4", 0x4},
  134. {"f5", 0x5},
  135. {"f6", 0x6},
  136. {"f7", 0x7},
  137. {"f8", 0x8},
  138. {"f9", 0x9},
  139. };
  140. static const struct cc_entry
  141. {
  142. char *name;
  143. int code;
  144. } cc_table [] =
  145. {
  146. {"cc", 6},
  147. {"cs", 2},
  148. {"eq", 1},
  149. {"fa", 0},
  150. {"ge", 9},
  151. {"gt", 10},
  152. {"hi", 11},
  153. {"le", 12},
  154. {"ls", 13},
  155. {"lt", 14},
  156. {"nc", 8},
  157. {"ne", 5},
  158. {"ns", 4},
  159. {"oc", 7},
  160. {"os", 3},
  161. {"tr", 15},
  162. };
  163. enum addressing_mode
  164. {
  165. mode_d, /* register := */
  166. mode_a, /* op= register */
  167. mode_da, /* register := register */
  168. mode_ab, /* register * register */
  169. mode_dab, /* register := register * register */
  170. mode_iab, /* 5-bit immediate * register * register */
  171. mode_0ab, /* zero * register * register */
  172. mode_da0, /* register := register * zero */
  173. mode_cad, /* condition * register * register */
  174. mode_das, /* register := register * 5-bit immed/register shift count */
  175. mode_di, /* register := 5-bit immediate */
  176. mode_ir, /* 5-bit immediate * register */
  177. mode_ai, /* register 16-bit unsigned immediate */
  178. mode_i, /* 16-bit unsigned immediate */
  179. mode_bax, /* register * register * 5-bit immediate */
  180. mode_dax, /* register := register * 5-bit immediate */
  181. mode_s, /* special mode */
  182. mode_sr, /* special mode with register */
  183. mode_ci, /* condition * 16-bit signed word displacement */
  184. mode_fdab, /* float := float * float */
  185. mode_ifdab, /* fpinst: 4-bit immediate * float * float * float */
  186. mode_idfab, /* fpuread: 4-bit immediate * register * float * float */
  187. mode_fda, /* float := float */
  188. mode_fdra, /* float := register */
  189. mode_rdfab, /* register := float * float */
  190. mode_rdfa, /* register := float */
  191. mode_rrr, /* 3 register sources and destinations (block move) */
  192. };
  193. #define class0 (0<<25)
  194. #define class1 (1<<25)
  195. #define class2 (2<<25)
  196. #define class3 (3<<25)
  197. static const struct opcode_entry
  198. {
  199. char *mnem;
  200. enum addressing_mode mode;
  201. unsigned code;
  202. char flags;
  203. }
  204. opcode_table[] =
  205. {
  206. { "adc.b", mode_dab, class3|(1<<21)|(1), def },
  207. { "adc.l", mode_dab, class3|(1<<21)|(4), def },
  208. { "adc.w", mode_dab, class3|(1<<21)|(2), def },
  209. { "add.b", mode_dab, class3|(0<<21)|(1), def },
  210. { "add.l", mode_dab, class3|(0<<21)|(4), def },
  211. { "add.w", mode_dab, class3|(0<<21)|(2), def },
  212. { "addi", mode_ai, class2, def },
  213. { "and.b", mode_dab, class3|(10<<21)|(1), def},
  214. { "and.l", mode_dab, class3|(10<<21)|(4), def },
  215. { "and.w", mode_dab, class3|(10<<21)|(2), def },
  216. { "asl.b", mode_das, class3|(7<<21)|(1), def },
  217. { "asl.l", mode_das, class3|(7<<21)|(4), def },
  218. { "asl.w", mode_das, class3|(7<<21)|(2), def },
  219. { "asld", mode_a, class1|(15<<21)|(1<<15)|(11<<10)|(4), def },
  220. { "asr.b", mode_das, class3|(5<<21)|(1), def },
  221. { "asr.l", mode_das, class3|(5<<21)|(4), def },
  222. { "asr.w", mode_das, class3|(5<<21)|(2), def },
  223. { "asrd", mode_a, class1|(15<<21)|(1<<15)|(9<<10)|(4), def },
  224. { "bmd", mode_rrr, class1|(3<<21)|(3<<16)|(4), gr6 },
  225. { "bmi", mode_rrr, class1|(1<<21)|(3<<16)|(4), gr6 },
  226. { "bra", mode_cad, class3|(12<<21)|(4), def },
  227. { "brr", mode_ci, class0, def },
  228. { "cmp.b", mode_0ab, class3|(2<<21)|(1), def },
  229. { "cmp.l", mode_0ab, class3|(2<<21)|(4), def },
  230. { "cmp.w", mode_0ab, class3|(2<<21)|(2), def },
  231. { "cmpc.b", mode_0ab, class3|(3<<21)|(1), def },
  232. { "cmpc.l", mode_0ab, class3|(3<<21)|(4), def },
  233. { "cmpc.w", mode_0ab, class3|(3<<21)|(2), def },
  234. { "divds", mode_a, class1|(15<<21)|(1<<15)|(6<<10)|(4), def },
  235. { "divdu", mode_a, class1|(15<<21)|(1<<15)|(7<<10)|(4), def },
  236. { "divs", mode_a, class1|(15<<21)|(1<<15)|(2<<10)|(4), def },
  237. { "divu", mode_a, class1|(15<<21)|(1<<15)|(3<<10)|(4), def },
  238. { "dsi", mode_s, class1|(4<<21)|(4), def },
  239. { "eamread", mode_di, class3|(15<<21)|(1<<15)|(1<<9)|(4), def },
  240. { "eamwrite", mode_iab, class1|(15<<21)|(1<<15)|(4), def },
  241. { "eni", mode_s, class1|(5<<21)|(4), def },
  242. { "extb.b", mode_da, class3|(14<<21)|(1), def },
  243. { "extb.l", mode_da, class3|(14<<21)|(4), def },
  244. { "extb.w", mode_da, class3|(14<<21)|(2), def },
  245. { "extw.l", mode_da, class3|(4<<21)|(4), def },
  246. { "extw.w", mode_da, class3|(4<<21)|(2), def },
  247. { "fabs", mode_fda, class1|(7<<27)|(15<<21)|(1<<15)|(1<<3)|(4), gr5 },
  248. { "fadd", mode_fdab, class1|(1<<27)|(15<<21)|(1<<15)|(1<<3)|(4), gr5 },
  249. { "fcmp", mode_rdfab,class3|(10<<27)|(15<<21)|(1<<15)|(1<<9)|(1<<3)|(4), gr5 },
  250. { "fcmpe", mode_rdfab,class3|(11<<27)|(15<<21)|(1<<15)|(1<<9)|(1<<3)|(4), gr5 },
  251. { "fdiv", mode_fdab, class1|(4<<27)|(15<<21)|(1<<15)|(1<<3)|(4), gr5 },
  252. { "fload", mode_fdra, class1|(15<<21)|(1<<15)|(1<<3)|(4), gr5 },
  253. { "fmove", mode_fda, class1|(12<<27)|(15<<21)|(1<<15)|(1<<3)|(4), gr5},
  254. { "fmult", mode_fdab, class1|(3<<27)|(15<<21)|(1<<15)|(1<<3)|(4), gr5 },
  255. { "fneg", mode_fda, class1|(6<<27)|(15<<21)|(1<<15)|(1<<3)|(4), gr5 },
  256. { "fpinst", mode_ifdab,class1|(15<<21)|(1<<15)|(1<<3)|(4), gr5 },
  257. { "fpuread", mode_idfab,class3|(15<<21)|(1<<15)|(1<<9)|(1<<3)|(4), gr5 },
  258. { "fsqrt", mode_fda, class1|(5<<27)|(15<<21)|(1<<15)|(1<<3)|(4), gr5 },
  259. { "fstore", mode_rdfa, class3|(15<<21)|(1<<15)|(1<<9)|(1<<3)|(4), gr5 },
  260. { "fsub", mode_fdab, class1|(2<<27)|(15<<21)|(1<<15)|(1<<3)|(4), gr5 },
  261. { "ftoi", mode_fda, class1|(8<<27)|(15<<21)|(1<<15)|(1<<3)|(4), gr5 },
  262. { "itof", mode_fda, class1|(9<<27)|(15<<21)|(1<<15)|(1<<3)|(4), gr5 },
  263. { "lsr.b", mode_das, class3|(6<<21)|(1), def },
  264. { "lsr.l", mode_das, class3|(6<<21)|(4), def },
  265. { "lsr.w", mode_das, class3|(6<<21)|(2), def },
  266. { "lsrd", mode_a, class1|(15<<21)|(1<<15)|(10<<10)|(4), def },
  267. { "move.b", mode_da0, class3|(9<<21)|(1), def },
  268. { "move.l", mode_da0, class3|(9<<21)|(4), def },
  269. { "move.w", mode_da0, class3|(9<<21)|(2), def },
  270. { "movil", mode_ai, class2|(4<<21), def },
  271. { "moviq", mode_ai, class2|(6<<21), def },
  272. { "moviu", mode_ai, class2|(5<<21), def },
  273. { "mults", mode_ab, class1|(15<<21)|(1<<15)|(0<<10)|(4), def },
  274. { "multu", mode_ab, class1|(15<<21)|(1<<15)|(1<<10)|(4), def },
  275. { "nop", mode_s, class0, def },
  276. { "not.b", mode_da, class3|(11<<21)|(1), def },
  277. { "not.l", mode_da, class3|(11<<21)|(4), def },
  278. { "not.w", mode_da, class3|(11<<21)|(2), def },
  279. { "or.b", mode_dab, class3|(9<<21)|(1), def },
  280. { "or.l", mode_dab, class3|(9<<21)|(4), def },
  281. { "or.w", mode_dab, class3|(9<<21)|(2), def },
  282. { "read.b", mode_dax, class3|(15<<21)|(1<<9)|(1), def },
  283. { "read.l", mode_dax, class3|(15<<21)|(1<<9)|(4), def },
  284. { "read.w", mode_dax, class3|(15<<21)|(1<<9)|(2), def },
  285. { "readmda", mode_d, class3|(15<<21)|(1<<15)|(1<<9)|(4), def },
  286. { "readmdb", mode_d, class3|(15<<21)|(1<<15)|(1<<9)|(1<<4)|(4), def },
  287. { "readmdc", mode_d, class3|(15<<21)|(1<<15)|(1<<9)|(2<<4)|(4), def },
  288. { "rfi", mode_s, class1|(7<<21)|(30<<16)|(29<<4)|(4), def },
  289. { "rflag", mode_d, class3|(13<<21)|(4), def },
  290. { "stop", mode_ir, class1|(0<<21)|(4), def },
  291. { "sub.b", mode_dab, class3|(2<<21)|(1), def },
  292. { "sub.l", mode_dab, class3|(2<<21)|(4), def },
  293. { "sub.w", mode_dab, class3|(2<<21)|(2), def },
  294. { "subc.b", mode_dab, class3|(3<<21)|(1), def },
  295. { "subc.l", mode_dab, class3|(3<<21)|(4), def },
  296. { "subc.w", mode_dab, class3|(3<<21)|(2), def },
  297. { "subi", mode_ai, class2|(2<<21), def },
  298. { "trace", mode_ir, class1|(13<<21), def },
  299. { "write.b", mode_bax, class1|(15<<21)|(1), def },
  300. { "write.l", mode_bax, class1|(15<<21)|(4), def },
  301. { "write.w", mode_bax, class1|(15<<21)|(2), def },
  302. { "writemd", mode_ab, class1|(15<<21)|(1<<15)|(4<<10)|(4), def },
  303. { "writemdc", mode_a, class1|(15<<21)|(1<<15)|(5<<10)|(4), def },
  304. { "wrtl", mode_i, class2|(8<<21), gr6 },
  305. { "wrtu", mode_i, class2|(9<<21), gr6 },
  306. { "xor.b", mode_dab, class3|(8<<21)|(1), def },
  307. { "xor.l", mode_dab, class3|(8<<21)|(4), def },
  308. { "xor.w", mode_dab, class3|(8<<21)|(2), def },
  309. };