mt-desc.c 46 KB

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