Back to index

cell-binutils  2.17cvs20070401
tc-i960.h
Go to the documentation of this file.
00001 /* tc-i960.h - Basic 80960 instruction formats.
00002    Copyright 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1997, 1998, 1999,
00003    2000, 2001, 2002, 2003, 2007
00004    Free Software Foundation, Inc.
00005 
00006    This file is part of GAS, the GNU Assembler.
00007 
00008    GAS is free software; you can redistribute it and/or modify
00009    it under the terms of the GNU General Public License as
00010    published by the Free Software Foundation; either version 2,
00011    or (at your option) any later version.
00012 
00013    GAS is distributed in the hope that it will be useful, but
00014    WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
00016    the GNU General Public License for more details.
00017 
00018    You should have received a copy of the GNU General Public License
00019    along with GAS; see the file COPYING.  If not, write to the Free
00020    Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
00021    02110-1301, USA.  */
00022 
00023 #ifndef TC_I960
00024 #define TC_I960 1
00025 
00026 #ifdef OBJ_ELF
00027 #define TARGET_FORMAT "elf32-i960"
00028 #define TARGET_ARCH bfd_arch_i960
00029 #endif
00030 
00031 #define TARGET_BYTES_BIG_ENDIAN 0
00032 
00033 #define WORKING_DOT_WORD
00034 
00035 /*
00036  * The 'COJ' instructions are actually COBR instructions with the 'b' in
00037  * the mnemonic replaced by a 'j';  they are ALWAYS "de-optimized" if necessary:
00038  * if the displacement will not fit in 13 bits, the assembler will replace them
00039  * with the corresponding compare and branch instructions.
00040  *
00041  * All of the 'MEMn' instructions are the same format; the 'n' in the name
00042  * indicates the default index scale factor (the size of the datum operated on).
00043  *
00044  * The FBRA formats are not actually an instruction format.  They are the
00045  * "convenience directives" for branching on floating-point comparisons,
00046  * each of which generates 2 instructions (a 'bno' and one other branch).
00047  *
00048  * The CALLJ format is not actually an instruction format.  It indicates that
00049  * the instruction generated (a CTRL-format 'call') should have its relocation
00050  * specially flagged for link-time replacement with a 'bal' or 'calls' if
00051  * appropriate.
00052  */
00053 
00054 /* tailor gas */
00055 #define LOCAL_LABELS_FB 1
00056 #define BITFIELD_CONS_EXPRESSIONS
00057 
00058 /* tailor the coff format */
00059 #define COFF_MAGIC                        I960ROMAGIC
00060 #define OBJ_COFF_MAX_AUXENTRIES                  (2)
00061 
00062 /* MEANING OF 'n_other' in the symbol record.
00063  *
00064  * If non-zero, the 'n_other' fields indicates either a leaf procedure or
00065  * a system procedure, as follows:
00066  *
00067  *     1 <= n_other <= 32 :
00068  *            The symbol is the entry point to a system procedure.
00069  *            'n_value' is the address of the entry, as for any other
00070  *            procedure.  The system procedure number (which can be used in
00071  *            a 'calls' instruction) is (n_other-1).  These entries come from
00072  *            '.sysproc' directives.
00073  *
00074  *     n_other == N_CALLNAME
00075  *            the symbol is the 'call' entry point to a leaf procedure.
00076  *            The *next* symbol in the symbol table must be the corresponding
00077  *            'bal' entry point to the procedure (see following).  These
00078  *            entries come from '.leafproc' directives in which two different
00079  *            symbols are specified (the first one is represented here).
00080  *
00081  *
00082  *     n_other == N_BALNAME
00083  *            the symbol is the 'bal' entry point to a leaf procedure.
00084  *            These entries result from '.leafproc' directives in which only
00085  *            one symbol is specified, or in which the same symbol is
00086  *            specified twice.
00087  *
00088  * Note that an N_CALLNAME entry *must* have a corresponding N_BALNAME entry,
00089  * but not every N_BALNAME entry must have an N_CALLNAME entry.
00090  */
00091 #define       N_CALLNAME    ((char)-1)
00092 #define       N_BALNAME     ((char)-2)
00093 
00094 /* i960 uses a custom relocation record.  */
00095 
00096 /* let obj-aout.h know */
00097 #define CUSTOM_RELOC_FORMAT 1
00098 /* let aout_gnu.h know */
00099 #define N_RELOCATION_INFO_DECLARED 1
00100 struct relocation_info
00101   {
00102     int r_address;          /* File address of item to be relocated   */
00103     unsigned
00104       r_index:24,           /* Index of symbol on which relocation is based*/
00105       r_pcrel:1,            /* 1 => relocate PC-relative; else absolute
00106                              *     On i960, pc-relative implies 24-bit
00107                              *     address, absolute implies 32-bit.
00108                              */
00109       r_length:2,           /* Number of bytes to relocate:
00110                              *     0 => 1 byte
00111                              *     1 => 2 bytes
00112                              *     2 => 4 bytes -- only value used for i960
00113                              */
00114       r_extern:1, r_bsr:1,  /* Something for the GNU NS32K assembler */
00115       r_disp:1,                    /* Something for the GNU NS32K assembler */
00116       r_callj:1,            /* 1 if relocation target is an i960 'callj' */
00117       nuthin:1;                    /* Unused                          */
00118   };
00119 
00120 /* No shared lib support, so we don't need to ensure externally
00121    visible symbols can be overridden.  */
00122 #define EXTERN_FORCE_RELOC 0
00123 
00124 /* Makes no sense to use the difference of 2 arbitrary symbols
00125    as the target of a call instruction.  */
00126 #define TC_FORCE_RELOCATION_SUB_SAME(FIX, SEG)   \
00127   ((FIX)->fx_tcbit                        \
00128    || ! SEG_NORMAL (SEG)                  \
00129    || TC_FORCE_RELOCATION (FIX))
00130 
00131 /* reloc_callj() may replace a 'call' with a 'calls' or a
00132    'bal', in which cases it modifies *fixP as appropriate.
00133    In the case of a 'calls', no further work is required.  */
00134 extern int reloc_callj PARAMS ((struct fix *));
00135 
00136 #define TC_FORCE_RELOCATION_ABS(FIX)             \
00137   (TC_FORCE_RELOCATION (FIX)                     \
00138    || reloc_callj (FIX))
00139 
00140 #define TC_FORCE_RELOCATION_LOCAL(FIX)           \
00141   (!(FIX)->fx_pcrel                       \
00142    || TC_FORCE_RELOCATION (FIX)           \
00143    || reloc_callj (FIX))
00144 
00145 #ifdef OBJ_COFF
00146 
00147 /* We store the bal information in the sy_tc field.  */
00148 #define TC_SYMFIELD_TYPE symbolS *
00149 
00150 #define TC_ADJUST_RELOC_COUNT(FIX,COUNT) \
00151   { fixS *tcfixp = (FIX); \
00152     for (;tcfixp;tcfixp=tcfixp->fx_next) \
00153       if (tcfixp->fx_tcbit && tcfixp->fx_addsy != 0) \
00154        ++(COUNT); \
00155   }
00156 #endif
00157 
00158 extern int i960_validate_fix PARAMS ((struct fix *, segT));
00159 #define TC_VALIDATE_FIX(FIX,SEGTYPE,LABEL) \
00160        if (!i960_validate_fix (FIX, SEGTYPE)) goto LABEL
00161 
00162 #define tc_fix_adjustable(FIX)            ((FIX)->fx_bsr == 0)
00163 
00164 #ifndef OBJ_ELF
00165 /* Values passed to md_apply_fix sometimes include symbol values.  */
00166 #define MD_APPLY_SYM_VALUE(FIX) tc_fix_adjustable (FIX)
00167 #else
00168 /* Values passed to md_apply_fix don't include the symbol value.  */
00169 #define MD_APPLY_SYM_VALUE(FIX) 0
00170 #endif
00171 
00172 extern void brtab_emit PARAMS ((void));
00173 #define md_end()     brtab_emit ()
00174 
00175 extern void tc_set_bal_of_call PARAMS ((symbolS *, symbolS *));
00176 
00177 extern struct symbol *tc_get_bal_of_call PARAMS ((symbolS *));
00178 
00179 extern void i960_handle_align PARAMS ((struct frag *));
00180 #define HANDLE_ALIGN(FRAG)  i960_handle_align (FRAG)
00181 #define NO_RELOC -1
00182 
00183 #define md_operand(x)
00184 
00185 extern const struct relax_type md_relax_table[];
00186 #define TC_GENERIC_RELAX_TABLE md_relax_table
00187 
00188 #define LINKER_RELAXING_SHRINKS_ONLY
00189 
00190 #define TC_FIX_TYPE struct { unsigned bsr : 1; }
00191 #define fx_bsr tc_fix_data.bsr
00192 #define TC_INIT_FIX_DATA(F) ((F)->tc_fix_data.bsr = 0)
00193 
00194 #endif