1d2201f2fSdrahn /* CPU data for openrisc.
2d2201f2fSdrahn
3d2201f2fSdrahn THIS FILE IS MACHINE GENERATED WITH CGEN.
4d2201f2fSdrahn
5d2201f2fSdrahn Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
6d2201f2fSdrahn
7d2201f2fSdrahn This file is part of the GNU Binutils and/or GDB, the GNU debugger.
8d2201f2fSdrahn
9d2201f2fSdrahn This program is free software; you can redistribute it and/or modify
10d2201f2fSdrahn it under the terms of the GNU General Public License as published by
11d2201f2fSdrahn the Free Software Foundation; either version 2, or (at your option)
12d2201f2fSdrahn any later version.
13d2201f2fSdrahn
14d2201f2fSdrahn This program is distributed in the hope that it will be useful,
15d2201f2fSdrahn but WITHOUT ANY WARRANTY; without even the implied warranty of
16d2201f2fSdrahn MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17d2201f2fSdrahn GNU General Public License for more details.
18d2201f2fSdrahn
19d2201f2fSdrahn You should have received a copy of the GNU General Public License along
20d2201f2fSdrahn with this program; if not, write to the Free Software Foundation, Inc.,
21d2201f2fSdrahn 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22d2201f2fSdrahn
23d2201f2fSdrahn */
24d2201f2fSdrahn
25d2201f2fSdrahn #include "sysdep.h"
26d2201f2fSdrahn #include <stdio.h>
27d2201f2fSdrahn #include <stdarg.h>
28d2201f2fSdrahn #include "ansidecl.h"
29d2201f2fSdrahn #include "bfd.h"
30d2201f2fSdrahn #include "symcat.h"
31d2201f2fSdrahn #include "openrisc-desc.h"
32d2201f2fSdrahn #include "openrisc-opc.h"
33d2201f2fSdrahn #include "opintl.h"
34d2201f2fSdrahn #include "libiberty.h"
35d2201f2fSdrahn #include "xregex.h"
36d2201f2fSdrahn
37d2201f2fSdrahn /* Attributes. */
38d2201f2fSdrahn
39d2201f2fSdrahn static const CGEN_ATTR_ENTRY bool_attr[] =
40d2201f2fSdrahn {
41d2201f2fSdrahn { "#f", 0 },
42d2201f2fSdrahn { "#t", 1 },
43d2201f2fSdrahn { 0, 0 }
44d2201f2fSdrahn };
45d2201f2fSdrahn
46d2201f2fSdrahn static const CGEN_ATTR_ENTRY MACH_attr[] =
47d2201f2fSdrahn {
48d2201f2fSdrahn { "base", MACH_BASE },
49d2201f2fSdrahn { "openrisc", MACH_OPENRISC },
50d2201f2fSdrahn { "or1300", MACH_OR1300 },
51d2201f2fSdrahn { "max", MACH_MAX },
52d2201f2fSdrahn { 0, 0 }
53d2201f2fSdrahn };
54d2201f2fSdrahn
55d2201f2fSdrahn static const CGEN_ATTR_ENTRY ISA_attr[] =
56d2201f2fSdrahn {
57d2201f2fSdrahn { "or32", ISA_OR32 },
58d2201f2fSdrahn { "max", ISA_MAX },
59d2201f2fSdrahn { 0, 0 }
60d2201f2fSdrahn };
61d2201f2fSdrahn
62d2201f2fSdrahn static const CGEN_ATTR_ENTRY HAS_CACHE_attr[] =
63d2201f2fSdrahn {
64d2201f2fSdrahn { "DATA_CACHE", HAS_CACHE_DATA_CACHE },
65d2201f2fSdrahn { "INSN_CACHE", HAS_CACHE_INSN_CACHE },
66d2201f2fSdrahn { 0, 0 }
67d2201f2fSdrahn };
68d2201f2fSdrahn
69d2201f2fSdrahn const CGEN_ATTR_TABLE openrisc_cgen_ifield_attr_table[] =
70d2201f2fSdrahn {
71d2201f2fSdrahn { "MACH", & MACH_attr[0], & MACH_attr[0] },
72d2201f2fSdrahn { "VIRTUAL", &bool_attr[0], &bool_attr[0] },
73d2201f2fSdrahn { "PCREL-ADDR", &bool_attr[0], &bool_attr[0] },
74d2201f2fSdrahn { "ABS-ADDR", &bool_attr[0], &bool_attr[0] },
75d2201f2fSdrahn { "RESERVED", &bool_attr[0], &bool_attr[0] },
76d2201f2fSdrahn { "SIGN-OPT", &bool_attr[0], &bool_attr[0] },
77d2201f2fSdrahn { "SIGNED", &bool_attr[0], &bool_attr[0] },
78d2201f2fSdrahn { 0, 0, 0 }
79d2201f2fSdrahn };
80d2201f2fSdrahn
81d2201f2fSdrahn const CGEN_ATTR_TABLE openrisc_cgen_hardware_attr_table[] =
82d2201f2fSdrahn {
83d2201f2fSdrahn { "MACH", & MACH_attr[0], & MACH_attr[0] },
84d2201f2fSdrahn { "VIRTUAL", &bool_attr[0], &bool_attr[0] },
85d2201f2fSdrahn { "CACHE-ADDR", &bool_attr[0], &bool_attr[0] },
86d2201f2fSdrahn { "PC", &bool_attr[0], &bool_attr[0] },
87d2201f2fSdrahn { "PROFILE", &bool_attr[0], &bool_attr[0] },
88d2201f2fSdrahn { 0, 0, 0 }
89d2201f2fSdrahn };
90d2201f2fSdrahn
91d2201f2fSdrahn const CGEN_ATTR_TABLE openrisc_cgen_operand_attr_table[] =
92d2201f2fSdrahn {
93d2201f2fSdrahn { "MACH", & MACH_attr[0], & MACH_attr[0] },
94d2201f2fSdrahn { "VIRTUAL", &bool_attr[0], &bool_attr[0] },
95d2201f2fSdrahn { "PCREL-ADDR", &bool_attr[0], &bool_attr[0] },
96d2201f2fSdrahn { "ABS-ADDR", &bool_attr[0], &bool_attr[0] },
97d2201f2fSdrahn { "SIGN-OPT", &bool_attr[0], &bool_attr[0] },
98d2201f2fSdrahn { "SIGNED", &bool_attr[0], &bool_attr[0] },
99d2201f2fSdrahn { "NEGATIVE", &bool_attr[0], &bool_attr[0] },
100d2201f2fSdrahn { "RELAX", &bool_attr[0], &bool_attr[0] },
101d2201f2fSdrahn { "SEM-ONLY", &bool_attr[0], &bool_attr[0] },
102d2201f2fSdrahn { 0, 0, 0 }
103d2201f2fSdrahn };
104d2201f2fSdrahn
105d2201f2fSdrahn const CGEN_ATTR_TABLE openrisc_cgen_insn_attr_table[] =
106d2201f2fSdrahn {
107d2201f2fSdrahn { "MACH", & MACH_attr[0], & MACH_attr[0] },
108d2201f2fSdrahn { "ALIAS", &bool_attr[0], &bool_attr[0] },
109d2201f2fSdrahn { "VIRTUAL", &bool_attr[0], &bool_attr[0] },
110d2201f2fSdrahn { "UNCOND-CTI", &bool_attr[0], &bool_attr[0] },
111d2201f2fSdrahn { "COND-CTI", &bool_attr[0], &bool_attr[0] },
112d2201f2fSdrahn { "SKIP-CTI", &bool_attr[0], &bool_attr[0] },
113d2201f2fSdrahn { "DELAY-SLOT", &bool_attr[0], &bool_attr[0] },
114d2201f2fSdrahn { "RELAXABLE", &bool_attr[0], &bool_attr[0] },
115*cf2f2c56Smiod { "RELAXED", &bool_attr[0], &bool_attr[0] },
116d2201f2fSdrahn { "NO-DIS", &bool_attr[0], &bool_attr[0] },
117d2201f2fSdrahn { "PBB", &bool_attr[0], &bool_attr[0] },
118d2201f2fSdrahn { "NOT-IN-DELAY-SLOT", &bool_attr[0], &bool_attr[0] },
119d2201f2fSdrahn { 0, 0, 0 }
120d2201f2fSdrahn };
121d2201f2fSdrahn
122d2201f2fSdrahn /* Instruction set variants. */
123d2201f2fSdrahn
124d2201f2fSdrahn static const CGEN_ISA openrisc_cgen_isa_table[] = {
125d2201f2fSdrahn { "or32", 32, 32, 32, 32 },
126d2201f2fSdrahn { 0, 0, 0, 0, 0 }
127d2201f2fSdrahn };
128d2201f2fSdrahn
129d2201f2fSdrahn /* Machine variants. */
130d2201f2fSdrahn
131d2201f2fSdrahn static const CGEN_MACH openrisc_cgen_mach_table[] = {
132d2201f2fSdrahn { "openrisc", "openrisc", MACH_OPENRISC, 0 },
133d2201f2fSdrahn { "or1300", "openrisc:1300", MACH_OR1300, 0 },
134d2201f2fSdrahn { 0, 0, 0, 0 }
135d2201f2fSdrahn };
136d2201f2fSdrahn
137d2201f2fSdrahn static CGEN_KEYWORD_ENTRY openrisc_cgen_opval_h_gr_entries[] =
138d2201f2fSdrahn {
139d2201f2fSdrahn { "r0", 0, {0, {0}}, 0, 0 },
140d2201f2fSdrahn { "r1", 1, {0, {0}}, 0, 0 },
141d2201f2fSdrahn { "r2", 2, {0, {0}}, 0, 0 },
142d2201f2fSdrahn { "r3", 3, {0, {0}}, 0, 0 },
143d2201f2fSdrahn { "r4", 4, {0, {0}}, 0, 0 },
144d2201f2fSdrahn { "r5", 5, {0, {0}}, 0, 0 },
145d2201f2fSdrahn { "r6", 6, {0, {0}}, 0, 0 },
146d2201f2fSdrahn { "r7", 7, {0, {0}}, 0, 0 },
147d2201f2fSdrahn { "r8", 8, {0, {0}}, 0, 0 },
148d2201f2fSdrahn { "r9", 9, {0, {0}}, 0, 0 },
149d2201f2fSdrahn { "r10", 10, {0, {0}}, 0, 0 },
150d2201f2fSdrahn { "r11", 11, {0, {0}}, 0, 0 },
151d2201f2fSdrahn { "r12", 12, {0, {0}}, 0, 0 },
152d2201f2fSdrahn { "r13", 13, {0, {0}}, 0, 0 },
153d2201f2fSdrahn { "r14", 14, {0, {0}}, 0, 0 },
154d2201f2fSdrahn { "r15", 15, {0, {0}}, 0, 0 },
155d2201f2fSdrahn { "r16", 16, {0, {0}}, 0, 0 },
156d2201f2fSdrahn { "r17", 17, {0, {0}}, 0, 0 },
157d2201f2fSdrahn { "r18", 18, {0, {0}}, 0, 0 },
158d2201f2fSdrahn { "r19", 19, {0, {0}}, 0, 0 },
159d2201f2fSdrahn { "r20", 20, {0, {0}}, 0, 0 },
160d2201f2fSdrahn { "r21", 21, {0, {0}}, 0, 0 },
161d2201f2fSdrahn { "r22", 22, {0, {0}}, 0, 0 },
162d2201f2fSdrahn { "r23", 23, {0, {0}}, 0, 0 },
163d2201f2fSdrahn { "r24", 24, {0, {0}}, 0, 0 },
164d2201f2fSdrahn { "r25", 25, {0, {0}}, 0, 0 },
165d2201f2fSdrahn { "r26", 26, {0, {0}}, 0, 0 },
166d2201f2fSdrahn { "r27", 27, {0, {0}}, 0, 0 },
167d2201f2fSdrahn { "r28", 28, {0, {0}}, 0, 0 },
168d2201f2fSdrahn { "r29", 29, {0, {0}}, 0, 0 },
169d2201f2fSdrahn { "r30", 30, {0, {0}}, 0, 0 },
170d2201f2fSdrahn { "r31", 31, {0, {0}}, 0, 0 },
171d2201f2fSdrahn { "lr", 11, {0, {0}}, 0, 0 },
172d2201f2fSdrahn { "sp", 1, {0, {0}}, 0, 0 },
173d2201f2fSdrahn { "fp", 2, {0, {0}}, 0, 0 }
174d2201f2fSdrahn };
175d2201f2fSdrahn
176d2201f2fSdrahn CGEN_KEYWORD openrisc_cgen_opval_h_gr =
177d2201f2fSdrahn {
178d2201f2fSdrahn & openrisc_cgen_opval_h_gr_entries[0],
179d2201f2fSdrahn 35,
180d2201f2fSdrahn 0, 0, 0, 0, ""
181d2201f2fSdrahn };
182d2201f2fSdrahn
183d2201f2fSdrahn
184d2201f2fSdrahn /* The hardware table. */
185d2201f2fSdrahn
186d2201f2fSdrahn #if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
187d2201f2fSdrahn #define A(a) (1 << CGEN_HW_##a)
188d2201f2fSdrahn #else
189d2201f2fSdrahn #define A(a) (1 << CGEN_HW_/**/a)
190d2201f2fSdrahn #endif
191d2201f2fSdrahn
192d2201f2fSdrahn const CGEN_HW_ENTRY openrisc_cgen_hw_table[] =
193d2201f2fSdrahn {
194d2201f2fSdrahn { "h-memory", HW_H_MEMORY, CGEN_ASM_NONE, 0, { 0, { (1<<MACH_BASE) } } },
195d2201f2fSdrahn { "h-sint", HW_H_SINT, CGEN_ASM_NONE, 0, { 0, { (1<<MACH_BASE) } } },
196d2201f2fSdrahn { "h-uint", HW_H_UINT, CGEN_ASM_NONE, 0, { 0, { (1<<MACH_BASE) } } },
197d2201f2fSdrahn { "h-addr", HW_H_ADDR, CGEN_ASM_NONE, 0, { 0, { (1<<MACH_BASE) } } },
198d2201f2fSdrahn { "h-iaddr", HW_H_IADDR, CGEN_ASM_NONE, 0, { 0, { (1<<MACH_BASE) } } },
199d2201f2fSdrahn { "h-pc", HW_H_PC, CGEN_ASM_NONE, 0, { 0|A(PROFILE)|A(PC), { (1<<MACH_BASE) } } },
200d2201f2fSdrahn { "h-gr", HW_H_GR, CGEN_ASM_KEYWORD, (PTR) & openrisc_cgen_opval_h_gr, { 0|A(PROFILE), { (1<<MACH_BASE) } } },
201d2201f2fSdrahn { "h-sr", HW_H_SR, CGEN_ASM_NONE, 0, { 0, { (1<<MACH_BASE) } } },
202d2201f2fSdrahn { "h-hi16", HW_H_HI16, CGEN_ASM_NONE, 0, { 0, { (1<<MACH_BASE) } } },
203d2201f2fSdrahn { "h-lo16", HW_H_LO16, CGEN_ASM_NONE, 0, { 0, { (1<<MACH_BASE) } } },
204d2201f2fSdrahn { "h-cbit", HW_H_CBIT, CGEN_ASM_NONE, 0, { 0, { (1<<MACH_BASE) } } },
205d2201f2fSdrahn { "h-delay-insn", HW_H_DELAY_INSN, CGEN_ASM_NONE, 0, { 0, { (1<<MACH_BASE) } } },
206d2201f2fSdrahn { 0, 0, CGEN_ASM_NONE, 0, {0, {0}} }
207d2201f2fSdrahn };
208d2201f2fSdrahn
209d2201f2fSdrahn #undef A
210d2201f2fSdrahn
211d2201f2fSdrahn
212d2201f2fSdrahn /* The instruction field table. */
213d2201f2fSdrahn
214d2201f2fSdrahn #if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
215d2201f2fSdrahn #define A(a) (1 << CGEN_IFLD_##a)
216d2201f2fSdrahn #else
217d2201f2fSdrahn #define A(a) (1 << CGEN_IFLD_/**/a)
218d2201f2fSdrahn #endif
219d2201f2fSdrahn
220d2201f2fSdrahn const CGEN_IFLD openrisc_cgen_ifld_table[] =
221d2201f2fSdrahn {
222d2201f2fSdrahn { OPENRISC_F_NIL, "f-nil", 0, 0, 0, 0, { 0, { (1<<MACH_BASE) } } },
223d2201f2fSdrahn { OPENRISC_F_ANYOF, "f-anyof", 0, 0, 0, 0, { 0, { (1<<MACH_BASE) } } },
224d2201f2fSdrahn { OPENRISC_F_CLASS, "f-class", 0, 32, 31, 2, { 0, { (1<<MACH_BASE) } } },
225d2201f2fSdrahn { OPENRISC_F_SUB, "f-sub", 0, 32, 29, 4, { 0, { (1<<MACH_BASE) } } },
226d2201f2fSdrahn { OPENRISC_F_R1, "f-r1", 0, 32, 25, 5, { 0, { (1<<MACH_BASE) } } },
227d2201f2fSdrahn { OPENRISC_F_R2, "f-r2", 0, 32, 20, 5, { 0, { (1<<MACH_BASE) } } },
228d2201f2fSdrahn { OPENRISC_F_R3, "f-r3", 0, 32, 15, 5, { 0, { (1<<MACH_BASE) } } },
229d2201f2fSdrahn { OPENRISC_F_SIMM16, "f-simm16", 0, 32, 15, 16, { 0, { (1<<MACH_BASE) } } },
230d2201f2fSdrahn { OPENRISC_F_UIMM16, "f-uimm16", 0, 32, 15, 16, { 0, { (1<<MACH_BASE) } } },
231d2201f2fSdrahn { OPENRISC_F_UIMM5, "f-uimm5", 0, 32, 4, 5, { 0, { (1<<MACH_BASE) } } },
232d2201f2fSdrahn { OPENRISC_F_HI16, "f-hi16", 0, 32, 15, 16, { 0, { (1<<MACH_BASE) } } },
233d2201f2fSdrahn { OPENRISC_F_LO16, "f-lo16", 0, 32, 15, 16, { 0, { (1<<MACH_BASE) } } },
234d2201f2fSdrahn { OPENRISC_F_OP1, "f-op1", 0, 32, 31, 2, { 0, { (1<<MACH_BASE) } } },
235d2201f2fSdrahn { OPENRISC_F_OP2, "f-op2", 0, 32, 29, 4, { 0, { (1<<MACH_BASE) } } },
236d2201f2fSdrahn { OPENRISC_F_OP3, "f-op3", 0, 32, 25, 2, { 0, { (1<<MACH_BASE) } } },
237d2201f2fSdrahn { OPENRISC_F_OP4, "f-op4", 0, 32, 23, 3, { 0, { (1<<MACH_BASE) } } },
238d2201f2fSdrahn { OPENRISC_F_OP5, "f-op5", 0, 32, 25, 5, { 0, { (1<<MACH_BASE) } } },
239d2201f2fSdrahn { OPENRISC_F_OP6, "f-op6", 0, 32, 7, 3, { 0, { (1<<MACH_BASE) } } },
240d2201f2fSdrahn { OPENRISC_F_OP7, "f-op7", 0, 32, 3, 4, { 0, { (1<<MACH_BASE) } } },
241d2201f2fSdrahn { OPENRISC_F_I16_1, "f-i16-1", 0, 32, 10, 11, { 0, { (1<<MACH_BASE) } } },
242d2201f2fSdrahn { OPENRISC_F_I16_2, "f-i16-2", 0, 32, 25, 5, { 0, { (1<<MACH_BASE) } } },
243d2201f2fSdrahn { OPENRISC_F_DISP26, "f-disp26", 0, 32, 25, 26, { 0|A(PCREL_ADDR), { (1<<MACH_BASE) } } },
244d2201f2fSdrahn { OPENRISC_F_ABS26, "f-abs26", 0, 32, 25, 26, { 0|A(ABS_ADDR), { (1<<MACH_BASE) } } },
245d2201f2fSdrahn { OPENRISC_F_I16NC, "f-i16nc", 0, 0, 0, 0,{ 0|A(SIGN_OPT)|A(VIRTUAL), { (1<<MACH_BASE) } } },
246d2201f2fSdrahn { OPENRISC_F_F_15_8, "f-f-15-8", 0, 32, 15, 8, { 0|A(RESERVED), { (1<<MACH_BASE) } } },
247d2201f2fSdrahn { OPENRISC_F_F_10_3, "f-f-10-3", 0, 32, 10, 3, { 0|A(RESERVED), { (1<<MACH_BASE) } } },
248d2201f2fSdrahn { OPENRISC_F_F_4_1, "f-f-4-1", 0, 32, 4, 1, { 0|A(RESERVED), { (1<<MACH_BASE) } } },
249d2201f2fSdrahn { OPENRISC_F_F_7_3, "f-f-7-3", 0, 32, 7, 3, { 0|A(RESERVED), { (1<<MACH_BASE) } } },
250d2201f2fSdrahn { OPENRISC_F_F_10_7, "f-f-10-7", 0, 32, 10, 7, { 0|A(RESERVED), { (1<<MACH_BASE) } } },
251d2201f2fSdrahn { OPENRISC_F_F_10_11, "f-f-10-11", 0, 32, 10, 11, { 0|A(RESERVED), { (1<<MACH_BASE) } } },
252d2201f2fSdrahn { 0, 0, 0, 0, 0, 0, {0, {0}} }
253d2201f2fSdrahn };
254d2201f2fSdrahn
255d2201f2fSdrahn #undef A
256d2201f2fSdrahn
257d2201f2fSdrahn
258d2201f2fSdrahn
259d2201f2fSdrahn /* multi ifield declarations */
260d2201f2fSdrahn
261d2201f2fSdrahn const CGEN_MAYBE_MULTI_IFLD OPENRISC_F_I16NC_MULTI_IFIELD [];
262d2201f2fSdrahn
263d2201f2fSdrahn
264d2201f2fSdrahn /* multi ifield definitions */
265d2201f2fSdrahn
266d2201f2fSdrahn const CGEN_MAYBE_MULTI_IFLD OPENRISC_F_I16NC_MULTI_IFIELD [] =
267d2201f2fSdrahn {
268d2201f2fSdrahn { 0, { (const PTR) &openrisc_cgen_ifld_table[OPENRISC_F_I16_1] } },
269d2201f2fSdrahn { 0, { (const PTR) &openrisc_cgen_ifld_table[OPENRISC_F_I16_2] } },
270d2201f2fSdrahn { 0, { (const PTR) 0 } }
271d2201f2fSdrahn };
272d2201f2fSdrahn
273d2201f2fSdrahn /* The operand table. */
274d2201f2fSdrahn
275d2201f2fSdrahn #if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
276d2201f2fSdrahn #define A(a) (1 << CGEN_OPERAND_##a)
277d2201f2fSdrahn #else
278d2201f2fSdrahn #define A(a) (1 << CGEN_OPERAND_/**/a)
279d2201f2fSdrahn #endif
280d2201f2fSdrahn #if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
281d2201f2fSdrahn #define OPERAND(op) OPENRISC_OPERAND_##op
282d2201f2fSdrahn #else
283d2201f2fSdrahn #define OPERAND(op) OPENRISC_OPERAND_/**/op
284d2201f2fSdrahn #endif
285d2201f2fSdrahn
286d2201f2fSdrahn const CGEN_OPERAND openrisc_cgen_operand_table[] =
287d2201f2fSdrahn {
288d2201f2fSdrahn /* pc: program counter */
289d2201f2fSdrahn { "pc", OPENRISC_OPERAND_PC, HW_H_PC, 0, 0,
290d2201f2fSdrahn { 0, { (const PTR) &openrisc_cgen_ifld_table[OPENRISC_F_NIL] } },
291d2201f2fSdrahn { 0|A(SEM_ONLY), { (1<<MACH_BASE) } } },
292d2201f2fSdrahn /* sr: special register */
293d2201f2fSdrahn { "sr", OPENRISC_OPERAND_SR, HW_H_SR, 0, 0,
294d2201f2fSdrahn { 0, { (const PTR) 0 } },
295d2201f2fSdrahn { 0|A(SEM_ONLY), { (1<<MACH_BASE) } } },
296d2201f2fSdrahn /* cbit: condition bit */
297d2201f2fSdrahn { "cbit", OPENRISC_OPERAND_CBIT, HW_H_CBIT, 0, 0,
298d2201f2fSdrahn { 0, { (const PTR) 0 } },
299d2201f2fSdrahn { 0|A(SEM_ONLY), { (1<<MACH_BASE) } } },
300d2201f2fSdrahn /* simm-16: 16 bit signed immediate */
301d2201f2fSdrahn { "simm-16", OPENRISC_OPERAND_SIMM_16, HW_H_SINT, 15, 16,
302d2201f2fSdrahn { 0, { (const PTR) &openrisc_cgen_ifld_table[OPENRISC_F_SIMM16] } },
303d2201f2fSdrahn { 0, { (1<<MACH_BASE) } } },
304d2201f2fSdrahn /* uimm-16: 16 bit unsigned immediate */
305d2201f2fSdrahn { "uimm-16", OPENRISC_OPERAND_UIMM_16, HW_H_UINT, 15, 16,
306d2201f2fSdrahn { 0, { (const PTR) &openrisc_cgen_ifld_table[OPENRISC_F_UIMM16] } },
307d2201f2fSdrahn { 0, { (1<<MACH_BASE) } } },
308d2201f2fSdrahn /* disp-26: pc-rel 26 bit */
309d2201f2fSdrahn { "disp-26", OPENRISC_OPERAND_DISP_26, HW_H_IADDR, 25, 26,
310d2201f2fSdrahn { 0, { (const PTR) &openrisc_cgen_ifld_table[OPENRISC_F_DISP26] } },
311d2201f2fSdrahn { 0|A(PCREL_ADDR), { (1<<MACH_BASE) } } },
312d2201f2fSdrahn /* abs-26: abs 26 bit */
313d2201f2fSdrahn { "abs-26", OPENRISC_OPERAND_ABS_26, HW_H_IADDR, 25, 26,
314d2201f2fSdrahn { 0, { (const PTR) &openrisc_cgen_ifld_table[OPENRISC_F_ABS26] } },
315d2201f2fSdrahn { 0|A(ABS_ADDR), { (1<<MACH_BASE) } } },
316d2201f2fSdrahn /* uimm-5: imm5 */
317d2201f2fSdrahn { "uimm-5", OPENRISC_OPERAND_UIMM_5, HW_H_UINT, 4, 5,
318d2201f2fSdrahn { 0, { (const PTR) &openrisc_cgen_ifld_table[OPENRISC_F_UIMM5] } },
319d2201f2fSdrahn { 0, { (1<<MACH_BASE) } } },
320d2201f2fSdrahn /* rD: destination register */
321d2201f2fSdrahn { "rD", OPENRISC_OPERAND_RD, HW_H_GR, 25, 5,
322d2201f2fSdrahn { 0, { (const PTR) &openrisc_cgen_ifld_table[OPENRISC_F_R1] } },
323d2201f2fSdrahn { 0, { (1<<MACH_BASE) } } },
324d2201f2fSdrahn /* rA: source register A */
325d2201f2fSdrahn { "rA", OPENRISC_OPERAND_RA, HW_H_GR, 20, 5,
326d2201f2fSdrahn { 0, { (const PTR) &openrisc_cgen_ifld_table[OPENRISC_F_R2] } },
327d2201f2fSdrahn { 0, { (1<<MACH_BASE) } } },
328d2201f2fSdrahn /* rB: source register B */
329d2201f2fSdrahn { "rB", OPENRISC_OPERAND_RB, HW_H_GR, 15, 5,
330d2201f2fSdrahn { 0, { (const PTR) &openrisc_cgen_ifld_table[OPENRISC_F_R3] } },
331d2201f2fSdrahn { 0, { (1<<MACH_BASE) } } },
332d2201f2fSdrahn /* op-f-23: f-op23 */
333d2201f2fSdrahn { "op-f-23", OPENRISC_OPERAND_OP_F_23, HW_H_UINT, 23, 3,
334d2201f2fSdrahn { 0, { (const PTR) &openrisc_cgen_ifld_table[OPENRISC_F_OP4] } },
335d2201f2fSdrahn { 0, { (1<<MACH_BASE) } } },
336d2201f2fSdrahn /* op-f-3: f-op3 */
337d2201f2fSdrahn { "op-f-3", OPENRISC_OPERAND_OP_F_3, HW_H_UINT, 25, 5,
338d2201f2fSdrahn { 0, { (const PTR) &openrisc_cgen_ifld_table[OPENRISC_F_OP5] } },
339d2201f2fSdrahn { 0, { (1<<MACH_BASE) } } },
340d2201f2fSdrahn /* hi16: high 16 bit immediate, sign optional */
341d2201f2fSdrahn { "hi16", OPENRISC_OPERAND_HI16, HW_H_HI16, 15, 16,
342d2201f2fSdrahn { 0, { (const PTR) &openrisc_cgen_ifld_table[OPENRISC_F_SIMM16] } },
343d2201f2fSdrahn { 0|A(SIGN_OPT), { (1<<MACH_BASE) } } },
344d2201f2fSdrahn /* lo16: low 16 bit immediate, sign optional */
345d2201f2fSdrahn { "lo16", OPENRISC_OPERAND_LO16, HW_H_LO16, 15, 16,
346d2201f2fSdrahn { 0, { (const PTR) &openrisc_cgen_ifld_table[OPENRISC_F_LO16] } },
347d2201f2fSdrahn { 0|A(SIGN_OPT), { (1<<MACH_BASE) } } },
348d2201f2fSdrahn /* ui16nc: 16 bit immediate, sign optional */
349d2201f2fSdrahn { "ui16nc", OPENRISC_OPERAND_UI16NC, HW_H_LO16, 10, 16,
350d2201f2fSdrahn { 2, { (const PTR) &OPENRISC_F_I16NC_MULTI_IFIELD[0] } },
351d2201f2fSdrahn { 0|A(SIGN_OPT)|A(VIRTUAL), { (1<<MACH_BASE) } } },
352d2201f2fSdrahn /* sentinel */
353d2201f2fSdrahn { 0, 0, 0, 0, 0,
354d2201f2fSdrahn { 0, { (const PTR) 0 } },
355d2201f2fSdrahn { 0, { 0 } } }
356d2201f2fSdrahn };
357d2201f2fSdrahn
358d2201f2fSdrahn #undef A
359d2201f2fSdrahn
360d2201f2fSdrahn
361d2201f2fSdrahn /* The instruction table. */
362d2201f2fSdrahn
363d2201f2fSdrahn #define OP(field) CGEN_SYNTAX_MAKE_FIELD (OPERAND (field))
364d2201f2fSdrahn #if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
365d2201f2fSdrahn #define A(a) (1 << CGEN_INSN_##a)
366d2201f2fSdrahn #else
367d2201f2fSdrahn #define A(a) (1 << CGEN_INSN_/**/a)
368d2201f2fSdrahn #endif
369d2201f2fSdrahn
370d2201f2fSdrahn static const CGEN_IBASE openrisc_cgen_insn_table[MAX_INSNS] =
371d2201f2fSdrahn {
372d2201f2fSdrahn /* Special null first entry.
373d2201f2fSdrahn A `num' value of zero is thus invalid.
374d2201f2fSdrahn Also, the special `invalid' insn resides here. */
375d2201f2fSdrahn { 0, 0, 0, 0, {0, {0}} },
376d2201f2fSdrahn /* l.j ${abs-26} */
377d2201f2fSdrahn {
378d2201f2fSdrahn OPENRISC_INSN_L_J, "l-j", "l.j", 32,
379d2201f2fSdrahn { 0|A(NOT_IN_DELAY_SLOT)|A(UNCOND_CTI)|A(DELAY_SLOT), { (1<<MACH_BASE) } }
380d2201f2fSdrahn },
381d2201f2fSdrahn /* l.jal ${abs-26} */
382d2201f2fSdrahn {
383d2201f2fSdrahn OPENRISC_INSN_L_JAL, "l-jal", "l.jal", 32,
384d2201f2fSdrahn { 0|A(NOT_IN_DELAY_SLOT)|A(UNCOND_CTI)|A(DELAY_SLOT), { (1<<MACH_BASE) } }
385d2201f2fSdrahn },
386d2201f2fSdrahn /* l.jr $rA */
387d2201f2fSdrahn {
388d2201f2fSdrahn OPENRISC_INSN_L_JR, "l-jr", "l.jr", 32,
389d2201f2fSdrahn { 0|A(NOT_IN_DELAY_SLOT)|A(UNCOND_CTI)|A(DELAY_SLOT), { (1<<MACH_BASE) } }
390d2201f2fSdrahn },
391d2201f2fSdrahn /* l.jalr $rA */
392d2201f2fSdrahn {
393d2201f2fSdrahn OPENRISC_INSN_L_JALR, "l-jalr", "l.jalr", 32,
394d2201f2fSdrahn { 0|A(NOT_IN_DELAY_SLOT)|A(UNCOND_CTI)|A(DELAY_SLOT), { (1<<MACH_BASE) } }
395d2201f2fSdrahn },
396d2201f2fSdrahn /* l.bal ${disp-26} */
397d2201f2fSdrahn {
398d2201f2fSdrahn OPENRISC_INSN_L_BAL, "l-bal", "l.bal", 32,
399d2201f2fSdrahn { 0|A(NOT_IN_DELAY_SLOT)|A(UNCOND_CTI)|A(DELAY_SLOT), { (1<<MACH_BASE) } }
400d2201f2fSdrahn },
401d2201f2fSdrahn /* l.bnf ${disp-26} */
402d2201f2fSdrahn {
403d2201f2fSdrahn OPENRISC_INSN_L_BNF, "l-bnf", "l.bnf", 32,
404d2201f2fSdrahn { 0|A(NOT_IN_DELAY_SLOT)|A(COND_CTI)|A(DELAY_SLOT), { (1<<MACH_BASE) } }
405d2201f2fSdrahn },
406d2201f2fSdrahn /* l.bf ${disp-26} */
407d2201f2fSdrahn {
408d2201f2fSdrahn OPENRISC_INSN_L_BF, "l-bf", "l.bf", 32,
409d2201f2fSdrahn { 0|A(NOT_IN_DELAY_SLOT)|A(COND_CTI)|A(DELAY_SLOT), { (1<<MACH_BASE) } }
410d2201f2fSdrahn },
411d2201f2fSdrahn /* l.brk ${uimm-16} */
412d2201f2fSdrahn {
413d2201f2fSdrahn OPENRISC_INSN_L_BRK, "l-brk", "l.brk", 32,
414d2201f2fSdrahn { 0|A(NOT_IN_DELAY_SLOT), { (1<<MACH_BASE) } }
415d2201f2fSdrahn },
416d2201f2fSdrahn /* l.rfe $rA */
417d2201f2fSdrahn {
418d2201f2fSdrahn OPENRISC_INSN_L_RFE, "l-rfe", "l.rfe", 32,
419d2201f2fSdrahn { 0|A(NOT_IN_DELAY_SLOT)|A(UNCOND_CTI)|A(DELAY_SLOT), { (1<<MACH_BASE) } }
420d2201f2fSdrahn },
421d2201f2fSdrahn /* l.sys ${uimm-16} */
422d2201f2fSdrahn {
423d2201f2fSdrahn OPENRISC_INSN_L_SYS, "l-sys", "l.sys", 32,
424d2201f2fSdrahn { 0|A(NOT_IN_DELAY_SLOT)|A(UNCOND_CTI)|A(DELAY_SLOT), { (1<<MACH_BASE) } }
425d2201f2fSdrahn },
426d2201f2fSdrahn /* l.nop */
427d2201f2fSdrahn {
428d2201f2fSdrahn OPENRISC_INSN_L_NOP, "l-nop", "l.nop", 32,
429d2201f2fSdrahn { 0, { (1<<MACH_BASE) } }
430d2201f2fSdrahn },
431d2201f2fSdrahn /* l.movhi $rD,$hi16 */
432d2201f2fSdrahn {
433d2201f2fSdrahn OPENRISC_INSN_L_MOVHI, "l-movhi", "l.movhi", 32,
434d2201f2fSdrahn { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
435d2201f2fSdrahn },
436d2201f2fSdrahn /* l.mfsr $rD,$rA */
437d2201f2fSdrahn {
438d2201f2fSdrahn OPENRISC_INSN_L_MFSR, "l-mfsr", "l.mfsr", 32,
439d2201f2fSdrahn { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
440d2201f2fSdrahn },
441d2201f2fSdrahn /* l.mtsr $rA,$rB */
442d2201f2fSdrahn {
443d2201f2fSdrahn OPENRISC_INSN_L_MTSR, "l-mtsr", "l.mtsr", 32,
444d2201f2fSdrahn { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
445d2201f2fSdrahn },
446d2201f2fSdrahn /* l.lw $rD,${simm-16}($rA) */
447d2201f2fSdrahn {
448d2201f2fSdrahn OPENRISC_INSN_L_LW, "l-lw", "l.lw", 32,
449d2201f2fSdrahn { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
450d2201f2fSdrahn },
451d2201f2fSdrahn /* l.lbz $rD,${simm-16}($rA) */
452d2201f2fSdrahn {
453d2201f2fSdrahn OPENRISC_INSN_L_LBZ, "l-lbz", "l.lbz", 32,
454d2201f2fSdrahn { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
455d2201f2fSdrahn },
456d2201f2fSdrahn /* l.lbs $rD,${simm-16}($rA) */
457d2201f2fSdrahn {
458d2201f2fSdrahn OPENRISC_INSN_L_LBS, "l-lbs", "l.lbs", 32,
459d2201f2fSdrahn { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
460d2201f2fSdrahn },
461d2201f2fSdrahn /* l.lhz $rD,${simm-16}($rA) */
462d2201f2fSdrahn {
463d2201f2fSdrahn OPENRISC_INSN_L_LHZ, "l-lhz", "l.lhz", 32,
464d2201f2fSdrahn { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
465d2201f2fSdrahn },
466d2201f2fSdrahn /* l.lhs $rD,${simm-16}($rA) */
467d2201f2fSdrahn {
468d2201f2fSdrahn OPENRISC_INSN_L_LHS, "l-lhs", "l.lhs", 32,
469d2201f2fSdrahn { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
470d2201f2fSdrahn },
471d2201f2fSdrahn /* l.sw ${ui16nc}($rA),$rB */
472d2201f2fSdrahn {
473d2201f2fSdrahn OPENRISC_INSN_L_SW, "l-sw", "l.sw", 32,
474d2201f2fSdrahn { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
475d2201f2fSdrahn },
476d2201f2fSdrahn /* l.sb ${ui16nc}($rA),$rB */
477d2201f2fSdrahn {
478d2201f2fSdrahn OPENRISC_INSN_L_SB, "l-sb", "l.sb", 32,
479d2201f2fSdrahn { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
480d2201f2fSdrahn },
481d2201f2fSdrahn /* l.sh ${ui16nc}($rA),$rB */
482d2201f2fSdrahn {
483d2201f2fSdrahn OPENRISC_INSN_L_SH, "l-sh", "l.sh", 32,
484d2201f2fSdrahn { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
485d2201f2fSdrahn },
486d2201f2fSdrahn /* l.sll $rD,$rA,$rB */
487d2201f2fSdrahn {
488d2201f2fSdrahn OPENRISC_INSN_L_SLL, "l-sll", "l.sll", 32,
489d2201f2fSdrahn { 0, { (1<<MACH_BASE) } }
490d2201f2fSdrahn },
491d2201f2fSdrahn /* l.slli $rD,$rA,${uimm-5} */
492d2201f2fSdrahn {
493d2201f2fSdrahn OPENRISC_INSN_L_SLLI, "l-slli", "l.slli", 32,
494d2201f2fSdrahn { 0, { (1<<MACH_BASE) } }
495d2201f2fSdrahn },
496d2201f2fSdrahn /* l.srl $rD,$rA,$rB */
497d2201f2fSdrahn {
498d2201f2fSdrahn OPENRISC_INSN_L_SRL, "l-srl", "l.srl", 32,
499d2201f2fSdrahn { 0, { (1<<MACH_BASE) } }
500d2201f2fSdrahn },
501d2201f2fSdrahn /* l.srli $rD,$rA,${uimm-5} */
502d2201f2fSdrahn {
503d2201f2fSdrahn OPENRISC_INSN_L_SRLI, "l-srli", "l.srli", 32,
504d2201f2fSdrahn { 0, { (1<<MACH_BASE) } }
505d2201f2fSdrahn },
506d2201f2fSdrahn /* l.sra $rD,$rA,$rB */
507d2201f2fSdrahn {
508d2201f2fSdrahn OPENRISC_INSN_L_SRA, "l-sra", "l.sra", 32,
509d2201f2fSdrahn { 0, { (1<<MACH_BASE) } }
510d2201f2fSdrahn },
511d2201f2fSdrahn /* l.srai $rD,$rA,${uimm-5} */
512d2201f2fSdrahn {
513d2201f2fSdrahn OPENRISC_INSN_L_SRAI, "l-srai", "l.srai", 32,
514d2201f2fSdrahn { 0, { (1<<MACH_BASE) } }
515d2201f2fSdrahn },
516d2201f2fSdrahn /* l.ror $rD,$rA,$rB */
517d2201f2fSdrahn {
518d2201f2fSdrahn OPENRISC_INSN_L_ROR, "l-ror", "l.ror", 32,
519d2201f2fSdrahn { 0, { (1<<MACH_BASE) } }
520d2201f2fSdrahn },
521d2201f2fSdrahn /* l.rori $rD,$rA,${uimm-5} */
522d2201f2fSdrahn {
523d2201f2fSdrahn OPENRISC_INSN_L_RORI, "l-rori", "l.rori", 32,
524d2201f2fSdrahn { 0, { (1<<MACH_BASE) } }
525d2201f2fSdrahn },
526d2201f2fSdrahn /* l.add $rD,$rA,$rB */
527d2201f2fSdrahn {
528d2201f2fSdrahn OPENRISC_INSN_L_ADD, "l-add", "l.add", 32,
529d2201f2fSdrahn { 0, { (1<<MACH_BASE) } }
530d2201f2fSdrahn },
531d2201f2fSdrahn /* l.addi $rD,$rA,$lo16 */
532d2201f2fSdrahn {
533d2201f2fSdrahn OPENRISC_INSN_L_ADDI, "l-addi", "l.addi", 32,
534d2201f2fSdrahn { 0, { (1<<MACH_BASE) } }
535d2201f2fSdrahn },
536d2201f2fSdrahn /* l.sub $rD,$rA,$rB */
537d2201f2fSdrahn {
538d2201f2fSdrahn OPENRISC_INSN_L_SUB, "l-sub", "l.sub", 32,
539d2201f2fSdrahn { 0, { (1<<MACH_BASE) } }
540d2201f2fSdrahn },
541d2201f2fSdrahn /* l.subi $rD,$rA,$lo16 */
542d2201f2fSdrahn {
543d2201f2fSdrahn OPENRISC_INSN_L_SUBI, "l-subi", "l.subi", 32,
544d2201f2fSdrahn { 0, { (1<<MACH_BASE) } }
545d2201f2fSdrahn },
546d2201f2fSdrahn /* l.and $rD,$rA,$rB */
547d2201f2fSdrahn {
548d2201f2fSdrahn OPENRISC_INSN_L_AND, "l-and", "l.and", 32,
549d2201f2fSdrahn { 0, { (1<<MACH_BASE) } }
550d2201f2fSdrahn },
551d2201f2fSdrahn /* l.andi $rD,$rA,$lo16 */
552d2201f2fSdrahn {
553d2201f2fSdrahn OPENRISC_INSN_L_ANDI, "l-andi", "l.andi", 32,
554d2201f2fSdrahn { 0, { (1<<MACH_BASE) } }
555d2201f2fSdrahn },
556d2201f2fSdrahn /* l.or $rD,$rA,$rB */
557d2201f2fSdrahn {
558d2201f2fSdrahn OPENRISC_INSN_L_OR, "l-or", "l.or", 32,
559d2201f2fSdrahn { 0, { (1<<MACH_BASE) } }
560d2201f2fSdrahn },
561d2201f2fSdrahn /* l.ori $rD,$rA,$lo16 */
562d2201f2fSdrahn {
563d2201f2fSdrahn OPENRISC_INSN_L_ORI, "l-ori", "l.ori", 32,
564d2201f2fSdrahn { 0, { (1<<MACH_BASE) } }
565d2201f2fSdrahn },
566d2201f2fSdrahn /* l.xor $rD,$rA,$rB */
567d2201f2fSdrahn {
568d2201f2fSdrahn OPENRISC_INSN_L_XOR, "l-xor", "l.xor", 32,
569d2201f2fSdrahn { 0, { (1<<MACH_BASE) } }
570d2201f2fSdrahn },
571d2201f2fSdrahn /* l.xori $rD,$rA,$lo16 */
572d2201f2fSdrahn {
573d2201f2fSdrahn OPENRISC_INSN_L_XORI, "l-xori", "l.xori", 32,
574d2201f2fSdrahn { 0, { (1<<MACH_BASE) } }
575d2201f2fSdrahn },
576d2201f2fSdrahn /* l.mul $rD,$rA,$rB */
577d2201f2fSdrahn {
578d2201f2fSdrahn OPENRISC_INSN_L_MUL, "l-mul", "l.mul", 32,
579d2201f2fSdrahn { 0, { (1<<MACH_BASE) } }
580d2201f2fSdrahn },
581d2201f2fSdrahn /* l.muli $rD,$rA,$lo16 */
582d2201f2fSdrahn {
583d2201f2fSdrahn OPENRISC_INSN_L_MULI, "l-muli", "l.muli", 32,
584d2201f2fSdrahn { 0, { (1<<MACH_BASE) } }
585d2201f2fSdrahn },
586d2201f2fSdrahn /* l.div $rD,$rA,$rB */
587d2201f2fSdrahn {
588d2201f2fSdrahn OPENRISC_INSN_L_DIV, "l-div", "l.div", 32,
589d2201f2fSdrahn { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
590d2201f2fSdrahn },
591d2201f2fSdrahn /* l.divu $rD,$rA,$rB */
592d2201f2fSdrahn {
593d2201f2fSdrahn OPENRISC_INSN_L_DIVU, "l-divu", "l.divu", 32,
594d2201f2fSdrahn { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
595d2201f2fSdrahn },
596d2201f2fSdrahn /* l.sfgts $rA,$rB */
597d2201f2fSdrahn {
598d2201f2fSdrahn OPENRISC_INSN_L_SFGTS, "l-sfgts", "l.sfgts", 32,
599d2201f2fSdrahn { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
600d2201f2fSdrahn },
601d2201f2fSdrahn /* l.sfgtu $rA,$rB */
602d2201f2fSdrahn {
603d2201f2fSdrahn OPENRISC_INSN_L_SFGTU, "l-sfgtu", "l.sfgtu", 32,
604d2201f2fSdrahn { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
605d2201f2fSdrahn },
606d2201f2fSdrahn /* l.sfges $rA,$rB */
607d2201f2fSdrahn {
608d2201f2fSdrahn OPENRISC_INSN_L_SFGES, "l-sfges", "l.sfges", 32,
609d2201f2fSdrahn { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
610d2201f2fSdrahn },
611d2201f2fSdrahn /* l.sfgeu $rA,$rB */
612d2201f2fSdrahn {
613d2201f2fSdrahn OPENRISC_INSN_L_SFGEU, "l-sfgeu", "l.sfgeu", 32,
614d2201f2fSdrahn { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
615d2201f2fSdrahn },
616d2201f2fSdrahn /* l.sflts $rA,$rB */
617d2201f2fSdrahn {
618d2201f2fSdrahn OPENRISC_INSN_L_SFLTS, "l-sflts", "l.sflts", 32,
619d2201f2fSdrahn { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
620d2201f2fSdrahn },
621d2201f2fSdrahn /* l.sfltu $rA,$rB */
622d2201f2fSdrahn {
623d2201f2fSdrahn OPENRISC_INSN_L_SFLTU, "l-sfltu", "l.sfltu", 32,
624d2201f2fSdrahn { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
625d2201f2fSdrahn },
626d2201f2fSdrahn /* l.sfles $rA,$rB */
627d2201f2fSdrahn {
628d2201f2fSdrahn OPENRISC_INSN_L_SFLES, "l-sfles", "l.sfles", 32,
629d2201f2fSdrahn { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
630d2201f2fSdrahn },
631d2201f2fSdrahn /* l.sfleu $rA,$rB */
632d2201f2fSdrahn {
633d2201f2fSdrahn OPENRISC_INSN_L_SFLEU, "l-sfleu", "l.sfleu", 32,
634d2201f2fSdrahn { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
635d2201f2fSdrahn },
636d2201f2fSdrahn /* l.sfgtsi $rA,${simm-16} */
637d2201f2fSdrahn {
638d2201f2fSdrahn OPENRISC_INSN_L_SFGTSI, "l-sfgtsi", "l.sfgtsi", 32,
639d2201f2fSdrahn { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
640d2201f2fSdrahn },
641d2201f2fSdrahn /* l.sfgtui $rA,${uimm-16} */
642d2201f2fSdrahn {
643d2201f2fSdrahn OPENRISC_INSN_L_SFGTUI, "l-sfgtui", "l.sfgtui", 32,
644d2201f2fSdrahn { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
645d2201f2fSdrahn },
646d2201f2fSdrahn /* l.sfgesi $rA,${simm-16} */
647d2201f2fSdrahn {
648d2201f2fSdrahn OPENRISC_INSN_L_SFGESI, "l-sfgesi", "l.sfgesi", 32,
649d2201f2fSdrahn { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
650d2201f2fSdrahn },
651d2201f2fSdrahn /* l.sfgeui $rA,${uimm-16} */
652d2201f2fSdrahn {
653d2201f2fSdrahn OPENRISC_INSN_L_SFGEUI, "l-sfgeui", "l.sfgeui", 32,
654d2201f2fSdrahn { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
655d2201f2fSdrahn },
656d2201f2fSdrahn /* l.sfltsi $rA,${simm-16} */
657d2201f2fSdrahn {
658d2201f2fSdrahn OPENRISC_INSN_L_SFLTSI, "l-sfltsi", "l.sfltsi", 32,
659d2201f2fSdrahn { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
660d2201f2fSdrahn },
661d2201f2fSdrahn /* l.sfltui $rA,${uimm-16} */
662d2201f2fSdrahn {
663d2201f2fSdrahn OPENRISC_INSN_L_SFLTUI, "l-sfltui", "l.sfltui", 32,
664d2201f2fSdrahn { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
665d2201f2fSdrahn },
666d2201f2fSdrahn /* l.sflesi $rA,${simm-16} */
667d2201f2fSdrahn {
668d2201f2fSdrahn OPENRISC_INSN_L_SFLESI, "l-sflesi", "l.sflesi", 32,
669d2201f2fSdrahn { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
670d2201f2fSdrahn },
671d2201f2fSdrahn /* l.sfleui $rA,${uimm-16} */
672d2201f2fSdrahn {
673d2201f2fSdrahn OPENRISC_INSN_L_SFLEUI, "l-sfleui", "l.sfleui", 32,
674d2201f2fSdrahn { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
675d2201f2fSdrahn },
676d2201f2fSdrahn /* l.sfeq $rA,$rB */
677d2201f2fSdrahn {
678d2201f2fSdrahn OPENRISC_INSN_L_SFEQ, "l-sfeq", "l.sfeq", 32,
679d2201f2fSdrahn { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
680d2201f2fSdrahn },
681d2201f2fSdrahn /* l.sfeqi $rA,${simm-16} */
682d2201f2fSdrahn {
683d2201f2fSdrahn OPENRISC_INSN_L_SFEQI, "l-sfeqi", "l.sfeqi", 32,
684d2201f2fSdrahn { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
685d2201f2fSdrahn },
686d2201f2fSdrahn /* l.sfne $rA,$rB */
687d2201f2fSdrahn {
688d2201f2fSdrahn OPENRISC_INSN_L_SFNE, "l-sfne", "l.sfne", 32,
689d2201f2fSdrahn { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
690d2201f2fSdrahn },
691d2201f2fSdrahn /* l.sfnei $rA,${simm-16} */
692d2201f2fSdrahn {
693d2201f2fSdrahn OPENRISC_INSN_L_SFNEI, "l-sfnei", "l.sfnei", 32,
694d2201f2fSdrahn { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
695d2201f2fSdrahn },
696d2201f2fSdrahn };
697d2201f2fSdrahn
698d2201f2fSdrahn #undef OP
699d2201f2fSdrahn #undef A
700d2201f2fSdrahn
701d2201f2fSdrahn /* Initialize anything needed to be done once, before any cpu_open call. */
702d2201f2fSdrahn static void init_tables PARAMS ((void));
703d2201f2fSdrahn
704d2201f2fSdrahn static void
init_tables()705d2201f2fSdrahn init_tables ()
706d2201f2fSdrahn {
707d2201f2fSdrahn }
708d2201f2fSdrahn
709d2201f2fSdrahn static const CGEN_MACH * lookup_mach_via_bfd_name
710d2201f2fSdrahn PARAMS ((const CGEN_MACH *, const char *));
711d2201f2fSdrahn static void build_hw_table PARAMS ((CGEN_CPU_TABLE *));
712d2201f2fSdrahn static void build_ifield_table PARAMS ((CGEN_CPU_TABLE *));
713d2201f2fSdrahn static void build_operand_table PARAMS ((CGEN_CPU_TABLE *));
714d2201f2fSdrahn static void build_insn_table PARAMS ((CGEN_CPU_TABLE *));
715d2201f2fSdrahn static void openrisc_cgen_rebuild_tables PARAMS ((CGEN_CPU_TABLE *));
716d2201f2fSdrahn
717d2201f2fSdrahn /* Subroutine of openrisc_cgen_cpu_open to look up a mach via its bfd name. */
718d2201f2fSdrahn
719d2201f2fSdrahn static const CGEN_MACH *
lookup_mach_via_bfd_name(table,name)720d2201f2fSdrahn lookup_mach_via_bfd_name (table, name)
721d2201f2fSdrahn const CGEN_MACH *table;
722d2201f2fSdrahn const char *name;
723d2201f2fSdrahn {
724d2201f2fSdrahn while (table->name)
725d2201f2fSdrahn {
726d2201f2fSdrahn if (strcmp (name, table->bfd_name) == 0)
727d2201f2fSdrahn return table;
728d2201f2fSdrahn ++table;
729d2201f2fSdrahn }
730d2201f2fSdrahn abort ();
731d2201f2fSdrahn }
732d2201f2fSdrahn
733d2201f2fSdrahn /* Subroutine of openrisc_cgen_cpu_open to build the hardware table. */
734d2201f2fSdrahn
735d2201f2fSdrahn static void
build_hw_table(cd)736d2201f2fSdrahn build_hw_table (cd)
737d2201f2fSdrahn CGEN_CPU_TABLE *cd;
738d2201f2fSdrahn {
739d2201f2fSdrahn int i;
740d2201f2fSdrahn int machs = cd->machs;
741d2201f2fSdrahn const CGEN_HW_ENTRY *init = & openrisc_cgen_hw_table[0];
742d2201f2fSdrahn /* MAX_HW is only an upper bound on the number of selected entries.
743d2201f2fSdrahn However each entry is indexed by it's enum so there can be holes in
744d2201f2fSdrahn the table. */
745d2201f2fSdrahn const CGEN_HW_ENTRY **selected =
746d2201f2fSdrahn (const CGEN_HW_ENTRY **) xmalloc (MAX_HW * sizeof (CGEN_HW_ENTRY *));
747d2201f2fSdrahn
748d2201f2fSdrahn cd->hw_table.init_entries = init;
749d2201f2fSdrahn cd->hw_table.entry_size = sizeof (CGEN_HW_ENTRY);
750d2201f2fSdrahn memset (selected, 0, MAX_HW * sizeof (CGEN_HW_ENTRY *));
751d2201f2fSdrahn /* ??? For now we just use machs to determine which ones we want. */
752d2201f2fSdrahn for (i = 0; init[i].name != NULL; ++i)
753d2201f2fSdrahn if (CGEN_HW_ATTR_VALUE (&init[i], CGEN_HW_MACH)
754d2201f2fSdrahn & machs)
755d2201f2fSdrahn selected[init[i].type] = &init[i];
756d2201f2fSdrahn cd->hw_table.entries = selected;
757d2201f2fSdrahn cd->hw_table.num_entries = MAX_HW;
758d2201f2fSdrahn }
759d2201f2fSdrahn
760d2201f2fSdrahn /* Subroutine of openrisc_cgen_cpu_open to build the hardware table. */
761d2201f2fSdrahn
762d2201f2fSdrahn static void
build_ifield_table(cd)763d2201f2fSdrahn build_ifield_table (cd)
764d2201f2fSdrahn CGEN_CPU_TABLE *cd;
765d2201f2fSdrahn {
766d2201f2fSdrahn cd->ifld_table = & openrisc_cgen_ifld_table[0];
767d2201f2fSdrahn }
768d2201f2fSdrahn
769d2201f2fSdrahn /* Subroutine of openrisc_cgen_cpu_open to build the hardware table. */
770d2201f2fSdrahn
771d2201f2fSdrahn static void
build_operand_table(cd)772d2201f2fSdrahn build_operand_table (cd)
773d2201f2fSdrahn CGEN_CPU_TABLE *cd;
774d2201f2fSdrahn {
775d2201f2fSdrahn int i;
776d2201f2fSdrahn int machs = cd->machs;
777d2201f2fSdrahn const CGEN_OPERAND *init = & openrisc_cgen_operand_table[0];
778d2201f2fSdrahn /* MAX_OPERANDS is only an upper bound on the number of selected entries.
779d2201f2fSdrahn However each entry is indexed by it's enum so there can be holes in
780d2201f2fSdrahn the table. */
781d2201f2fSdrahn const CGEN_OPERAND **selected =
782d2201f2fSdrahn (const CGEN_OPERAND **) xmalloc (MAX_OPERANDS * sizeof (CGEN_OPERAND *));
783d2201f2fSdrahn
784d2201f2fSdrahn cd->operand_table.init_entries = init;
785d2201f2fSdrahn cd->operand_table.entry_size = sizeof (CGEN_OPERAND);
786d2201f2fSdrahn memset (selected, 0, MAX_OPERANDS * sizeof (CGEN_OPERAND *));
787d2201f2fSdrahn /* ??? For now we just use mach to determine which ones we want. */
788d2201f2fSdrahn for (i = 0; init[i].name != NULL; ++i)
789d2201f2fSdrahn if (CGEN_OPERAND_ATTR_VALUE (&init[i], CGEN_OPERAND_MACH)
790d2201f2fSdrahn & machs)
791d2201f2fSdrahn selected[init[i].type] = &init[i];
792d2201f2fSdrahn cd->operand_table.entries = selected;
793d2201f2fSdrahn cd->operand_table.num_entries = MAX_OPERANDS;
794d2201f2fSdrahn }
795d2201f2fSdrahn
796d2201f2fSdrahn /* Subroutine of openrisc_cgen_cpu_open to build the hardware table.
797d2201f2fSdrahn ??? This could leave out insns not supported by the specified mach/isa,
798d2201f2fSdrahn but that would cause errors like "foo only supported by bar" to become
799d2201f2fSdrahn "unknown insn", so for now we include all insns and require the app to
800d2201f2fSdrahn do the checking later.
801d2201f2fSdrahn ??? On the other hand, parsing of such insns may require their hardware or
802d2201f2fSdrahn operand elements to be in the table [which they mightn't be]. */
803d2201f2fSdrahn
804d2201f2fSdrahn static void
build_insn_table(cd)805d2201f2fSdrahn build_insn_table (cd)
806d2201f2fSdrahn CGEN_CPU_TABLE *cd;
807d2201f2fSdrahn {
808d2201f2fSdrahn int i;
809d2201f2fSdrahn const CGEN_IBASE *ib = & openrisc_cgen_insn_table[0];
810d2201f2fSdrahn CGEN_INSN *insns = (CGEN_INSN *) xmalloc (MAX_INSNS * sizeof (CGEN_INSN));
811d2201f2fSdrahn
812d2201f2fSdrahn memset (insns, 0, MAX_INSNS * sizeof (CGEN_INSN));
813d2201f2fSdrahn for (i = 0; i < MAX_INSNS; ++i)
814d2201f2fSdrahn insns[i].base = &ib[i];
815d2201f2fSdrahn cd->insn_table.init_entries = insns;
816d2201f2fSdrahn cd->insn_table.entry_size = sizeof (CGEN_IBASE);
817d2201f2fSdrahn cd->insn_table.num_init_entries = MAX_INSNS;
818d2201f2fSdrahn }
819d2201f2fSdrahn
820d2201f2fSdrahn /* Subroutine of openrisc_cgen_cpu_open to rebuild the tables. */
821d2201f2fSdrahn
822d2201f2fSdrahn static void
openrisc_cgen_rebuild_tables(cd)823d2201f2fSdrahn openrisc_cgen_rebuild_tables (cd)
824d2201f2fSdrahn CGEN_CPU_TABLE *cd;
825d2201f2fSdrahn {
826d2201f2fSdrahn int i;
827d2201f2fSdrahn unsigned int isas = cd->isas;
828d2201f2fSdrahn unsigned int machs = cd->machs;
829d2201f2fSdrahn
830d2201f2fSdrahn cd->int_insn_p = CGEN_INT_INSN_P;
831d2201f2fSdrahn
832d2201f2fSdrahn /* Data derived from the isa spec. */
833d2201f2fSdrahn #define UNSET (CGEN_SIZE_UNKNOWN + 1)
834d2201f2fSdrahn cd->default_insn_bitsize = UNSET;
835d2201f2fSdrahn cd->base_insn_bitsize = UNSET;
836d2201f2fSdrahn cd->min_insn_bitsize = 65535; /* some ridiculously big number */
837d2201f2fSdrahn cd->max_insn_bitsize = 0;
838d2201f2fSdrahn for (i = 0; i < MAX_ISAS; ++i)
839d2201f2fSdrahn if (((1 << i) & isas) != 0)
840d2201f2fSdrahn {
841d2201f2fSdrahn const CGEN_ISA *isa = & openrisc_cgen_isa_table[i];
842d2201f2fSdrahn
843d2201f2fSdrahn /* Default insn sizes of all selected isas must be
844d2201f2fSdrahn equal or we set the result to 0, meaning "unknown". */
845d2201f2fSdrahn if (cd->default_insn_bitsize == UNSET)
846d2201f2fSdrahn cd->default_insn_bitsize = isa->default_insn_bitsize;
847d2201f2fSdrahn else if (isa->default_insn_bitsize == cd->default_insn_bitsize)
848d2201f2fSdrahn ; /* this is ok */
849d2201f2fSdrahn else
850d2201f2fSdrahn cd->default_insn_bitsize = CGEN_SIZE_UNKNOWN;
851d2201f2fSdrahn
852d2201f2fSdrahn /* Base insn sizes of all selected isas must be equal
853d2201f2fSdrahn or we set the result to 0, meaning "unknown". */
854d2201f2fSdrahn if (cd->base_insn_bitsize == UNSET)
855d2201f2fSdrahn cd->base_insn_bitsize = isa->base_insn_bitsize;
856d2201f2fSdrahn else if (isa->base_insn_bitsize == cd->base_insn_bitsize)
857d2201f2fSdrahn ; /* this is ok */
858d2201f2fSdrahn else
859d2201f2fSdrahn cd->base_insn_bitsize = CGEN_SIZE_UNKNOWN;
860d2201f2fSdrahn
861d2201f2fSdrahn /* Set min,max insn sizes. */
862d2201f2fSdrahn if (isa->min_insn_bitsize < cd->min_insn_bitsize)
863d2201f2fSdrahn cd->min_insn_bitsize = isa->min_insn_bitsize;
864d2201f2fSdrahn if (isa->max_insn_bitsize > cd->max_insn_bitsize)
865d2201f2fSdrahn cd->max_insn_bitsize = isa->max_insn_bitsize;
866d2201f2fSdrahn }
867d2201f2fSdrahn
868d2201f2fSdrahn /* Data derived from the mach spec. */
869d2201f2fSdrahn for (i = 0; i < MAX_MACHS; ++i)
870d2201f2fSdrahn if (((1 << i) & machs) != 0)
871d2201f2fSdrahn {
872d2201f2fSdrahn const CGEN_MACH *mach = & openrisc_cgen_mach_table[i];
873d2201f2fSdrahn
874d2201f2fSdrahn if (mach->insn_chunk_bitsize != 0)
875d2201f2fSdrahn {
876d2201f2fSdrahn if (cd->insn_chunk_bitsize != 0 && cd->insn_chunk_bitsize != mach->insn_chunk_bitsize)
877d2201f2fSdrahn {
878d2201f2fSdrahn fprintf (stderr, "openrisc_cgen_rebuild_tables: conflicting insn-chunk-bitsize values: `%d' vs. `%d'\n",
879d2201f2fSdrahn cd->insn_chunk_bitsize, mach->insn_chunk_bitsize);
880d2201f2fSdrahn abort ();
881d2201f2fSdrahn }
882d2201f2fSdrahn
883d2201f2fSdrahn cd->insn_chunk_bitsize = mach->insn_chunk_bitsize;
884d2201f2fSdrahn }
885d2201f2fSdrahn }
886d2201f2fSdrahn
887d2201f2fSdrahn /* Determine which hw elements are used by MACH. */
888d2201f2fSdrahn build_hw_table (cd);
889d2201f2fSdrahn
890d2201f2fSdrahn /* Build the ifield table. */
891d2201f2fSdrahn build_ifield_table (cd);
892d2201f2fSdrahn
893d2201f2fSdrahn /* Determine which operands are used by MACH/ISA. */
894d2201f2fSdrahn build_operand_table (cd);
895d2201f2fSdrahn
896d2201f2fSdrahn /* Build the instruction table. */
897d2201f2fSdrahn build_insn_table (cd);
898d2201f2fSdrahn }
899d2201f2fSdrahn
900d2201f2fSdrahn /* Initialize a cpu table and return a descriptor.
901d2201f2fSdrahn It's much like opening a file, and must be the first function called.
902d2201f2fSdrahn The arguments are a set of (type/value) pairs, terminated with
903d2201f2fSdrahn CGEN_CPU_OPEN_END.
904d2201f2fSdrahn
905d2201f2fSdrahn Currently supported values:
906d2201f2fSdrahn CGEN_CPU_OPEN_ISAS: bitmap of values in enum isa_attr
907d2201f2fSdrahn CGEN_CPU_OPEN_MACHS: bitmap of values in enum mach_attr
908d2201f2fSdrahn CGEN_CPU_OPEN_BFDMACH: specify 1 mach using bfd name
909d2201f2fSdrahn CGEN_CPU_OPEN_ENDIAN: specify endian choice
910d2201f2fSdrahn CGEN_CPU_OPEN_END: terminates arguments
911d2201f2fSdrahn
912d2201f2fSdrahn ??? Simultaneous multiple isas might not make sense, but it's not (yet)
913d2201f2fSdrahn precluded.
914d2201f2fSdrahn
915d2201f2fSdrahn ??? We only support ISO C stdargs here, not K&R.
916d2201f2fSdrahn Laziness, plus experiment to see if anything requires K&R - eventually
917d2201f2fSdrahn K&R will no longer be supported - e.g. GDB is currently trying this. */
918d2201f2fSdrahn
919d2201f2fSdrahn CGEN_CPU_DESC
openrisc_cgen_cpu_open(enum cgen_cpu_open_arg arg_type,...)920d2201f2fSdrahn openrisc_cgen_cpu_open (enum cgen_cpu_open_arg arg_type, ...)
921d2201f2fSdrahn {
922d2201f2fSdrahn CGEN_CPU_TABLE *cd = (CGEN_CPU_TABLE *) xmalloc (sizeof (CGEN_CPU_TABLE));
923d2201f2fSdrahn static int init_p;
924d2201f2fSdrahn unsigned int isas = 0; /* 0 = "unspecified" */
925d2201f2fSdrahn unsigned int machs = 0; /* 0 = "unspecified" */
926d2201f2fSdrahn enum cgen_endian endian = CGEN_ENDIAN_UNKNOWN;
927d2201f2fSdrahn va_list ap;
928d2201f2fSdrahn
929d2201f2fSdrahn if (! init_p)
930d2201f2fSdrahn {
931d2201f2fSdrahn init_tables ();
932d2201f2fSdrahn init_p = 1;
933d2201f2fSdrahn }
934d2201f2fSdrahn
935d2201f2fSdrahn memset (cd, 0, sizeof (*cd));
936d2201f2fSdrahn
937d2201f2fSdrahn va_start (ap, arg_type);
938d2201f2fSdrahn while (arg_type != CGEN_CPU_OPEN_END)
939d2201f2fSdrahn {
940d2201f2fSdrahn switch (arg_type)
941d2201f2fSdrahn {
942d2201f2fSdrahn case CGEN_CPU_OPEN_ISAS :
943d2201f2fSdrahn isas = va_arg (ap, unsigned int);
944d2201f2fSdrahn break;
945d2201f2fSdrahn case CGEN_CPU_OPEN_MACHS :
946d2201f2fSdrahn machs = va_arg (ap, unsigned int);
947d2201f2fSdrahn break;
948d2201f2fSdrahn case CGEN_CPU_OPEN_BFDMACH :
949d2201f2fSdrahn {
950d2201f2fSdrahn const char *name = va_arg (ap, const char *);
951d2201f2fSdrahn const CGEN_MACH *mach =
952d2201f2fSdrahn lookup_mach_via_bfd_name (openrisc_cgen_mach_table, name);
953d2201f2fSdrahn
954d2201f2fSdrahn machs |= 1 << mach->num;
955d2201f2fSdrahn break;
956d2201f2fSdrahn }
957d2201f2fSdrahn case CGEN_CPU_OPEN_ENDIAN :
958d2201f2fSdrahn endian = va_arg (ap, enum cgen_endian);
959d2201f2fSdrahn break;
960d2201f2fSdrahn default :
961d2201f2fSdrahn fprintf (stderr, "openrisc_cgen_cpu_open: unsupported argument `%d'\n",
962d2201f2fSdrahn arg_type);
963d2201f2fSdrahn abort (); /* ??? return NULL? */
964d2201f2fSdrahn }
965d2201f2fSdrahn arg_type = va_arg (ap, enum cgen_cpu_open_arg);
966d2201f2fSdrahn }
967d2201f2fSdrahn va_end (ap);
968d2201f2fSdrahn
969d2201f2fSdrahn /* mach unspecified means "all" */
970d2201f2fSdrahn if (machs == 0)
971d2201f2fSdrahn machs = (1 << MAX_MACHS) - 1;
972d2201f2fSdrahn /* base mach is always selected */
973d2201f2fSdrahn machs |= 1;
974d2201f2fSdrahn /* isa unspecified means "all" */
975d2201f2fSdrahn if (isas == 0)
976d2201f2fSdrahn isas = (1 << MAX_ISAS) - 1;
977d2201f2fSdrahn if (endian == CGEN_ENDIAN_UNKNOWN)
978d2201f2fSdrahn {
979d2201f2fSdrahn /* ??? If target has only one, could have a default. */
980d2201f2fSdrahn fprintf (stderr, "openrisc_cgen_cpu_open: no endianness specified\n");
981d2201f2fSdrahn abort ();
982d2201f2fSdrahn }
983d2201f2fSdrahn
984d2201f2fSdrahn cd->isas = isas;
985d2201f2fSdrahn cd->machs = machs;
986d2201f2fSdrahn cd->endian = endian;
987d2201f2fSdrahn /* FIXME: for the sparc case we can determine insn-endianness statically.
988d2201f2fSdrahn The worry here is where both data and insn endian can be independently
989d2201f2fSdrahn chosen, in which case this function will need another argument.
990d2201f2fSdrahn Actually, will want to allow for more arguments in the future anyway. */
991d2201f2fSdrahn cd->insn_endian = endian;
992d2201f2fSdrahn
993d2201f2fSdrahn /* Table (re)builder. */
994d2201f2fSdrahn cd->rebuild_tables = openrisc_cgen_rebuild_tables;
995d2201f2fSdrahn openrisc_cgen_rebuild_tables (cd);
996d2201f2fSdrahn
997d2201f2fSdrahn /* Default to not allowing signed overflow. */
998d2201f2fSdrahn cd->signed_overflow_ok_p = 0;
999d2201f2fSdrahn
1000d2201f2fSdrahn return (CGEN_CPU_DESC) cd;
1001d2201f2fSdrahn }
1002d2201f2fSdrahn
1003d2201f2fSdrahn /* Cover fn to openrisc_cgen_cpu_open to handle the simple case of 1 isa, 1 mach.
1004d2201f2fSdrahn MACH_NAME is the bfd name of the mach. */
1005d2201f2fSdrahn
1006d2201f2fSdrahn CGEN_CPU_DESC
openrisc_cgen_cpu_open_1(mach_name,endian)1007d2201f2fSdrahn openrisc_cgen_cpu_open_1 (mach_name, endian)
1008d2201f2fSdrahn const char *mach_name;
1009d2201f2fSdrahn enum cgen_endian endian;
1010d2201f2fSdrahn {
1011d2201f2fSdrahn return openrisc_cgen_cpu_open (CGEN_CPU_OPEN_BFDMACH, mach_name,
1012d2201f2fSdrahn CGEN_CPU_OPEN_ENDIAN, endian,
1013d2201f2fSdrahn CGEN_CPU_OPEN_END);
1014d2201f2fSdrahn }
1015d2201f2fSdrahn
1016d2201f2fSdrahn /* Close a cpu table.
1017d2201f2fSdrahn ??? This can live in a machine independent file, but there's currently
1018d2201f2fSdrahn no place to put this file (there's no libcgen). libopcodes is the wrong
1019d2201f2fSdrahn place as some simulator ports use this but they don't use libopcodes. */
1020d2201f2fSdrahn
1021d2201f2fSdrahn void
openrisc_cgen_cpu_close(cd)1022d2201f2fSdrahn openrisc_cgen_cpu_close (cd)
1023d2201f2fSdrahn CGEN_CPU_DESC cd;
1024d2201f2fSdrahn {
1025d2201f2fSdrahn unsigned int i;
1026d2201f2fSdrahn const CGEN_INSN *insns;
1027d2201f2fSdrahn
1028d2201f2fSdrahn if (cd->macro_insn_table.init_entries)
1029d2201f2fSdrahn {
1030d2201f2fSdrahn insns = cd->macro_insn_table.init_entries;
1031d2201f2fSdrahn for (i = 0; i < cd->macro_insn_table.num_init_entries; ++i, ++insns)
1032d2201f2fSdrahn {
1033d2201f2fSdrahn if (CGEN_INSN_RX ((insns)))
1034d2201f2fSdrahn regfree (CGEN_INSN_RX (insns));
1035d2201f2fSdrahn }
1036d2201f2fSdrahn }
1037d2201f2fSdrahn
1038d2201f2fSdrahn if (cd->insn_table.init_entries)
1039d2201f2fSdrahn {
1040d2201f2fSdrahn insns = cd->insn_table.init_entries;
1041d2201f2fSdrahn for (i = 0; i < cd->insn_table.num_init_entries; ++i, ++insns)
1042d2201f2fSdrahn {
1043d2201f2fSdrahn if (CGEN_INSN_RX (insns))
1044d2201f2fSdrahn regfree (CGEN_INSN_RX (insns));
1045d2201f2fSdrahn }
1046d2201f2fSdrahn }
1047d2201f2fSdrahn
1048d2201f2fSdrahn
1049d2201f2fSdrahn
1050d2201f2fSdrahn if (cd->macro_insn_table.init_entries)
1051d2201f2fSdrahn free ((CGEN_INSN *) cd->macro_insn_table.init_entries);
1052d2201f2fSdrahn
1053d2201f2fSdrahn if (cd->insn_table.init_entries)
1054d2201f2fSdrahn free ((CGEN_INSN *) cd->insn_table.init_entries);
1055d2201f2fSdrahn
1056d2201f2fSdrahn if (cd->hw_table.entries)
1057d2201f2fSdrahn free ((CGEN_HW_ENTRY *) cd->hw_table.entries);
1058d2201f2fSdrahn
1059d2201f2fSdrahn if (cd->operand_table.entries)
1060d2201f2fSdrahn free ((CGEN_HW_ENTRY *) cd->operand_table.entries);
1061d2201f2fSdrahn
1062d2201f2fSdrahn free (cd);
1063d2201f2fSdrahn }
1064d2201f2fSdrahn
1065