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