mt-desc.c 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318
  1. /* DO NOT EDIT! -*- buffer-read-only: t -*- vi:set ro: */
  2. /* CPU data for mt.
  3. THIS FILE IS MACHINE GENERATED WITH CGEN.
  4. Copyright (C) 1996-2022 Free Software Foundation, Inc.
  5. This file is part of the GNU Binutils and/or GDB, the GNU debugger.
  6. This file is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 3, or (at your option)
  9. any later version.
  10. It is distributed in the hope that it will be useful, but WITHOUT
  11. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  12. or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  13. License for more details.
  14. You should have received a copy of the GNU General Public License along
  15. with this program; if not, write to the Free Software Foundation, Inc.,
  16. 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
  17. */
  18. #include "sysdep.h"
  19. #include <stdio.h>
  20. #include <stdarg.h>
  21. #include <stdlib.h>
  22. #include "ansidecl.h"
  23. #include "bfd.h"
  24. #include "symcat.h"
  25. #include "mt-desc.h"
  26. #include "mt-opc.h"
  27. #include "opintl.h"
  28. #include "libiberty.h"
  29. #include "xregex.h"
  30. /* Attributes. */
  31. static const CGEN_ATTR_ENTRY bool_attr[] =
  32. {
  33. { "#f", 0 },
  34. { "#t", 1 },
  35. { 0, 0 }
  36. };
  37. static const CGEN_ATTR_ENTRY MACH_attr[] ATTRIBUTE_UNUSED =
  38. {
  39. { "base", MACH_BASE },
  40. { "ms1", MACH_MS1 },
  41. { "ms1_003", MACH_MS1_003 },
  42. { "ms2", MACH_MS2 },
  43. { "max", MACH_MAX },
  44. { 0, 0 }
  45. };
  46. static const CGEN_ATTR_ENTRY ISA_attr[] ATTRIBUTE_UNUSED =
  47. {
  48. { "mt", ISA_MT },
  49. { "max", ISA_MAX },
  50. { 0, 0 }
  51. };
  52. const CGEN_ATTR_TABLE mt_cgen_ifield_attr_table[] =
  53. {
  54. { "MACH", & MACH_attr[0], & MACH_attr[0] },
  55. { "VIRTUAL", &bool_attr[0], &bool_attr[0] },
  56. { "PCREL-ADDR", &bool_attr[0], &bool_attr[0] },
  57. { "ABS-ADDR", &bool_attr[0], &bool_attr[0] },
  58. { "RESERVED", &bool_attr[0], &bool_attr[0] },
  59. { "SIGN-OPT", &bool_attr[0], &bool_attr[0] },
  60. { "SIGNED", &bool_attr[0], &bool_attr[0] },
  61. { 0, 0, 0 }
  62. };
  63. const CGEN_ATTR_TABLE mt_cgen_hardware_attr_table[] =
  64. {
  65. { "MACH", & MACH_attr[0], & MACH_attr[0] },
  66. { "VIRTUAL", &bool_attr[0], &bool_attr[0] },
  67. { "CACHE-ADDR", &bool_attr[0], &bool_attr[0] },
  68. { "PC", &bool_attr[0], &bool_attr[0] },
  69. { "PROFILE", &bool_attr[0], &bool_attr[0] },
  70. { 0, 0, 0 }
  71. };
  72. const CGEN_ATTR_TABLE mt_cgen_operand_attr_table[] =
  73. {
  74. { "MACH", & MACH_attr[0], & MACH_attr[0] },
  75. { "VIRTUAL", &bool_attr[0], &bool_attr[0] },
  76. { "PCREL-ADDR", &bool_attr[0], &bool_attr[0] },
  77. { "ABS-ADDR", &bool_attr[0], &bool_attr[0] },
  78. { "SIGN-OPT", &bool_attr[0], &bool_attr[0] },
  79. { "SIGNED", &bool_attr[0], &bool_attr[0] },
  80. { "NEGATIVE", &bool_attr[0], &bool_attr[0] },
  81. { "RELAX", &bool_attr[0], &bool_attr[0] },
  82. { "SEM-ONLY", &bool_attr[0], &bool_attr[0] },
  83. { 0, 0, 0 }
  84. };
  85. const CGEN_ATTR_TABLE mt_cgen_insn_attr_table[] =
  86. {
  87. { "MACH", & MACH_attr[0], & MACH_attr[0] },
  88. { "ALIAS", &bool_attr[0], &bool_attr[0] },
  89. { "VIRTUAL", &bool_attr[0], &bool_attr[0] },
  90. { "UNCOND-CTI", &bool_attr[0], &bool_attr[0] },
  91. { "COND-CTI", &bool_attr[0], &bool_attr[0] },
  92. { "SKIP-CTI", &bool_attr[0], &bool_attr[0] },
  93. { "DELAY-SLOT", &bool_attr[0], &bool_attr[0] },
  94. { "RELAXABLE", &bool_attr[0], &bool_attr[0] },
  95. { "RELAXED", &bool_attr[0], &bool_attr[0] },
  96. { "NO-DIS", &bool_attr[0], &bool_attr[0] },
  97. { "PBB", &bool_attr[0], &bool_attr[0] },
  98. { "LOAD-DELAY", &bool_attr[0], &bool_attr[0] },
  99. { "MEMORY-ACCESS", &bool_attr[0], &bool_attr[0] },
  100. { "AL-INSN", &bool_attr[0], &bool_attr[0] },
  101. { "IO-INSN", &bool_attr[0], &bool_attr[0] },
  102. { "BR-INSN", &bool_attr[0], &bool_attr[0] },
  103. { "JAL-HAZARD", &bool_attr[0], &bool_attr[0] },
  104. { "USES-FRDR", &bool_attr[0], &bool_attr[0] },
  105. { "USES-FRDRRR", &bool_attr[0], &bool_attr[0] },
  106. { "USES-FRSR1", &bool_attr[0], &bool_attr[0] },
  107. { "USES-FRSR2", &bool_attr[0], &bool_attr[0] },
  108. { "SKIPA", &bool_attr[0], &bool_attr[0] },
  109. { 0, 0, 0 }
  110. };
  111. /* Instruction set variants. */
  112. static const CGEN_ISA mt_cgen_isa_table[] = {
  113. { "mt", 32, 32, 32, 32 },
  114. { 0, 0, 0, 0, 0 }
  115. };
  116. /* Machine variants. */
  117. static const CGEN_MACH mt_cgen_mach_table[] = {
  118. { "ms1", "ms1", MACH_MS1, 0 },
  119. { "ms1-003", "ms1-003", MACH_MS1_003, 0 },
  120. { "ms2", "ms2", MACH_MS2, 0 },
  121. { 0, 0, 0, 0 }
  122. };
  123. static CGEN_KEYWORD_ENTRY mt_cgen_opval_msys_syms_entries[] =
  124. {
  125. { "DUP", 1, {0, {{{0, 0}}}}, 0, 0 },
  126. { "XX", 0, {0, {{{0, 0}}}}, 0, 0 }
  127. };
  128. CGEN_KEYWORD mt_cgen_opval_msys_syms =
  129. {
  130. & mt_cgen_opval_msys_syms_entries[0],
  131. 2,
  132. 0, 0, 0, 0, ""
  133. };
  134. static CGEN_KEYWORD_ENTRY mt_cgen_opval_h_spr_entries[] =
  135. {
  136. { "R0", 0, {0, {{{0, 0}}}}, 0, 0 },
  137. { "R1", 1, {0, {{{0, 0}}}}, 0, 0 },
  138. { "R2", 2, {0, {{{0, 0}}}}, 0, 0 },
  139. { "R3", 3, {0, {{{0, 0}}}}, 0, 0 },
  140. { "R4", 4, {0, {{{0, 0}}}}, 0, 0 },
  141. { "R5", 5, {0, {{{0, 0}}}}, 0, 0 },
  142. { "R6", 6, {0, {{{0, 0}}}}, 0, 0 },
  143. { "R7", 7, {0, {{{0, 0}}}}, 0, 0 },
  144. { "R8", 8, {0, {{{0, 0}}}}, 0, 0 },
  145. { "R9", 9, {0, {{{0, 0}}}}, 0, 0 },
  146. { "R10", 10, {0, {{{0, 0}}}}, 0, 0 },
  147. { "R11", 11, {0, {{{0, 0}}}}, 0, 0 },
  148. { "R12", 12, {0, {{{0, 0}}}}, 0, 0 },
  149. { "fp", 12, {0, {{{0, 0}}}}, 0, 0 },
  150. { "R13", 13, {0, {{{0, 0}}}}, 0, 0 },
  151. { "sp", 13, {0, {{{0, 0}}}}, 0, 0 },
  152. { "R14", 14, {0, {{{0, 0}}}}, 0, 0 },
  153. { "ra", 14, {0, {{{0, 0}}}}, 0, 0 },
  154. { "R15", 15, {0, {{{0, 0}}}}, 0, 0 },
  155. { "ira", 15, {0, {{{0, 0}}}}, 0, 0 }
  156. };
  157. CGEN_KEYWORD mt_cgen_opval_h_spr =
  158. {
  159. & mt_cgen_opval_h_spr_entries[0],
  160. 20,
  161. 0, 0, 0, 0, ""
  162. };
  163. /* The hardware table. */
  164. #define A(a) (1 << CGEN_HW_##a)
  165. const CGEN_HW_ENTRY mt_cgen_hw_table[] =
  166. {
  167. { "h-memory", HW_H_MEMORY, CGEN_ASM_NONE, 0, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  168. { "h-sint", HW_H_SINT, CGEN_ASM_NONE, 0, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  169. { "h-uint", HW_H_UINT, CGEN_ASM_NONE, 0, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  170. { "h-addr", HW_H_ADDR, CGEN_ASM_NONE, 0, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  171. { "h-iaddr", HW_H_IADDR, CGEN_ASM_NONE, 0, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  172. { "h-spr", HW_H_SPR, CGEN_ASM_KEYWORD, (PTR) & mt_cgen_opval_h_spr, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  173. { "h-pc", HW_H_PC, CGEN_ASM_NONE, 0, { 0|A(PROFILE)|A(PC), { { { (1<<MACH_BASE), 0 } } } } },
  174. { 0, 0, CGEN_ASM_NONE, 0, { 0, { { { (1<<MACH_BASE), 0 } } } } }
  175. };
  176. #undef A
  177. /* The instruction field table. */
  178. #define A(a) (1 << CGEN_IFLD_##a)
  179. const CGEN_IFLD mt_cgen_ifld_table[] =
  180. {
  181. { MT_F_NIL, "f-nil", 0, 0, 0, 0, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  182. { MT_F_ANYOF, "f-anyof", 0, 0, 0, 0, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  183. { MT_F_MSYS, "f-msys", 0, 32, 31, 1, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  184. { MT_F_OPC, "f-opc", 0, 32, 30, 6, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  185. { MT_F_IMM, "f-imm", 0, 32, 24, 1, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  186. { MT_F_UU24, "f-uu24", 0, 32, 23, 24, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  187. { MT_F_SR1, "f-sr1", 0, 32, 23, 4, { 0|A(ABS_ADDR), { { { (1<<MACH_BASE), 0 } } } } },
  188. { MT_F_SR2, "f-sr2", 0, 32, 19, 4, { 0|A(ABS_ADDR), { { { (1<<MACH_BASE), 0 } } } } },
  189. { MT_F_DR, "f-dr", 0, 32, 19, 4, { 0|A(ABS_ADDR), { { { (1<<MACH_BASE), 0 } } } } },
  190. { MT_F_DRRR, "f-drrr", 0, 32, 15, 4, { 0|A(ABS_ADDR), { { { (1<<MACH_BASE), 0 } } } } },
  191. { MT_F_IMM16U, "f-imm16u", 0, 32, 15, 16, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  192. { MT_F_IMM16S, "f-imm16s", 0, 32, 15, 16, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  193. { MT_F_IMM16A, "f-imm16a", 0, 32, 15, 16, { 0|A(PCREL_ADDR), { { { (1<<MACH_BASE), 0 } } } } },
  194. { MT_F_UU4A, "f-uu4a", 0, 32, 19, 4, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  195. { MT_F_UU4B, "f-uu4b", 0, 32, 23, 4, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  196. { MT_F_UU12, "f-uu12", 0, 32, 11, 12, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  197. { MT_F_UU8, "f-uu8", 0, 32, 15, 8, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  198. { MT_F_UU16, "f-uu16", 0, 32, 15, 16, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  199. { MT_F_UU1, "f-uu1", 0, 32, 7, 1, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  200. { MT_F_MSOPC, "f-msopc", 0, 32, 30, 5, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  201. { MT_F_UU_26_25, "f-uu-26-25", 0, 32, 25, 26, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  202. { MT_F_MASK, "f-mask", 0, 32, 25, 16, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  203. { MT_F_BANKADDR, "f-bankaddr", 0, 32, 25, 13, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  204. { MT_F_RDA, "f-rda", 0, 32, 25, 1, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  205. { MT_F_UU_2_25, "f-uu-2-25", 0, 32, 25, 2, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  206. { MT_F_RBBC, "f-rbbc", 0, 32, 25, 2, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  207. { MT_F_PERM, "f-perm", 0, 32, 25, 2, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  208. { MT_F_MODE, "f-mode", 0, 32, 25, 2, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  209. { MT_F_UU_1_24, "f-uu-1-24", 0, 32, 24, 1, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  210. { MT_F_WR, "f-wr", 0, 32, 24, 1, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  211. { MT_F_FBINCR, "f-fbincr", 0, 32, 23, 4, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  212. { MT_F_UU_2_23, "f-uu-2-23", 0, 32, 23, 2, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  213. { MT_F_XMODE, "f-xmode", 0, 32, 23, 1, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  214. { MT_F_A23, "f-a23", 0, 32, 23, 1, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  215. { MT_F_MASK1, "f-mask1", 0, 32, 22, 3, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  216. { MT_F_CR, "f-cr", 0, 32, 22, 3, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  217. { MT_F_TYPE, "f-type", 0, 32, 21, 2, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  218. { MT_F_INCAMT, "f-incamt", 0, 32, 19, 8, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  219. { MT_F_CBS, "f-cbs", 0, 32, 19, 2, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  220. { MT_F_UU_1_19, "f-uu-1-19", 0, 32, 19, 1, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  221. { MT_F_BALL, "f-ball", 0, 32, 19, 1, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  222. { MT_F_COLNUM, "f-colnum", 0, 32, 18, 3, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  223. { MT_F_BRC, "f-brc", 0, 32, 18, 3, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  224. { MT_F_INCR, "f-incr", 0, 32, 17, 6, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  225. { MT_F_FBDISP, "f-fbdisp", 0, 32, 15, 6, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  226. { MT_F_UU_4_15, "f-uu-4-15", 0, 32, 15, 4, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  227. { MT_F_LENGTH, "f-length", 0, 32, 15, 3, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  228. { MT_F_UU_1_15, "f-uu-1-15", 0, 32, 15, 1, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  229. { MT_F_RC, "f-rc", 0, 32, 15, 1, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  230. { MT_F_RCNUM, "f-rcnum", 0, 32, 14, 3, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  231. { MT_F_ROWNUM, "f-rownum", 0, 32, 14, 3, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  232. { MT_F_CBX, "f-cbx", 0, 32, 14, 3, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  233. { MT_F_ID, "f-id", 0, 32, 14, 1, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  234. { MT_F_SIZE, "f-size", 0, 32, 13, 14, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  235. { MT_F_ROWNUM1, "f-rownum1", 0, 32, 12, 3, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  236. { MT_F_UU_3_11, "f-uu-3-11", 0, 32, 11, 3, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  237. { MT_F_RC1, "f-rc1", 0, 32, 11, 1, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  238. { MT_F_CCB, "f-ccb", 0, 32, 11, 1, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  239. { MT_F_CBRB, "f-cbrb", 0, 32, 10, 1, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  240. { MT_F_CDB, "f-cdb", 0, 32, 10, 1, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  241. { MT_F_ROWNUM2, "f-rownum2", 0, 32, 9, 3, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  242. { MT_F_CELL, "f-cell", 0, 32, 9, 3, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  243. { MT_F_UU_3_9, "f-uu-3-9", 0, 32, 9, 3, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  244. { MT_F_CONTNUM, "f-contnum", 0, 32, 8, 9, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  245. { MT_F_UU_1_6, "f-uu-1-6", 0, 32, 6, 1, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  246. { MT_F_DUP, "f-dup", 0, 32, 6, 1, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  247. { MT_F_RC2, "f-rc2", 0, 32, 6, 1, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  248. { MT_F_CTXDISP, "f-ctxdisp", 0, 32, 5, 6, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  249. { MT_F_IMM16L, "f-imm16l", 0, 32, 23, 16, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  250. { MT_F_LOOPO, "f-loopo", 0, 32, 7, 8, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  251. { MT_F_CB1SEL, "f-cb1sel", 0, 32, 25, 3, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  252. { MT_F_CB2SEL, "f-cb2sel", 0, 32, 22, 3, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  253. { MT_F_CB1INCR, "f-cb1incr", 0, 32, 19, 6, { 0|A(SIGNED), { { { (1<<MACH_BASE), 0 } } } } },
  254. { MT_F_CB2INCR, "f-cb2incr", 0, 32, 13, 6, { 0|A(SIGNED), { { { (1<<MACH_BASE), 0 } } } } },
  255. { MT_F_RC3, "f-rc3", 0, 32, 7, 1, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  256. { MT_F_MSYSFRSR2, "f-msysfrsr2", 0, 32, 19, 4, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  257. { MT_F_BRC2, "f-brc2", 0, 32, 14, 3, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  258. { MT_F_BALL2, "f-ball2", 0, 32, 15, 1, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  259. { 0, 0, 0, 0, 0, 0, { 0, { { { (1<<MACH_BASE), 0 } } } } }
  260. };
  261. #undef A
  262. /* multi ifield declarations */
  263. /* multi ifield definitions */
  264. /* The operand table. */
  265. #define A(a) (1 << CGEN_OPERAND_##a)
  266. #define OPERAND(op) MT_OPERAND_##op
  267. const CGEN_OPERAND mt_cgen_operand_table[] =
  268. {
  269. /* pc: program counter */
  270. { "pc", MT_OPERAND_PC, HW_H_PC, 0, 0,
  271. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_NIL] } },
  272. { 0|A(SEM_ONLY), { { { (1<<MACH_BASE), 0 } } } } },
  273. /* frsr1: register */
  274. { "frsr1", MT_OPERAND_FRSR1, HW_H_SPR, 23, 4,
  275. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_SR1] } },
  276. { 0|A(ABS_ADDR), { { { (1<<MACH_BASE), 0 } } } } },
  277. /* frsr2: register */
  278. { "frsr2", MT_OPERAND_FRSR2, HW_H_SPR, 19, 4,
  279. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_SR2] } },
  280. { 0|A(ABS_ADDR), { { { (1<<MACH_BASE), 0 } } } } },
  281. /* frdr: register */
  282. { "frdr", MT_OPERAND_FRDR, HW_H_SPR, 19, 4,
  283. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_DR] } },
  284. { 0|A(ABS_ADDR), { { { (1<<MACH_BASE), 0 } } } } },
  285. /* frdrrr: register */
  286. { "frdrrr", MT_OPERAND_FRDRRR, HW_H_SPR, 15, 4,
  287. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_DRRR] } },
  288. { 0|A(ABS_ADDR), { { { (1<<MACH_BASE), 0 } } } } },
  289. /* imm16: immediate value - sign extd */
  290. { "imm16", MT_OPERAND_IMM16, HW_H_SINT, 15, 16,
  291. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_IMM16S] } },
  292. { 0, { { { (1<<MACH_BASE), 0 } } } } },
  293. /* imm16z: immediate value - zero extd */
  294. { "imm16z", MT_OPERAND_IMM16Z, HW_H_UINT, 15, 16,
  295. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_IMM16U] } },
  296. { 0, { { { (1<<MACH_BASE), 0 } } } } },
  297. /* imm16o: immediate value */
  298. { "imm16o", MT_OPERAND_IMM16O, HW_H_UINT, 15, 16,
  299. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_IMM16S] } },
  300. { 0|A(PCREL_ADDR), { { { (1<<MACH_BASE), 0 } } } } },
  301. /* rc: rc */
  302. { "rc", MT_OPERAND_RC, HW_H_UINT, 15, 1,
  303. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_RC] } },
  304. { 0, { { { (1<<MACH_BASE), 0 } } } } },
  305. /* rcnum: rcnum */
  306. { "rcnum", MT_OPERAND_RCNUM, HW_H_UINT, 14, 3,
  307. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_RCNUM] } },
  308. { 0, { { { (1<<MACH_BASE), 0 } } } } },
  309. /* contnum: context number */
  310. { "contnum", MT_OPERAND_CONTNUM, HW_H_UINT, 8, 9,
  311. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_CONTNUM] } },
  312. { 0, { { { (1<<MACH_BASE), 0 } } } } },
  313. /* rbbc: omega network configuration */
  314. { "rbbc", MT_OPERAND_RBBC, HW_H_UINT, 25, 2,
  315. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_RBBC] } },
  316. { 0, { { { (1<<MACH_BASE), 0 } } } } },
  317. /* colnum: column number */
  318. { "colnum", MT_OPERAND_COLNUM, HW_H_UINT, 18, 3,
  319. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_COLNUM] } },
  320. { 0, { { { (1<<MACH_BASE), 0 } } } } },
  321. /* rownum: row number */
  322. { "rownum", MT_OPERAND_ROWNUM, HW_H_UINT, 14, 3,
  323. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_ROWNUM] } },
  324. { 0, { { { (1<<MACH_BASE), 0 } } } } },
  325. /* rownum1: row number */
  326. { "rownum1", MT_OPERAND_ROWNUM1, HW_H_UINT, 12, 3,
  327. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_ROWNUM1] } },
  328. { 0, { { { (1<<MACH_BASE), 0 } } } } },
  329. /* rownum2: row number */
  330. { "rownum2", MT_OPERAND_ROWNUM2, HW_H_UINT, 9, 3,
  331. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_ROWNUM2] } },
  332. { 0, { { { (1<<MACH_BASE), 0 } } } } },
  333. /* rc1: rc1 */
  334. { "rc1", MT_OPERAND_RC1, HW_H_UINT, 11, 1,
  335. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_RC1] } },
  336. { 0, { { { (1<<MACH_BASE), 0 } } } } },
  337. /* rc2: rc2 */
  338. { "rc2", MT_OPERAND_RC2, HW_H_UINT, 6, 1,
  339. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_RC2] } },
  340. { 0, { { { (1<<MACH_BASE), 0 } } } } },
  341. /* cbrb: data-bus orientation */
  342. { "cbrb", MT_OPERAND_CBRB, HW_H_UINT, 10, 1,
  343. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_CBRB] } },
  344. { 0, { { { (1<<MACH_BASE), 0 } } } } },
  345. /* cell: cell */
  346. { "cell", MT_OPERAND_CELL, HW_H_UINT, 9, 3,
  347. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_CELL] } },
  348. { 0, { { { (1<<MACH_BASE), 0 } } } } },
  349. /* dup: dup */
  350. { "dup", MT_OPERAND_DUP, HW_H_UINT, 6, 1,
  351. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_DUP] } },
  352. { 0, { { { (1<<MACH_BASE), 0 } } } } },
  353. /* ctxdisp: context displacement */
  354. { "ctxdisp", MT_OPERAND_CTXDISP, HW_H_UINT, 5, 6,
  355. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_CTXDISP] } },
  356. { 0, { { { (1<<MACH_BASE), 0 } } } } },
  357. /* fbdisp: frame buffer displacement */
  358. { "fbdisp", MT_OPERAND_FBDISP, HW_H_UINT, 15, 6,
  359. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_FBDISP] } },
  360. { 0, { { { (1<<MACH_BASE), 0 } } } } },
  361. /* type: type */
  362. { "type", MT_OPERAND_TYPE, HW_H_UINT, 21, 2,
  363. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_TYPE] } },
  364. { 0, { { { (1<<MACH_BASE), 0 } } } } },
  365. /* mask: mask */
  366. { "mask", MT_OPERAND_MASK, HW_H_UINT, 25, 16,
  367. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_MASK] } },
  368. { 0, { { { (1<<MACH_BASE), 0 } } } } },
  369. /* bankaddr: bank address */
  370. { "bankaddr", MT_OPERAND_BANKADDR, HW_H_UINT, 25, 13,
  371. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_BANKADDR] } },
  372. { 0, { { { (1<<MACH_BASE), 0 } } } } },
  373. /* incamt: increment amount */
  374. { "incamt", MT_OPERAND_INCAMT, HW_H_UINT, 19, 8,
  375. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_INCAMT] } },
  376. { 0, { { { (1<<MACH_BASE), 0 } } } } },
  377. /* xmode: xmode */
  378. { "xmode", MT_OPERAND_XMODE, HW_H_UINT, 23, 1,
  379. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_XMODE] } },
  380. { 0, { { { (1<<MACH_BASE), 0 } } } } },
  381. /* mask1: mask1 */
  382. { "mask1", MT_OPERAND_MASK1, HW_H_UINT, 22, 3,
  383. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_MASK1] } },
  384. { 0, { { { (1<<MACH_BASE), 0 } } } } },
  385. /* ball: b_all */
  386. { "ball", MT_OPERAND_BALL, HW_H_UINT, 19, 1,
  387. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_BALL] } },
  388. { 0, { { { (1<<MACH_BASE), 0 } } } } },
  389. /* brc: b_r_c */
  390. { "brc", MT_OPERAND_BRC, HW_H_UINT, 18, 3,
  391. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_BRC] } },
  392. { 0, { { { (1<<MACH_BASE), 0 } } } } },
  393. /* rda: rd */
  394. { "rda", MT_OPERAND_RDA, HW_H_UINT, 25, 1,
  395. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_RDA] } },
  396. { 0, { { { (1<<MACH_BASE), 0 } } } } },
  397. /* wr: wr */
  398. { "wr", MT_OPERAND_WR, HW_H_UINT, 24, 1,
  399. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_WR] } },
  400. { 0, { { { (1<<MACH_BASE), 0 } } } } },
  401. /* ball2: b_all2 */
  402. { "ball2", MT_OPERAND_BALL2, HW_H_UINT, 15, 1,
  403. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_BALL2] } },
  404. { 0, { { { (1<<MACH_BASE), 0 } } } } },
  405. /* brc2: b_r_c2 */
  406. { "brc2", MT_OPERAND_BRC2, HW_H_UINT, 14, 3,
  407. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_BRC2] } },
  408. { 0, { { { (1<<MACH_BASE), 0 } } } } },
  409. /* perm: perm */
  410. { "perm", MT_OPERAND_PERM, HW_H_UINT, 25, 2,
  411. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_PERM] } },
  412. { 0, { { { (1<<MACH_BASE), 0 } } } } },
  413. /* a23: a23 */
  414. { "a23", MT_OPERAND_A23, HW_H_UINT, 23, 1,
  415. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_A23] } },
  416. { 0, { { { (1<<MACH_BASE), 0 } } } } },
  417. /* cr: c-r */
  418. { "cr", MT_OPERAND_CR, HW_H_UINT, 22, 3,
  419. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_CR] } },
  420. { 0, { { { (1<<MACH_BASE), 0 } } } } },
  421. /* cbs: cbs */
  422. { "cbs", MT_OPERAND_CBS, HW_H_UINT, 19, 2,
  423. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_CBS] } },
  424. { 0, { { { (1<<MACH_BASE), 0 } } } } },
  425. /* incr: incr */
  426. { "incr", MT_OPERAND_INCR, HW_H_UINT, 17, 6,
  427. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_INCR] } },
  428. { 0, { { { (1<<MACH_BASE), 0 } } } } },
  429. /* length: length */
  430. { "length", MT_OPERAND_LENGTH, HW_H_UINT, 15, 3,
  431. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_LENGTH] } },
  432. { 0, { { { (1<<MACH_BASE), 0 } } } } },
  433. /* cbx: cbx */
  434. { "cbx", MT_OPERAND_CBX, HW_H_UINT, 14, 3,
  435. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_CBX] } },
  436. { 0, { { { (1<<MACH_BASE), 0 } } } } },
  437. /* ccb: ccb */
  438. { "ccb", MT_OPERAND_CCB, HW_H_UINT, 11, 1,
  439. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_CCB] } },
  440. { 0, { { { (1<<MACH_BASE), 0 } } } } },
  441. /* cdb: cdb */
  442. { "cdb", MT_OPERAND_CDB, HW_H_UINT, 10, 1,
  443. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_CDB] } },
  444. { 0, { { { (1<<MACH_BASE), 0 } } } } },
  445. /* mode: mode */
  446. { "mode", MT_OPERAND_MODE, HW_H_UINT, 25, 2,
  447. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_MODE] } },
  448. { 0, { { { (1<<MACH_BASE), 0 } } } } },
  449. /* id: i/d */
  450. { "id", MT_OPERAND_ID, HW_H_UINT, 14, 1,
  451. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_ID] } },
  452. { 0, { { { (1<<MACH_BASE), 0 } } } } },
  453. /* size: size */
  454. { "size", MT_OPERAND_SIZE, HW_H_UINT, 13, 14,
  455. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_SIZE] } },
  456. { 0, { { { (1<<MACH_BASE), 0 } } } } },
  457. /* fbincr: fb incr */
  458. { "fbincr", MT_OPERAND_FBINCR, HW_H_UINT, 23, 4,
  459. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_FBINCR] } },
  460. { 0, { { { (1<<MACH_BASE), 0 } } } } },
  461. /* loopsize: immediate value */
  462. { "loopsize", MT_OPERAND_LOOPSIZE, HW_H_UINT, 7, 8,
  463. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_LOOPO] } },
  464. { 0|A(PCREL_ADDR), { { { (1<<MACH_MS2), 0 } } } } },
  465. /* imm16l: immediate value */
  466. { "imm16l", MT_OPERAND_IMM16L, HW_H_UINT, 23, 16,
  467. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_IMM16L] } },
  468. { 0, { { { (1<<MACH_MS2), 0 } } } } },
  469. /* rc3: rc3 */
  470. { "rc3", MT_OPERAND_RC3, HW_H_UINT, 7, 1,
  471. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_RC3] } },
  472. { 0, { { { (1<<MACH_MS2), 0 } } } } },
  473. /* cb1sel: cb1sel */
  474. { "cb1sel", MT_OPERAND_CB1SEL, HW_H_UINT, 25, 3,
  475. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_CB1SEL] } },
  476. { 0, { { { (1<<MACH_MS2), 0 } } } } },
  477. /* cb2sel: cb2sel */
  478. { "cb2sel", MT_OPERAND_CB2SEL, HW_H_UINT, 22, 3,
  479. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_CB2SEL] } },
  480. { 0, { { { (1<<MACH_MS2), 0 } } } } },
  481. /* cb1incr: cb1incr */
  482. { "cb1incr", MT_OPERAND_CB1INCR, HW_H_SINT, 19, 6,
  483. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_CB1INCR] } },
  484. { 0|A(SIGNED), { { { (1<<MACH_MS2), 0 } } } } },
  485. /* cb2incr: cb2incr */
  486. { "cb2incr", MT_OPERAND_CB2INCR, HW_H_SINT, 13, 6,
  487. { 0, { (const PTR) &mt_cgen_ifld_table[MT_F_CB2INCR] } },
  488. { 0|A(SIGNED), { { { (1<<MACH_MS2), 0 } } } } },
  489. /* sentinel */
  490. { 0, 0, 0, 0, 0,
  491. { 0, { (const PTR) 0 } },
  492. { 0, { { { (1<<MACH_BASE), 0 } } } } }
  493. };
  494. #undef A
  495. /* The instruction table. */
  496. #define OP(field) CGEN_SYNTAX_MAKE_FIELD (OPERAND (field))
  497. #define A(a) (1 << CGEN_INSN_##a)
  498. static const CGEN_IBASE mt_cgen_insn_table[MAX_INSNS] =
  499. {
  500. /* Special null first entry.
  501. A `num' value of zero is thus invalid.
  502. Also, the special `invalid' insn resides here. */
  503. { 0, 0, 0, 0, { 0, { { { (1<<MACH_BASE), 0 } } } } },
  504. /* add $frdrrr,$frsr1,$frsr2 */
  505. {
  506. MT_INSN_ADD, "add", "add", 32,
  507. { 0|A(USES_FRSR2)|A(USES_FRSR1)|A(USES_FRDRRR)|A(AL_INSN), { { { (1<<MACH_BASE), 0 } } } }
  508. },
  509. /* addu $frdrrr,$frsr1,$frsr2 */
  510. {
  511. MT_INSN_ADDU, "addu", "addu", 32,
  512. { 0|A(USES_FRSR2)|A(USES_FRSR1)|A(USES_FRDRRR)|A(AL_INSN), { { { (1<<MACH_BASE), 0 } } } }
  513. },
  514. /* addi $frdr,$frsr1,#$imm16 */
  515. {
  516. MT_INSN_ADDI, "addi", "addi", 32,
  517. { 0|A(USES_FRSR1)|A(USES_FRDR)|A(AL_INSN), { { { (1<<MACH_BASE), 0 } } } }
  518. },
  519. /* addui $frdr,$frsr1,#$imm16z */
  520. {
  521. MT_INSN_ADDUI, "addui", "addui", 32,
  522. { 0|A(USES_FRSR1)|A(USES_FRDR)|A(AL_INSN), { { { (1<<MACH_BASE), 0 } } } }
  523. },
  524. /* sub $frdrrr,$frsr1,$frsr2 */
  525. {
  526. MT_INSN_SUB, "sub", "sub", 32,
  527. { 0|A(USES_FRSR2)|A(USES_FRSR1)|A(USES_FRDRRR)|A(AL_INSN), { { { (1<<MACH_BASE), 0 } } } }
  528. },
  529. /* subu $frdrrr,$frsr1,$frsr2 */
  530. {
  531. MT_INSN_SUBU, "subu", "subu", 32,
  532. { 0|A(USES_FRSR2)|A(USES_FRSR1)|A(USES_FRDRRR)|A(AL_INSN), { { { (1<<MACH_BASE), 0 } } } }
  533. },
  534. /* subi $frdr,$frsr1,#$imm16 */
  535. {
  536. MT_INSN_SUBI, "subi", "subi", 32,
  537. { 0|A(USES_FRSR1)|A(USES_FRDR)|A(AL_INSN), { { { (1<<MACH_BASE), 0 } } } }
  538. },
  539. /* subui $frdr,$frsr1,#$imm16z */
  540. {
  541. MT_INSN_SUBUI, "subui", "subui", 32,
  542. { 0|A(USES_FRSR1)|A(USES_FRDR)|A(AL_INSN), { { { (1<<MACH_BASE), 0 } } } }
  543. },
  544. /* mul $frdrrr,$frsr1,$frsr2 */
  545. {
  546. MT_INSN_MUL, "mul", "mul", 32,
  547. { 0|A(USES_FRSR2)|A(USES_FRSR1)|A(USES_FRDRRR)|A(AL_INSN), { { { (1<<MACH_MS1_003)|(1<<MACH_MS2), 0 } } } }
  548. },
  549. /* muli $frdr,$frsr1,#$imm16 */
  550. {
  551. MT_INSN_MULI, "muli", "muli", 32,
  552. { 0|A(USES_FRSR1)|A(USES_FRDR)|A(AL_INSN), { { { (1<<MACH_MS1_003)|(1<<MACH_MS2), 0 } } } }
  553. },
  554. /* and $frdrrr,$frsr1,$frsr2 */
  555. {
  556. MT_INSN_AND, "and", "and", 32,
  557. { 0|A(USES_FRSR2)|A(USES_FRSR1)|A(USES_FRDRRR)|A(AL_INSN), { { { (1<<MACH_BASE), 0 } } } }
  558. },
  559. /* andi $frdr,$frsr1,#$imm16z */
  560. {
  561. MT_INSN_ANDI, "andi", "andi", 32,
  562. { 0|A(USES_FRSR1)|A(USES_FRDR)|A(AL_INSN), { { { (1<<MACH_BASE), 0 } } } }
  563. },
  564. /* or $frdrrr,$frsr1,$frsr2 */
  565. {
  566. MT_INSN_OR, "or", "or", 32,
  567. { 0|A(USES_FRSR2)|A(USES_FRSR1)|A(USES_FRDRRR)|A(AL_INSN), { { { (1<<MACH_BASE), 0 } } } }
  568. },
  569. /* nop */
  570. {
  571. MT_INSN_NOP, "nop", "nop", 32,
  572. { 0, { { { (1<<MACH_BASE), 0 } } } }
  573. },
  574. /* ori $frdr,$frsr1,#$imm16z */
  575. {
  576. MT_INSN_ORI, "ori", "ori", 32,
  577. { 0|A(USES_FRSR1)|A(USES_FRDR)|A(AL_INSN), { { { (1<<MACH_BASE), 0 } } } }
  578. },
  579. /* xor $frdrrr,$frsr1,$frsr2 */
  580. {
  581. MT_INSN_XOR, "xor", "xor", 32,
  582. { 0|A(USES_FRSR2)|A(USES_FRSR1)|A(USES_FRDRRR)|A(AL_INSN), { { { (1<<MACH_BASE), 0 } } } }
  583. },
  584. /* xori $frdr,$frsr1,#$imm16z */
  585. {
  586. MT_INSN_XORI, "xori", "xori", 32,
  587. { 0|A(USES_FRSR1)|A(USES_FRDR)|A(AL_INSN), { { { (1<<MACH_BASE), 0 } } } }
  588. },
  589. /* nand $frdrrr,$frsr1,$frsr2 */
  590. {
  591. MT_INSN_NAND, "nand", "nand", 32,
  592. { 0|A(USES_FRSR2)|A(USES_FRSR1)|A(USES_FRDRRR)|A(AL_INSN), { { { (1<<MACH_BASE), 0 } } } }
  593. },
  594. /* nandi $frdr,$frsr1,#$imm16z */
  595. {
  596. MT_INSN_NANDI, "nandi", "nandi", 32,
  597. { 0|A(USES_FRSR1)|A(USES_FRDR)|A(AL_INSN), { { { (1<<MACH_BASE), 0 } } } }
  598. },
  599. /* nor $frdrrr,$frsr1,$frsr2 */
  600. {
  601. MT_INSN_NOR, "nor", "nor", 32,
  602. { 0|A(USES_FRSR2)|A(USES_FRSR1)|A(USES_FRDRRR)|A(AL_INSN), { { { (1<<MACH_BASE), 0 } } } }
  603. },
  604. /* nori $frdr,$frsr1,#$imm16z */
  605. {
  606. MT_INSN_NORI, "nori", "nori", 32,
  607. { 0|A(USES_FRSR1)|A(USES_FRDR)|A(AL_INSN), { { { (1<<MACH_BASE), 0 } } } }
  608. },
  609. /* xnor $frdrrr,$frsr1,$frsr2 */
  610. {
  611. MT_INSN_XNOR, "xnor", "xnor", 32,
  612. { 0|A(USES_FRSR2)|A(USES_FRSR1)|A(USES_FRDRRR)|A(AL_INSN), { { { (1<<MACH_BASE), 0 } } } }
  613. },
  614. /* xnori $frdr,$frsr1,#$imm16z */
  615. {
  616. MT_INSN_XNORI, "xnori", "xnori", 32,
  617. { 0|A(USES_FRSR1)|A(USES_FRDR)|A(AL_INSN), { { { (1<<MACH_BASE), 0 } } } }
  618. },
  619. /* ldui $frdr,#$imm16z */
  620. {
  621. MT_INSN_LDUI, "ldui", "ldui", 32,
  622. { 0|A(USES_FRDR)|A(AL_INSN), { { { (1<<MACH_BASE), 0 } } } }
  623. },
  624. /* lsl $frdrrr,$frsr1,$frsr2 */
  625. {
  626. MT_INSN_LSL, "lsl", "lsl", 32,
  627. { 0|A(USES_FRSR2)|A(USES_FRSR1)|A(USES_FRDRRR), { { { (1<<MACH_BASE), 0 } } } }
  628. },
  629. /* lsli $frdr,$frsr1,#$imm16 */
  630. {
  631. MT_INSN_LSLI, "lsli", "lsli", 32,
  632. { 0|A(USES_FRSR1)|A(USES_FRDR), { { { (1<<MACH_BASE), 0 } } } }
  633. },
  634. /* lsr $frdrrr,$frsr1,$frsr2 */
  635. {
  636. MT_INSN_LSR, "lsr", "lsr", 32,
  637. { 0|A(USES_FRSR2)|A(USES_FRSR1)|A(USES_FRDRRR), { { { (1<<MACH_BASE), 0 } } } }
  638. },
  639. /* lsri $frdr,$frsr1,#$imm16 */
  640. {
  641. MT_INSN_LSRI, "lsri", "lsri", 32,
  642. { 0|A(USES_FRSR1)|A(USES_FRDR), { { { (1<<MACH_BASE), 0 } } } }
  643. },
  644. /* asr $frdrrr,$frsr1,$frsr2 */
  645. {
  646. MT_INSN_ASR, "asr", "asr", 32,
  647. { 0|A(USES_FRSR2)|A(USES_FRSR1)|A(USES_FRDRRR), { { { (1<<MACH_BASE), 0 } } } }
  648. },
  649. /* asri $frdr,$frsr1,#$imm16 */
  650. {
  651. MT_INSN_ASRI, "asri", "asri", 32,
  652. { 0|A(USES_FRSR1)|A(USES_FRDR), { { { (1<<MACH_BASE), 0 } } } }
  653. },
  654. /* brlt $frsr1,$frsr2,$imm16o */
  655. {
  656. MT_INSN_BRLT, "brlt", "brlt", 32,
  657. { 0|A(USES_FRSR2)|A(USES_FRSR1)|A(USES_FRDRRR)|A(DELAY_SLOT)|A(BR_INSN), { { { (1<<MACH_BASE), 0 } } } }
  658. },
  659. /* brle $frsr1,$frsr2,$imm16o */
  660. {
  661. MT_INSN_BRLE, "brle", "brle", 32,
  662. { 0|A(USES_FRSR2)|A(USES_FRSR1)|A(DELAY_SLOT)|A(BR_INSN), { { { (1<<MACH_BASE), 0 } } } }
  663. },
  664. /* breq $frsr1,$frsr2,$imm16o */
  665. {
  666. MT_INSN_BREQ, "breq", "breq", 32,
  667. { 0|A(USES_FRSR2)|A(USES_FRSR1)|A(DELAY_SLOT)|A(BR_INSN), { { { (1<<MACH_BASE), 0 } } } }
  668. },
  669. /* brne $frsr1,$frsr2,$imm16o */
  670. {
  671. MT_INSN_BRNE, "brne", "brne", 32,
  672. { 0|A(USES_FRSR2)|A(USES_FRSR1)|A(DELAY_SLOT)|A(BR_INSN), { { { (1<<MACH_BASE), 0 } } } }
  673. },
  674. /* jmp $imm16o */
  675. {
  676. MT_INSN_JMP, "jmp", "jmp", 32,
  677. { 0|A(BR_INSN)|A(DELAY_SLOT), { { { (1<<MACH_BASE), 0 } } } }
  678. },
  679. /* jal $frdrrr,$frsr1 */
  680. {
  681. MT_INSN_JAL, "jal", "jal", 32,
  682. { 0|A(JAL_HAZARD)|A(USES_FRSR1)|A(USES_FRDR)|A(BR_INSN)|A(DELAY_SLOT), { { { (1<<MACH_BASE), 0 } } } }
  683. },
  684. /* dbnz $frsr1,$imm16o */
  685. {
  686. MT_INSN_DBNZ, "dbnz", "dbnz", 32,
  687. { 0|A(USES_FRSR1)|A(DELAY_SLOT)|A(BR_INSN), { { { (1<<MACH_MS1_003)|(1<<MACH_MS2), 0 } } } }
  688. },
  689. /* ei */
  690. {
  691. MT_INSN_EI, "ei", "ei", 32,
  692. { 0, { { { (1<<MACH_BASE), 0 } } } }
  693. },
  694. /* di */
  695. {
  696. MT_INSN_DI, "di", "di", 32,
  697. { 0, { { { (1<<MACH_BASE), 0 } } } }
  698. },
  699. /* si $frdrrr */
  700. {
  701. MT_INSN_SI, "si", "si", 32,
  702. { 0|A(USES_FRDR)|A(BR_INSN)|A(DELAY_SLOT), { { { (1<<MACH_BASE), 0 } } } }
  703. },
  704. /* reti $frsr1 */
  705. {
  706. MT_INSN_RETI, "reti", "reti", 32,
  707. { 0|A(JAL_HAZARD)|A(USES_FRSR1)|A(BR_INSN)|A(DELAY_SLOT), { { { (1<<MACH_BASE), 0 } } } }
  708. },
  709. /* ldw $frdr,$frsr1,#$imm16 */
  710. {
  711. MT_INSN_LDW, "ldw", "ldw", 32,
  712. { 0|A(USES_FRSR1)|A(USES_FRDR)|A(MEMORY_ACCESS)|A(LOAD_DELAY), { { { (1<<MACH_BASE), 0 } } } }
  713. },
  714. /* stw $frsr2,$frsr1,#$imm16 */
  715. {
  716. MT_INSN_STW, "stw", "stw", 32,
  717. { 0|A(USES_FRSR2)|A(USES_FRSR1)|A(MEMORY_ACCESS), { { { (1<<MACH_BASE), 0 } } } }
  718. },
  719. /* break */
  720. {
  721. MT_INSN_BREAK, "break", "break", 32,
  722. { 0, { { { (1<<MACH_BASE), 0 } } } }
  723. },
  724. /* iflush */
  725. {
  726. MT_INSN_IFLUSH, "iflush", "iflush", 32,
  727. { 0, { { { (1<<MACH_MS1_003)|(1<<MACH_MS2), 0 } } } }
  728. },
  729. /* ldctxt $frsr1,$frsr2,#$rc,#$rcnum,#$contnum */
  730. {
  731. MT_INSN_LDCTXT, "ldctxt", "ldctxt", 32,
  732. { 0, { { { (1<<MACH_MS1), 0 } } } }
  733. },
  734. /* ldfb $frsr1,$frsr2,#$imm16z */
  735. {
  736. MT_INSN_LDFB, "ldfb", "ldfb", 32,
  737. { 0, { { { (1<<MACH_MS1), 0 } } } }
  738. },
  739. /* stfb $frsr1,$frsr2,#$imm16z */
  740. {
  741. MT_INSN_STFB, "stfb", "stfb", 32,
  742. { 0, { { { (1<<MACH_MS1), 0 } } } }
  743. },
  744. /* fbcb $frsr1,#$rbbc,#$ball,#$brc,#$rc1,#$cbrb,#$cell,#$dup,#$ctxdisp */
  745. {
  746. MT_INSN_FBCB, "fbcb", "fbcb", 32,
  747. { 0, { { { (1<<MACH_MS1)|(1<<MACH_MS1_003), 0 } } } }
  748. },
  749. /* mfbcb $frsr1,#$rbbc,$frsr2,#$rc1,#$cbrb,#$cell,#$dup,#$ctxdisp */
  750. {
  751. MT_INSN_MFBCB, "mfbcb", "mfbcb", 32,
  752. { 0, { { { (1<<MACH_BASE), 0 } } } }
  753. },
  754. /* fbcci $frsr1,#$rbbc,#$ball,#$brc,#$fbdisp,#$cell,#$dup,#$ctxdisp */
  755. {
  756. MT_INSN_FBCCI, "fbcci", "fbcci", 32,
  757. { 0, { { { (1<<MACH_BASE), 0 } } } }
  758. },
  759. /* fbrci $frsr1,#$rbbc,#$ball,#$brc,#$fbdisp,#$cell,#$dup,#$ctxdisp */
  760. {
  761. MT_INSN_FBRCI, "fbrci", "fbrci", 32,
  762. { 0, { { { (1<<MACH_BASE), 0 } } } }
  763. },
  764. /* fbcri $frsr1,#$rbbc,#$ball,#$brc,#$fbdisp,#$cell,#$dup,#$ctxdisp */
  765. {
  766. MT_INSN_FBCRI, "fbcri", "fbcri", 32,
  767. { 0, { { { (1<<MACH_BASE), 0 } } } }
  768. },
  769. /* fbrri $frsr1,#$rbbc,#$ball,#$brc,#$fbdisp,#$cell,#$dup,#$ctxdisp */
  770. {
  771. MT_INSN_FBRRI, "fbrri", "fbrri", 32,
  772. { 0, { { { (1<<MACH_BASE), 0 } } } }
  773. },
  774. /* mfbcci $frsr1,#$rbbc,$frsr2,#$fbdisp,#$cell,#$dup,#$ctxdisp */
  775. {
  776. MT_INSN_MFBCCI, "mfbcci", "mfbcci", 32,
  777. { 0, { { { (1<<MACH_BASE), 0 } } } }
  778. },
  779. /* mfbrci $frsr1,#$rbbc,$frsr2,#$fbdisp,#$cell,#$dup,#$ctxdisp */
  780. {
  781. MT_INSN_MFBRCI, "mfbrci", "mfbrci", 32,
  782. { 0, { { { (1<<MACH_BASE), 0 } } } }
  783. },
  784. /* mfbcri $frsr1,#$rbbc,$frsr2,#$fbdisp,#$cell,#$dup,#$ctxdisp */
  785. {
  786. MT_INSN_MFBCRI, "mfbcri", "mfbcri", 32,
  787. { 0, { { { (1<<MACH_BASE), 0 } } } }
  788. },
  789. /* mfbrri $frsr1,#$rbbc,$frsr2,#$fbdisp,#$cell,#$dup,#$ctxdisp */
  790. {
  791. MT_INSN_MFBRRI, "mfbrri", "mfbrri", 32,
  792. { 0, { { { (1<<MACH_BASE), 0 } } } }
  793. },
  794. /* fbcbdr $frsr1,#$rbbc,$frsr2,#$ball2,#$brc2,#$rc1,#$cbrb,#$cell,#$dup,#$ctxdisp */
  795. {
  796. MT_INSN_FBCBDR, "fbcbdr", "fbcbdr", 32,
  797. { 0, { { { (1<<MACH_BASE), 0 } } } }
  798. },
  799. /* rcfbcb #$rbbc,#$type,#$ball,#$brc,#$rownum,#$rc1,#$cbrb,#$cell,#$dup,#$ctxdisp */
  800. {
  801. MT_INSN_RCFBCB, "rcfbcb", "rcfbcb", 32,
  802. { 0, { { { (1<<MACH_BASE), 0 } } } }
  803. },
  804. /* mrcfbcb $frsr2,#$rbbc,#$type,#$rownum,#$rc1,#$cbrb,#$cell,#$dup,#$ctxdisp */
  805. {
  806. MT_INSN_MRCFBCB, "mrcfbcb", "mrcfbcb", 32,
  807. { 0, { { { (1<<MACH_BASE), 0 } } } }
  808. },
  809. /* cbcast #$mask,#$rc2,#$ctxdisp */
  810. {
  811. MT_INSN_CBCAST, "cbcast", "cbcast", 32,
  812. { 0, { { { (1<<MACH_BASE), 0 } } } }
  813. },
  814. /* dupcbcast #$mask,#$cell,#$rc2,#$ctxdisp */
  815. {
  816. MT_INSN_DUPCBCAST, "dupcbcast", "dupcbcast", 32,
  817. { 0, { { { (1<<MACH_BASE), 0 } } } }
  818. },
  819. /* wfbi #$bankaddr,#$rownum1,#$cell,#$dup,#$ctxdisp */
  820. {
  821. MT_INSN_WFBI, "wfbi", "wfbi", 32,
  822. { 0, { { { (1<<MACH_BASE), 0 } } } }
  823. },
  824. /* wfb $frsr1,$frsr2,#$fbdisp,#$rownum2,#$ctxdisp */
  825. {
  826. MT_INSN_WFB, "wfb", "wfb", 32,
  827. { 0, { { { (1<<MACH_BASE), 0 } } } }
  828. },
  829. /* rcrisc $frdrrr,#$rbbc,$frsr1,#$colnum,#$rc1,#$cbrb,#$cell,#$dup,#$ctxdisp */
  830. {
  831. MT_INSN_RCRISC, "rcrisc", "rcrisc", 32,
  832. { 0, { { { (1<<MACH_BASE), 0 } } } }
  833. },
  834. /* fbcbinc $frsr1,#$rbbc,#$incamt,#$rc1,#$cbrb,#$cell,#$dup,#$ctxdisp */
  835. {
  836. MT_INSN_FBCBINC, "fbcbinc", "fbcbinc", 32,
  837. { 0, { { { (1<<MACH_BASE), 0 } } } }
  838. },
  839. /* rcxmode $frsr2,#$rda,#$wr,#$xmode,#$mask1,#$fbdisp,#$rownum2,#$rc2,#$ctxdisp */
  840. {
  841. MT_INSN_RCXMODE, "rcxmode", "rcxmode", 32,
  842. { 0, { { { (1<<MACH_BASE), 0 } } } }
  843. },
  844. /* intlvr $frsr1,#$mode,$frsr2,#$id,#$size */
  845. {
  846. MT_INSN_INTERLEAVER, "interleaver", "intlvr", 32,
  847. { 0, { { { (1<<MACH_BASE), 0 } } } }
  848. },
  849. /* wfbinc #$rda,#$wr,#$fbincr,#$ball,#$colnum,#$length,#$rownum1,#$rownum2,#$dup,#$ctxdisp */
  850. {
  851. MT_INSN_WFBINC, "wfbinc", "wfbinc", 32,
  852. { 0, { { { (1<<MACH_MS1_003)|(1<<MACH_MS2), 0 } } } }
  853. },
  854. /* mwfbinc $frsr2,#$rda,#$wr,#$fbincr,#$length,#$rownum1,#$rownum2,#$dup,#$ctxdisp */
  855. {
  856. MT_INSN_MWFBINC, "mwfbinc", "mwfbinc", 32,
  857. { 0, { { { (1<<MACH_MS1_003)|(1<<MACH_MS2), 0 } } } }
  858. },
  859. /* wfbincr $frsr1,#$rda,#$wr,#$ball,#$colnum,#$length,#$rownum1,#$rownum2,#$dup,#$ctxdisp */
  860. {
  861. MT_INSN_WFBINCR, "wfbincr", "wfbincr", 32,
  862. { 0, { { { (1<<MACH_MS1_003)|(1<<MACH_MS2), 0 } } } }
  863. },
  864. /* mwfbincr $frsr1,$frsr2,#$rda,#$wr,#$length,#$rownum1,#$rownum2,#$dup,#$ctxdisp */
  865. {
  866. MT_INSN_MWFBINCR, "mwfbincr", "mwfbincr", 32,
  867. { 0, { { { (1<<MACH_MS1_003)|(1<<MACH_MS2), 0 } } } }
  868. },
  869. /* fbcbincs #$perm,#$a23,#$cr,#$cbs,#$incr,#$ccb,#$cdb,#$rownum2,#$dup,#$ctxdisp */
  870. {
  871. MT_INSN_FBCBINCS, "fbcbincs", "fbcbincs", 32,
  872. { 0, { { { (1<<MACH_MS1_003)|(1<<MACH_MS2), 0 } } } }
  873. },
  874. /* mfbcbincs $frsr1,#$perm,#$cbs,#$incr,#$ccb,#$cdb,#$rownum2,#$dup,#$ctxdisp */
  875. {
  876. MT_INSN_MFBCBINCS, "mfbcbincs", "mfbcbincs", 32,
  877. { 0, { { { (1<<MACH_MS1_003)|(1<<MACH_MS2), 0 } } } }
  878. },
  879. /* fbcbincrs $frsr1,#$perm,#$ball,#$colnum,#$cbx,#$ccb,#$cdb,#$rownum2,#$dup,#$ctxdisp */
  880. {
  881. MT_INSN_FBCBINCRS, "fbcbincrs", "fbcbincrs", 32,
  882. { 0, { { { (1<<MACH_MS1_003)|(1<<MACH_MS2), 0 } } } }
  883. },
  884. /* mfbcbincrs $frsr1,$frsr2,#$perm,#$cbx,#$ccb,#$cdb,#$rownum2,#$dup,#$ctxdisp */
  885. {
  886. MT_INSN_MFBCBINCRS, "mfbcbincrs", "mfbcbincrs", 32,
  887. { 0, { { { (1<<MACH_MS1_003)|(1<<MACH_MS2), 0 } } } }
  888. },
  889. /* loop $frsr1,$loopsize */
  890. {
  891. MT_INSN_LOOP, "loop", "loop", 32,
  892. { 0|A(USES_FRSR1)|A(DELAY_SLOT), { { { (1<<MACH_MS2), 0 } } } }
  893. },
  894. /* loopi #$imm16l,$loopsize */
  895. {
  896. MT_INSN_LOOPI, "loopi", "loopi", 32,
  897. { 0|A(DELAY_SLOT), { { { (1<<MACH_MS2), 0 } } } }
  898. },
  899. /* dfbc #$cb1sel,#$cb2sel,#$cb1incr,#$cb2incr,#$rc3,#$rc2,#$ctxdisp */
  900. {
  901. MT_INSN_DFBC, "dfbc", "dfbc", 32,
  902. { 0, { { { (1<<MACH_MS2), 0 } } } }
  903. },
  904. /* dwfb #$cb1sel,#$cb2sel,#$cb1incr,#$cb2incr,#$rc2,#$ctxdisp */
  905. {
  906. MT_INSN_DWFB, "dwfb", "dwfb", 32,
  907. { 0, { { { (1<<MACH_MS2), 0 } } } }
  908. },
  909. /* fbwfb #$cb1sel,#$cb2sel,#$cb1incr,#$cb2incr,#$rc3,#$rc2,#$ctxdisp */
  910. {
  911. MT_INSN_FBWFB, "fbwfb", "fbwfb", 32,
  912. { 0, { { { (1<<MACH_MS2), 0 } } } }
  913. },
  914. /* dfbr #$cb1sel,#$cb2sel,$frsr2,#$length,#$rownum1,#$rownum2,#$rc2,#$ctxdisp */
  915. {
  916. MT_INSN_DFBR, "dfbr", "dfbr", 32,
  917. { 0|A(USES_FRSR2), { { { (1<<MACH_MS2), 0 } } } }
  918. },
  919. };
  920. #undef OP
  921. #undef A
  922. /* Initialize anything needed to be done once, before any cpu_open call. */
  923. static void
  924. init_tables (void)
  925. {
  926. }
  927. #ifndef opcodes_error_handler
  928. #define opcodes_error_handler(...) \
  929. fprintf (stderr, __VA_ARGS__); fputc ('\n', stderr)
  930. #endif
  931. static const CGEN_MACH * lookup_mach_via_bfd_name (const CGEN_MACH *, const char *);
  932. static void build_hw_table (CGEN_CPU_TABLE *);
  933. static void build_ifield_table (CGEN_CPU_TABLE *);
  934. static void build_operand_table (CGEN_CPU_TABLE *);
  935. static void build_insn_table (CGEN_CPU_TABLE *);
  936. static void mt_cgen_rebuild_tables (CGEN_CPU_TABLE *);
  937. /* Subroutine of mt_cgen_cpu_open to look up a mach via its bfd name. */
  938. static const CGEN_MACH *
  939. lookup_mach_via_bfd_name (const CGEN_MACH *table, const char *name)
  940. {
  941. while (table->name)
  942. {
  943. if (strcmp (name, table->bfd_name) == 0)
  944. return table;
  945. ++table;
  946. }
  947. return NULL;
  948. }
  949. /* Subroutine of mt_cgen_cpu_open to build the hardware table. */
  950. static void
  951. build_hw_table (CGEN_CPU_TABLE *cd)
  952. {
  953. int i;
  954. int machs = cd->machs;
  955. const CGEN_HW_ENTRY *init = & mt_cgen_hw_table[0];
  956. /* MAX_HW is only an upper bound on the number of selected entries.
  957. However each entry is indexed by it's enum so there can be holes in
  958. the table. */
  959. const CGEN_HW_ENTRY **selected =
  960. (const CGEN_HW_ENTRY **) xmalloc (MAX_HW * sizeof (CGEN_HW_ENTRY *));
  961. cd->hw_table.init_entries = init;
  962. cd->hw_table.entry_size = sizeof (CGEN_HW_ENTRY);
  963. memset (selected, 0, MAX_HW * sizeof (CGEN_HW_ENTRY *));
  964. /* ??? For now we just use machs to determine which ones we want. */
  965. for (i = 0; init[i].name != NULL; ++i)
  966. if (CGEN_HW_ATTR_VALUE (&init[i], CGEN_HW_MACH)
  967. & machs)
  968. selected[init[i].type] = &init[i];
  969. cd->hw_table.entries = selected;
  970. cd->hw_table.num_entries = MAX_HW;
  971. }
  972. /* Subroutine of mt_cgen_cpu_open to build the hardware table. */
  973. static void
  974. build_ifield_table (CGEN_CPU_TABLE *cd)
  975. {
  976. cd->ifld_table = & mt_cgen_ifld_table[0];
  977. }
  978. /* Subroutine of mt_cgen_cpu_open to build the hardware table. */
  979. static void
  980. build_operand_table (CGEN_CPU_TABLE *cd)
  981. {
  982. int i;
  983. int machs = cd->machs;
  984. const CGEN_OPERAND *init = & mt_cgen_operand_table[0];
  985. /* MAX_OPERANDS is only an upper bound on the number of selected entries.
  986. However each entry is indexed by it's enum so there can be holes in
  987. the table. */
  988. const CGEN_OPERAND **selected = xmalloc (MAX_OPERANDS * sizeof (* selected));
  989. cd->operand_table.init_entries = init;
  990. cd->operand_table.entry_size = sizeof (CGEN_OPERAND);
  991. memset (selected, 0, MAX_OPERANDS * sizeof (CGEN_OPERAND *));
  992. /* ??? For now we just use mach to determine which ones we want. */
  993. for (i = 0; init[i].name != NULL; ++i)
  994. if (CGEN_OPERAND_ATTR_VALUE (&init[i], CGEN_OPERAND_MACH)
  995. & machs)
  996. selected[init[i].type] = &init[i];
  997. cd->operand_table.entries = selected;
  998. cd->operand_table.num_entries = MAX_OPERANDS;
  999. }
  1000. /* Subroutine of mt_cgen_cpu_open to build the hardware table.
  1001. ??? This could leave out insns not supported by the specified mach/isa,
  1002. but that would cause errors like "foo only supported by bar" to become
  1003. "unknown insn", so for now we include all insns and require the app to
  1004. do the checking later.
  1005. ??? On the other hand, parsing of such insns may require their hardware or
  1006. operand elements to be in the table [which they mightn't be]. */
  1007. static void
  1008. build_insn_table (CGEN_CPU_TABLE *cd)
  1009. {
  1010. int i;
  1011. const CGEN_IBASE *ib = & mt_cgen_insn_table[0];
  1012. CGEN_INSN *insns = xmalloc (MAX_INSNS * sizeof (CGEN_INSN));
  1013. memset (insns, 0, MAX_INSNS * sizeof (CGEN_INSN));
  1014. for (i = 0; i < MAX_INSNS; ++i)
  1015. insns[i].base = &ib[i];
  1016. cd->insn_table.init_entries = insns;
  1017. cd->insn_table.entry_size = sizeof (CGEN_IBASE);
  1018. cd->insn_table.num_init_entries = MAX_INSNS;
  1019. }
  1020. /* Subroutine of mt_cgen_cpu_open to rebuild the tables. */
  1021. static void
  1022. mt_cgen_rebuild_tables (CGEN_CPU_TABLE *cd)
  1023. {
  1024. int i;
  1025. CGEN_BITSET *isas = cd->isas;
  1026. unsigned int machs = cd->machs;
  1027. cd->int_insn_p = CGEN_INT_INSN_P;
  1028. /* Data derived from the isa spec. */
  1029. #define UNSET (CGEN_SIZE_UNKNOWN + 1)
  1030. cd->default_insn_bitsize = UNSET;
  1031. cd->base_insn_bitsize = UNSET;
  1032. cd->min_insn_bitsize = 65535; /* Some ridiculously big number. */
  1033. cd->max_insn_bitsize = 0;
  1034. for (i = 0; i < MAX_ISAS; ++i)
  1035. if (cgen_bitset_contains (isas, i))
  1036. {
  1037. const CGEN_ISA *isa = & mt_cgen_isa_table[i];
  1038. /* Default insn sizes of all selected isas must be
  1039. equal or we set the result to 0, meaning "unknown". */
  1040. if (cd->default_insn_bitsize == UNSET)
  1041. cd->default_insn_bitsize = isa->default_insn_bitsize;
  1042. else if (isa->default_insn_bitsize == cd->default_insn_bitsize)
  1043. ; /* This is ok. */
  1044. else
  1045. cd->default_insn_bitsize = CGEN_SIZE_UNKNOWN;
  1046. /* Base insn sizes of all selected isas must be equal
  1047. or we set the result to 0, meaning "unknown". */
  1048. if (cd->base_insn_bitsize == UNSET)
  1049. cd->base_insn_bitsize = isa->base_insn_bitsize;
  1050. else if (isa->base_insn_bitsize == cd->base_insn_bitsize)
  1051. ; /* This is ok. */
  1052. else
  1053. cd->base_insn_bitsize = CGEN_SIZE_UNKNOWN;
  1054. /* Set min,max insn sizes. */
  1055. if (isa->min_insn_bitsize < cd->min_insn_bitsize)
  1056. cd->min_insn_bitsize = isa->min_insn_bitsize;
  1057. if (isa->max_insn_bitsize > cd->max_insn_bitsize)
  1058. cd->max_insn_bitsize = isa->max_insn_bitsize;
  1059. }
  1060. /* Data derived from the mach spec. */
  1061. for (i = 0; i < MAX_MACHS; ++i)
  1062. if (((1 << i) & machs) != 0)
  1063. {
  1064. const CGEN_MACH *mach = & mt_cgen_mach_table[i];
  1065. if (mach->insn_chunk_bitsize != 0)
  1066. {
  1067. if (cd->insn_chunk_bitsize != 0 && cd->insn_chunk_bitsize != mach->insn_chunk_bitsize)
  1068. {
  1069. opcodes_error_handler
  1070. (/* xgettext:c-format */
  1071. _("internal error: mt_cgen_rebuild_tables: "
  1072. "conflicting insn-chunk-bitsize values: `%d' vs. `%d'"),
  1073. cd->insn_chunk_bitsize, mach->insn_chunk_bitsize);
  1074. abort ();
  1075. }
  1076. cd->insn_chunk_bitsize = mach->insn_chunk_bitsize;
  1077. }
  1078. }
  1079. /* Determine which hw elements are used by MACH. */
  1080. build_hw_table (cd);
  1081. /* Build the ifield table. */
  1082. build_ifield_table (cd);
  1083. /* Determine which operands are used by MACH/ISA. */
  1084. build_operand_table (cd);
  1085. /* Build the instruction table. */
  1086. build_insn_table (cd);
  1087. }
  1088. /* Initialize a cpu table and return a descriptor.
  1089. It's much like opening a file, and must be the first function called.
  1090. The arguments are a set of (type/value) pairs, terminated with
  1091. CGEN_CPU_OPEN_END.
  1092. Currently supported values:
  1093. CGEN_CPU_OPEN_ISAS: bitmap of values in enum isa_attr
  1094. CGEN_CPU_OPEN_MACHS: bitmap of values in enum mach_attr
  1095. CGEN_CPU_OPEN_BFDMACH: specify 1 mach using bfd name
  1096. CGEN_CPU_OPEN_ENDIAN: specify endian choice
  1097. CGEN_CPU_OPEN_INSN_ENDIAN: specify instruction endian choice
  1098. CGEN_CPU_OPEN_END: terminates arguments
  1099. ??? Simultaneous multiple isas might not make sense, but it's not (yet)
  1100. precluded. */
  1101. CGEN_CPU_DESC
  1102. mt_cgen_cpu_open (enum cgen_cpu_open_arg arg_type, ...)
  1103. {
  1104. CGEN_CPU_TABLE *cd = (CGEN_CPU_TABLE *) xmalloc (sizeof (CGEN_CPU_TABLE));
  1105. static int init_p;
  1106. CGEN_BITSET *isas = 0; /* 0 = "unspecified" */
  1107. unsigned int machs = 0; /* 0 = "unspecified" */
  1108. enum cgen_endian endian = CGEN_ENDIAN_UNKNOWN;
  1109. enum cgen_endian insn_endian = CGEN_ENDIAN_UNKNOWN;
  1110. va_list ap;
  1111. if (! init_p)
  1112. {
  1113. init_tables ();
  1114. init_p = 1;
  1115. }
  1116. memset (cd, 0, sizeof (*cd));
  1117. va_start (ap, arg_type);
  1118. while (arg_type != CGEN_CPU_OPEN_END)
  1119. {
  1120. switch (arg_type)
  1121. {
  1122. case CGEN_CPU_OPEN_ISAS :
  1123. isas = va_arg (ap, CGEN_BITSET *);
  1124. break;
  1125. case CGEN_CPU_OPEN_MACHS :
  1126. machs = va_arg (ap, unsigned int);
  1127. break;
  1128. case CGEN_CPU_OPEN_BFDMACH :
  1129. {
  1130. const char *name = va_arg (ap, const char *);
  1131. const CGEN_MACH *mach =
  1132. lookup_mach_via_bfd_name (mt_cgen_mach_table, name);
  1133. if (mach != NULL)
  1134. machs |= 1 << mach->num;
  1135. break;
  1136. }
  1137. case CGEN_CPU_OPEN_ENDIAN :
  1138. endian = va_arg (ap, enum cgen_endian);
  1139. break;
  1140. case CGEN_CPU_OPEN_INSN_ENDIAN :
  1141. insn_endian = va_arg (ap, enum cgen_endian);
  1142. break;
  1143. default :
  1144. opcodes_error_handler
  1145. (/* xgettext:c-format */
  1146. _("internal error: mt_cgen_cpu_open: "
  1147. "unsupported argument `%d'"),
  1148. arg_type);
  1149. abort (); /* ??? return NULL? */
  1150. }
  1151. arg_type = va_arg (ap, enum cgen_cpu_open_arg);
  1152. }
  1153. va_end (ap);
  1154. /* Mach unspecified means "all". */
  1155. if (machs == 0)
  1156. machs = (1 << MAX_MACHS) - 1;
  1157. /* Base mach is always selected. */
  1158. machs |= 1;
  1159. if (endian == CGEN_ENDIAN_UNKNOWN)
  1160. {
  1161. /* ??? If target has only one, could have a default. */
  1162. opcodes_error_handler
  1163. (/* xgettext:c-format */
  1164. _("internal error: mt_cgen_cpu_open: no endianness specified"));
  1165. abort ();
  1166. }
  1167. cd->isas = cgen_bitset_copy (isas);
  1168. cd->machs = machs;
  1169. cd->endian = endian;
  1170. cd->insn_endian
  1171. = (insn_endian == CGEN_ENDIAN_UNKNOWN ? endian : insn_endian);
  1172. /* Table (re)builder. */
  1173. cd->rebuild_tables = mt_cgen_rebuild_tables;
  1174. mt_cgen_rebuild_tables (cd);
  1175. /* Default to not allowing signed overflow. */
  1176. cd->signed_overflow_ok_p = 0;
  1177. return (CGEN_CPU_DESC) cd;
  1178. }
  1179. /* Cover fn to mt_cgen_cpu_open to handle the simple case of 1 isa, 1 mach.
  1180. MACH_NAME is the bfd name of the mach. */
  1181. CGEN_CPU_DESC
  1182. mt_cgen_cpu_open_1 (const char *mach_name, enum cgen_endian endian)
  1183. {
  1184. return mt_cgen_cpu_open (CGEN_CPU_OPEN_BFDMACH, mach_name,
  1185. CGEN_CPU_OPEN_ENDIAN, endian,
  1186. CGEN_CPU_OPEN_END);
  1187. }
  1188. /* Close a cpu table.
  1189. ??? This can live in a machine independent file, but there's currently
  1190. no place to put this file (there's no libcgen). libopcodes is the wrong
  1191. place as some simulator ports use this but they don't use libopcodes. */
  1192. void
  1193. mt_cgen_cpu_close (CGEN_CPU_DESC cd)
  1194. {
  1195. unsigned int i;
  1196. const CGEN_INSN *insns;
  1197. if (cd->macro_insn_table.init_entries)
  1198. {
  1199. insns = cd->macro_insn_table.init_entries;
  1200. for (i = 0; i < cd->macro_insn_table.num_init_entries; ++i, ++insns)
  1201. if (CGEN_INSN_RX ((insns)))
  1202. regfree (CGEN_INSN_RX (insns));
  1203. }
  1204. if (cd->insn_table.init_entries)
  1205. {
  1206. insns = cd->insn_table.init_entries;
  1207. for (i = 0; i < cd->insn_table.num_init_entries; ++i, ++insns)
  1208. if (CGEN_INSN_RX (insns))
  1209. regfree (CGEN_INSN_RX (insns));
  1210. }
  1211. free ((CGEN_INSN *) cd->macro_insn_table.init_entries);
  1212. free ((CGEN_INSN *) cd->insn_table.init_entries);
  1213. free ((CGEN_HW_ENTRY *) cd->hw_table.entries);
  1214. free ((CGEN_HW_ENTRY *) cd->operand_table.entries);
  1215. free (cd);
  1216. }