1 |
24 |
jeremybenn |
/* Internal definitions for configurable Xtensa ISA support.
|
2 |
|
|
Copyright 2003, 2004, 2005 Free Software Foundation, Inc.
|
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
|
18 |
|
|
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
|
19 |
|
|
|
20 |
|
|
#ifndef XTENSA_ISA_INTERNAL_H
|
21 |
|
|
#define XTENSA_ISA_INTERNAL_H
|
22 |
|
|
|
23 |
|
|
/* Flags. */
|
24 |
|
|
|
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
|
29 |
|
|
|
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
|
34 |
|
|
|
35 |
|
|
#define XTENSA_STATE_IS_EXPORTED 0x00000001
|
36 |
|
|
|
37 |
|
|
#define XTENSA_INTERFACE_HAS_SIDE_EFFECT 0x00000001
|
38 |
|
|
|
39 |
|
|
/* Function pointer typedefs */
|
40 |
|
|
typedef void (*xtensa_format_encode_fn) (xtensa_insnbuf);
|
41 |
|
|
typedef void (*xtensa_get_slot_fn) (const xtensa_insnbuf, xtensa_insnbuf);
|
42 |
|
|
typedef void (*xtensa_set_slot_fn) (xtensa_insnbuf, const xtensa_insnbuf);
|
43 |
|
|
typedef int (*xtensa_opcode_decode_fn) (const xtensa_insnbuf);
|
44 |
|
|
typedef uint32 (*xtensa_get_field_fn) (const xtensa_insnbuf);
|
45 |
|
|
typedef void (*xtensa_set_field_fn) (xtensa_insnbuf, uint32);
|
46 |
|
|
typedef int (*xtensa_immed_decode_fn) (uint32 *);
|
47 |
|
|
typedef int (*xtensa_immed_encode_fn) (uint32 *);
|
48 |
|
|
typedef int (*xtensa_do_reloc_fn) (uint32 *, uint32);
|
49 |
|
|
typedef int (*xtensa_undo_reloc_fn) (uint32 *, uint32);
|
50 |
|
|
typedef void (*xtensa_opcode_encode_fn) (xtensa_insnbuf);
|
51 |
|
|
typedef int (*xtensa_format_decode_fn) (const xtensa_insnbuf);
|
52 |
|
|
typedef int (*xtensa_length_decode_fn) (const unsigned char *);
|
53 |
|
|
|
54 |
|
|
typedef 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 |
|
|
|
63 |
|
|
typedef 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;
|
75 |
|
|
|
76 |
|
|
typedef struct xtensa_operand_internal_struct
|
77 |
|
|
{
|
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. */
|
83 |
|
|
xtensa_immed_encode_fn encode; /* Encode the operand value. */
|
84 |
|
|
xtensa_immed_decode_fn decode; /* Decode the value from the field. */
|
85 |
|
|
xtensa_do_reloc_fn do_reloc; /* Perform a PC-relative reloc. */
|
86 |
|
|
xtensa_undo_reloc_fn undo_reloc; /* Undo a PC-relative relocation. */
|
87 |
|
|
} xtensa_operand_internal;
|
88 |
|
|
|
89 |
|
|
typedef 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;
|
97 |
|
|
|
98 |
|
|
typedef struct xtensa_iclass_internal_struct
|
99 |
|
|
{
|
100 |
|
|
int num_operands; /* Size of "operands" array. */
|
101 |
|
|
xtensa_arg_internal *operands; /* Array[num_operands]. */
|
102 |
|
|
|
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;
|
109 |
|
|
|
110 |
|
|
typedef struct xtensa_opcode_internal_struct
|
111 |
|
|
{
|
112 |
|
|
const char *name; /* Opcode mnemonic. */
|
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]. */
|
118 |
|
|
} xtensa_opcode_internal;
|
119 |
|
|
|
120 |
|
|
typedef 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 |
|
|
|
129 |
|
|
typedef 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. */
|
134 |
|
|
int class_id; /* Class of related interfaces. */
|
135 |
|
|
char inout; /* "i" or "o". */
|
136 |
|
|
} xtensa_interface_internal;
|
137 |
|
|
|
138 |
|
|
typedef struct xtensa_funcUnit_internal_struct
|
139 |
|
|
{
|
140 |
|
|
const char *name; /* Functional unit name. */
|
141 |
|
|
int num_copies; /* Number of instances. */
|
142 |
|
|
} xtensa_funcUnit_internal;
|
143 |
|
|
|
144 |
|
|
typedef struct xtensa_state_internal_struct
|
145 |
|
|
{
|
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;
|
150 |
|
|
|
151 |
|
|
typedef 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 |
|
|
|
158 |
|
|
typedef 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;
|
170 |
|
|
|
171 |
|
|
typedef 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. */
|
176 |
|
|
|
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;
|
181 |
|
|
|
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 |
|
|
|
227 |
|
|
extern int xtensa_isa_name_compare (const void *, const void *);
|
228 |
|
|
|
229 |
|
|
extern xtensa_isa_status xtisa_errno;
|
230 |
|
|
extern char xtisa_error_msg[];
|
231 |
|
|
|
232 |
|
|
#endif /* !XTENSA_ISA_INTERNAL_H */
|