1 /* DO NOT EDIT! -*- buffer-read-only: t -*- vi:set ro: */
2 /* CPU data for xstormy16.
4 THIS FILE IS MACHINE GENERATED WITH CGEN.
6 Copyright (C) 1996-2018 Free Software Foundation, Inc.
8 This file is part of the GNU Binutils and/or GDB, the GNU debugger.
10 This file is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 3, or (at your option)
15 It is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
18 License for more details.
20 You should have received a copy of the GNU General Public License along
21 with this program; if not, write to the Free Software Foundation, Inc.,
22 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
32 #include "xstormy16-desc.h"
33 #include "xstormy16-opc.h"
35 #include "libiberty.h"
40 static const CGEN_ATTR_ENTRY bool_attr[] =
47 static const CGEN_ATTR_ENTRY MACH_attr[] ATTRIBUTE_UNUSED =
49 { "base", MACH_BASE },
50 { "xstormy16", MACH_XSTORMY16 },
55 static const CGEN_ATTR_ENTRY ISA_attr[] ATTRIBUTE_UNUSED =
57 { "xstormy16", ISA_XSTORMY16 },
62 const CGEN_ATTR_TABLE xstormy16_cgen_ifield_attr_table[] =
64 { "MACH", & MACH_attr[0], & MACH_attr[0] },
65 { "VIRTUAL", &bool_attr[0], &bool_attr[0] },
66 { "PCREL-ADDR", &bool_attr[0], &bool_attr[0] },
67 { "ABS-ADDR", &bool_attr[0], &bool_attr[0] },
68 { "RESERVED", &bool_attr[0], &bool_attr[0] },
69 { "SIGN-OPT", &bool_attr[0], &bool_attr[0] },
70 { "SIGNED", &bool_attr[0], &bool_attr[0] },
74 const CGEN_ATTR_TABLE xstormy16_cgen_hardware_attr_table[] =
76 { "MACH", & MACH_attr[0], & MACH_attr[0] },
77 { "VIRTUAL", &bool_attr[0], &bool_attr[0] },
78 { "CACHE-ADDR", &bool_attr[0], &bool_attr[0] },
79 { "PC", &bool_attr[0], &bool_attr[0] },
80 { "PROFILE", &bool_attr[0], &bool_attr[0] },
84 const CGEN_ATTR_TABLE xstormy16_cgen_operand_attr_table[] =
86 { "MACH", & MACH_attr[0], & MACH_attr[0] },
87 { "VIRTUAL", &bool_attr[0], &bool_attr[0] },
88 { "PCREL-ADDR", &bool_attr[0], &bool_attr[0] },
89 { "ABS-ADDR", &bool_attr[0], &bool_attr[0] },
90 { "SIGN-OPT", &bool_attr[0], &bool_attr[0] },
91 { "SIGNED", &bool_attr[0], &bool_attr[0] },
92 { "NEGATIVE", &bool_attr[0], &bool_attr[0] },
93 { "RELAX", &bool_attr[0], &bool_attr[0] },
94 { "SEM-ONLY", &bool_attr[0], &bool_attr[0] },
98 const CGEN_ATTR_TABLE xstormy16_cgen_insn_attr_table[] =
100 { "MACH", & MACH_attr[0], & MACH_attr[0] },
101 { "ALIAS", &bool_attr[0], &bool_attr[0] },
102 { "VIRTUAL", &bool_attr[0], &bool_attr[0] },
103 { "UNCOND-CTI", &bool_attr[0], &bool_attr[0] },
104 { "COND-CTI", &bool_attr[0], &bool_attr[0] },
105 { "SKIP-CTI", &bool_attr[0], &bool_attr[0] },
106 { "DELAY-SLOT", &bool_attr[0], &bool_attr[0] },
107 { "RELAXABLE", &bool_attr[0], &bool_attr[0] },
108 { "RELAXED", &bool_attr[0], &bool_attr[0] },
109 { "NO-DIS", &bool_attr[0], &bool_attr[0] },
110 { "PBB", &bool_attr[0], &bool_attr[0] },
114 /* Instruction set variants. */
116 static const CGEN_ISA xstormy16_cgen_isa_table[] = {
117 { "xstormy16", 32, 32, 16, 32 },
121 /* Machine variants. */
123 static const CGEN_MACH xstormy16_cgen_mach_table[] = {
124 { "xstormy16", "xstormy16", MACH_XSTORMY16, 16 },
128 static CGEN_KEYWORD_ENTRY xstormy16_cgen_opval_gr_names_entries[] =
130 { "r0", 0, {0, {{{0, 0}}}}, 0, 0 },
131 { "r1", 1, {0, {{{0, 0}}}}, 0, 0 },
132 { "r2", 2, {0, {{{0, 0}}}}, 0, 0 },
133 { "r3", 3, {0, {{{0, 0}}}}, 0, 0 },
134 { "r4", 4, {0, {{{0, 0}}}}, 0, 0 },
135 { "r5", 5, {0, {{{0, 0}}}}, 0, 0 },
136 { "r6", 6, {0, {{{0, 0}}}}, 0, 0 },
137 { "r7", 7, {0, {{{0, 0}}}}, 0, 0 },
138 { "r8", 8, {0, {{{0, 0}}}}, 0, 0 },
139 { "r9", 9, {0, {{{0, 0}}}}, 0, 0 },
140 { "r10", 10, {0, {{{0, 0}}}}, 0, 0 },
141 { "r11", 11, {0, {{{0, 0}}}}, 0, 0 },
142 { "r12", 12, {0, {{{0, 0}}}}, 0, 0 },
143 { "r13", 13, {0, {{{0, 0}}}}, 0, 0 },
144 { "r14", 14, {0, {{{0, 0}}}}, 0, 0 },
145 { "r15", 15, {0, {{{0, 0}}}}, 0, 0 },
146 { "psw", 14, {0, {{{0, 0}}}}, 0, 0 },
147 { "sp", 15, {0, {{{0, 0}}}}, 0, 0 }
150 CGEN_KEYWORD xstormy16_cgen_opval_gr_names =
152 & xstormy16_cgen_opval_gr_names_entries[0],
157 static CGEN_KEYWORD_ENTRY xstormy16_cgen_opval_gr_Rb_names_entries[] =
159 { "r8", 0, {0, {{{0, 0}}}}, 0, 0 },
160 { "r9", 1, {0, {{{0, 0}}}}, 0, 0 },
161 { "r10", 2, {0, {{{0, 0}}}}, 0, 0 },
162 { "r11", 3, {0, {{{0, 0}}}}, 0, 0 },
163 { "r12", 4, {0, {{{0, 0}}}}, 0, 0 },
164 { "r13", 5, {0, {{{0, 0}}}}, 0, 0 },
165 { "r14", 6, {0, {{{0, 0}}}}, 0, 0 },
166 { "r15", 7, {0, {{{0, 0}}}}, 0, 0 },
167 { "psw", 6, {0, {{{0, 0}}}}, 0, 0 },
168 { "sp", 7, {0, {{{0, 0}}}}, 0, 0 }
171 CGEN_KEYWORD xstormy16_cgen_opval_gr_Rb_names =
173 & xstormy16_cgen_opval_gr_Rb_names_entries[0],
178 static CGEN_KEYWORD_ENTRY xstormy16_cgen_opval_h_branchcond_entries[] =
180 { "ge", 0, {0, {{{0, 0}}}}, 0, 0 },
181 { "nc", 1, {0, {{{0, 0}}}}, 0, 0 },
182 { "lt", 2, {0, {{{0, 0}}}}, 0, 0 },
183 { "c", 3, {0, {{{0, 0}}}}, 0, 0 },
184 { "gt", 4, {0, {{{0, 0}}}}, 0, 0 },
185 { "hi", 5, {0, {{{0, 0}}}}, 0, 0 },
186 { "le", 6, {0, {{{0, 0}}}}, 0, 0 },
187 { "ls", 7, {0, {{{0, 0}}}}, 0, 0 },
188 { "pl", 8, {0, {{{0, 0}}}}, 0, 0 },
189 { "nv", 9, {0, {{{0, 0}}}}, 0, 0 },
190 { "mi", 10, {0, {{{0, 0}}}}, 0, 0 },
191 { "v", 11, {0, {{{0, 0}}}}, 0, 0 },
192 { "nz.b", 12, {0, {{{0, 0}}}}, 0, 0 },
193 { "nz", 13, {0, {{{0, 0}}}}, 0, 0 },
194 { "z.b", 14, {0, {{{0, 0}}}}, 0, 0 },
195 { "z", 15, {0, {{{0, 0}}}}, 0, 0 }
198 CGEN_KEYWORD xstormy16_cgen_opval_h_branchcond =
200 & xstormy16_cgen_opval_h_branchcond_entries[0],
205 static CGEN_KEYWORD_ENTRY xstormy16_cgen_opval_h_wordsize_entries[] =
207 { ".b", 0, {0, {{{0, 0}}}}, 0, 0 },
208 { ".w", 1, {0, {{{0, 0}}}}, 0, 0 },
209 { "", 1, {0, {{{0, 0}}}}, 0, 0 }
212 CGEN_KEYWORD xstormy16_cgen_opval_h_wordsize =
214 & xstormy16_cgen_opval_h_wordsize_entries[0],
220 /* The hardware table. */
222 #define A(a) (1 << CGEN_HW_##a)
224 const CGEN_HW_ENTRY xstormy16_cgen_hw_table[] =
226 { "h-memory", HW_H_MEMORY, CGEN_ASM_NONE, 0, { 0, { { { (1<<MACH_BASE), 0 } } } } },
227 { "h-sint", HW_H_SINT, CGEN_ASM_NONE, 0, { 0, { { { (1<<MACH_BASE), 0 } } } } },
228 { "h-uint", HW_H_UINT, CGEN_ASM_NONE, 0, { 0, { { { (1<<MACH_BASE), 0 } } } } },
229 { "h-addr", HW_H_ADDR, CGEN_ASM_NONE, 0, { 0, { { { (1<<MACH_BASE), 0 } } } } },
230 { "h-iaddr", HW_H_IADDR, CGEN_ASM_NONE, 0, { 0, { { { (1<<MACH_BASE), 0 } } } } },
231 { "h-pc", HW_H_PC, CGEN_ASM_NONE, 0, { 0|A(PC), { { { (1<<MACH_BASE), 0 } } } } },
232 { "h-gr", HW_H_GR, CGEN_ASM_KEYWORD, (PTR) & xstormy16_cgen_opval_gr_names, { 0, { { { (1<<MACH_BASE), 0 } } } } },
233 { "h-Rb", HW_H_RB, CGEN_ASM_KEYWORD, (PTR) & xstormy16_cgen_opval_gr_Rb_names, { 0|A(VIRTUAL), { { { (1<<MACH_BASE), 0 } } } } },
234 { "h-Rbj", HW_H_RBJ, CGEN_ASM_KEYWORD, (PTR) & xstormy16_cgen_opval_gr_Rb_names, { 0|A(VIRTUAL), { { { (1<<MACH_BASE), 0 } } } } },
235 { "h-Rpsw", HW_H_RPSW, CGEN_ASM_NONE, 0, { 0|A(VIRTUAL), { { { (1<<MACH_BASE), 0 } } } } },
236 { "h-z8", HW_H_Z8, CGEN_ASM_NONE, 0, { 0|A(VIRTUAL), { { { (1<<MACH_BASE), 0 } } } } },
237 { "h-z16", HW_H_Z16, CGEN_ASM_NONE, 0, { 0|A(VIRTUAL), { { { (1<<MACH_BASE), 0 } } } } },
238 { "h-cy", HW_H_CY, CGEN_ASM_NONE, 0, { 0|A(VIRTUAL), { { { (1<<MACH_BASE), 0 } } } } },
239 { "h-hc", HW_H_HC, CGEN_ASM_NONE, 0, { 0|A(VIRTUAL), { { { (1<<MACH_BASE), 0 } } } } },
240 { "h-ov", HW_H_OV, CGEN_ASM_NONE, 0, { 0|A(VIRTUAL), { { { (1<<MACH_BASE), 0 } } } } },
241 { "h-pt", HW_H_PT, CGEN_ASM_NONE, 0, { 0|A(VIRTUAL), { { { (1<<MACH_BASE), 0 } } } } },
242 { "h-s", HW_H_S, CGEN_ASM_NONE, 0, { 0|A(VIRTUAL), { { { (1<<MACH_BASE), 0 } } } } },
243 { "h-branchcond", HW_H_BRANCHCOND, CGEN_ASM_KEYWORD, (PTR) & xstormy16_cgen_opval_h_branchcond, { 0, { { { (1<<MACH_BASE), 0 } } } } },
244 { "h-wordsize", HW_H_WORDSIZE, CGEN_ASM_KEYWORD, (PTR) & xstormy16_cgen_opval_h_wordsize, { 0, { { { (1<<MACH_BASE), 0 } } } } },
245 { 0, 0, CGEN_ASM_NONE, 0, { 0, { { { (1<<MACH_BASE), 0 } } } } }
251 /* The instruction field table. */
253 #define A(a) (1 << CGEN_IFLD_##a)
255 const CGEN_IFLD xstormy16_cgen_ifld_table[] =
257 { XSTORMY16_F_NIL, "f-nil", 0, 0, 0, 0, { 0, { { { (1<<MACH_BASE), 0 } } } } },
258 { XSTORMY16_F_ANYOF, "f-anyof", 0, 0, 0, 0, { 0, { { { (1<<MACH_BASE), 0 } } } } },
259 { XSTORMY16_F_RD, "f-Rd", 0, 32, 12, 4, { 0, { { { (1<<MACH_BASE), 0 } } } } },
260 { XSTORMY16_F_RDM, "f-Rdm", 0, 32, 13, 3, { 0, { { { (1<<MACH_BASE), 0 } } } } },
261 { XSTORMY16_F_RM, "f-Rm", 0, 32, 4, 3, { 0, { { { (1<<MACH_BASE), 0 } } } } },
262 { XSTORMY16_F_RS, "f-Rs", 0, 32, 8, 4, { 0, { { { (1<<MACH_BASE), 0 } } } } },
263 { XSTORMY16_F_RB, "f-Rb", 0, 32, 17, 3, { 0, { { { (1<<MACH_BASE), 0 } } } } },
264 { XSTORMY16_F_RBJ, "f-Rbj", 0, 32, 11, 1, { 0, { { { (1<<MACH_BASE), 0 } } } } },
265 { XSTORMY16_F_OP1, "f-op1", 0, 32, 0, 4, { 0, { { { (1<<MACH_BASE), 0 } } } } },
266 { XSTORMY16_F_OP2, "f-op2", 0, 32, 4, 4, { 0, { { { (1<<MACH_BASE), 0 } } } } },
267 { XSTORMY16_F_OP2A, "f-op2a", 0, 32, 4, 3, { 0, { { { (1<<MACH_BASE), 0 } } } } },
268 { XSTORMY16_F_OP2M, "f-op2m", 0, 32, 7, 1, { 0, { { { (1<<MACH_BASE), 0 } } } } },
269 { XSTORMY16_F_OP3, "f-op3", 0, 32, 8, 4, { 0, { { { (1<<MACH_BASE), 0 } } } } },
270 { XSTORMY16_F_OP3A, "f-op3a", 0, 32, 8, 2, { 0, { { { (1<<MACH_BASE), 0 } } } } },
271 { XSTORMY16_F_OP3B, "f-op3b", 0, 32, 8, 3, { 0, { { { (1<<MACH_BASE), 0 } } } } },
272 { XSTORMY16_F_OP4, "f-op4", 0, 32, 12, 4, { 0, { { { (1<<MACH_BASE), 0 } } } } },
273 { XSTORMY16_F_OP4M, "f-op4m", 0, 32, 12, 1, { 0, { { { (1<<MACH_BASE), 0 } } } } },
274 { XSTORMY16_F_OP4B, "f-op4b", 0, 32, 15, 1, { 0, { { { (1<<MACH_BASE), 0 } } } } },
275 { XSTORMY16_F_OP5, "f-op5", 0, 32, 16, 4, { 0, { { { (1<<MACH_BASE), 0 } } } } },
276 { XSTORMY16_F_OP5A, "f-op5a", 0, 32, 16, 1, { 0, { { { (1<<MACH_BASE), 0 } } } } },
277 { XSTORMY16_F_OP, "f-op", 0, 32, 0, 16, { 0, { { { (1<<MACH_BASE), 0 } } } } },
278 { XSTORMY16_F_IMM2, "f-imm2", 0, 32, 10, 2, { 0, { { { (1<<MACH_BASE), 0 } } } } },
279 { XSTORMY16_F_IMM3, "f-imm3", 0, 32, 4, 3, { 0, { { { (1<<MACH_BASE), 0 } } } } },
280 { XSTORMY16_F_IMM3B, "f-imm3b", 0, 32, 17, 3, { 0, { { { (1<<MACH_BASE), 0 } } } } },
281 { XSTORMY16_F_IMM4, "f-imm4", 0, 32, 8, 4, { 0, { { { (1<<MACH_BASE), 0 } } } } },
282 { XSTORMY16_F_IMM8, "f-imm8", 0, 32, 8, 8, { 0, { { { (1<<MACH_BASE), 0 } } } } },
283 { XSTORMY16_F_IMM12, "f-imm12", 0, 32, 20, 12, { 0, { { { (1<<MACH_BASE), 0 } } } } },
284 { XSTORMY16_F_IMM16, "f-imm16", 0, 32, 16, 16, { 0|A(SIGN_OPT), { { { (1<<MACH_BASE), 0 } } } } },
285 { XSTORMY16_F_LMEM8, "f-lmem8", 0, 32, 8, 8, { 0|A(ABS_ADDR), { { { (1<<MACH_BASE), 0 } } } } },
286 { XSTORMY16_F_HMEM8, "f-hmem8", 0, 32, 8, 8, { 0|A(ABS_ADDR), { { { (1<<MACH_BASE), 0 } } } } },
287 { XSTORMY16_F_REL8_2, "f-rel8-2", 0, 32, 8, 8, { 0|A(PCREL_ADDR), { { { (1<<MACH_BASE), 0 } } } } },
288 { XSTORMY16_F_REL8_4, "f-rel8-4", 0, 32, 8, 8, { 0|A(PCREL_ADDR), { { { (1<<MACH_BASE), 0 } } } } },
289 { XSTORMY16_F_REL12, "f-rel12", 0, 32, 20, 12, { 0|A(PCREL_ADDR), { { { (1<<MACH_BASE), 0 } } } } },
290 { XSTORMY16_F_REL12A, "f-rel12a", 0, 32, 4, 11, { 0|A(PCREL_ADDR), { { { (1<<MACH_BASE), 0 } } } } },
291 { XSTORMY16_F_ABS24_1, "f-abs24-1", 0, 32, 8, 8, { 0, { { { (1<<MACH_BASE), 0 } } } } },
292 { XSTORMY16_F_ABS24_2, "f-abs24-2", 0, 32, 16, 16, { 0, { { { (1<<MACH_BASE), 0 } } } } },
293 { XSTORMY16_F_ABS24, "f-abs24", 0, 0, 0, 0,{ 0|A(ABS_ADDR)|A(VIRTUAL), { { { (1<<MACH_BASE), 0 } } } } },
294 { 0, 0, 0, 0, 0, 0, { 0, { { { (1<<MACH_BASE), 0 } } } } }
301 /* multi ifield declarations */
303 const CGEN_MAYBE_MULTI_IFLD XSTORMY16_F_ABS24_MULTI_IFIELD [];
306 /* multi ifield definitions */
308 const CGEN_MAYBE_MULTI_IFLD XSTORMY16_F_ABS24_MULTI_IFIELD [] =
310 { 0, { (const PTR) &xstormy16_cgen_ifld_table[XSTORMY16_F_ABS24_1] } },
311 { 0, { (const PTR) &xstormy16_cgen_ifld_table[XSTORMY16_F_ABS24_2] } },
312 { 0, { (const PTR) 0 } }
315 /* The operand table. */
317 #define A(a) (1 << CGEN_OPERAND_##a)
318 #define OPERAND(op) XSTORMY16_OPERAND_##op
320 const CGEN_OPERAND xstormy16_cgen_operand_table[] =
322 /* pc: program counter */
323 { "pc", XSTORMY16_OPERAND_PC, HW_H_PC, 0, 0,
324 { 0, { (const PTR) &xstormy16_cgen_ifld_table[XSTORMY16_F_NIL] } },
325 { 0|A(SEM_ONLY), { { { (1<<MACH_BASE), 0 } } } } },
327 { "psw-z8", XSTORMY16_OPERAND_PSW_Z8, HW_H_Z8, 0, 0,
328 { 0, { (const PTR) 0 } },
329 { 0|A(SEM_ONLY), { { { (1<<MACH_BASE), 0 } } } } },
331 { "psw-z16", XSTORMY16_OPERAND_PSW_Z16, HW_H_Z16, 0, 0,
332 { 0, { (const PTR) 0 } },
333 { 0|A(SEM_ONLY), { { { (1<<MACH_BASE), 0 } } } } },
335 { "psw-cy", XSTORMY16_OPERAND_PSW_CY, HW_H_CY, 0, 0,
336 { 0, { (const PTR) 0 } },
337 { 0|A(SEM_ONLY), { { { (1<<MACH_BASE), 0 } } } } },
339 { "psw-hc", XSTORMY16_OPERAND_PSW_HC, HW_H_HC, 0, 0,
340 { 0, { (const PTR) 0 } },
341 { 0|A(SEM_ONLY), { { { (1<<MACH_BASE), 0 } } } } },
343 { "psw-ov", XSTORMY16_OPERAND_PSW_OV, HW_H_OV, 0, 0,
344 { 0, { (const PTR) 0 } },
345 { 0|A(SEM_ONLY), { { { (1<<MACH_BASE), 0 } } } } },
347 { "psw-pt", XSTORMY16_OPERAND_PSW_PT, HW_H_PT, 0, 0,
348 { 0, { (const PTR) 0 } },
349 { 0|A(SEM_ONLY), { { { (1<<MACH_BASE), 0 } } } } },
351 { "psw-s", XSTORMY16_OPERAND_PSW_S, HW_H_S, 0, 0,
352 { 0, { (const PTR) 0 } },
353 { 0|A(SEM_ONLY), { { { (1<<MACH_BASE), 0 } } } } },
354 /* Rd: general register destination */
355 { "Rd", XSTORMY16_OPERAND_RD, HW_H_GR, 12, 4,
356 { 0, { (const PTR) &xstormy16_cgen_ifld_table[XSTORMY16_F_RD] } },
357 { 0, { { { (1<<MACH_BASE), 0 } } } } },
358 /* Rdm: general register destination */
359 { "Rdm", XSTORMY16_OPERAND_RDM, HW_H_GR, 13, 3,
360 { 0, { (const PTR) &xstormy16_cgen_ifld_table[XSTORMY16_F_RDM] } },
361 { 0, { { { (1<<MACH_BASE), 0 } } } } },
362 /* Rm: general register for memory */
363 { "Rm", XSTORMY16_OPERAND_RM, HW_H_GR, 4, 3,
364 { 0, { (const PTR) &xstormy16_cgen_ifld_table[XSTORMY16_F_RM] } },
365 { 0, { { { (1<<MACH_BASE), 0 } } } } },
366 /* Rs: general register source */
367 { "Rs", XSTORMY16_OPERAND_RS, HW_H_GR, 8, 4,
368 { 0, { (const PTR) &xstormy16_cgen_ifld_table[XSTORMY16_F_RS] } },
369 { 0, { { { (1<<MACH_BASE), 0 } } } } },
370 /* Rb: base register */
371 { "Rb", XSTORMY16_OPERAND_RB, HW_H_RB, 17, 3,
372 { 0, { (const PTR) &xstormy16_cgen_ifld_table[XSTORMY16_F_RB] } },
373 { 0, { { { (1<<MACH_BASE), 0 } } } } },
374 /* Rbj: base register for jump */
375 { "Rbj", XSTORMY16_OPERAND_RBJ, HW_H_RBJ, 11, 1,
376 { 0, { (const PTR) &xstormy16_cgen_ifld_table[XSTORMY16_F_RBJ] } },
377 { 0, { { { (1<<MACH_BASE), 0 } } } } },
378 /* bcond2: branch condition opcode */
379 { "bcond2", XSTORMY16_OPERAND_BCOND2, HW_H_BRANCHCOND, 4, 4,
380 { 0, { (const PTR) &xstormy16_cgen_ifld_table[XSTORMY16_F_OP2] } },
381 { 0, { { { (1<<MACH_BASE), 0 } } } } },
382 /* ws2: word size opcode */
383 { "ws2", XSTORMY16_OPERAND_WS2, HW_H_WORDSIZE, 7, 1,
384 { 0, { (const PTR) &xstormy16_cgen_ifld_table[XSTORMY16_F_OP2M] } },
385 { 0, { { { (1<<MACH_BASE), 0 } } } } },
386 /* bcond5: branch condition opcode */
387 { "bcond5", XSTORMY16_OPERAND_BCOND5, HW_H_BRANCHCOND, 16, 4,
388 { 0, { (const PTR) &xstormy16_cgen_ifld_table[XSTORMY16_F_OP5] } },
389 { 0, { { { (1<<MACH_BASE), 0 } } } } },
390 /* imm2: 2 bit unsigned immediate */
391 { "imm2", XSTORMY16_OPERAND_IMM2, HW_H_UINT, 10, 2,
392 { 0, { (const PTR) &xstormy16_cgen_ifld_table[XSTORMY16_F_IMM2] } },
393 { 0, { { { (1<<MACH_BASE), 0 } } } } },
394 /* imm3: 3 bit unsigned immediate */
395 { "imm3", XSTORMY16_OPERAND_IMM3, HW_H_UINT, 4, 3,
396 { 0, { (const PTR) &xstormy16_cgen_ifld_table[XSTORMY16_F_IMM3] } },
397 { 0, { { { (1<<MACH_BASE), 0 } } } } },
398 /* imm3b: 3 bit unsigned immediate for bit tests */
399 { "imm3b", XSTORMY16_OPERAND_IMM3B, HW_H_UINT, 17, 3,
400 { 0, { (const PTR) &xstormy16_cgen_ifld_table[XSTORMY16_F_IMM3B] } },
401 { 0, { { { (1<<MACH_BASE), 0 } } } } },
402 /* imm4: 4 bit unsigned immediate */
403 { "imm4", XSTORMY16_OPERAND_IMM4, HW_H_UINT, 8, 4,
404 { 0, { (const PTR) &xstormy16_cgen_ifld_table[XSTORMY16_F_IMM4] } },
405 { 0, { { { (1<<MACH_BASE), 0 } } } } },
406 /* imm8: 8 bit unsigned immediate */
407 { "imm8", XSTORMY16_OPERAND_IMM8, HW_H_UINT, 8, 8,
408 { 0, { (const PTR) &xstormy16_cgen_ifld_table[XSTORMY16_F_IMM8] } },
409 { 0, { { { (1<<MACH_BASE), 0 } } } } },
410 /* imm8small: 8 bit unsigned immediate */
411 { "imm8small", XSTORMY16_OPERAND_IMM8SMALL, HW_H_UINT, 8, 8,
412 { 0, { (const PTR) &xstormy16_cgen_ifld_table[XSTORMY16_F_IMM8] } },
413 { 0, { { { (1<<MACH_BASE), 0 } } } } },
414 /* imm12: 12 bit signed immediate */
415 { "imm12", XSTORMY16_OPERAND_IMM12, HW_H_SINT, 20, 12,
416 { 0, { (const PTR) &xstormy16_cgen_ifld_table[XSTORMY16_F_IMM12] } },
417 { 0, { { { (1<<MACH_BASE), 0 } } } } },
418 /* imm16: 16 bit immediate */
419 { "imm16", XSTORMY16_OPERAND_IMM16, HW_H_UINT, 16, 16,
420 { 0, { (const PTR) &xstormy16_cgen_ifld_table[XSTORMY16_F_IMM16] } },
421 { 0|A(SIGN_OPT), { { { (1<<MACH_BASE), 0 } } } } },
422 /* lmem8: 8 bit unsigned immediate low memory */
423 { "lmem8", XSTORMY16_OPERAND_LMEM8, HW_H_UINT, 8, 8,
424 { 0, { (const PTR) &xstormy16_cgen_ifld_table[XSTORMY16_F_LMEM8] } },
425 { 0|A(ABS_ADDR), { { { (1<<MACH_BASE), 0 } } } } },
426 /* hmem8: 8 bit unsigned immediate high memory */
427 { "hmem8", XSTORMY16_OPERAND_HMEM8, HW_H_UINT, 8, 8,
428 { 0, { (const PTR) &xstormy16_cgen_ifld_table[XSTORMY16_F_HMEM8] } },
429 { 0|A(ABS_ADDR), { { { (1<<MACH_BASE), 0 } } } } },
430 /* rel8-2: 8 bit relative address */
431 { "rel8-2", XSTORMY16_OPERAND_REL8_2, HW_H_UINT, 8, 8,
432 { 0, { (const PTR) &xstormy16_cgen_ifld_table[XSTORMY16_F_REL8_2] } },
433 { 0|A(PCREL_ADDR), { { { (1<<MACH_BASE), 0 } } } } },
434 /* rel8-4: 8 bit relative address */
435 { "rel8-4", XSTORMY16_OPERAND_REL8_4, HW_H_UINT, 8, 8,
436 { 0, { (const PTR) &xstormy16_cgen_ifld_table[XSTORMY16_F_REL8_4] } },
437 { 0|A(PCREL_ADDR), { { { (1<<MACH_BASE), 0 } } } } },
438 /* rel12: 12 bit relative address */
439 { "rel12", XSTORMY16_OPERAND_REL12, HW_H_UINT, 20, 12,
440 { 0, { (const PTR) &xstormy16_cgen_ifld_table[XSTORMY16_F_REL12] } },
441 { 0|A(PCREL_ADDR), { { { (1<<MACH_BASE), 0 } } } } },
442 /* rel12a: 12 bit relative address */
443 { "rel12a", XSTORMY16_OPERAND_REL12A, HW_H_UINT, 4, 11,
444 { 0, { (const PTR) &xstormy16_cgen_ifld_table[XSTORMY16_F_REL12A] } },
445 { 0|A(PCREL_ADDR), { { { (1<<MACH_BASE), 0 } } } } },
446 /* abs24: 24 bit absolute address */
447 { "abs24", XSTORMY16_OPERAND_ABS24, HW_H_UINT, 8, 24,
448 { 2, { (const PTR) &XSTORMY16_F_ABS24_MULTI_IFIELD[0] } },
449 { 0|A(ABS_ADDR)|A(VIRTUAL), { { { (1<<MACH_BASE), 0 } } } } },
450 /* psw: program status word */
451 { "psw", XSTORMY16_OPERAND_PSW, HW_H_GR, 0, 0,
452 { 0, { (const PTR) 0 } },
453 { 0|A(SEM_ONLY), { { { (1<<MACH_BASE), 0 } } } } },
454 /* Rpsw: N0-N3 of the program status word */
455 { "Rpsw", XSTORMY16_OPERAND_RPSW, HW_H_RPSW, 0, 0,
456 { 0, { (const PTR) 0 } },
457 { 0|A(SEM_ONLY), { { { (1<<MACH_BASE), 0 } } } } },
458 /* sp: stack pointer */
459 { "sp", XSTORMY16_OPERAND_SP, HW_H_GR, 0, 0,
460 { 0, { (const PTR) 0 } },
461 { 0|A(SEM_ONLY), { { { (1<<MACH_BASE), 0 } } } } },
463 { "R0", XSTORMY16_OPERAND_R0, HW_H_GR, 0, 0,
464 { 0, { (const PTR) 0 } },
465 { 0|A(SEM_ONLY), { { { (1<<MACH_BASE), 0 } } } } },
467 { "R1", XSTORMY16_OPERAND_R1, HW_H_GR, 0, 0,
468 { 0, { (const PTR) 0 } },
469 { 0|A(SEM_ONLY), { { { (1<<MACH_BASE), 0 } } } } },
471 { "R2", XSTORMY16_OPERAND_R2, HW_H_GR, 0, 0,
472 { 0, { (const PTR) 0 } },
473 { 0|A(SEM_ONLY), { { { (1<<MACH_BASE), 0 } } } } },
475 { "R8", XSTORMY16_OPERAND_R8, HW_H_GR, 0, 0,
476 { 0, { (const PTR) 0 } },
477 { 0|A(SEM_ONLY), { { { (1<<MACH_BASE), 0 } } } } },
480 { 0, { (const PTR) 0 } },
481 { 0, { { { (1<<MACH_BASE), 0 } } } } }
487 /* The instruction table. */
489 #define OP(field) CGEN_SYNTAX_MAKE_FIELD (OPERAND (field))
490 #define A(a) (1 << CGEN_INSN_##a)
492 static const CGEN_IBASE xstormy16_cgen_insn_table[MAX_INSNS] =
494 /* Special null first entry.
495 A `num' value of zero is thus invalid.
496 Also, the special `invalid' insn resides here. */
497 { 0, 0, 0, 0, { 0, { { { (1<<MACH_BASE), 0 } } } } },
498 /* mov$ws2 $lmem8,#$imm16 */
500 XSTORMY16_INSN_MOVLMEMIMM, "movlmemimm", "mov", 32,
501 { 0, { { { (1<<MACH_BASE), 0 } } } }
503 /* mov$ws2 $hmem8,#$imm16 */
505 XSTORMY16_INSN_MOVHMEMIMM, "movhmemimm", "mov", 32,
506 { 0, { { { (1<<MACH_BASE), 0 } } } }
508 /* mov$ws2 $Rm,$lmem8 */
510 XSTORMY16_INSN_MOVLGRMEM, "movlgrmem", "mov", 16,
511 { 0, { { { (1<<MACH_BASE), 0 } } } }
513 /* mov$ws2 $Rm,$hmem8 */
515 XSTORMY16_INSN_MOVHGRMEM, "movhgrmem", "mov", 16,
516 { 0, { { { (1<<MACH_BASE), 0 } } } }
518 /* mov$ws2 $lmem8,$Rm */
520 XSTORMY16_INSN_MOVLMEMGR, "movlmemgr", "mov", 16,
521 { 0, { { { (1<<MACH_BASE), 0 } } } }
523 /* mov$ws2 $hmem8,$Rm */
525 XSTORMY16_INSN_MOVHMEMGR, "movhmemgr", "mov", 16,
526 { 0, { { { (1<<MACH_BASE), 0 } } } }
528 /* mov$ws2 $Rdm,($Rs) */
530 XSTORMY16_INSN_MOVGRGRI, "movgrgri", "mov", 16,
531 { 0, { { { (1<<MACH_BASE), 0 } } } }
533 /* mov$ws2 $Rdm,($Rs++) */
535 XSTORMY16_INSN_MOVGRGRIPOSTINC, "movgrgripostinc", "mov", 16,
536 { 0, { { { (1<<MACH_BASE), 0 } } } }
538 /* mov$ws2 $Rdm,(--$Rs) */
540 XSTORMY16_INSN_MOVGRGRIPREDEC, "movgrgripredec", "mov", 16,
541 { 0, { { { (1<<MACH_BASE), 0 } } } }
543 /* mov$ws2 ($Rs),$Rdm */
545 XSTORMY16_INSN_MOVGRIGR, "movgrigr", "mov", 16,
546 { 0, { { { (1<<MACH_BASE), 0 } } } }
548 /* mov$ws2 ($Rs++),$Rdm */
550 XSTORMY16_INSN_MOVGRIPOSTINCGR, "movgripostincgr", "mov", 16,
551 { 0, { { { (1<<MACH_BASE), 0 } } } }
553 /* mov$ws2 (--$Rs),$Rdm */
555 XSTORMY16_INSN_MOVGRIPREDECGR, "movgripredecgr", "mov", 16,
556 { 0, { { { (1<<MACH_BASE), 0 } } } }
558 /* mov$ws2 $Rdm,($Rs,$imm12) */
560 XSTORMY16_INSN_MOVGRGRII, "movgrgrii", "mov", 32,
561 { 0, { { { (1<<MACH_BASE), 0 } } } }
563 /* mov$ws2 $Rdm,($Rs++,$imm12) */
565 XSTORMY16_INSN_MOVGRGRIIPOSTINC, "movgrgriipostinc", "mov", 32,
566 { 0, { { { (1<<MACH_BASE), 0 } } } }
568 /* mov$ws2 $Rdm,(--$Rs,$imm12) */
570 XSTORMY16_INSN_MOVGRGRIIPREDEC, "movgrgriipredec", "mov", 32,
571 { 0, { { { (1<<MACH_BASE), 0 } } } }
573 /* mov$ws2 ($Rs,$imm12),$Rdm */
575 XSTORMY16_INSN_MOVGRIIGR, "movgriigr", "mov", 32,
576 { 0, { { { (1<<MACH_BASE), 0 } } } }
578 /* mov$ws2 ($Rs++,$imm12),$Rdm */
580 XSTORMY16_INSN_MOVGRIIPOSTINCGR, "movgriipostincgr", "mov", 32,
581 { 0, { { { (1<<MACH_BASE), 0 } } } }
583 /* mov$ws2 (--$Rs,$imm12),$Rdm */
585 XSTORMY16_INSN_MOVGRIIPREDECGR, "movgriipredecgr", "mov", 32,
586 { 0, { { { (1<<MACH_BASE), 0 } } } }
590 XSTORMY16_INSN_MOVGRGR, "movgrgr", "mov", 16,
591 { 0, { { { (1<<MACH_BASE), 0 } } } }
593 /* mov.w Rx,#$imm8 */
595 XSTORMY16_INSN_MOVWIMM8, "movwimm8", "mov.w", 16,
596 { 0, { { { (1<<MACH_BASE), 0 } } } }
598 /* mov.w $Rm,#$imm8small */
600 XSTORMY16_INSN_MOVWGRIMM8, "movwgrimm8", "mov.w", 16,
601 { 0, { { { (1<<MACH_BASE), 0 } } } }
603 /* mov.w $Rd,#$imm16 */
605 XSTORMY16_INSN_MOVWGRIMM16, "movwgrimm16", "mov.w", 32,
606 { 0, { { { (1<<MACH_BASE), 0 } } } }
610 XSTORMY16_INSN_MOVLOWGR, "movlowgr", "mov.b", 16,
611 { 0, { { { (1<<MACH_BASE), 0 } } } }
615 XSTORMY16_INSN_MOVHIGHGR, "movhighgr", "mov.b", 16,
616 { 0, { { { (1<<MACH_BASE), 0 } } } }
618 /* movf$ws2 $Rdm,($Rs) */
620 XSTORMY16_INSN_MOVFGRGRI, "movfgrgri", "movf", 16,
621 { 0, { { { (1<<MACH_BASE), 0 } } } }
623 /* movf$ws2 $Rdm,($Rs++) */
625 XSTORMY16_INSN_MOVFGRGRIPOSTINC, "movfgrgripostinc", "movf", 16,
626 { 0, { { { (1<<MACH_BASE), 0 } } } }
628 /* movf$ws2 $Rdm,(--$Rs) */
630 XSTORMY16_INSN_MOVFGRGRIPREDEC, "movfgrgripredec", "movf", 16,
631 { 0, { { { (1<<MACH_BASE), 0 } } } }
633 /* movf$ws2 ($Rs),$Rdm */
635 XSTORMY16_INSN_MOVFGRIGR, "movfgrigr", "movf", 16,
636 { 0, { { { (1<<MACH_BASE), 0 } } } }
638 /* movf$ws2 ($Rs++),$Rdm */
640 XSTORMY16_INSN_MOVFGRIPOSTINCGR, "movfgripostincgr", "movf", 16,
641 { 0, { { { (1<<MACH_BASE), 0 } } } }
643 /* movf$ws2 (--$Rs),$Rdm */
645 XSTORMY16_INSN_MOVFGRIPREDECGR, "movfgripredecgr", "movf", 16,
646 { 0, { { { (1<<MACH_BASE), 0 } } } }
648 /* movf$ws2 $Rdm,($Rb,$Rs,$imm12) */
650 XSTORMY16_INSN_MOVFGRGRII, "movfgrgrii", "movf", 32,
651 { 0, { { { (1<<MACH_BASE), 0 } } } }
653 /* movf$ws2 $Rdm,($Rb,$Rs++,$imm12) */
655 XSTORMY16_INSN_MOVFGRGRIIPOSTINC, "movfgrgriipostinc", "movf", 32,
656 { 0, { { { (1<<MACH_BASE), 0 } } } }
658 /* movf$ws2 $Rdm,($Rb,--$Rs,$imm12) */
660 XSTORMY16_INSN_MOVFGRGRIIPREDEC, "movfgrgriipredec", "movf", 32,
661 { 0, { { { (1<<MACH_BASE), 0 } } } }
663 /* movf$ws2 ($Rb,$Rs,$imm12),$Rdm */
665 XSTORMY16_INSN_MOVFGRIIGR, "movfgriigr", "movf", 32,
666 { 0, { { { (1<<MACH_BASE), 0 } } } }
668 /* movf$ws2 ($Rb,$Rs++,$imm12),$Rdm */
670 XSTORMY16_INSN_MOVFGRIIPOSTINCGR, "movfgriipostincgr", "movf", 32,
671 { 0, { { { (1<<MACH_BASE), 0 } } } }
673 /* movf$ws2 ($Rb,--$Rs,$imm12),$Rdm */
675 XSTORMY16_INSN_MOVFGRIIPREDECGR, "movfgriipredecgr", "movf", 32,
676 { 0, { { { (1<<MACH_BASE), 0 } } } }
680 XSTORMY16_INSN_MASKGRGR, "maskgrgr", "mask", 16,
681 { 0, { { { (1<<MACH_BASE), 0 } } } }
683 /* mask $Rd,#$imm16 */
685 XSTORMY16_INSN_MASKGRIMM16, "maskgrimm16", "mask", 32,
686 { 0, { { { (1<<MACH_BASE), 0 } } } }
690 XSTORMY16_INSN_PUSHGR, "pushgr", "push", 16,
691 { 0, { { { (1<<MACH_BASE), 0 } } } }
695 XSTORMY16_INSN_POPGR, "popgr", "pop", 16,
696 { 0, { { { (1<<MACH_BASE), 0 } } } }
700 XSTORMY16_INSN_SWPN, "swpn", "swpn", 16,
701 { 0, { { { (1<<MACH_BASE), 0 } } } }
705 XSTORMY16_INSN_SWPB, "swpb", "swpb", 16,
706 { 0, { { { (1<<MACH_BASE), 0 } } } }
710 XSTORMY16_INSN_SWPW, "swpw", "swpw", 16,
711 { 0, { { { (1<<MACH_BASE), 0 } } } }
715 XSTORMY16_INSN_ANDGRGR, "andgrgr", "and", 16,
716 { 0, { { { (1<<MACH_BASE), 0 } } } }
720 XSTORMY16_INSN_ANDIMM8, "andimm8", "and", 16,
721 { 0, { { { (1<<MACH_BASE), 0 } } } }
723 /* and $Rd,#$imm16 */
725 XSTORMY16_INSN_ANDGRIMM16, "andgrimm16", "and", 32,
726 { 0, { { { (1<<MACH_BASE), 0 } } } }
730 XSTORMY16_INSN_ORGRGR, "orgrgr", "or", 16,
731 { 0, { { { (1<<MACH_BASE), 0 } } } }
735 XSTORMY16_INSN_ORIMM8, "orimm8", "or", 16,
736 { 0, { { { (1<<MACH_BASE), 0 } } } }
740 XSTORMY16_INSN_ORGRIMM16, "orgrimm16", "or", 32,
741 { 0, { { { (1<<MACH_BASE), 0 } } } }
745 XSTORMY16_INSN_XORGRGR, "xorgrgr", "xor", 16,
746 { 0, { { { (1<<MACH_BASE), 0 } } } }
750 XSTORMY16_INSN_XORIMM8, "xorimm8", "xor", 16,
751 { 0, { { { (1<<MACH_BASE), 0 } } } }
753 /* xor $Rd,#$imm16 */
755 XSTORMY16_INSN_XORGRIMM16, "xorgrimm16", "xor", 32,
756 { 0, { { { (1<<MACH_BASE), 0 } } } }
760 XSTORMY16_INSN_NOTGR, "notgr", "not", 16,
761 { 0, { { { (1<<MACH_BASE), 0 } } } }
765 XSTORMY16_INSN_ADDGRGR, "addgrgr", "add", 16,
766 { 0, { { { (1<<MACH_BASE), 0 } } } }
770 XSTORMY16_INSN_ADDGRIMM4, "addgrimm4", "add", 16,
771 { 0, { { { (1<<MACH_BASE), 0 } } } }
775 XSTORMY16_INSN_ADDIMM8, "addimm8", "add", 16,
776 { 0, { { { (1<<MACH_BASE), 0 } } } }
778 /* add $Rd,#$imm16 */
780 XSTORMY16_INSN_ADDGRIMM16, "addgrimm16", "add", 32,
781 { 0, { { { (1<<MACH_BASE), 0 } } } }
785 XSTORMY16_INSN_ADCGRGR, "adcgrgr", "adc", 16,
786 { 0, { { { (1<<MACH_BASE), 0 } } } }
790 XSTORMY16_INSN_ADCGRIMM4, "adcgrimm4", "adc", 16,
791 { 0, { { { (1<<MACH_BASE), 0 } } } }
795 XSTORMY16_INSN_ADCIMM8, "adcimm8", "adc", 16,
796 { 0, { { { (1<<MACH_BASE), 0 } } } }
798 /* adc $Rd,#$imm16 */
800 XSTORMY16_INSN_ADCGRIMM16, "adcgrimm16", "adc", 32,
801 { 0, { { { (1<<MACH_BASE), 0 } } } }
805 XSTORMY16_INSN_SUBGRGR, "subgrgr", "sub", 16,
806 { 0, { { { (1<<MACH_BASE), 0 } } } }
810 XSTORMY16_INSN_SUBGRIMM4, "subgrimm4", "sub", 16,
811 { 0, { { { (1<<MACH_BASE), 0 } } } }
815 XSTORMY16_INSN_SUBIMM8, "subimm8", "sub", 16,
816 { 0, { { { (1<<MACH_BASE), 0 } } } }
818 /* sub $Rd,#$imm16 */
820 XSTORMY16_INSN_SUBGRIMM16, "subgrimm16", "sub", 32,
821 { 0, { { { (1<<MACH_BASE), 0 } } } }
825 XSTORMY16_INSN_SBCGRGR, "sbcgrgr", "sbc", 16,
826 { 0, { { { (1<<MACH_BASE), 0 } } } }
830 XSTORMY16_INSN_SBCGRIMM4, "sbcgrimm4", "sbc", 16,
831 { 0, { { { (1<<MACH_BASE), 0 } } } }
835 XSTORMY16_INSN_SBCGRIMM8, "sbcgrimm8", "sbc", 16,
836 { 0, { { { (1<<MACH_BASE), 0 } } } }
838 /* sbc $Rd,#$imm16 */
840 XSTORMY16_INSN_SBCGRIMM16, "sbcgrimm16", "sbc", 32,
841 { 0, { { { (1<<MACH_BASE), 0 } } } }
845 XSTORMY16_INSN_INCGRIMM2, "incgrimm2", "inc", 16,
846 { 0, { { { (1<<MACH_BASE), 0 } } } }
850 XSTORMY16_INSN_DECGRIMM2, "decgrimm2", "dec", 16,
851 { 0, { { { (1<<MACH_BASE), 0 } } } }
855 XSTORMY16_INSN_RRCGRGR, "rrcgrgr", "rrc", 16,
856 { 0, { { { (1<<MACH_BASE), 0 } } } }
860 XSTORMY16_INSN_RRCGRIMM4, "rrcgrimm4", "rrc", 16,
861 { 0, { { { (1<<MACH_BASE), 0 } } } }
865 XSTORMY16_INSN_RLCGRGR, "rlcgrgr", "rlc", 16,
866 { 0, { { { (1<<MACH_BASE), 0 } } } }
870 XSTORMY16_INSN_RLCGRIMM4, "rlcgrimm4", "rlc", 16,
871 { 0, { { { (1<<MACH_BASE), 0 } } } }
875 XSTORMY16_INSN_SHRGRGR, "shrgrgr", "shr", 16,
876 { 0, { { { (1<<MACH_BASE), 0 } } } }
880 XSTORMY16_INSN_SHRGRIMM, "shrgrimm", "shr", 16,
881 { 0, { { { (1<<MACH_BASE), 0 } } } }
885 XSTORMY16_INSN_SHLGRGR, "shlgrgr", "shl", 16,
886 { 0, { { { (1<<MACH_BASE), 0 } } } }
890 XSTORMY16_INSN_SHLGRIMM, "shlgrimm", "shl", 16,
891 { 0, { { { (1<<MACH_BASE), 0 } } } }
895 XSTORMY16_INSN_ASRGRGR, "asrgrgr", "asr", 16,
896 { 0, { { { (1<<MACH_BASE), 0 } } } }
900 XSTORMY16_INSN_ASRGRIMM, "asrgrimm", "asr", 16,
901 { 0, { { { (1<<MACH_BASE), 0 } } } }
903 /* set1 $Rd,#$imm4 */
905 XSTORMY16_INSN_SET1GRIMM, "set1grimm", "set1", 16,
906 { 0, { { { (1<<MACH_BASE), 0 } } } }
910 XSTORMY16_INSN_SET1GRGR, "set1grgr", "set1", 16,
911 { 0, { { { (1<<MACH_BASE), 0 } } } }
913 /* set1 $lmem8,#$imm3 */
915 XSTORMY16_INSN_SET1LMEMIMM, "set1lmemimm", "set1", 16,
916 { 0, { { { (1<<MACH_BASE), 0 } } } }
918 /* set1 $hmem8,#$imm3 */
920 XSTORMY16_INSN_SET1HMEMIMM, "set1hmemimm", "set1", 16,
921 { 0, { { { (1<<MACH_BASE), 0 } } } }
923 /* clr1 $Rd,#$imm4 */
925 XSTORMY16_INSN_CLR1GRIMM, "clr1grimm", "clr1", 16,
926 { 0, { { { (1<<MACH_BASE), 0 } } } }
930 XSTORMY16_INSN_CLR1GRGR, "clr1grgr", "clr1", 16,
931 { 0, { { { (1<<MACH_BASE), 0 } } } }
933 /* clr1 $lmem8,#$imm3 */
935 XSTORMY16_INSN_CLR1LMEMIMM, "clr1lmemimm", "clr1", 16,
936 { 0, { { { (1<<MACH_BASE), 0 } } } }
938 /* clr1 $hmem8,#$imm3 */
940 XSTORMY16_INSN_CLR1HMEMIMM, "clr1hmemimm", "clr1", 16,
941 { 0, { { { (1<<MACH_BASE), 0 } } } }
945 XSTORMY16_INSN_CBWGR, "cbwgr", "cbw", 16,
946 { 0, { { { (1<<MACH_BASE), 0 } } } }
950 XSTORMY16_INSN_REVGR, "revgr", "rev", 16,
951 { 0, { { { (1<<MACH_BASE), 0 } } } }
953 /* b$bcond5 $Rd,$Rs,$rel12 */
955 XSTORMY16_INSN_BCCGRGR, "bccgrgr", "b", 32,
956 { 0|A(COND_CTI), { { { (1<<MACH_BASE), 0 } } } }
958 /* b$bcond5 $Rm,#$imm8,$rel12 */
960 XSTORMY16_INSN_BCCGRIMM8, "bccgrimm8", "b", 32,
961 { 0|A(COND_CTI), { { { (1<<MACH_BASE), 0 } } } }
963 /* b$bcond2 Rx,#$imm16,${rel8-4} */
965 XSTORMY16_INSN_BCCIMM16, "bccimm16", "b", 32,
966 { 0|A(COND_CTI), { { { (1<<MACH_BASE), 0 } } } }
968 /* bn $Rd,#$imm4,$rel12 */
970 XSTORMY16_INSN_BNGRIMM4, "bngrimm4", "bn", 32,
971 { 0|A(COND_CTI), { { { (1<<MACH_BASE), 0 } } } }
973 /* bn $Rd,$Rs,$rel12 */
975 XSTORMY16_INSN_BNGRGR, "bngrgr", "bn", 32,
976 { 0|A(COND_CTI), { { { (1<<MACH_BASE), 0 } } } }
978 /* bn $lmem8,#$imm3b,$rel12 */
980 XSTORMY16_INSN_BNLMEMIMM, "bnlmemimm", "bn", 32,
981 { 0|A(COND_CTI), { { { (1<<MACH_BASE), 0 } } } }
983 /* bn $hmem8,#$imm3b,$rel12 */
985 XSTORMY16_INSN_BNHMEMIMM, "bnhmemimm", "bn", 32,
986 { 0|A(COND_CTI), { { { (1<<MACH_BASE), 0 } } } }
988 /* bp $Rd,#$imm4,$rel12 */
990 XSTORMY16_INSN_BPGRIMM4, "bpgrimm4", "bp", 32,
991 { 0|A(COND_CTI), { { { (1<<MACH_BASE), 0 } } } }
993 /* bp $Rd,$Rs,$rel12 */
995 XSTORMY16_INSN_BPGRGR, "bpgrgr", "bp", 32,
996 { 0|A(COND_CTI), { { { (1<<MACH_BASE), 0 } } } }
998 /* bp $lmem8,#$imm3b,$rel12 */
1000 XSTORMY16_INSN_BPLMEMIMM, "bplmemimm", "bp", 32,
1001 { 0|A(COND_CTI), { { { (1<<MACH_BASE), 0 } } } }
1003 /* bp $hmem8,#$imm3b,$rel12 */
1005 XSTORMY16_INSN_BPHMEMIMM, "bphmemimm", "bp", 32,
1006 { 0|A(COND_CTI), { { { (1<<MACH_BASE), 0 } } } }
1008 /* b$bcond2 ${rel8-2} */
1010 XSTORMY16_INSN_BCC, "bcc", "b", 16,
1011 { 0|A(COND_CTI), { { { (1<<MACH_BASE), 0 } } } }
1015 XSTORMY16_INSN_BGR, "bgr", "br", 16,
1016 { 0|A(UNCOND_CTI), { { { (1<<MACH_BASE), 0 } } } }
1020 XSTORMY16_INSN_BR, "br", "br", 16,
1021 { 0|A(UNCOND_CTI), { { { (1<<MACH_BASE), 0 } } } }
1025 XSTORMY16_INSN_JMP, "jmp", "jmp", 16,
1026 { 0|A(UNCOND_CTI), { { { (1<<MACH_BASE), 0 } } } }
1030 XSTORMY16_INSN_JMPF, "jmpf", "jmpf", 32,
1031 { 0|A(UNCOND_CTI), { { { (1<<MACH_BASE), 0 } } } }
1035 XSTORMY16_INSN_CALLRGR, "callrgr", "callr", 16,
1036 { 0|A(UNCOND_CTI), { { { (1<<MACH_BASE), 0 } } } }
1040 XSTORMY16_INSN_CALLRIMM, "callrimm", "callr", 16,
1041 { 0|A(UNCOND_CTI), { { { (1<<MACH_BASE), 0 } } } }
1045 XSTORMY16_INSN_CALLGR, "callgr", "call", 16,
1046 { 0|A(UNCOND_CTI), { { { (1<<MACH_BASE), 0 } } } }
1050 XSTORMY16_INSN_CALLFIMM, "callfimm", "callf", 32,
1051 { 0|A(UNCOND_CTI), { { { (1<<MACH_BASE), 0 } } } }
1055 XSTORMY16_INSN_ICALLRGR, "icallrgr", "icallr", 16,
1056 { 0|A(UNCOND_CTI), { { { (1<<MACH_BASE), 0 } } } }
1058 /* icall $Rbj,$Rd */
1060 XSTORMY16_INSN_ICALLGR, "icallgr", "icall", 16,
1061 { 0|A(UNCOND_CTI), { { { (1<<MACH_BASE), 0 } } } }
1065 XSTORMY16_INSN_ICALLFIMM, "icallfimm", "icallf", 32,
1066 { 0|A(UNCOND_CTI), { { { (1<<MACH_BASE), 0 } } } }
1070 XSTORMY16_INSN_IRET, "iret", "iret", 16,
1071 { 0|A(UNCOND_CTI), { { { (1<<MACH_BASE), 0 } } } }
1075 XSTORMY16_INSN_RET, "ret", "ret", 16,
1076 { 0|A(UNCOND_CTI), { { { (1<<MACH_BASE), 0 } } } }
1080 XSTORMY16_INSN_MUL, "mul", "mul", 16,
1081 { 0, { { { (1<<MACH_BASE), 0 } } } }
1085 XSTORMY16_INSN_DIV, "div", "div", 16,
1086 { 0, { { { (1<<MACH_BASE), 0 } } } }
1090 XSTORMY16_INSN_SDIV, "sdiv", "sdiv", 16,
1091 { 0, { { { (1<<MACH_BASE), 0 } } } }
1095 XSTORMY16_INSN_SDIVLH, "sdivlh", "sdivlh", 16,
1096 { 0, { { { (1<<MACH_BASE), 0 } } } }
1100 XSTORMY16_INSN_DIVLH, "divlh", "divlh", 16,
1101 { 0, { { { (1<<MACH_BASE), 0 } } } }
1105 XSTORMY16_INSN_RESET, "reset", "reset", 16,
1106 { 0, { { { (1<<MACH_BASE), 0 } } } }
1110 XSTORMY16_INSN_NOP, "nop", "nop", 16,
1111 { 0, { { { (1<<MACH_BASE), 0 } } } }
1115 XSTORMY16_INSN_HALT, "halt", "halt", 16,
1116 { 0, { { { (1<<MACH_BASE), 0 } } } }
1120 XSTORMY16_INSN_HOLD, "hold", "hold", 16,
1121 { 0, { { { (1<<MACH_BASE), 0 } } } }
1125 XSTORMY16_INSN_HOLDX, "holdx", "holdx", 16,
1126 { 0, { { { (1<<MACH_BASE), 0 } } } }
1130 XSTORMY16_INSN_BRK, "brk", "brk", 16,
1131 { 0, { { { (1<<MACH_BASE), 0 } } } }
1135 XSTORMY16_INSN_SYSCALL, "syscall", "--unused--", 16,
1136 { 0, { { { (1<<MACH_BASE), 0 } } } }
1143 /* Initialize anything needed to be done once, before any cpu_open call. */
1150 static const CGEN_MACH * lookup_mach_via_bfd_name (const CGEN_MACH *, const char *);
1151 static void build_hw_table (CGEN_CPU_TABLE *);
1152 static void build_ifield_table (CGEN_CPU_TABLE *);
1153 static void build_operand_table (CGEN_CPU_TABLE *);
1154 static void build_insn_table (CGEN_CPU_TABLE *);
1155 static void xstormy16_cgen_rebuild_tables (CGEN_CPU_TABLE *);
1157 /* Subroutine of xstormy16_cgen_cpu_open to look up a mach via its bfd name. */
1159 static const CGEN_MACH *
1160 lookup_mach_via_bfd_name (const CGEN_MACH *table, const char *name)
1164 if (strcmp (name, table->bfd_name) == 0)
1171 /* Subroutine of xstormy16_cgen_cpu_open to build the hardware table. */
1174 build_hw_table (CGEN_CPU_TABLE *cd)
1177 int machs = cd->machs;
1178 const CGEN_HW_ENTRY *init = & xstormy16_cgen_hw_table[0];
1179 /* MAX_HW is only an upper bound on the number of selected entries.
1180 However each entry is indexed by it's enum so there can be holes in
1182 const CGEN_HW_ENTRY **selected =
1183 (const CGEN_HW_ENTRY **) xmalloc (MAX_HW * sizeof (CGEN_HW_ENTRY *));
1185 cd->hw_table.init_entries = init;
1186 cd->hw_table.entry_size = sizeof (CGEN_HW_ENTRY);
1187 memset (selected, 0, MAX_HW * sizeof (CGEN_HW_ENTRY *));
1188 /* ??? For now we just use machs to determine which ones we want. */
1189 for (i = 0; init[i].name != NULL; ++i)
1190 if (CGEN_HW_ATTR_VALUE (&init[i], CGEN_HW_MACH)
1192 selected[init[i].type] = &init[i];
1193 cd->hw_table.entries = selected;
1194 cd->hw_table.num_entries = MAX_HW;
1197 /* Subroutine of xstormy16_cgen_cpu_open to build the hardware table. */
1200 build_ifield_table (CGEN_CPU_TABLE *cd)
1202 cd->ifld_table = & xstormy16_cgen_ifld_table[0];
1205 /* Subroutine of xstormy16_cgen_cpu_open to build the hardware table. */
1208 build_operand_table (CGEN_CPU_TABLE *cd)
1211 int machs = cd->machs;
1212 const CGEN_OPERAND *init = & xstormy16_cgen_operand_table[0];
1213 /* MAX_OPERANDS is only an upper bound on the number of selected entries.
1214 However each entry is indexed by it's enum so there can be holes in
1216 const CGEN_OPERAND **selected = xmalloc (MAX_OPERANDS * sizeof (* selected));
1218 cd->operand_table.init_entries = init;
1219 cd->operand_table.entry_size = sizeof (CGEN_OPERAND);
1220 memset (selected, 0, MAX_OPERANDS * sizeof (CGEN_OPERAND *));
1221 /* ??? For now we just use mach to determine which ones we want. */
1222 for (i = 0; init[i].name != NULL; ++i)
1223 if (CGEN_OPERAND_ATTR_VALUE (&init[i], CGEN_OPERAND_MACH)
1225 selected[init[i].type] = &init[i];
1226 cd->operand_table.entries = selected;
1227 cd->operand_table.num_entries = MAX_OPERANDS;
1230 /* Subroutine of xstormy16_cgen_cpu_open to build the hardware table.
1231 ??? This could leave out insns not supported by the specified mach/isa,
1232 but that would cause errors like "foo only supported by bar" to become
1233 "unknown insn", so for now we include all insns and require the app to
1234 do the checking later.
1235 ??? On the other hand, parsing of such insns may require their hardware or
1236 operand elements to be in the table [which they mightn't be]. */
1239 build_insn_table (CGEN_CPU_TABLE *cd)
1242 const CGEN_IBASE *ib = & xstormy16_cgen_insn_table[0];
1243 CGEN_INSN *insns = xmalloc (MAX_INSNS * sizeof (CGEN_INSN));
1245 memset (insns, 0, MAX_INSNS * sizeof (CGEN_INSN));
1246 for (i = 0; i < MAX_INSNS; ++i)
1247 insns[i].base = &ib[i];
1248 cd->insn_table.init_entries = insns;
1249 cd->insn_table.entry_size = sizeof (CGEN_IBASE);
1250 cd->insn_table.num_init_entries = MAX_INSNS;
1253 /* Subroutine of xstormy16_cgen_cpu_open to rebuild the tables. */
1256 xstormy16_cgen_rebuild_tables (CGEN_CPU_TABLE *cd)
1259 CGEN_BITSET *isas = cd->isas;
1260 unsigned int machs = cd->machs;
1262 cd->int_insn_p = CGEN_INT_INSN_P;
1264 /* Data derived from the isa spec. */
1265 #define UNSET (CGEN_SIZE_UNKNOWN + 1)
1266 cd->default_insn_bitsize = UNSET;
1267 cd->base_insn_bitsize = UNSET;
1268 cd->min_insn_bitsize = 65535; /* Some ridiculously big number. */
1269 cd->max_insn_bitsize = 0;
1270 for (i = 0; i < MAX_ISAS; ++i)
1271 if (cgen_bitset_contains (isas, i))
1273 const CGEN_ISA *isa = & xstormy16_cgen_isa_table[i];
1275 /* Default insn sizes of all selected isas must be
1276 equal or we set the result to 0, meaning "unknown". */
1277 if (cd->default_insn_bitsize == UNSET)
1278 cd->default_insn_bitsize = isa->default_insn_bitsize;
1279 else if (isa->default_insn_bitsize == cd->default_insn_bitsize)
1282 cd->default_insn_bitsize = CGEN_SIZE_UNKNOWN;
1284 /* Base insn sizes of all selected isas must be equal
1285 or we set the result to 0, meaning "unknown". */
1286 if (cd->base_insn_bitsize == UNSET)
1287 cd->base_insn_bitsize = isa->base_insn_bitsize;
1288 else if (isa->base_insn_bitsize == cd->base_insn_bitsize)
1291 cd->base_insn_bitsize = CGEN_SIZE_UNKNOWN;
1293 /* Set min,max insn sizes. */
1294 if (isa->min_insn_bitsize < cd->min_insn_bitsize)
1295 cd->min_insn_bitsize = isa->min_insn_bitsize;
1296 if (isa->max_insn_bitsize > cd->max_insn_bitsize)
1297 cd->max_insn_bitsize = isa->max_insn_bitsize;
1300 /* Data derived from the mach spec. */
1301 for (i = 0; i < MAX_MACHS; ++i)
1302 if (((1 << i) & machs) != 0)
1304 const CGEN_MACH *mach = & xstormy16_cgen_mach_table[i];
1306 if (mach->insn_chunk_bitsize != 0)
1308 if (cd->insn_chunk_bitsize != 0 && cd->insn_chunk_bitsize != mach->insn_chunk_bitsize)
1310 fprintf (stderr, "xstormy16_cgen_rebuild_tables: conflicting insn-chunk-bitsize values: `%d' vs. `%d'\n",
1311 cd->insn_chunk_bitsize, mach->insn_chunk_bitsize);
1315 cd->insn_chunk_bitsize = mach->insn_chunk_bitsize;
1319 /* Determine which hw elements are used by MACH. */
1320 build_hw_table (cd);
1322 /* Build the ifield table. */
1323 build_ifield_table (cd);
1325 /* Determine which operands are used by MACH/ISA. */
1326 build_operand_table (cd);
1328 /* Build the instruction table. */
1329 build_insn_table (cd);
1332 /* Initialize a cpu table and return a descriptor.
1333 It's much like opening a file, and must be the first function called.
1334 The arguments are a set of (type/value) pairs, terminated with
1337 Currently supported values:
1338 CGEN_CPU_OPEN_ISAS: bitmap of values in enum isa_attr
1339 CGEN_CPU_OPEN_MACHS: bitmap of values in enum mach_attr
1340 CGEN_CPU_OPEN_BFDMACH: specify 1 mach using bfd name
1341 CGEN_CPU_OPEN_ENDIAN: specify endian choice
1342 CGEN_CPU_OPEN_END: terminates arguments
1344 ??? Simultaneous multiple isas might not make sense, but it's not (yet)
1348 xstormy16_cgen_cpu_open (enum cgen_cpu_open_arg arg_type, ...)
1350 CGEN_CPU_TABLE *cd = (CGEN_CPU_TABLE *) xmalloc (sizeof (CGEN_CPU_TABLE));
1352 CGEN_BITSET *isas = 0; /* 0 = "unspecified" */
1353 unsigned int machs = 0; /* 0 = "unspecified" */
1354 enum cgen_endian endian = CGEN_ENDIAN_UNKNOWN;
1363 memset (cd, 0, sizeof (*cd));
1365 va_start (ap, arg_type);
1366 while (arg_type != CGEN_CPU_OPEN_END)
1370 case CGEN_CPU_OPEN_ISAS :
1371 isas = va_arg (ap, CGEN_BITSET *);
1373 case CGEN_CPU_OPEN_MACHS :
1374 machs = va_arg (ap, unsigned int);
1376 case CGEN_CPU_OPEN_BFDMACH :
1378 const char *name = va_arg (ap, const char *);
1379 const CGEN_MACH *mach =
1380 lookup_mach_via_bfd_name (xstormy16_cgen_mach_table, name);
1383 machs |= 1 << mach->num;
1386 case CGEN_CPU_OPEN_ENDIAN :
1387 endian = va_arg (ap, enum cgen_endian);
1390 fprintf (stderr, "xstormy16_cgen_cpu_open: unsupported argument `%d'\n",
1392 abort (); /* ??? return NULL? */
1394 arg_type = va_arg (ap, enum cgen_cpu_open_arg);
1398 /* Mach unspecified means "all". */
1400 machs = (1 << MAX_MACHS) - 1;
1401 /* Base mach is always selected. */
1403 if (endian == CGEN_ENDIAN_UNKNOWN)
1405 /* ??? If target has only one, could have a default. */
1406 fprintf (stderr, "xstormy16_cgen_cpu_open: no endianness specified\n");
1410 cd->isas = cgen_bitset_copy (isas);
1412 cd->endian = endian;
1413 /* FIXME: for the sparc case we can determine insn-endianness statically.
1414 The worry here is where both data and insn endian can be independently
1415 chosen, in which case this function will need another argument.
1416 Actually, will want to allow for more arguments in the future anyway. */
1417 cd->insn_endian = endian;
1419 /* Table (re)builder. */
1420 cd->rebuild_tables = xstormy16_cgen_rebuild_tables;
1421 xstormy16_cgen_rebuild_tables (cd);
1423 /* Default to not allowing signed overflow. */
1424 cd->signed_overflow_ok_p = 0;
1426 return (CGEN_CPU_DESC) cd;
1429 /* Cover fn to xstormy16_cgen_cpu_open to handle the simple case of 1 isa, 1 mach.
1430 MACH_NAME is the bfd name of the mach. */
1433 xstormy16_cgen_cpu_open_1 (const char *mach_name, enum cgen_endian endian)
1435 return xstormy16_cgen_cpu_open (CGEN_CPU_OPEN_BFDMACH, mach_name,
1436 CGEN_CPU_OPEN_ENDIAN, endian,
1440 /* Close a cpu table.
1441 ??? This can live in a machine independent file, but there's currently
1442 no place to put this file (there's no libcgen). libopcodes is the wrong
1443 place as some simulator ports use this but they don't use libopcodes. */
1446 xstormy16_cgen_cpu_close (CGEN_CPU_DESC cd)
1449 const CGEN_INSN *insns;
1451 if (cd->macro_insn_table.init_entries)
1453 insns = cd->macro_insn_table.init_entries;
1454 for (i = 0; i < cd->macro_insn_table.num_init_entries; ++i, ++insns)
1455 if (CGEN_INSN_RX ((insns)))
1456 regfree (CGEN_INSN_RX (insns));
1459 if (cd->insn_table.init_entries)
1461 insns = cd->insn_table.init_entries;
1462 for (i = 0; i < cd->insn_table.num_init_entries; ++i, ++insns)
1463 if (CGEN_INSN_RX (insns))
1464 regfree (CGEN_INSN_RX (insns));
1467 if (cd->macro_insn_table.init_entries)
1468 free ((CGEN_INSN *) cd->macro_insn_table.init_entries);
1470 if (cd->insn_table.init_entries)
1471 free ((CGEN_INSN *) cd->insn_table.init_entries);
1473 if (cd->hw_table.entries)
1474 free ((CGEN_HW_ENTRY *) cd->hw_table.entries);
1476 if (cd->operand_table.entries)
1477 free ((CGEN_HW_ENTRY *) cd->operand_table.entries);