Back to index

cell-binutils  2.17cvs20070401
xtensa-isa-internal.h
Go to the documentation of this file.
00001 /* Internal definitions for configurable Xtensa ISA support.
00002    Copyright 2003, 2004, 2005 Free Software Foundation, Inc.
00003 
00004    This file is part of BFD, the Binary File Descriptor library.
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 2 of the License, or
00009    (at your option) any later version.
00010 
00011    This program is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014    GNU General Public License for more details.
00015 
00016    You should have received a copy of the GNU General Public License
00017    along with this program; if not, write to the Free Software
00018    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
00019 
00020 #ifndef XTENSA_ISA_INTERNAL_H
00021 #define XTENSA_ISA_INTERNAL_H
00022 
00023 /* Flags.  */
00024 
00025 #define XTENSA_OPERAND_IS_REGISTER 0x00000001
00026 #define XTENSA_OPERAND_IS_PCRELATIVE      0x00000002
00027 #define XTENSA_OPERAND_IS_INVISIBLE       0x00000004
00028 #define XTENSA_OPERAND_IS_UNKNOWN  0x00000008
00029 
00030 #define XTENSA_OPCODE_IS_BRANCH           0x00000001
00031 #define XTENSA_OPCODE_IS_JUMP             0x00000002
00032 #define XTENSA_OPCODE_IS_LOOP             0x00000004
00033 #define XTENSA_OPCODE_IS_CALL             0x00000008
00034 
00035 #define XTENSA_STATE_IS_EXPORTED   0x00000001
00036 
00037 #define XTENSA_INTERFACE_HAS_SIDE_EFFECT 0x00000001
00038 
00039 /* Function pointer typedefs */
00040 typedef void (*xtensa_format_encode_fn) (xtensa_insnbuf);
00041 typedef void (*xtensa_get_slot_fn) (const xtensa_insnbuf, xtensa_insnbuf);
00042 typedef void (*xtensa_set_slot_fn) (xtensa_insnbuf, const xtensa_insnbuf);
00043 typedef int (*xtensa_opcode_decode_fn) (const xtensa_insnbuf);
00044 typedef uint32 (*xtensa_get_field_fn) (const xtensa_insnbuf);
00045 typedef void (*xtensa_set_field_fn) (xtensa_insnbuf, uint32);
00046 typedef int (*xtensa_immed_decode_fn) (uint32 *);
00047 typedef int (*xtensa_immed_encode_fn) (uint32 *);
00048 typedef int (*xtensa_do_reloc_fn) (uint32 *, uint32);
00049 typedef int (*xtensa_undo_reloc_fn) (uint32 *, uint32);
00050 typedef void (*xtensa_opcode_encode_fn) (xtensa_insnbuf);
00051 typedef int (*xtensa_format_decode_fn) (const xtensa_insnbuf);
00052 typedef int (*xtensa_length_decode_fn) (const unsigned char *);
00053 
00054 typedef struct xtensa_format_internal_struct
00055 {
00056   const char *name;                /* Instruction format name.  */
00057   int length;                      /* Instruction length in bytes.  */
00058   xtensa_format_encode_fn encode_fn;
00059   int num_slots;
00060   int *slot_id;                           /* Array[num_slots] of slot IDs.  */
00061 } xtensa_format_internal;
00062 
00063 typedef struct xtensa_slot_internal_struct
00064 {
00065   const char *name;                /* Not necessarily unique.  */
00066   const char *format;
00067   int position;
00068   xtensa_get_slot_fn get_fn;
00069   xtensa_set_slot_fn set_fn;
00070   xtensa_get_field_fn *get_field_fns;     /* Array[field_id].  */
00071   xtensa_set_field_fn *set_field_fns;     /* Array[field_id].  */
00072   xtensa_opcode_decode_fn opcode_decode_fn;
00073   const char *nop_name;
00074 } xtensa_slot_internal;
00075 
00076 typedef struct xtensa_operand_internal_struct
00077 {
00078   const char *name;
00079   int field_id;
00080   xtensa_regfile regfile;          /* Register file.  */
00081   int num_regs;                           /* Usually 1; 2 for reg pairs, etc.  */
00082   uint32 flags;                           /* See XTENSA_OPERAND_* flags.  */
00083   xtensa_immed_encode_fn encode;   /* Encode the operand value.  */
00084   xtensa_immed_decode_fn decode;   /* Decode the value from the field.  */
00085   xtensa_do_reloc_fn do_reloc;            /* Perform a PC-relative reloc.  */
00086   xtensa_undo_reloc_fn undo_reloc; /* Undo a PC-relative relocation.  */
00087 } xtensa_operand_internal;
00088 
00089 typedef struct xtensa_arg_internal_struct
00090 {
00091   union {
00092     int operand_id;                /* For normal operands.  */
00093     xtensa_state state;                   /* For stateOperands.  */
00094   } u;
00095   char inout;                      /* Direction: 'i', 'o', or 'm'.  */
00096 } xtensa_arg_internal;
00097 
00098 typedef struct xtensa_iclass_internal_struct
00099 {
00100   int num_operands;                /* Size of "operands" array.  */
00101   xtensa_arg_internal *operands;   /* Array[num_operands].  */
00102 
00103   int num_stateOperands;           /* Size of "stateOperands" array.  */
00104   xtensa_arg_internal *stateOperands;     /* Array[num_stateOperands].  */
00105 
00106   int num_interfaceOperands;              /* Size of "interfaceOperands".  */
00107   xtensa_interface *interfaceOperands;    /* Array[num_interfaceOperands].  */
00108 } xtensa_iclass_internal;
00109 
00110 typedef struct xtensa_opcode_internal_struct
00111 {
00112   const char *name;                /* Opcode mnemonic.  */
00113   int iclass_id;                   /* Iclass for this opcode.  */
00114   uint32 flags;                           /* See XTENSA_OPCODE_* flags.  */
00115   xtensa_opcode_encode_fn *encode_fns;    /* Array[slot_id].  */
00116   int num_funcUnit_uses;           /* Number of funcUnit_use entries.  */
00117   xtensa_funcUnit_use *funcUnit_uses;     /* Array[num_funcUnit_uses].  */
00118 } xtensa_opcode_internal;
00119 
00120 typedef struct xtensa_regfile_internal_struct
00121 {
00122   const char *name;                /* Full name of the regfile.  */
00123   const char *shortname;           /* Abbreviated name.  */
00124   xtensa_regfile parent;           /* View parent (or identity).  */
00125   int num_bits;                           /* Width of the registers.  */
00126   int num_entries;                 /* Number of registers.  */
00127 } xtensa_regfile_internal;
00128 
00129 typedef struct xtensa_interface_internal_struct
00130 {
00131   const char *name;                /* Interface name.  */
00132   int num_bits;                           /* Width of the interface.  */
00133   uint32 flags;                           /* See XTENSA_INTERFACE_* flags.  */
00134   int class_id;                           /* Class of related interfaces.  */
00135   char inout;                      /* "i" or "o".  */
00136 } xtensa_interface_internal;
00137 
00138 typedef struct xtensa_funcUnit_internal_struct
00139 {
00140   const char *name;                /* Functional unit name.  */
00141   int num_copies;                  /* Number of instances.  */
00142 } xtensa_funcUnit_internal;
00143 
00144 typedef struct xtensa_state_internal_struct
00145 {
00146   const char *name;                /* State name.  */
00147   int num_bits;                           /* Number of state bits.  */
00148   uint32 flags;                           /* See XTENSA_STATE_* flags.  */
00149 } xtensa_state_internal;
00150 
00151 typedef struct xtensa_sysreg_internal_struct
00152 {
00153   const char *name;                /* Register name.  */
00154   int number;                      /* Register number.  */
00155   int is_user;                            /* Non-zero if a "user register".  */
00156 } xtensa_sysreg_internal;
00157 
00158 typedef struct xtensa_lookup_entry_struct
00159 {
00160   const char *key;
00161   union
00162   {
00163     xtensa_opcode opcode;          /* Internal opcode number.  */
00164     xtensa_sysreg sysreg;          /* Internal sysreg number.  */
00165     xtensa_state state;                   /* Internal state number.  */
00166     xtensa_interface intf;         /* Internal interface number.  */
00167     xtensa_funcUnit fun;           /* Internal funcUnit number.  */
00168   } u;
00169 } xtensa_lookup_entry;
00170 
00171 typedef struct xtensa_isa_internal_struct
00172 {
00173   int is_big_endian;               /* Endianness.  */
00174   int insn_size;                   /* Maximum length in bytes.  */
00175   int insnbuf_size;                /* Number of insnbuf_words.  */
00176 
00177   int num_formats;
00178   xtensa_format_internal *formats;
00179   xtensa_format_decode_fn format_decode_fn;
00180   xtensa_length_decode_fn length_decode_fn;
00181 
00182   int num_slots;
00183   xtensa_slot_internal *slots;
00184 
00185   int num_fields;
00186 
00187   int num_operands;
00188   xtensa_operand_internal *operands;
00189 
00190   int num_iclasses;
00191   xtensa_iclass_internal *iclasses;
00192 
00193   int num_opcodes;
00194   xtensa_opcode_internal *opcodes;
00195   xtensa_lookup_entry *opname_lookup_table;
00196 
00197   int num_regfiles;
00198   xtensa_regfile_internal *regfiles;
00199 
00200   int num_states;
00201   xtensa_state_internal *states;
00202   xtensa_lookup_entry *state_lookup_table;
00203 
00204   int num_sysregs;
00205   xtensa_sysreg_internal *sysregs;
00206   xtensa_lookup_entry *sysreg_lookup_table;
00207 
00208   /* The current Xtensa ISA only supports 256 of each kind of sysreg so
00209      we can get away with implementing lookups with tables indexed by
00210      the register numbers.  If we ever allow larger sysreg numbers, this
00211      may have to be reimplemented.  The first entry in the following
00212      arrays corresponds to "special" registers and the second to "user"
00213      registers.  */
00214   int max_sysreg_num[2];
00215   xtensa_sysreg *sysreg_table[2];
00216 
00217   int num_interfaces;
00218   xtensa_interface_internal *interfaces;
00219   xtensa_lookup_entry *interface_lookup_table;
00220 
00221   int num_funcUnits;
00222   xtensa_funcUnit_internal *funcUnits;
00223   xtensa_lookup_entry *funcUnit_lookup_table;
00224 
00225 } xtensa_isa_internal;
00226 
00227 extern int xtensa_isa_name_compare (const void *, const void *);
00228 
00229 extern xtensa_isa_status xtisa_errno;
00230 extern char xtisa_error_msg[];
00231 
00232 #endif /* !XTENSA_ISA_INTERNAL_H */