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