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