merge from gcc
[deliverable/binutils-gdb.git] / include / xtensa-isa-internal.h
CommitLineData
e0001a05 1/* Internal definitions for configurable Xtensa ISA support.
f075ee0c 2 Copyright 2003, 2004, 2005 Free Software Foundation, Inc.
e0001a05
NC
3
4 This file is part of BFD, the Binary File Descriptor library.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
e172dbf8 18 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
e0001a05 19
43cd72b9
BW
20#ifndef XTENSA_ISA_INTERNAL_H
21#define XTENSA_ISA_INTERNAL_H
e0001a05 22
43cd72b9 23/* Flags. */
e0001a05 24
43cd72b9
BW
25#define XTENSA_OPERAND_IS_REGISTER 0x00000001
26#define XTENSA_OPERAND_IS_PCRELATIVE 0x00000002
27#define XTENSA_OPERAND_IS_INVISIBLE 0x00000004
28#define XTENSA_OPERAND_IS_UNKNOWN 0x00000008
e0001a05 29
43cd72b9
BW
30#define XTENSA_OPCODE_IS_BRANCH 0x00000001
31#define XTENSA_OPCODE_IS_JUMP 0x00000002
32#define XTENSA_OPCODE_IS_LOOP 0x00000004
33#define XTENSA_OPCODE_IS_CALL 0x00000008
e0001a05 34
43cd72b9 35#define XTENSA_STATE_IS_EXPORTED 0x00000001
e0001a05 36
43cd72b9 37#define XTENSA_INTERFACE_HAS_SIDE_EFFECT 0x00000001
e0001a05 38
43cd72b9
BW
39/* Function pointer typedefs */
40typedef void (*xtensa_format_encode_fn) (xtensa_insnbuf);
41typedef void (*xtensa_get_slot_fn) (const xtensa_insnbuf, xtensa_insnbuf);
42typedef void (*xtensa_set_slot_fn) (xtensa_insnbuf, const xtensa_insnbuf);
43typedef int (*xtensa_opcode_decode_fn) (const xtensa_insnbuf);
44typedef uint32 (*xtensa_get_field_fn) (const xtensa_insnbuf);
45typedef void (*xtensa_set_field_fn) (xtensa_insnbuf, uint32);
46typedef int (*xtensa_immed_decode_fn) (uint32 *);
47typedef int (*xtensa_immed_encode_fn) (uint32 *);
48typedef int (*xtensa_do_reloc_fn) (uint32 *, uint32);
49typedef int (*xtensa_undo_reloc_fn) (uint32 *, uint32);
50typedef void (*xtensa_opcode_encode_fn) (xtensa_insnbuf);
51typedef int (*xtensa_format_decode_fn) (const xtensa_insnbuf);
f075ee0c 52typedef int (*xtensa_length_decode_fn) (const unsigned char *);
43cd72b9
BW
53
54typedef struct xtensa_format_internal_struct
55{
56 const char *name; /* Instruction format name. */
57 int length; /* Instruction length in bytes. */
58 xtensa_format_encode_fn encode_fn;
59 int num_slots;
60 int *slot_id; /* Array[num_slots] of slot IDs. */
61} xtensa_format_internal;
62
63typedef struct xtensa_slot_internal_struct
64{
65 const char *name; /* Not necessarily unique. */
66 const char *format;
67 int position;
68 xtensa_get_slot_fn get_fn;
69 xtensa_set_slot_fn set_fn;
70 xtensa_get_field_fn *get_field_fns; /* Array[field_id]. */
71 xtensa_set_field_fn *set_field_fns; /* Array[field_id]. */
72 xtensa_opcode_decode_fn opcode_decode_fn;
73 const char *nop_name;
74} xtensa_slot_internal;
e0001a05
NC
75
76typedef struct xtensa_operand_internal_struct
77{
43cd72b9
BW
78 const char *name;
79 int field_id;
80 xtensa_regfile regfile; /* Register file. */
81 int num_regs; /* Usually 1; 2 for reg pairs, etc. */
82 uint32 flags; /* See XTENSA_OPERAND_* flags. */
e0001a05
NC
83 xtensa_immed_encode_fn encode; /* Encode the operand value. */
84 xtensa_immed_decode_fn decode; /* Decode the value from the field. */
43cd72b9 85 xtensa_do_reloc_fn do_reloc; /* Perform a PC-relative reloc. */
e0001a05
NC
86 xtensa_undo_reloc_fn undo_reloc; /* Undo a PC-relative relocation. */
87} xtensa_operand_internal;
88
43cd72b9
BW
89typedef struct xtensa_arg_internal_struct
90{
91 union {
92 int operand_id; /* For normal operands. */
93 xtensa_state state; /* For stateOperands. */
94 } u;
95 char inout; /* Direction: 'i', 'o', or 'm'. */
96} xtensa_arg_internal;
e0001a05
NC
97
98typedef struct xtensa_iclass_internal_struct
99{
100 int num_operands; /* Size of "operands" array. */
43cd72b9 101 xtensa_arg_internal *operands; /* Array[num_operands]. */
e0001a05 102
43cd72b9
BW
103 int num_stateOperands; /* Size of "stateOperands" array. */
104 xtensa_arg_internal *stateOperands; /* Array[num_stateOperands]. */
105
106 int num_interfaceOperands; /* Size of "interfaceOperands". */
107 xtensa_interface *interfaceOperands; /* Array[num_interfaceOperands]. */
108} xtensa_iclass_internal;
e0001a05
NC
109
110typedef struct xtensa_opcode_internal_struct
111{
112 const char *name; /* Opcode mnemonic. */
43cd72b9
BW
113 int iclass_id; /* Iclass for this opcode. */
114 uint32 flags; /* See XTENSA_OPCODE_* flags. */
115 xtensa_opcode_encode_fn *encode_fns; /* Array[slot_id]. */
116 int num_funcUnit_uses; /* Number of funcUnit_use entries. */
117 xtensa_funcUnit_use *funcUnit_uses; /* Array[num_funcUnit_uses]. */
e0001a05
NC
118} xtensa_opcode_internal;
119
43cd72b9
BW
120typedef struct xtensa_regfile_internal_struct
121{
122 const char *name; /* Full name of the regfile. */
123 const char *shortname; /* Abbreviated name. */
124 xtensa_regfile parent; /* View parent (or identity). */
125 int num_bits; /* Width of the registers. */
126 int num_entries; /* Number of registers. */
127} xtensa_regfile_internal;
128
129typedef struct xtensa_interface_internal_struct
130{
131 const char *name; /* Interface name. */
132 int num_bits; /* Width of the interface. */
133 uint32 flags; /* See XTENSA_INTERFACE_* flags. */
a1ace8d8 134 int class_id; /* Class of related interfaces. */
43cd72b9
BW
135 char inout; /* "i" or "o". */
136} xtensa_interface_internal;
137
138typedef struct xtensa_funcUnit_internal_struct
139{
140 const char *name; /* Functional unit name. */
141 int num_copies; /* Number of instances. */
142} xtensa_funcUnit_internal;
e0001a05 143
43cd72b9 144typedef struct xtensa_state_internal_struct
e0001a05 145{
43cd72b9
BW
146 const char *name; /* State name. */
147 int num_bits; /* Number of state bits. */
148 uint32 flags; /* See XTENSA_STATE_* flags. */
149} xtensa_state_internal;
e0001a05 150
43cd72b9
BW
151typedef struct xtensa_sysreg_internal_struct
152{
153 const char *name; /* Register name. */
154 int number; /* Register number. */
155 int is_user; /* Non-zero if a "user register". */
156} xtensa_sysreg_internal;
157
158typedef struct xtensa_lookup_entry_struct
159{
160 const char *key;
161 union
162 {
163 xtensa_opcode opcode; /* Internal opcode number. */
164 xtensa_sysreg sysreg; /* Internal sysreg number. */
165 xtensa_state state; /* Internal state number. */
166 xtensa_interface intf; /* Internal interface number. */
167 xtensa_funcUnit fun; /* Internal funcUnit number. */
168 } u;
169} xtensa_lookup_entry;
e0001a05
NC
170
171typedef struct xtensa_isa_internal_struct
172{
173 int is_big_endian; /* Endianness. */
174 int insn_size; /* Maximum length in bytes. */
175 int insnbuf_size; /* Number of insnbuf_words. */
e0001a05 176
43cd72b9
BW
177 int num_formats;
178 xtensa_format_internal *formats;
179 xtensa_format_decode_fn format_decode_fn;
180 xtensa_length_decode_fn length_decode_fn;
e0001a05 181
43cd72b9
BW
182 int num_slots;
183 xtensa_slot_internal *slots;
184
185 int num_fields;
186
187 int num_operands;
188 xtensa_operand_internal *operands;
189
190 int num_iclasses;
191 xtensa_iclass_internal *iclasses;
192
193 int num_opcodes;
194 xtensa_opcode_internal *opcodes;
195 xtensa_lookup_entry *opname_lookup_table;
196
197 int num_regfiles;
198 xtensa_regfile_internal *regfiles;
199
200 int num_states;
201 xtensa_state_internal *states;
202 xtensa_lookup_entry *state_lookup_table;
203
204 int num_sysregs;
205 xtensa_sysreg_internal *sysregs;
206 xtensa_lookup_entry *sysreg_lookup_table;
207
208 /* The current Xtensa ISA only supports 256 of each kind of sysreg so
209 we can get away with implementing lookups with tables indexed by
210 the register numbers. If we ever allow larger sysreg numbers, this
211 may have to be reimplemented. The first entry in the following
212 arrays corresponds to "special" registers and the second to "user"
213 registers. */
214 int max_sysreg_num[2];
215 xtensa_sysreg *sysreg_table[2];
216
217 int num_interfaces;
218 xtensa_interface_internal *interfaces;
219 xtensa_lookup_entry *interface_lookup_table;
220
221 int num_funcUnits;
222 xtensa_funcUnit_internal *funcUnits;
223 xtensa_lookup_entry *funcUnit_lookup_table;
224
225} xtensa_isa_internal;
226
227extern int xtensa_isa_name_compare (const void *, const void *);
e0001a05 228
43cd72b9
BW
229extern xtensa_isa_status xtisa_errno;
230extern char xtisa_error_msg[];
e0001a05 231
43cd72b9 232#endif /* !XTENSA_ISA_INTERNAL_H */
This page took 0.244776 seconds and 4 git commands to generate.