1*3d8817e4Smiod /* CPU data for ip2k.
2*3d8817e4Smiod 
3*3d8817e4Smiod THIS FILE IS MACHINE GENERATED WITH CGEN.
4*3d8817e4Smiod 
5*3d8817e4Smiod Copyright 1996-2005 Free Software Foundation, Inc.
6*3d8817e4Smiod 
7*3d8817e4Smiod This file is part of the GNU Binutils and/or GDB, the GNU debugger.
8*3d8817e4Smiod 
9*3d8817e4Smiod This program is free software; you can redistribute it and/or modify
10*3d8817e4Smiod it under the terms of the GNU General Public License as published by
11*3d8817e4Smiod the Free Software Foundation; either version 2, or (at your option)
12*3d8817e4Smiod any later version.
13*3d8817e4Smiod 
14*3d8817e4Smiod This program is distributed in the hope that it will be useful,
15*3d8817e4Smiod but WITHOUT ANY WARRANTY; without even the implied warranty of
16*3d8817e4Smiod MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17*3d8817e4Smiod GNU General Public License for more details.
18*3d8817e4Smiod 
19*3d8817e4Smiod You should have received a copy of the GNU General Public License along
20*3d8817e4Smiod with this program; if not, write to the Free Software Foundation, Inc.,
21*3d8817e4Smiod 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
22*3d8817e4Smiod 
23*3d8817e4Smiod */
24*3d8817e4Smiod 
25*3d8817e4Smiod #include "sysdep.h"
26*3d8817e4Smiod #include <stdio.h>
27*3d8817e4Smiod #include <stdarg.h>
28*3d8817e4Smiod #include "ansidecl.h"
29*3d8817e4Smiod #include "bfd.h"
30*3d8817e4Smiod #include "symcat.h"
31*3d8817e4Smiod #include "ip2k-desc.h"
32*3d8817e4Smiod #include "ip2k-opc.h"
33*3d8817e4Smiod #include "opintl.h"
34*3d8817e4Smiod #include "libiberty.h"
35*3d8817e4Smiod #include "xregex.h"
36*3d8817e4Smiod 
37*3d8817e4Smiod /* Attributes.  */
38*3d8817e4Smiod 
39*3d8817e4Smiod static const CGEN_ATTR_ENTRY bool_attr[] =
40*3d8817e4Smiod {
41*3d8817e4Smiod   { "#f", 0 },
42*3d8817e4Smiod   { "#t", 1 },
43*3d8817e4Smiod   { 0, 0 }
44*3d8817e4Smiod };
45*3d8817e4Smiod 
46*3d8817e4Smiod static const CGEN_ATTR_ENTRY MACH_attr[] ATTRIBUTE_UNUSED =
47*3d8817e4Smiod {
48*3d8817e4Smiod   { "base", MACH_BASE },
49*3d8817e4Smiod   { "ip2022", MACH_IP2022 },
50*3d8817e4Smiod   { "ip2022ext", MACH_IP2022EXT },
51*3d8817e4Smiod   { "max", MACH_MAX },
52*3d8817e4Smiod   { 0, 0 }
53*3d8817e4Smiod };
54*3d8817e4Smiod 
55*3d8817e4Smiod static const CGEN_ATTR_ENTRY ISA_attr[] ATTRIBUTE_UNUSED =
56*3d8817e4Smiod {
57*3d8817e4Smiod   { "ip2k", ISA_IP2K },
58*3d8817e4Smiod   { "max", ISA_MAX },
59*3d8817e4Smiod   { 0, 0 }
60*3d8817e4Smiod };
61*3d8817e4Smiod 
62*3d8817e4Smiod const CGEN_ATTR_TABLE ip2k_cgen_ifield_attr_table[] =
63*3d8817e4Smiod {
64*3d8817e4Smiod   { "MACH", & MACH_attr[0], & MACH_attr[0] },
65*3d8817e4Smiod   { "VIRTUAL", &bool_attr[0], &bool_attr[0] },
66*3d8817e4Smiod   { "PCREL-ADDR", &bool_attr[0], &bool_attr[0] },
67*3d8817e4Smiod   { "ABS-ADDR", &bool_attr[0], &bool_attr[0] },
68*3d8817e4Smiod   { "RESERVED", &bool_attr[0], &bool_attr[0] },
69*3d8817e4Smiod   { "SIGN-OPT", &bool_attr[0], &bool_attr[0] },
70*3d8817e4Smiod   { "SIGNED", &bool_attr[0], &bool_attr[0] },
71*3d8817e4Smiod   { 0, 0, 0 }
72*3d8817e4Smiod };
73*3d8817e4Smiod 
74*3d8817e4Smiod const CGEN_ATTR_TABLE ip2k_cgen_hardware_attr_table[] =
75*3d8817e4Smiod {
76*3d8817e4Smiod   { "MACH", & MACH_attr[0], & MACH_attr[0] },
77*3d8817e4Smiod   { "VIRTUAL", &bool_attr[0], &bool_attr[0] },
78*3d8817e4Smiod   { "CACHE-ADDR", &bool_attr[0], &bool_attr[0] },
79*3d8817e4Smiod   { "PC", &bool_attr[0], &bool_attr[0] },
80*3d8817e4Smiod   { "PROFILE", &bool_attr[0], &bool_attr[0] },
81*3d8817e4Smiod   { 0, 0, 0 }
82*3d8817e4Smiod };
83*3d8817e4Smiod 
84*3d8817e4Smiod const CGEN_ATTR_TABLE ip2k_cgen_operand_attr_table[] =
85*3d8817e4Smiod {
86*3d8817e4Smiod   { "MACH", & MACH_attr[0], & MACH_attr[0] },
87*3d8817e4Smiod   { "VIRTUAL", &bool_attr[0], &bool_attr[0] },
88*3d8817e4Smiod   { "PCREL-ADDR", &bool_attr[0], &bool_attr[0] },
89*3d8817e4Smiod   { "ABS-ADDR", &bool_attr[0], &bool_attr[0] },
90*3d8817e4Smiod   { "SIGN-OPT", &bool_attr[0], &bool_attr[0] },
91*3d8817e4Smiod   { "SIGNED", &bool_attr[0], &bool_attr[0] },
92*3d8817e4Smiod   { "NEGATIVE", &bool_attr[0], &bool_attr[0] },
93*3d8817e4Smiod   { "RELAX", &bool_attr[0], &bool_attr[0] },
94*3d8817e4Smiod   { "SEM-ONLY", &bool_attr[0], &bool_attr[0] },
95*3d8817e4Smiod   { 0, 0, 0 }
96*3d8817e4Smiod };
97*3d8817e4Smiod 
98*3d8817e4Smiod const CGEN_ATTR_TABLE ip2k_cgen_insn_attr_table[] =
99*3d8817e4Smiod {
100*3d8817e4Smiod   { "MACH", & MACH_attr[0], & MACH_attr[0] },
101*3d8817e4Smiod   { "ALIAS", &bool_attr[0], &bool_attr[0] },
102*3d8817e4Smiod   { "VIRTUAL", &bool_attr[0], &bool_attr[0] },
103*3d8817e4Smiod   { "UNCOND-CTI", &bool_attr[0], &bool_attr[0] },
104*3d8817e4Smiod   { "COND-CTI", &bool_attr[0], &bool_attr[0] },
105*3d8817e4Smiod   { "SKIP-CTI", &bool_attr[0], &bool_attr[0] },
106*3d8817e4Smiod   { "DELAY-SLOT", &bool_attr[0], &bool_attr[0] },
107*3d8817e4Smiod   { "RELAXABLE", &bool_attr[0], &bool_attr[0] },
108*3d8817e4Smiod   { "RELAXED", &bool_attr[0], &bool_attr[0] },
109*3d8817e4Smiod   { "NO-DIS", &bool_attr[0], &bool_attr[0] },
110*3d8817e4Smiod   { "PBB", &bool_attr[0], &bool_attr[0] },
111*3d8817e4Smiod   { "EXT-SKIP-INSN", &bool_attr[0], &bool_attr[0] },
112*3d8817e4Smiod   { "SKIPA", &bool_attr[0], &bool_attr[0] },
113*3d8817e4Smiod   { 0, 0, 0 }
114*3d8817e4Smiod };
115*3d8817e4Smiod 
116*3d8817e4Smiod /* Instruction set variants.  */
117*3d8817e4Smiod 
118*3d8817e4Smiod static const CGEN_ISA ip2k_cgen_isa_table[] = {
119*3d8817e4Smiod   { "ip2k", 16, 16, 16, 16 },
120*3d8817e4Smiod   { 0, 0, 0, 0, 0 }
121*3d8817e4Smiod };
122*3d8817e4Smiod 
123*3d8817e4Smiod /* Machine variants.  */
124*3d8817e4Smiod 
125*3d8817e4Smiod static const CGEN_MACH ip2k_cgen_mach_table[] = {
126*3d8817e4Smiod   { "ip2022", "ip2022", MACH_IP2022, 0 },
127*3d8817e4Smiod   { "ip2022ext", "ip2022ext", MACH_IP2022EXT, 0 },
128*3d8817e4Smiod   { 0, 0, 0, 0 }
129*3d8817e4Smiod };
130*3d8817e4Smiod 
131*3d8817e4Smiod static CGEN_KEYWORD_ENTRY ip2k_cgen_opval_register_names_entries[] =
132*3d8817e4Smiod {
133*3d8817e4Smiod   { "ADDRSEL", 2, {0, {{{0, 0}}}}, 0, 0 },
134*3d8817e4Smiod   { "ADDRX", 3, {0, {{{0, 0}}}}, 0, 0 },
135*3d8817e4Smiod   { "IPH", 4, {0, {{{0, 0}}}}, 0, 0 },
136*3d8817e4Smiod   { "IPL", 5, {0, {{{0, 0}}}}, 0, 0 },
137*3d8817e4Smiod   { "SPH", 6, {0, {{{0, 0}}}}, 0, 0 },
138*3d8817e4Smiod   { "SPL", 7, {0, {{{0, 0}}}}, 0, 0 },
139*3d8817e4Smiod   { "PCH", 8, {0, {{{0, 0}}}}, 0, 0 },
140*3d8817e4Smiod   { "PCL", 9, {0, {{{0, 0}}}}, 0, 0 },
141*3d8817e4Smiod   { "WREG", 10, {0, {{{0, 0}}}}, 0, 0 },
142*3d8817e4Smiod   { "STATUS", 11, {0, {{{0, 0}}}}, 0, 0 },
143*3d8817e4Smiod   { "DPH", 12, {0, {{{0, 0}}}}, 0, 0 },
144*3d8817e4Smiod   { "DPL", 13, {0, {{{0, 0}}}}, 0, 0 },
145*3d8817e4Smiod   { "SPDREG", 14, {0, {{{0, 0}}}}, 0, 0 },
146*3d8817e4Smiod   { "MULH", 15, {0, {{{0, 0}}}}, 0, 0 },
147*3d8817e4Smiod   { "ADDRH", 16, {0, {{{0, 0}}}}, 0, 0 },
148*3d8817e4Smiod   { "ADDRL", 17, {0, {{{0, 0}}}}, 0, 0 },
149*3d8817e4Smiod   { "DATAH", 18, {0, {{{0, 0}}}}, 0, 0 },
150*3d8817e4Smiod   { "DATAL", 19, {0, {{{0, 0}}}}, 0, 0 },
151*3d8817e4Smiod   { "INTVECH", 20, {0, {{{0, 0}}}}, 0, 0 },
152*3d8817e4Smiod   { "INTVECL", 21, {0, {{{0, 0}}}}, 0, 0 },
153*3d8817e4Smiod   { "INTSPD", 22, {0, {{{0, 0}}}}, 0, 0 },
154*3d8817e4Smiod   { "INTF", 23, {0, {{{0, 0}}}}, 0, 0 },
155*3d8817e4Smiod   { "INTE", 24, {0, {{{0, 0}}}}, 0, 0 },
156*3d8817e4Smiod   { "INTED", 25, {0, {{{0, 0}}}}, 0, 0 },
157*3d8817e4Smiod   { "FCFG", 26, {0, {{{0, 0}}}}, 0, 0 },
158*3d8817e4Smiod   { "TCTRL", 27, {0, {{{0, 0}}}}, 0, 0 },
159*3d8817e4Smiod   { "XCFG", 28, {0, {{{0, 0}}}}, 0, 0 },
160*3d8817e4Smiod   { "EMCFG", 29, {0, {{{0, 0}}}}, 0, 0 },
161*3d8817e4Smiod   { "IPCH", 30, {0, {{{0, 0}}}}, 0, 0 },
162*3d8817e4Smiod   { "IPCL", 31, {0, {{{0, 0}}}}, 0, 0 },
163*3d8817e4Smiod   { "RAIN", 32, {0, {{{0, 0}}}}, 0, 0 },
164*3d8817e4Smiod   { "RAOUT", 33, {0, {{{0, 0}}}}, 0, 0 },
165*3d8817e4Smiod   { "RADIR", 34, {0, {{{0, 0}}}}, 0, 0 },
166*3d8817e4Smiod   { "LFSRH", 35, {0, {{{0, 0}}}}, 0, 0 },
167*3d8817e4Smiod   { "RBIN", 36, {0, {{{0, 0}}}}, 0, 0 },
168*3d8817e4Smiod   { "RBOUT", 37, {0, {{{0, 0}}}}, 0, 0 },
169*3d8817e4Smiod   { "RBDIR", 38, {0, {{{0, 0}}}}, 0, 0 },
170*3d8817e4Smiod   { "LFSRL", 39, {0, {{{0, 0}}}}, 0, 0 },
171*3d8817e4Smiod   { "RCIN", 40, {0, {{{0, 0}}}}, 0, 0 },
172*3d8817e4Smiod   { "RCOUT", 41, {0, {{{0, 0}}}}, 0, 0 },
173*3d8817e4Smiod   { "RCDIR", 42, {0, {{{0, 0}}}}, 0, 0 },
174*3d8817e4Smiod   { "LFSRA", 43, {0, {{{0, 0}}}}, 0, 0 },
175*3d8817e4Smiod   { "RDIN", 44, {0, {{{0, 0}}}}, 0, 0 },
176*3d8817e4Smiod   { "RDOUT", 45, {0, {{{0, 0}}}}, 0, 0 },
177*3d8817e4Smiod   { "RDDIR", 46, {0, {{{0, 0}}}}, 0, 0 },
178*3d8817e4Smiod   { "REIN", 48, {0, {{{0, 0}}}}, 0, 0 },
179*3d8817e4Smiod   { "REOUT", 49, {0, {{{0, 0}}}}, 0, 0 },
180*3d8817e4Smiod   { "REDIR", 50, {0, {{{0, 0}}}}, 0, 0 },
181*3d8817e4Smiod   { "RFIN", 52, {0, {{{0, 0}}}}, 0, 0 },
182*3d8817e4Smiod   { "RFOUT", 53, {0, {{{0, 0}}}}, 0, 0 },
183*3d8817e4Smiod   { "RFDIR", 54, {0, {{{0, 0}}}}, 0, 0 },
184*3d8817e4Smiod   { "RGOUT", 57, {0, {{{0, 0}}}}, 0, 0 },
185*3d8817e4Smiod   { "RGDIR", 58, {0, {{{0, 0}}}}, 0, 0 },
186*3d8817e4Smiod   { "RTTMR", 64, {0, {{{0, 0}}}}, 0, 0 },
187*3d8817e4Smiod   { "RTCFG", 65, {0, {{{0, 0}}}}, 0, 0 },
188*3d8817e4Smiod   { "T0TMR", 66, {0, {{{0, 0}}}}, 0, 0 },
189*3d8817e4Smiod   { "T0CFG", 67, {0, {{{0, 0}}}}, 0, 0 },
190*3d8817e4Smiod   { "T1CNTH", 68, {0, {{{0, 0}}}}, 0, 0 },
191*3d8817e4Smiod   { "T1CNTL", 69, {0, {{{0, 0}}}}, 0, 0 },
192*3d8817e4Smiod   { "T1CAP1H", 70, {0, {{{0, 0}}}}, 0, 0 },
193*3d8817e4Smiod   { "T1CAP1L", 71, {0, {{{0, 0}}}}, 0, 0 },
194*3d8817e4Smiod   { "T1CAP2H", 72, {0, {{{0, 0}}}}, 0, 0 },
195*3d8817e4Smiod   { "T1CMP2H", 72, {0, {{{0, 0}}}}, 0, 0 },
196*3d8817e4Smiod   { "T1CAP2L", 73, {0, {{{0, 0}}}}, 0, 0 },
197*3d8817e4Smiod   { "T1CMP2L", 73, {0, {{{0, 0}}}}, 0, 0 },
198*3d8817e4Smiod   { "T1CMP1H", 74, {0, {{{0, 0}}}}, 0, 0 },
199*3d8817e4Smiod   { "T1CMP1L", 75, {0, {{{0, 0}}}}, 0, 0 },
200*3d8817e4Smiod   { "T1CFG1H", 76, {0, {{{0, 0}}}}, 0, 0 },
201*3d8817e4Smiod   { "T1CFG1L", 77, {0, {{{0, 0}}}}, 0, 0 },
202*3d8817e4Smiod   { "T1CFG2H", 78, {0, {{{0, 0}}}}, 0, 0 },
203*3d8817e4Smiod   { "T1CFG2L", 79, {0, {{{0, 0}}}}, 0, 0 },
204*3d8817e4Smiod   { "ADCH", 80, {0, {{{0, 0}}}}, 0, 0 },
205*3d8817e4Smiod   { "ADCL", 81, {0, {{{0, 0}}}}, 0, 0 },
206*3d8817e4Smiod   { "ADCCFG", 82, {0, {{{0, 0}}}}, 0, 0 },
207*3d8817e4Smiod   { "ADCTMR", 83, {0, {{{0, 0}}}}, 0, 0 },
208*3d8817e4Smiod   { "T2CNTH", 84, {0, {{{0, 0}}}}, 0, 0 },
209*3d8817e4Smiod   { "T2CNTL", 85, {0, {{{0, 0}}}}, 0, 0 },
210*3d8817e4Smiod   { "T2CAP1H", 86, {0, {{{0, 0}}}}, 0, 0 },
211*3d8817e4Smiod   { "T2CAP1L", 87, {0, {{{0, 0}}}}, 0, 0 },
212*3d8817e4Smiod   { "T2CAP2H", 88, {0, {{{0, 0}}}}, 0, 0 },
213*3d8817e4Smiod   { "T2CMP2H", 88, {0, {{{0, 0}}}}, 0, 0 },
214*3d8817e4Smiod   { "T2CAP2L", 89, {0, {{{0, 0}}}}, 0, 0 },
215*3d8817e4Smiod   { "T2CMP2L", 89, {0, {{{0, 0}}}}, 0, 0 },
216*3d8817e4Smiod   { "T2CMP1H", 90, {0, {{{0, 0}}}}, 0, 0 },
217*3d8817e4Smiod   { "T2CMP1L", 91, {0, {{{0, 0}}}}, 0, 0 },
218*3d8817e4Smiod   { "T2CFG1H", 92, {0, {{{0, 0}}}}, 0, 0 },
219*3d8817e4Smiod   { "T2CFG1L", 93, {0, {{{0, 0}}}}, 0, 0 },
220*3d8817e4Smiod   { "T2CFG2H", 94, {0, {{{0, 0}}}}, 0, 0 },
221*3d8817e4Smiod   { "T2CFG2L", 95, {0, {{{0, 0}}}}, 0, 0 },
222*3d8817e4Smiod   { "S1TMRH", 96, {0, {{{0, 0}}}}, 0, 0 },
223*3d8817e4Smiod   { "S1TMRL", 97, {0, {{{0, 0}}}}, 0, 0 },
224*3d8817e4Smiod   { "S1TBUFH", 98, {0, {{{0, 0}}}}, 0, 0 },
225*3d8817e4Smiod   { "S1TBUFL", 99, {0, {{{0, 0}}}}, 0, 0 },
226*3d8817e4Smiod   { "S1TCFG", 100, {0, {{{0, 0}}}}, 0, 0 },
227*3d8817e4Smiod   { "S1RCNT", 101, {0, {{{0, 0}}}}, 0, 0 },
228*3d8817e4Smiod   { "S1RBUFH", 102, {0, {{{0, 0}}}}, 0, 0 },
229*3d8817e4Smiod   { "S1RBUFL", 103, {0, {{{0, 0}}}}, 0, 0 },
230*3d8817e4Smiod   { "S1RCFG", 104, {0, {{{0, 0}}}}, 0, 0 },
231*3d8817e4Smiod   { "S1RSYNC", 105, {0, {{{0, 0}}}}, 0, 0 },
232*3d8817e4Smiod   { "S1INTF", 106, {0, {{{0, 0}}}}, 0, 0 },
233*3d8817e4Smiod   { "S1INTE", 107, {0, {{{0, 0}}}}, 0, 0 },
234*3d8817e4Smiod   { "S1MODE", 108, {0, {{{0, 0}}}}, 0, 0 },
235*3d8817e4Smiod   { "S1SMASK", 109, {0, {{{0, 0}}}}, 0, 0 },
236*3d8817e4Smiod   { "PSPCFG", 110, {0, {{{0, 0}}}}, 0, 0 },
237*3d8817e4Smiod   { "CMPCFG", 111, {0, {{{0, 0}}}}, 0, 0 },
238*3d8817e4Smiod   { "S2TMRH", 112, {0, {{{0, 0}}}}, 0, 0 },
239*3d8817e4Smiod   { "S2TMRL", 113, {0, {{{0, 0}}}}, 0, 0 },
240*3d8817e4Smiod   { "S2TBUFH", 114, {0, {{{0, 0}}}}, 0, 0 },
241*3d8817e4Smiod   { "S2TBUFL", 115, {0, {{{0, 0}}}}, 0, 0 },
242*3d8817e4Smiod   { "S2TCFG", 116, {0, {{{0, 0}}}}, 0, 0 },
243*3d8817e4Smiod   { "S2RCNT", 117, {0, {{{0, 0}}}}, 0, 0 },
244*3d8817e4Smiod   { "S2RBUFH", 118, {0, {{{0, 0}}}}, 0, 0 },
245*3d8817e4Smiod   { "S2RBUFL", 119, {0, {{{0, 0}}}}, 0, 0 },
246*3d8817e4Smiod   { "S2RCFG", 120, {0, {{{0, 0}}}}, 0, 0 },
247*3d8817e4Smiod   { "S2RSYNC", 121, {0, {{{0, 0}}}}, 0, 0 },
248*3d8817e4Smiod   { "S2INTF", 122, {0, {{{0, 0}}}}, 0, 0 },
249*3d8817e4Smiod   { "S2INTE", 123, {0, {{{0, 0}}}}, 0, 0 },
250*3d8817e4Smiod   { "S2MODE", 124, {0, {{{0, 0}}}}, 0, 0 },
251*3d8817e4Smiod   { "S2SMASK", 125, {0, {{{0, 0}}}}, 0, 0 },
252*3d8817e4Smiod   { "CALLH", 126, {0, {{{0, 0}}}}, 0, 0 },
253*3d8817e4Smiod   { "CALLL", 127, {0, {{{0, 0}}}}, 0, 0 }
254*3d8817e4Smiod };
255*3d8817e4Smiod 
256*3d8817e4Smiod CGEN_KEYWORD ip2k_cgen_opval_register_names =
257*3d8817e4Smiod {
258*3d8817e4Smiod   & ip2k_cgen_opval_register_names_entries[0],
259*3d8817e4Smiod   121,
260*3d8817e4Smiod   0, 0, 0, 0, ""
261*3d8817e4Smiod };
262*3d8817e4Smiod 
263*3d8817e4Smiod 
264*3d8817e4Smiod /* The hardware table.  */
265*3d8817e4Smiod 
266*3d8817e4Smiod #if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
267*3d8817e4Smiod #define A(a) (1 << CGEN_HW_##a)
268*3d8817e4Smiod #else
269*3d8817e4Smiod #define A(a) (1 << CGEN_HW_/**/a)
270*3d8817e4Smiod #endif
271*3d8817e4Smiod 
272*3d8817e4Smiod const CGEN_HW_ENTRY ip2k_cgen_hw_table[] =
273*3d8817e4Smiod {
274*3d8817e4Smiod   { "h-memory", HW_H_MEMORY, CGEN_ASM_NONE, 0, { 0, { { { (1<<MACH_BASE), 0 } } } } },
275*3d8817e4Smiod   { "h-sint", HW_H_SINT, CGEN_ASM_NONE, 0, { 0, { { { (1<<MACH_BASE), 0 } } } } },
276*3d8817e4Smiod   { "h-uint", HW_H_UINT, CGEN_ASM_NONE, 0, { 0, { { { (1<<MACH_BASE), 0 } } } } },
277*3d8817e4Smiod   { "h-addr", HW_H_ADDR, CGEN_ASM_NONE, 0, { 0, { { { (1<<MACH_BASE), 0 } } } } },
278*3d8817e4Smiod   { "h-iaddr", HW_H_IADDR, CGEN_ASM_NONE, 0, { 0, { { { (1<<MACH_BASE), 0 } } } } },
279*3d8817e4Smiod   { "h-spr", HW_H_SPR, CGEN_ASM_NONE, 0, { 0, { { { (1<<MACH_BASE), 0 } } } } },
280*3d8817e4Smiod   { "h-registers", HW_H_REGISTERS, CGEN_ASM_NONE, 0, { 0|A(VIRTUAL), { { { (1<<MACH_BASE), 0 } } } } },
281*3d8817e4Smiod   { "h-stack", HW_H_STACK, CGEN_ASM_NONE, 0, { 0, { { { (1<<MACH_BASE), 0 } } } } },
282*3d8817e4Smiod   { "h-pabits", HW_H_PABITS, CGEN_ASM_NONE, 0, { 0, { { { (1<<MACH_BASE), 0 } } } } },
283*3d8817e4Smiod   { "h-zbit", HW_H_ZBIT, CGEN_ASM_NONE, 0, { 0, { { { (1<<MACH_BASE), 0 } } } } },
284*3d8817e4Smiod   { "h-cbit", HW_H_CBIT, CGEN_ASM_NONE, 0, { 0, { { { (1<<MACH_BASE), 0 } } } } },
285*3d8817e4Smiod   { "h-dcbit", HW_H_DCBIT, CGEN_ASM_NONE, 0, { 0, { { { (1<<MACH_BASE), 0 } } } } },
286*3d8817e4Smiod   { "h-pc", HW_H_PC, CGEN_ASM_NONE, 0, { 0|A(PROFILE)|A(PC), { { { (1<<MACH_BASE), 0 } } } } },
287*3d8817e4Smiod   { 0, 0, CGEN_ASM_NONE, 0, { 0, { { { (1<<MACH_BASE), 0 } } } } }
288*3d8817e4Smiod };
289*3d8817e4Smiod 
290*3d8817e4Smiod #undef A
291*3d8817e4Smiod 
292*3d8817e4Smiod 
293*3d8817e4Smiod /* The instruction field table.  */
294*3d8817e4Smiod 
295*3d8817e4Smiod #if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
296*3d8817e4Smiod #define A(a) (1 << CGEN_IFLD_##a)
297*3d8817e4Smiod #else
298*3d8817e4Smiod #define A(a) (1 << CGEN_IFLD_/**/a)
299*3d8817e4Smiod #endif
300*3d8817e4Smiod 
301*3d8817e4Smiod const CGEN_IFLD ip2k_cgen_ifld_table[] =
302*3d8817e4Smiod {
303*3d8817e4Smiod   { IP2K_F_NIL, "f-nil", 0, 0, 0, 0, { 0, { { { (1<<MACH_BASE), 0 } } } }  },
304*3d8817e4Smiod   { IP2K_F_ANYOF, "f-anyof", 0, 0, 0, 0, { 0, { { { (1<<MACH_BASE), 0 } } } }  },
305*3d8817e4Smiod   { IP2K_F_IMM8, "f-imm8", 0, 16, 7, 8, { 0, { { { (1<<MACH_BASE), 0 } } } }  },
306*3d8817e4Smiod   { IP2K_F_REG, "f-reg", 0, 16, 8, 9, { 0|A(ABS_ADDR), { { { (1<<MACH_BASE), 0 } } } }  },
307*3d8817e4Smiod   { IP2K_F_ADDR16CJP, "f-addr16cjp", 0, 16, 12, 13, { 0|A(ABS_ADDR), { { { (1<<MACH_BASE), 0 } } } }  },
308*3d8817e4Smiod   { IP2K_F_DIR, "f-dir", 0, 16, 9, 1, { 0, { { { (1<<MACH_BASE), 0 } } } }  },
309*3d8817e4Smiod   { IP2K_F_BITNO, "f-bitno", 0, 16, 11, 3, { 0, { { { (1<<MACH_BASE), 0 } } } }  },
310*3d8817e4Smiod   { IP2K_F_OP3, "f-op3", 0, 16, 15, 3, { 0, { { { (1<<MACH_BASE), 0 } } } }  },
311*3d8817e4Smiod   { IP2K_F_OP4, "f-op4", 0, 16, 15, 4, { 0, { { { (1<<MACH_BASE), 0 } } } }  },
312*3d8817e4Smiod   { IP2K_F_OP4MID, "f-op4mid", 0, 16, 11, 4, { 0, { { { (1<<MACH_BASE), 0 } } } }  },
313*3d8817e4Smiod   { IP2K_F_OP6, "f-op6", 0, 16, 15, 6, { 0, { { { (1<<MACH_BASE), 0 } } } }  },
314*3d8817e4Smiod   { IP2K_F_OP8, "f-op8", 0, 16, 15, 8, { 0, { { { (1<<MACH_BASE), 0 } } } }  },
315*3d8817e4Smiod   { IP2K_F_OP6_10LOW, "f-op6-10low", 0, 16, 9, 10, { 0, { { { (1<<MACH_BASE), 0 } } } }  },
316*3d8817e4Smiod   { IP2K_F_OP6_7LOW, "f-op6-7low", 0, 16, 9, 7, { 0, { { { (1<<MACH_BASE), 0 } } } }  },
317*3d8817e4Smiod   { IP2K_F_RETI3, "f-reti3", 0, 16, 2, 3, { 0, { { { (1<<MACH_BASE), 0 } } } }  },
318*3d8817e4Smiod   { IP2K_F_SKIPB, "f-skipb", 0, 16, 12, 1, { 0|A(ABS_ADDR), { { { (1<<MACH_BASE), 0 } } } }  },
319*3d8817e4Smiod   { IP2K_F_PAGE3, "f-page3", 0, 16, 2, 3, { 0, { { { (1<<MACH_BASE), 0 } } } }  },
320*3d8817e4Smiod   { 0, 0, 0, 0, 0, 0, { 0, { { { (1<<MACH_BASE), 0 } } } } }
321*3d8817e4Smiod };
322*3d8817e4Smiod 
323*3d8817e4Smiod #undef A
324*3d8817e4Smiod 
325*3d8817e4Smiod 
326*3d8817e4Smiod 
327*3d8817e4Smiod /* multi ifield declarations */
328*3d8817e4Smiod 
329*3d8817e4Smiod 
330*3d8817e4Smiod 
331*3d8817e4Smiod /* multi ifield definitions */
332*3d8817e4Smiod 
333*3d8817e4Smiod 
334*3d8817e4Smiod /* The operand table.  */
335*3d8817e4Smiod 
336*3d8817e4Smiod #if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
337*3d8817e4Smiod #define A(a) (1 << CGEN_OPERAND_##a)
338*3d8817e4Smiod #else
339*3d8817e4Smiod #define A(a) (1 << CGEN_OPERAND_/**/a)
340*3d8817e4Smiod #endif
341*3d8817e4Smiod #if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
342*3d8817e4Smiod #define OPERAND(op) IP2K_OPERAND_##op
343*3d8817e4Smiod #else
344*3d8817e4Smiod #define OPERAND(op) IP2K_OPERAND_/**/op
345*3d8817e4Smiod #endif
346*3d8817e4Smiod 
347*3d8817e4Smiod const CGEN_OPERAND ip2k_cgen_operand_table[] =
348*3d8817e4Smiod {
349*3d8817e4Smiod /* pc: program counter */
350*3d8817e4Smiod   { "pc", IP2K_OPERAND_PC, HW_H_PC, 0, 0,
351*3d8817e4Smiod     { 0, { (const PTR) &ip2k_cgen_ifld_table[IP2K_F_NIL] } },
352*3d8817e4Smiod     { 0|A(SEM_ONLY), { { { (1<<MACH_BASE), 0 } } } }  },
353*3d8817e4Smiod /* addr16cjp: 13-bit address */
354*3d8817e4Smiod   { "addr16cjp", IP2K_OPERAND_ADDR16CJP, HW_H_UINT, 12, 13,
355*3d8817e4Smiod     { 0, { (const PTR) &ip2k_cgen_ifld_table[IP2K_F_ADDR16CJP] } },
356*3d8817e4Smiod     { 0|A(ABS_ADDR), { { { (1<<MACH_BASE), 0 } } } }  },
357*3d8817e4Smiod /* fr: register */
358*3d8817e4Smiod   { "fr", IP2K_OPERAND_FR, HW_H_REGISTERS, 8, 9,
359*3d8817e4Smiod     { 0, { (const PTR) &ip2k_cgen_ifld_table[IP2K_F_REG] } },
360*3d8817e4Smiod     { 0|A(ABS_ADDR), { { { (1<<MACH_BASE), 0 } } } }  },
361*3d8817e4Smiod /* lit8: 8-bit signed literal */
362*3d8817e4Smiod   { "lit8", IP2K_OPERAND_LIT8, HW_H_SINT, 7, 8,
363*3d8817e4Smiod     { 0, { (const PTR) &ip2k_cgen_ifld_table[IP2K_F_IMM8] } },
364*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }  },
365*3d8817e4Smiod /* bitno: bit number */
366*3d8817e4Smiod   { "bitno", IP2K_OPERAND_BITNO, HW_H_UINT, 11, 3,
367*3d8817e4Smiod     { 0, { (const PTR) &ip2k_cgen_ifld_table[IP2K_F_BITNO] } },
368*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }  },
369*3d8817e4Smiod /* addr16p: page number */
370*3d8817e4Smiod   { "addr16p", IP2K_OPERAND_ADDR16P, HW_H_UINT, 2, 3,
371*3d8817e4Smiod     { 0, { (const PTR) &ip2k_cgen_ifld_table[IP2K_F_PAGE3] } },
372*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }  },
373*3d8817e4Smiod /* addr16h: high 8 bits of address */
374*3d8817e4Smiod   { "addr16h", IP2K_OPERAND_ADDR16H, HW_H_UINT, 7, 8,
375*3d8817e4Smiod     { 0, { (const PTR) &ip2k_cgen_ifld_table[IP2K_F_IMM8] } },
376*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }  },
377*3d8817e4Smiod /* addr16l: low 8 bits of address */
378*3d8817e4Smiod   { "addr16l", IP2K_OPERAND_ADDR16L, HW_H_UINT, 7, 8,
379*3d8817e4Smiod     { 0, { (const PTR) &ip2k_cgen_ifld_table[IP2K_F_IMM8] } },
380*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }  },
381*3d8817e4Smiod /* reti3: reti flags */
382*3d8817e4Smiod   { "reti3", IP2K_OPERAND_RETI3, HW_H_UINT, 2, 3,
383*3d8817e4Smiod     { 0, { (const PTR) &ip2k_cgen_ifld_table[IP2K_F_RETI3] } },
384*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }  },
385*3d8817e4Smiod /* pabits: page bits */
386*3d8817e4Smiod   { "pabits", IP2K_OPERAND_PABITS, HW_H_PABITS, 0, 0,
387*3d8817e4Smiod     { 0, { (const PTR) 0 } },
388*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }  },
389*3d8817e4Smiod /* zbit: zero bit */
390*3d8817e4Smiod   { "zbit", IP2K_OPERAND_ZBIT, HW_H_ZBIT, 0, 0,
391*3d8817e4Smiod     { 0, { (const PTR) 0 } },
392*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }  },
393*3d8817e4Smiod /* cbit: carry bit */
394*3d8817e4Smiod   { "cbit", IP2K_OPERAND_CBIT, HW_H_CBIT, 0, 0,
395*3d8817e4Smiod     { 0, { (const PTR) 0 } },
396*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }  },
397*3d8817e4Smiod /* dcbit: digit carry bit */
398*3d8817e4Smiod   { "dcbit", IP2K_OPERAND_DCBIT, HW_H_DCBIT, 0, 0,
399*3d8817e4Smiod     { 0, { (const PTR) 0 } },
400*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }  },
401*3d8817e4Smiod /* sentinel */
402*3d8817e4Smiod   { 0, 0, 0, 0, 0,
403*3d8817e4Smiod     { 0, { (const PTR) 0 } },
404*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } } }
405*3d8817e4Smiod };
406*3d8817e4Smiod 
407*3d8817e4Smiod #undef A
408*3d8817e4Smiod 
409*3d8817e4Smiod 
410*3d8817e4Smiod /* The instruction table.  */
411*3d8817e4Smiod 
412*3d8817e4Smiod #define OP(field) CGEN_SYNTAX_MAKE_FIELD (OPERAND (field))
413*3d8817e4Smiod #if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
414*3d8817e4Smiod #define A(a) (1 << CGEN_INSN_##a)
415*3d8817e4Smiod #else
416*3d8817e4Smiod #define A(a) (1 << CGEN_INSN_/**/a)
417*3d8817e4Smiod #endif
418*3d8817e4Smiod 
419*3d8817e4Smiod static const CGEN_IBASE ip2k_cgen_insn_table[MAX_INSNS] =
420*3d8817e4Smiod {
421*3d8817e4Smiod   /* Special null first entry.
422*3d8817e4Smiod      A `num' value of zero is thus invalid.
423*3d8817e4Smiod      Also, the special `invalid' insn resides here.  */
424*3d8817e4Smiod   { 0, 0, 0, 0, { 0, { { { (1<<MACH_BASE), 0 } } } } },
425*3d8817e4Smiod /* jmp $addr16cjp */
426*3d8817e4Smiod   {
427*3d8817e4Smiod     IP2K_INSN_JMP, "jmp", "jmp", 16,
428*3d8817e4Smiod     { 0|A(UNCOND_CTI), { { { (1<<MACH_BASE), 0 } } } }
429*3d8817e4Smiod   },
430*3d8817e4Smiod /* call $addr16cjp */
431*3d8817e4Smiod   {
432*3d8817e4Smiod     IP2K_INSN_CALL, "call", "call", 16,
433*3d8817e4Smiod     { 0|A(UNCOND_CTI), { { { (1<<MACH_BASE), 0 } } } }
434*3d8817e4Smiod   },
435*3d8817e4Smiod /* sb $fr,$bitno */
436*3d8817e4Smiod   {
437*3d8817e4Smiod     IP2K_INSN_SB, "sb", "sb", 16,
438*3d8817e4Smiod     { 0|A(SKIP_CTI), { { { (1<<MACH_BASE), 0 } } } }
439*3d8817e4Smiod   },
440*3d8817e4Smiod /* snb $fr,$bitno */
441*3d8817e4Smiod   {
442*3d8817e4Smiod     IP2K_INSN_SNB, "snb", "snb", 16,
443*3d8817e4Smiod     { 0|A(SKIP_CTI), { { { (1<<MACH_BASE), 0 } } } }
444*3d8817e4Smiod   },
445*3d8817e4Smiod /* setb $fr,$bitno */
446*3d8817e4Smiod   {
447*3d8817e4Smiod     IP2K_INSN_SETB, "setb", "setb", 16,
448*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
449*3d8817e4Smiod   },
450*3d8817e4Smiod /* clrb $fr,$bitno */
451*3d8817e4Smiod   {
452*3d8817e4Smiod     IP2K_INSN_CLRB, "clrb", "clrb", 16,
453*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
454*3d8817e4Smiod   },
455*3d8817e4Smiod /* xor W,#$lit8 */
456*3d8817e4Smiod   {
457*3d8817e4Smiod     IP2K_INSN_XORW_L, "xorw_l", "xor", 16,
458*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
459*3d8817e4Smiod   },
460*3d8817e4Smiod /* and W,#$lit8 */
461*3d8817e4Smiod   {
462*3d8817e4Smiod     IP2K_INSN_ANDW_L, "andw_l", "and", 16,
463*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
464*3d8817e4Smiod   },
465*3d8817e4Smiod /* or W,#$lit8 */
466*3d8817e4Smiod   {
467*3d8817e4Smiod     IP2K_INSN_ORW_L, "orw_l", "or", 16,
468*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
469*3d8817e4Smiod   },
470*3d8817e4Smiod /* add W,#$lit8 */
471*3d8817e4Smiod   {
472*3d8817e4Smiod     IP2K_INSN_ADDW_L, "addw_l", "add", 16,
473*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
474*3d8817e4Smiod   },
475*3d8817e4Smiod /* sub W,#$lit8 */
476*3d8817e4Smiod   {
477*3d8817e4Smiod     IP2K_INSN_SUBW_L, "subw_l", "sub", 16,
478*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
479*3d8817e4Smiod   },
480*3d8817e4Smiod /* cmp W,#$lit8 */
481*3d8817e4Smiod   {
482*3d8817e4Smiod     IP2K_INSN_CMPW_L, "cmpw_l", "cmp", 16,
483*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
484*3d8817e4Smiod   },
485*3d8817e4Smiod /* retw #$lit8 */
486*3d8817e4Smiod   {
487*3d8817e4Smiod     IP2K_INSN_RETW_L, "retw_l", "retw", 16,
488*3d8817e4Smiod     { 0|A(UNCOND_CTI), { { { (1<<MACH_BASE), 0 } } } }
489*3d8817e4Smiod   },
490*3d8817e4Smiod /* cse W,#$lit8 */
491*3d8817e4Smiod   {
492*3d8817e4Smiod     IP2K_INSN_CSEW_L, "csew_l", "cse", 16,
493*3d8817e4Smiod     { 0|A(SKIP_CTI), { { { (1<<MACH_BASE), 0 } } } }
494*3d8817e4Smiod   },
495*3d8817e4Smiod /* csne W,#$lit8 */
496*3d8817e4Smiod   {
497*3d8817e4Smiod     IP2K_INSN_CSNEW_L, "csnew_l", "csne", 16,
498*3d8817e4Smiod     { 0|A(SKIP_CTI), { { { (1<<MACH_BASE), 0 } } } }
499*3d8817e4Smiod   },
500*3d8817e4Smiod /* push #$lit8 */
501*3d8817e4Smiod   {
502*3d8817e4Smiod     IP2K_INSN_PUSH_L, "push_l", "push", 16,
503*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
504*3d8817e4Smiod   },
505*3d8817e4Smiod /* muls W,#$lit8 */
506*3d8817e4Smiod   {
507*3d8817e4Smiod     IP2K_INSN_MULSW_L, "mulsw_l", "muls", 16,
508*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
509*3d8817e4Smiod   },
510*3d8817e4Smiod /* mulu W,#$lit8 */
511*3d8817e4Smiod   {
512*3d8817e4Smiod     IP2K_INSN_MULUW_L, "muluw_l", "mulu", 16,
513*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
514*3d8817e4Smiod   },
515*3d8817e4Smiod /* loadl #$lit8 */
516*3d8817e4Smiod   {
517*3d8817e4Smiod     IP2K_INSN_LOADL_L, "loadl_l", "loadl", 16,
518*3d8817e4Smiod     { 0|A(EXT_SKIP_INSN), { { { (1<<MACH_BASE), 0 } } } }
519*3d8817e4Smiod   },
520*3d8817e4Smiod /* loadh #$lit8 */
521*3d8817e4Smiod   {
522*3d8817e4Smiod     IP2K_INSN_LOADH_L, "loadh_l", "loadh", 16,
523*3d8817e4Smiod     { 0|A(EXT_SKIP_INSN), { { { (1<<MACH_BASE), 0 } } } }
524*3d8817e4Smiod   },
525*3d8817e4Smiod /* loadl $addr16l */
526*3d8817e4Smiod   {
527*3d8817e4Smiod     IP2K_INSN_LOADL_A, "loadl_a", "loadl", 16,
528*3d8817e4Smiod     { 0|A(EXT_SKIP_INSN), { { { (1<<MACH_BASE), 0 } } } }
529*3d8817e4Smiod   },
530*3d8817e4Smiod /* loadh $addr16h */
531*3d8817e4Smiod   {
532*3d8817e4Smiod     IP2K_INSN_LOADH_A, "loadh_a", "loadh", 16,
533*3d8817e4Smiod     { 0|A(EXT_SKIP_INSN), { { { (1<<MACH_BASE), 0 } } } }
534*3d8817e4Smiod   },
535*3d8817e4Smiod /* addc $fr,W */
536*3d8817e4Smiod   {
537*3d8817e4Smiod     IP2K_INSN_ADDCFR_W, "addcfr_w", "addc", 16,
538*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
539*3d8817e4Smiod   },
540*3d8817e4Smiod /* addc W,$fr */
541*3d8817e4Smiod   {
542*3d8817e4Smiod     IP2K_INSN_ADDCW_FR, "addcw_fr", "addc", 16,
543*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
544*3d8817e4Smiod   },
545*3d8817e4Smiod /* incsnz $fr */
546*3d8817e4Smiod   {
547*3d8817e4Smiod     IP2K_INSN_INCSNZ_FR, "incsnz_fr", "incsnz", 16,
548*3d8817e4Smiod     { 0|A(SKIP_CTI), { { { (1<<MACH_BASE), 0 } } } }
549*3d8817e4Smiod   },
550*3d8817e4Smiod /* incsnz W,$fr */
551*3d8817e4Smiod   {
552*3d8817e4Smiod     IP2K_INSN_INCSNZW_FR, "incsnzw_fr", "incsnz", 16,
553*3d8817e4Smiod     { 0|A(SKIP_CTI), { { { (1<<MACH_BASE), 0 } } } }
554*3d8817e4Smiod   },
555*3d8817e4Smiod /* muls W,$fr */
556*3d8817e4Smiod   {
557*3d8817e4Smiod     IP2K_INSN_MULSW_FR, "mulsw_fr", "muls", 16,
558*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
559*3d8817e4Smiod   },
560*3d8817e4Smiod /* mulu W,$fr */
561*3d8817e4Smiod   {
562*3d8817e4Smiod     IP2K_INSN_MULUW_FR, "muluw_fr", "mulu", 16,
563*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
564*3d8817e4Smiod   },
565*3d8817e4Smiod /* decsnz $fr */
566*3d8817e4Smiod   {
567*3d8817e4Smiod     IP2K_INSN_DECSNZ_FR, "decsnz_fr", "decsnz", 16,
568*3d8817e4Smiod     { 0|A(SKIP_CTI), { { { (1<<MACH_BASE), 0 } } } }
569*3d8817e4Smiod   },
570*3d8817e4Smiod /* decsnz W,$fr */
571*3d8817e4Smiod   {
572*3d8817e4Smiod     IP2K_INSN_DECSNZW_FR, "decsnzw_fr", "decsnz", 16,
573*3d8817e4Smiod     { 0|A(SKIP_CTI), { { { (1<<MACH_BASE), 0 } } } }
574*3d8817e4Smiod   },
575*3d8817e4Smiod /* subc W,$fr */
576*3d8817e4Smiod   {
577*3d8817e4Smiod     IP2K_INSN_SUBCW_FR, "subcw_fr", "subc", 16,
578*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
579*3d8817e4Smiod   },
580*3d8817e4Smiod /* subc $fr,W */
581*3d8817e4Smiod   {
582*3d8817e4Smiod     IP2K_INSN_SUBCFR_W, "subcfr_w", "subc", 16,
583*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
584*3d8817e4Smiod   },
585*3d8817e4Smiod /* pop $fr */
586*3d8817e4Smiod   {
587*3d8817e4Smiod     IP2K_INSN_POP_FR, "pop_fr", "pop", 16,
588*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
589*3d8817e4Smiod   },
590*3d8817e4Smiod /* push $fr */
591*3d8817e4Smiod   {
592*3d8817e4Smiod     IP2K_INSN_PUSH_FR, "push_fr", "push", 16,
593*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
594*3d8817e4Smiod   },
595*3d8817e4Smiod /* cse W,$fr */
596*3d8817e4Smiod   {
597*3d8817e4Smiod     IP2K_INSN_CSEW_FR, "csew_fr", "cse", 16,
598*3d8817e4Smiod     { 0|A(SKIP_CTI), { { { (1<<MACH_BASE), 0 } } } }
599*3d8817e4Smiod   },
600*3d8817e4Smiod /* csne W,$fr */
601*3d8817e4Smiod   {
602*3d8817e4Smiod     IP2K_INSN_CSNEW_FR, "csnew_fr", "csne", 16,
603*3d8817e4Smiod     { 0|A(SKIP_CTI), { { { (1<<MACH_BASE), 0 } } } }
604*3d8817e4Smiod   },
605*3d8817e4Smiod /* incsz $fr */
606*3d8817e4Smiod   {
607*3d8817e4Smiod     IP2K_INSN_INCSZ_FR, "incsz_fr", "incsz", 16,
608*3d8817e4Smiod     { 0|A(SKIP_CTI), { { { (1<<MACH_BASE), 0 } } } }
609*3d8817e4Smiod   },
610*3d8817e4Smiod /* incsz W,$fr */
611*3d8817e4Smiod   {
612*3d8817e4Smiod     IP2K_INSN_INCSZW_FR, "incszw_fr", "incsz", 16,
613*3d8817e4Smiod     { 0|A(SKIP_CTI), { { { (1<<MACH_BASE), 0 } } } }
614*3d8817e4Smiod   },
615*3d8817e4Smiod /* swap $fr */
616*3d8817e4Smiod   {
617*3d8817e4Smiod     IP2K_INSN_SWAP_FR, "swap_fr", "swap", 16,
618*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
619*3d8817e4Smiod   },
620*3d8817e4Smiod /* swap W,$fr */
621*3d8817e4Smiod   {
622*3d8817e4Smiod     IP2K_INSN_SWAPW_FR, "swapw_fr", "swap", 16,
623*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
624*3d8817e4Smiod   },
625*3d8817e4Smiod /* rl $fr */
626*3d8817e4Smiod   {
627*3d8817e4Smiod     IP2K_INSN_RL_FR, "rl_fr", "rl", 16,
628*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
629*3d8817e4Smiod   },
630*3d8817e4Smiod /* rl W,$fr */
631*3d8817e4Smiod   {
632*3d8817e4Smiod     IP2K_INSN_RLW_FR, "rlw_fr", "rl", 16,
633*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
634*3d8817e4Smiod   },
635*3d8817e4Smiod /* rr $fr */
636*3d8817e4Smiod   {
637*3d8817e4Smiod     IP2K_INSN_RR_FR, "rr_fr", "rr", 16,
638*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
639*3d8817e4Smiod   },
640*3d8817e4Smiod /* rr W,$fr */
641*3d8817e4Smiod   {
642*3d8817e4Smiod     IP2K_INSN_RRW_FR, "rrw_fr", "rr", 16,
643*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
644*3d8817e4Smiod   },
645*3d8817e4Smiod /* decsz $fr */
646*3d8817e4Smiod   {
647*3d8817e4Smiod     IP2K_INSN_DECSZ_FR, "decsz_fr", "decsz", 16,
648*3d8817e4Smiod     { 0|A(SKIP_CTI), { { { (1<<MACH_BASE), 0 } } } }
649*3d8817e4Smiod   },
650*3d8817e4Smiod /* decsz W,$fr */
651*3d8817e4Smiod   {
652*3d8817e4Smiod     IP2K_INSN_DECSZW_FR, "decszw_fr", "decsz", 16,
653*3d8817e4Smiod     { 0|A(SKIP_CTI), { { { (1<<MACH_BASE), 0 } } } }
654*3d8817e4Smiod   },
655*3d8817e4Smiod /* inc $fr */
656*3d8817e4Smiod   {
657*3d8817e4Smiod     IP2K_INSN_INC_FR, "inc_fr", "inc", 16,
658*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
659*3d8817e4Smiod   },
660*3d8817e4Smiod /* inc W,$fr */
661*3d8817e4Smiod   {
662*3d8817e4Smiod     IP2K_INSN_INCW_FR, "incw_fr", "inc", 16,
663*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
664*3d8817e4Smiod   },
665*3d8817e4Smiod /* not $fr */
666*3d8817e4Smiod   {
667*3d8817e4Smiod     IP2K_INSN_NOT_FR, "not_fr", "not", 16,
668*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
669*3d8817e4Smiod   },
670*3d8817e4Smiod /* not W,$fr */
671*3d8817e4Smiod   {
672*3d8817e4Smiod     IP2K_INSN_NOTW_FR, "notw_fr", "not", 16,
673*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
674*3d8817e4Smiod   },
675*3d8817e4Smiod /* test $fr */
676*3d8817e4Smiod   {
677*3d8817e4Smiod     IP2K_INSN_TEST_FR, "test_fr", "test", 16,
678*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
679*3d8817e4Smiod   },
680*3d8817e4Smiod /* mov W,#$lit8 */
681*3d8817e4Smiod   {
682*3d8817e4Smiod     IP2K_INSN_MOVW_L, "movw_l", "mov", 16,
683*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
684*3d8817e4Smiod   },
685*3d8817e4Smiod /* mov $fr,W */
686*3d8817e4Smiod   {
687*3d8817e4Smiod     IP2K_INSN_MOVFR_W, "movfr_w", "mov", 16,
688*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
689*3d8817e4Smiod   },
690*3d8817e4Smiod /* mov W,$fr */
691*3d8817e4Smiod   {
692*3d8817e4Smiod     IP2K_INSN_MOVW_FR, "movw_fr", "mov", 16,
693*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
694*3d8817e4Smiod   },
695*3d8817e4Smiod /* add $fr,W */
696*3d8817e4Smiod   {
697*3d8817e4Smiod     IP2K_INSN_ADDFR_W, "addfr_w", "add", 16,
698*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
699*3d8817e4Smiod   },
700*3d8817e4Smiod /* add W,$fr */
701*3d8817e4Smiod   {
702*3d8817e4Smiod     IP2K_INSN_ADDW_FR, "addw_fr", "add", 16,
703*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
704*3d8817e4Smiod   },
705*3d8817e4Smiod /* xor $fr,W */
706*3d8817e4Smiod   {
707*3d8817e4Smiod     IP2K_INSN_XORFR_W, "xorfr_w", "xor", 16,
708*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
709*3d8817e4Smiod   },
710*3d8817e4Smiod /* xor W,$fr */
711*3d8817e4Smiod   {
712*3d8817e4Smiod     IP2K_INSN_XORW_FR, "xorw_fr", "xor", 16,
713*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
714*3d8817e4Smiod   },
715*3d8817e4Smiod /* and $fr,W */
716*3d8817e4Smiod   {
717*3d8817e4Smiod     IP2K_INSN_ANDFR_W, "andfr_w", "and", 16,
718*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
719*3d8817e4Smiod   },
720*3d8817e4Smiod /* and W,$fr */
721*3d8817e4Smiod   {
722*3d8817e4Smiod     IP2K_INSN_ANDW_FR, "andw_fr", "and", 16,
723*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
724*3d8817e4Smiod   },
725*3d8817e4Smiod /* or $fr,W */
726*3d8817e4Smiod   {
727*3d8817e4Smiod     IP2K_INSN_ORFR_W, "orfr_w", "or", 16,
728*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
729*3d8817e4Smiod   },
730*3d8817e4Smiod /* or W,$fr */
731*3d8817e4Smiod   {
732*3d8817e4Smiod     IP2K_INSN_ORW_FR, "orw_fr", "or", 16,
733*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
734*3d8817e4Smiod   },
735*3d8817e4Smiod /* dec $fr */
736*3d8817e4Smiod   {
737*3d8817e4Smiod     IP2K_INSN_DEC_FR, "dec_fr", "dec", 16,
738*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
739*3d8817e4Smiod   },
740*3d8817e4Smiod /* dec W,$fr */
741*3d8817e4Smiod   {
742*3d8817e4Smiod     IP2K_INSN_DECW_FR, "decw_fr", "dec", 16,
743*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
744*3d8817e4Smiod   },
745*3d8817e4Smiod /* sub $fr,W */
746*3d8817e4Smiod   {
747*3d8817e4Smiod     IP2K_INSN_SUBFR_W, "subfr_w", "sub", 16,
748*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
749*3d8817e4Smiod   },
750*3d8817e4Smiod /* sub W,$fr */
751*3d8817e4Smiod   {
752*3d8817e4Smiod     IP2K_INSN_SUBW_FR, "subw_fr", "sub", 16,
753*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
754*3d8817e4Smiod   },
755*3d8817e4Smiod /* clr $fr */
756*3d8817e4Smiod   {
757*3d8817e4Smiod     IP2K_INSN_CLR_FR, "clr_fr", "clr", 16,
758*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
759*3d8817e4Smiod   },
760*3d8817e4Smiod /* cmp W,$fr */
761*3d8817e4Smiod   {
762*3d8817e4Smiod     IP2K_INSN_CMPW_FR, "cmpw_fr", "cmp", 16,
763*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
764*3d8817e4Smiod   },
765*3d8817e4Smiod /* speed #$lit8 */
766*3d8817e4Smiod   {
767*3d8817e4Smiod     IP2K_INSN_SPEED, "speed", "speed", 16,
768*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
769*3d8817e4Smiod   },
770*3d8817e4Smiod /* ireadi */
771*3d8817e4Smiod   {
772*3d8817e4Smiod     IP2K_INSN_IREADI, "ireadi", "ireadi", 16,
773*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
774*3d8817e4Smiod   },
775*3d8817e4Smiod /* iwritei */
776*3d8817e4Smiod   {
777*3d8817e4Smiod     IP2K_INSN_IWRITEI, "iwritei", "iwritei", 16,
778*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
779*3d8817e4Smiod   },
780*3d8817e4Smiod /* fread */
781*3d8817e4Smiod   {
782*3d8817e4Smiod     IP2K_INSN_FREAD, "fread", "fread", 16,
783*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
784*3d8817e4Smiod   },
785*3d8817e4Smiod /* fwrite */
786*3d8817e4Smiod   {
787*3d8817e4Smiod     IP2K_INSN_FWRITE, "fwrite", "fwrite", 16,
788*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
789*3d8817e4Smiod   },
790*3d8817e4Smiod /* iread */
791*3d8817e4Smiod   {
792*3d8817e4Smiod     IP2K_INSN_IREAD, "iread", "iread", 16,
793*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
794*3d8817e4Smiod   },
795*3d8817e4Smiod /* iwrite */
796*3d8817e4Smiod   {
797*3d8817e4Smiod     IP2K_INSN_IWRITE, "iwrite", "iwrite", 16,
798*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
799*3d8817e4Smiod   },
800*3d8817e4Smiod /* page $addr16p */
801*3d8817e4Smiod   {
802*3d8817e4Smiod     IP2K_INSN_PAGE, "page", "page", 16,
803*3d8817e4Smiod     { 0|A(EXT_SKIP_INSN), { { { (1<<MACH_BASE), 0 } } } }
804*3d8817e4Smiod   },
805*3d8817e4Smiod /* system */
806*3d8817e4Smiod   {
807*3d8817e4Smiod     IP2K_INSN_SYSTEM, "system", "system", 16,
808*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
809*3d8817e4Smiod   },
810*3d8817e4Smiod /* reti #$reti3 */
811*3d8817e4Smiod   {
812*3d8817e4Smiod     IP2K_INSN_RETI, "reti", "reti", 16,
813*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
814*3d8817e4Smiod   },
815*3d8817e4Smiod /* ret */
816*3d8817e4Smiod   {
817*3d8817e4Smiod     IP2K_INSN_RET, "ret", "ret", 16,
818*3d8817e4Smiod     { 0|A(UNCOND_CTI), { { { (1<<MACH_BASE), 0 } } } }
819*3d8817e4Smiod   },
820*3d8817e4Smiod /* int */
821*3d8817e4Smiod   {
822*3d8817e4Smiod     IP2K_INSN_INT, "int", "int", 16,
823*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
824*3d8817e4Smiod   },
825*3d8817e4Smiod /* breakx */
826*3d8817e4Smiod   {
827*3d8817e4Smiod     IP2K_INSN_BREAKX, "breakx", "breakx", 16,
828*3d8817e4Smiod     { 0|A(EXT_SKIP_INSN), { { { (1<<MACH_BASE), 0 } } } }
829*3d8817e4Smiod   },
830*3d8817e4Smiod /* cwdt */
831*3d8817e4Smiod   {
832*3d8817e4Smiod     IP2K_INSN_CWDT, "cwdt", "cwdt", 16,
833*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
834*3d8817e4Smiod   },
835*3d8817e4Smiod /* ferase */
836*3d8817e4Smiod   {
837*3d8817e4Smiod     IP2K_INSN_FERASE, "ferase", "ferase", 16,
838*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
839*3d8817e4Smiod   },
840*3d8817e4Smiod /* retnp */
841*3d8817e4Smiod   {
842*3d8817e4Smiod     IP2K_INSN_RETNP, "retnp", "retnp", 16,
843*3d8817e4Smiod     { 0|A(UNCOND_CTI), { { { (1<<MACH_BASE), 0 } } } }
844*3d8817e4Smiod   },
845*3d8817e4Smiod /* break */
846*3d8817e4Smiod   {
847*3d8817e4Smiod     IP2K_INSN_BREAK, "break", "break", 16,
848*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
849*3d8817e4Smiod   },
850*3d8817e4Smiod /* nop */
851*3d8817e4Smiod   {
852*3d8817e4Smiod     IP2K_INSN_NOP, "nop", "nop", 16,
853*3d8817e4Smiod     { 0, { { { (1<<MACH_BASE), 0 } } } }
854*3d8817e4Smiod   },
855*3d8817e4Smiod };
856*3d8817e4Smiod 
857*3d8817e4Smiod #undef OP
858*3d8817e4Smiod #undef A
859*3d8817e4Smiod 
860*3d8817e4Smiod /* Initialize anything needed to be done once, before any cpu_open call.  */
861*3d8817e4Smiod 
862*3d8817e4Smiod static void
init_tables(void)863*3d8817e4Smiod init_tables (void)
864*3d8817e4Smiod {
865*3d8817e4Smiod }
866*3d8817e4Smiod 
867*3d8817e4Smiod static const CGEN_MACH * lookup_mach_via_bfd_name (const CGEN_MACH *, const char *);
868*3d8817e4Smiod static void build_hw_table      (CGEN_CPU_TABLE *);
869*3d8817e4Smiod static void build_ifield_table  (CGEN_CPU_TABLE *);
870*3d8817e4Smiod static void build_operand_table (CGEN_CPU_TABLE *);
871*3d8817e4Smiod static void build_insn_table    (CGEN_CPU_TABLE *);
872*3d8817e4Smiod static void ip2k_cgen_rebuild_tables (CGEN_CPU_TABLE *);
873*3d8817e4Smiod 
874*3d8817e4Smiod /* Subroutine of ip2k_cgen_cpu_open to look up a mach via its bfd name.  */
875*3d8817e4Smiod 
876*3d8817e4Smiod static const CGEN_MACH *
lookup_mach_via_bfd_name(const CGEN_MACH * table,const char * name)877*3d8817e4Smiod lookup_mach_via_bfd_name (const CGEN_MACH *table, const char *name)
878*3d8817e4Smiod {
879*3d8817e4Smiod   while (table->name)
880*3d8817e4Smiod     {
881*3d8817e4Smiod       if (strcmp (name, table->bfd_name) == 0)
882*3d8817e4Smiod 	return table;
883*3d8817e4Smiod       ++table;
884*3d8817e4Smiod     }
885*3d8817e4Smiod   abort ();
886*3d8817e4Smiod }
887*3d8817e4Smiod 
888*3d8817e4Smiod /* Subroutine of ip2k_cgen_cpu_open to build the hardware table.  */
889*3d8817e4Smiod 
890*3d8817e4Smiod static void
build_hw_table(CGEN_CPU_TABLE * cd)891*3d8817e4Smiod build_hw_table (CGEN_CPU_TABLE *cd)
892*3d8817e4Smiod {
893*3d8817e4Smiod   int i;
894*3d8817e4Smiod   int machs = cd->machs;
895*3d8817e4Smiod   const CGEN_HW_ENTRY *init = & ip2k_cgen_hw_table[0];
896*3d8817e4Smiod   /* MAX_HW is only an upper bound on the number of selected entries.
897*3d8817e4Smiod      However each entry is indexed by it's enum so there can be holes in
898*3d8817e4Smiod      the table.  */
899*3d8817e4Smiod   const CGEN_HW_ENTRY **selected =
900*3d8817e4Smiod     (const CGEN_HW_ENTRY **) xmalloc (MAX_HW * sizeof (CGEN_HW_ENTRY *));
901*3d8817e4Smiod 
902*3d8817e4Smiod   cd->hw_table.init_entries = init;
903*3d8817e4Smiod   cd->hw_table.entry_size = sizeof (CGEN_HW_ENTRY);
904*3d8817e4Smiod   memset (selected, 0, MAX_HW * sizeof (CGEN_HW_ENTRY *));
905*3d8817e4Smiod   /* ??? For now we just use machs to determine which ones we want.  */
906*3d8817e4Smiod   for (i = 0; init[i].name != NULL; ++i)
907*3d8817e4Smiod     if (CGEN_HW_ATTR_VALUE (&init[i], CGEN_HW_MACH)
908*3d8817e4Smiod 	& machs)
909*3d8817e4Smiod       selected[init[i].type] = &init[i];
910*3d8817e4Smiod   cd->hw_table.entries = selected;
911*3d8817e4Smiod   cd->hw_table.num_entries = MAX_HW;
912*3d8817e4Smiod }
913*3d8817e4Smiod 
914*3d8817e4Smiod /* Subroutine of ip2k_cgen_cpu_open to build the hardware table.  */
915*3d8817e4Smiod 
916*3d8817e4Smiod static void
build_ifield_table(CGEN_CPU_TABLE * cd)917*3d8817e4Smiod build_ifield_table (CGEN_CPU_TABLE *cd)
918*3d8817e4Smiod {
919*3d8817e4Smiod   cd->ifld_table = & ip2k_cgen_ifld_table[0];
920*3d8817e4Smiod }
921*3d8817e4Smiod 
922*3d8817e4Smiod /* Subroutine of ip2k_cgen_cpu_open to build the hardware table.  */
923*3d8817e4Smiod 
924*3d8817e4Smiod static void
build_operand_table(CGEN_CPU_TABLE * cd)925*3d8817e4Smiod build_operand_table (CGEN_CPU_TABLE *cd)
926*3d8817e4Smiod {
927*3d8817e4Smiod   int i;
928*3d8817e4Smiod   int machs = cd->machs;
929*3d8817e4Smiod   const CGEN_OPERAND *init = & ip2k_cgen_operand_table[0];
930*3d8817e4Smiod   /* MAX_OPERANDS is only an upper bound on the number of selected entries.
931*3d8817e4Smiod      However each entry is indexed by it's enum so there can be holes in
932*3d8817e4Smiod      the table.  */
933*3d8817e4Smiod   const CGEN_OPERAND **selected = xmalloc (MAX_OPERANDS * sizeof (* selected));
934*3d8817e4Smiod 
935*3d8817e4Smiod   cd->operand_table.init_entries = init;
936*3d8817e4Smiod   cd->operand_table.entry_size = sizeof (CGEN_OPERAND);
937*3d8817e4Smiod   memset (selected, 0, MAX_OPERANDS * sizeof (CGEN_OPERAND *));
938*3d8817e4Smiod   /* ??? For now we just use mach to determine which ones we want.  */
939*3d8817e4Smiod   for (i = 0; init[i].name != NULL; ++i)
940*3d8817e4Smiod     if (CGEN_OPERAND_ATTR_VALUE (&init[i], CGEN_OPERAND_MACH)
941*3d8817e4Smiod 	& machs)
942*3d8817e4Smiod       selected[init[i].type] = &init[i];
943*3d8817e4Smiod   cd->operand_table.entries = selected;
944*3d8817e4Smiod   cd->operand_table.num_entries = MAX_OPERANDS;
945*3d8817e4Smiod }
946*3d8817e4Smiod 
947*3d8817e4Smiod /* Subroutine of ip2k_cgen_cpu_open to build the hardware table.
948*3d8817e4Smiod    ??? This could leave out insns not supported by the specified mach/isa,
949*3d8817e4Smiod    but that would cause errors like "foo only supported by bar" to become
950*3d8817e4Smiod    "unknown insn", so for now we include all insns and require the app to
951*3d8817e4Smiod    do the checking later.
952*3d8817e4Smiod    ??? On the other hand, parsing of such insns may require their hardware or
953*3d8817e4Smiod    operand elements to be in the table [which they mightn't be].  */
954*3d8817e4Smiod 
955*3d8817e4Smiod static void
build_insn_table(CGEN_CPU_TABLE * cd)956*3d8817e4Smiod build_insn_table (CGEN_CPU_TABLE *cd)
957*3d8817e4Smiod {
958*3d8817e4Smiod   int i;
959*3d8817e4Smiod   const CGEN_IBASE *ib = & ip2k_cgen_insn_table[0];
960*3d8817e4Smiod   CGEN_INSN *insns = xmalloc (MAX_INSNS * sizeof (CGEN_INSN));
961*3d8817e4Smiod 
962*3d8817e4Smiod   memset (insns, 0, MAX_INSNS * sizeof (CGEN_INSN));
963*3d8817e4Smiod   for (i = 0; i < MAX_INSNS; ++i)
964*3d8817e4Smiod     insns[i].base = &ib[i];
965*3d8817e4Smiod   cd->insn_table.init_entries = insns;
966*3d8817e4Smiod   cd->insn_table.entry_size = sizeof (CGEN_IBASE);
967*3d8817e4Smiod   cd->insn_table.num_init_entries = MAX_INSNS;
968*3d8817e4Smiod }
969*3d8817e4Smiod 
970*3d8817e4Smiod /* Subroutine of ip2k_cgen_cpu_open to rebuild the tables.  */
971*3d8817e4Smiod 
972*3d8817e4Smiod static void
ip2k_cgen_rebuild_tables(CGEN_CPU_TABLE * cd)973*3d8817e4Smiod ip2k_cgen_rebuild_tables (CGEN_CPU_TABLE *cd)
974*3d8817e4Smiod {
975*3d8817e4Smiod   int i;
976*3d8817e4Smiod   CGEN_BITSET *isas = cd->isas;
977*3d8817e4Smiod   unsigned int machs = cd->machs;
978*3d8817e4Smiod 
979*3d8817e4Smiod   cd->int_insn_p = CGEN_INT_INSN_P;
980*3d8817e4Smiod 
981*3d8817e4Smiod   /* Data derived from the isa spec.  */
982*3d8817e4Smiod #define UNSET (CGEN_SIZE_UNKNOWN + 1)
983*3d8817e4Smiod   cd->default_insn_bitsize = UNSET;
984*3d8817e4Smiod   cd->base_insn_bitsize = UNSET;
985*3d8817e4Smiod   cd->min_insn_bitsize = 65535; /* Some ridiculously big number.  */
986*3d8817e4Smiod   cd->max_insn_bitsize = 0;
987*3d8817e4Smiod   for (i = 0; i < MAX_ISAS; ++i)
988*3d8817e4Smiod     if (cgen_bitset_contains (isas, i))
989*3d8817e4Smiod       {
990*3d8817e4Smiod 	const CGEN_ISA *isa = & ip2k_cgen_isa_table[i];
991*3d8817e4Smiod 
992*3d8817e4Smiod 	/* Default insn sizes of all selected isas must be
993*3d8817e4Smiod 	   equal or we set the result to 0, meaning "unknown".  */
994*3d8817e4Smiod 	if (cd->default_insn_bitsize == UNSET)
995*3d8817e4Smiod 	  cd->default_insn_bitsize = isa->default_insn_bitsize;
996*3d8817e4Smiod 	else if (isa->default_insn_bitsize == cd->default_insn_bitsize)
997*3d8817e4Smiod 	  ; /* This is ok.  */
998*3d8817e4Smiod 	else
999*3d8817e4Smiod 	  cd->default_insn_bitsize = CGEN_SIZE_UNKNOWN;
1000*3d8817e4Smiod 
1001*3d8817e4Smiod 	/* Base insn sizes of all selected isas must be equal
1002*3d8817e4Smiod 	   or we set the result to 0, meaning "unknown".  */
1003*3d8817e4Smiod 	if (cd->base_insn_bitsize == UNSET)
1004*3d8817e4Smiod 	  cd->base_insn_bitsize = isa->base_insn_bitsize;
1005*3d8817e4Smiod 	else if (isa->base_insn_bitsize == cd->base_insn_bitsize)
1006*3d8817e4Smiod 	  ; /* This is ok.  */
1007*3d8817e4Smiod 	else
1008*3d8817e4Smiod 	  cd->base_insn_bitsize = CGEN_SIZE_UNKNOWN;
1009*3d8817e4Smiod 
1010*3d8817e4Smiod 	/* Set min,max insn sizes.  */
1011*3d8817e4Smiod 	if (isa->min_insn_bitsize < cd->min_insn_bitsize)
1012*3d8817e4Smiod 	  cd->min_insn_bitsize = isa->min_insn_bitsize;
1013*3d8817e4Smiod 	if (isa->max_insn_bitsize > cd->max_insn_bitsize)
1014*3d8817e4Smiod 	  cd->max_insn_bitsize = isa->max_insn_bitsize;
1015*3d8817e4Smiod       }
1016*3d8817e4Smiod 
1017*3d8817e4Smiod   /* Data derived from the mach spec.  */
1018*3d8817e4Smiod   for (i = 0; i < MAX_MACHS; ++i)
1019*3d8817e4Smiod     if (((1 << i) & machs) != 0)
1020*3d8817e4Smiod       {
1021*3d8817e4Smiod 	const CGEN_MACH *mach = & ip2k_cgen_mach_table[i];
1022*3d8817e4Smiod 
1023*3d8817e4Smiod 	if (mach->insn_chunk_bitsize != 0)
1024*3d8817e4Smiod 	{
1025*3d8817e4Smiod 	  if (cd->insn_chunk_bitsize != 0 && cd->insn_chunk_bitsize != mach->insn_chunk_bitsize)
1026*3d8817e4Smiod 	    {
1027*3d8817e4Smiod 	      fprintf (stderr, "ip2k_cgen_rebuild_tables: conflicting insn-chunk-bitsize values: `%d' vs. `%d'\n",
1028*3d8817e4Smiod 		       cd->insn_chunk_bitsize, mach->insn_chunk_bitsize);
1029*3d8817e4Smiod 	      abort ();
1030*3d8817e4Smiod 	    }
1031*3d8817e4Smiod 
1032*3d8817e4Smiod  	  cd->insn_chunk_bitsize = mach->insn_chunk_bitsize;
1033*3d8817e4Smiod 	}
1034*3d8817e4Smiod       }
1035*3d8817e4Smiod 
1036*3d8817e4Smiod   /* Determine which hw elements are used by MACH.  */
1037*3d8817e4Smiod   build_hw_table (cd);
1038*3d8817e4Smiod 
1039*3d8817e4Smiod   /* Build the ifield table.  */
1040*3d8817e4Smiod   build_ifield_table (cd);
1041*3d8817e4Smiod 
1042*3d8817e4Smiod   /* Determine which operands are used by MACH/ISA.  */
1043*3d8817e4Smiod   build_operand_table (cd);
1044*3d8817e4Smiod 
1045*3d8817e4Smiod   /* Build the instruction table.  */
1046*3d8817e4Smiod   build_insn_table (cd);
1047*3d8817e4Smiod }
1048*3d8817e4Smiod 
1049*3d8817e4Smiod /* Initialize a cpu table and return a descriptor.
1050*3d8817e4Smiod    It's much like opening a file, and must be the first function called.
1051*3d8817e4Smiod    The arguments are a set of (type/value) pairs, terminated with
1052*3d8817e4Smiod    CGEN_CPU_OPEN_END.
1053*3d8817e4Smiod 
1054*3d8817e4Smiod    Currently supported values:
1055*3d8817e4Smiod    CGEN_CPU_OPEN_ISAS:    bitmap of values in enum isa_attr
1056*3d8817e4Smiod    CGEN_CPU_OPEN_MACHS:   bitmap of values in enum mach_attr
1057*3d8817e4Smiod    CGEN_CPU_OPEN_BFDMACH: specify 1 mach using bfd name
1058*3d8817e4Smiod    CGEN_CPU_OPEN_ENDIAN:  specify endian choice
1059*3d8817e4Smiod    CGEN_CPU_OPEN_END:     terminates arguments
1060*3d8817e4Smiod 
1061*3d8817e4Smiod    ??? Simultaneous multiple isas might not make sense, but it's not (yet)
1062*3d8817e4Smiod    precluded.
1063*3d8817e4Smiod 
1064*3d8817e4Smiod    ??? We only support ISO C stdargs here, not K&R.
1065*3d8817e4Smiod    Laziness, plus experiment to see if anything requires K&R - eventually
1066*3d8817e4Smiod    K&R will no longer be supported - e.g. GDB is currently trying this.  */
1067*3d8817e4Smiod 
1068*3d8817e4Smiod CGEN_CPU_DESC
ip2k_cgen_cpu_open(enum cgen_cpu_open_arg arg_type,...)1069*3d8817e4Smiod ip2k_cgen_cpu_open (enum cgen_cpu_open_arg arg_type, ...)
1070*3d8817e4Smiod {
1071*3d8817e4Smiod   CGEN_CPU_TABLE *cd = (CGEN_CPU_TABLE *) xmalloc (sizeof (CGEN_CPU_TABLE));
1072*3d8817e4Smiod   static int init_p;
1073*3d8817e4Smiod   CGEN_BITSET *isas = 0;  /* 0 = "unspecified" */
1074*3d8817e4Smiod   unsigned int machs = 0; /* 0 = "unspecified" */
1075*3d8817e4Smiod   enum cgen_endian endian = CGEN_ENDIAN_UNKNOWN;
1076*3d8817e4Smiod   va_list ap;
1077*3d8817e4Smiod 
1078*3d8817e4Smiod   if (! init_p)
1079*3d8817e4Smiod     {
1080*3d8817e4Smiod       init_tables ();
1081*3d8817e4Smiod       init_p = 1;
1082*3d8817e4Smiod     }
1083*3d8817e4Smiod 
1084*3d8817e4Smiod   memset (cd, 0, sizeof (*cd));
1085*3d8817e4Smiod 
1086*3d8817e4Smiod   va_start (ap, arg_type);
1087*3d8817e4Smiod   while (arg_type != CGEN_CPU_OPEN_END)
1088*3d8817e4Smiod     {
1089*3d8817e4Smiod       switch (arg_type)
1090*3d8817e4Smiod 	{
1091*3d8817e4Smiod 	case CGEN_CPU_OPEN_ISAS :
1092*3d8817e4Smiod 	  isas = va_arg (ap, CGEN_BITSET *);
1093*3d8817e4Smiod 	  break;
1094*3d8817e4Smiod 	case CGEN_CPU_OPEN_MACHS :
1095*3d8817e4Smiod 	  machs = va_arg (ap, unsigned int);
1096*3d8817e4Smiod 	  break;
1097*3d8817e4Smiod 	case CGEN_CPU_OPEN_BFDMACH :
1098*3d8817e4Smiod 	  {
1099*3d8817e4Smiod 	    const char *name = va_arg (ap, const char *);
1100*3d8817e4Smiod 	    const CGEN_MACH *mach =
1101*3d8817e4Smiod 	      lookup_mach_via_bfd_name (ip2k_cgen_mach_table, name);
1102*3d8817e4Smiod 
1103*3d8817e4Smiod 	    machs |= 1 << mach->num;
1104*3d8817e4Smiod 	    break;
1105*3d8817e4Smiod 	  }
1106*3d8817e4Smiod 	case CGEN_CPU_OPEN_ENDIAN :
1107*3d8817e4Smiod 	  endian = va_arg (ap, enum cgen_endian);
1108*3d8817e4Smiod 	  break;
1109*3d8817e4Smiod 	default :
1110*3d8817e4Smiod 	  fprintf (stderr, "ip2k_cgen_cpu_open: unsupported argument `%d'\n",
1111*3d8817e4Smiod 		   arg_type);
1112*3d8817e4Smiod 	  abort (); /* ??? return NULL? */
1113*3d8817e4Smiod 	}
1114*3d8817e4Smiod       arg_type = va_arg (ap, enum cgen_cpu_open_arg);
1115*3d8817e4Smiod     }
1116*3d8817e4Smiod   va_end (ap);
1117*3d8817e4Smiod 
1118*3d8817e4Smiod   /* Mach unspecified means "all".  */
1119*3d8817e4Smiod   if (machs == 0)
1120*3d8817e4Smiod     machs = (1 << MAX_MACHS) - 1;
1121*3d8817e4Smiod   /* Base mach is always selected.  */
1122*3d8817e4Smiod   machs |= 1;
1123*3d8817e4Smiod   if (endian == CGEN_ENDIAN_UNKNOWN)
1124*3d8817e4Smiod     {
1125*3d8817e4Smiod       /* ??? If target has only one, could have a default.  */
1126*3d8817e4Smiod       fprintf (stderr, "ip2k_cgen_cpu_open: no endianness specified\n");
1127*3d8817e4Smiod       abort ();
1128*3d8817e4Smiod     }
1129*3d8817e4Smiod 
1130*3d8817e4Smiod   cd->isas = cgen_bitset_copy (isas);
1131*3d8817e4Smiod   cd->machs = machs;
1132*3d8817e4Smiod   cd->endian = endian;
1133*3d8817e4Smiod   /* FIXME: for the sparc case we can determine insn-endianness statically.
1134*3d8817e4Smiod      The worry here is where both data and insn endian can be independently
1135*3d8817e4Smiod      chosen, in which case this function will need another argument.
1136*3d8817e4Smiod      Actually, will want to allow for more arguments in the future anyway.  */
1137*3d8817e4Smiod   cd->insn_endian = endian;
1138*3d8817e4Smiod 
1139*3d8817e4Smiod   /* Table (re)builder.  */
1140*3d8817e4Smiod   cd->rebuild_tables = ip2k_cgen_rebuild_tables;
1141*3d8817e4Smiod   ip2k_cgen_rebuild_tables (cd);
1142*3d8817e4Smiod 
1143*3d8817e4Smiod   /* Default to not allowing signed overflow.  */
1144*3d8817e4Smiod   cd->signed_overflow_ok_p = 0;
1145*3d8817e4Smiod 
1146*3d8817e4Smiod   return (CGEN_CPU_DESC) cd;
1147*3d8817e4Smiod }
1148*3d8817e4Smiod 
1149*3d8817e4Smiod /* Cover fn to ip2k_cgen_cpu_open to handle the simple case of 1 isa, 1 mach.
1150*3d8817e4Smiod    MACH_NAME is the bfd name of the mach.  */
1151*3d8817e4Smiod 
1152*3d8817e4Smiod CGEN_CPU_DESC
ip2k_cgen_cpu_open_1(const char * mach_name,enum cgen_endian endian)1153*3d8817e4Smiod ip2k_cgen_cpu_open_1 (const char *mach_name, enum cgen_endian endian)
1154*3d8817e4Smiod {
1155*3d8817e4Smiod   return ip2k_cgen_cpu_open (CGEN_CPU_OPEN_BFDMACH, mach_name,
1156*3d8817e4Smiod 			       CGEN_CPU_OPEN_ENDIAN, endian,
1157*3d8817e4Smiod 			       CGEN_CPU_OPEN_END);
1158*3d8817e4Smiod }
1159*3d8817e4Smiod 
1160*3d8817e4Smiod /* Close a cpu table.
1161*3d8817e4Smiod    ??? This can live in a machine independent file, but there's currently
1162*3d8817e4Smiod    no place to put this file (there's no libcgen).  libopcodes is the wrong
1163*3d8817e4Smiod    place as some simulator ports use this but they don't use libopcodes.  */
1164*3d8817e4Smiod 
1165*3d8817e4Smiod void
ip2k_cgen_cpu_close(CGEN_CPU_DESC cd)1166*3d8817e4Smiod ip2k_cgen_cpu_close (CGEN_CPU_DESC cd)
1167*3d8817e4Smiod {
1168*3d8817e4Smiod   unsigned int i;
1169*3d8817e4Smiod   const CGEN_INSN *insns;
1170*3d8817e4Smiod 
1171*3d8817e4Smiod   if (cd->macro_insn_table.init_entries)
1172*3d8817e4Smiod     {
1173*3d8817e4Smiod       insns = cd->macro_insn_table.init_entries;
1174*3d8817e4Smiod       for (i = 0; i < cd->macro_insn_table.num_init_entries; ++i, ++insns)
1175*3d8817e4Smiod 	if (CGEN_INSN_RX ((insns)))
1176*3d8817e4Smiod 	  regfree (CGEN_INSN_RX (insns));
1177*3d8817e4Smiod     }
1178*3d8817e4Smiod 
1179*3d8817e4Smiod   if (cd->insn_table.init_entries)
1180*3d8817e4Smiod     {
1181*3d8817e4Smiod       insns = cd->insn_table.init_entries;
1182*3d8817e4Smiod       for (i = 0; i < cd->insn_table.num_init_entries; ++i, ++insns)
1183*3d8817e4Smiod 	if (CGEN_INSN_RX (insns))
1184*3d8817e4Smiod 	  regfree (CGEN_INSN_RX (insns));
1185*3d8817e4Smiod     }
1186*3d8817e4Smiod 
1187*3d8817e4Smiod   if (cd->macro_insn_table.init_entries)
1188*3d8817e4Smiod     free ((CGEN_INSN *) cd->macro_insn_table.init_entries);
1189*3d8817e4Smiod 
1190*3d8817e4Smiod   if (cd->insn_table.init_entries)
1191*3d8817e4Smiod     free ((CGEN_INSN *) cd->insn_table.init_entries);
1192*3d8817e4Smiod 
1193*3d8817e4Smiod   if (cd->hw_table.entries)
1194*3d8817e4Smiod     free ((CGEN_HW_ENTRY *) cd->hw_table.entries);
1195*3d8817e4Smiod 
1196*3d8817e4Smiod   if (cd->operand_table.entries)
1197*3d8817e4Smiod     free ((CGEN_HW_ENTRY *) cd->operand_table.entries);
1198*3d8817e4Smiod 
1199*3d8817e4Smiod   free (cd);
1200*3d8817e4Smiod }
1201*3d8817e4Smiod 
1202