]>
Commit | Line | Data |
---|---|---|
252b5132 | 1 | /* tc-i960.h - Basic 80960 instruction formats. |
f7e42eb4 | 2 | Copyright 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1997, 1998, 1999, |
1d3b2b27 | 3 | 2000, 2002, 2003 |
252b5132 RH |
4 | Free Software Foundation, Inc. |
5 | ||
6 | This file is part of GAS, the GNU Assembler. | |
7 | ||
8 | GAS is free software; you can redistribute it and/or modify | |
9 | it under the terms of the GNU General Public License as | |
10 | published by the Free Software Foundation; either version 2, | |
11 | or (at your option) any later version. | |
12 | ||
13 | GAS is distributed in the hope that it will be useful, but | |
14 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See | |
16 | the GNU General Public License for more details. | |
17 | ||
18 | You should have received a copy of the GNU General Public License | |
19 | along with GAS; see the file COPYING. If not, write to the Free | |
20 | Software Foundation, 59 Temple Place - Suite 330, Boston, MA | |
4a4f25cf | 21 | 02111-1307, USA. */ |
252b5132 RH |
22 | |
23 | #ifndef TC_I960 | |
24 | #define TC_I960 1 | |
25 | ||
bedf545c ILT |
26 | #ifdef OBJ_ELF |
27 | #define TARGET_FORMAT "elf32-i960" | |
28 | #define TARGET_ARCH bfd_arch_i960 | |
29 | #endif | |
30 | ||
252b5132 RH |
31 | #define TARGET_BYTES_BIG_ENDIAN 0 |
32 | ||
33 | #define WORKING_DOT_WORD | |
34 | ||
35 | /* | |
36 | * The 'COJ' instructions are actually COBR instructions with the 'b' in | |
37 | * the mnemonic replaced by a 'j'; they are ALWAYS "de-optimized" if necessary: | |
38 | * if the displacement will not fit in 13 bits, the assembler will replace them | |
39 | * with the corresponding compare and branch instructions. | |
40 | * | |
41 | * All of the 'MEMn' instructions are the same format; the 'n' in the name | |
42 | * indicates the default index scale factor (the size of the datum operated on). | |
43 | * | |
44 | * The FBRA formats are not actually an instruction format. They are the | |
45 | * "convenience directives" for branching on floating-point comparisons, | |
46 | * each of which generates 2 instructions (a 'bno' and one other branch). | |
47 | * | |
48 | * The CALLJ format is not actually an instruction format. It indicates that | |
49 | * the instruction generated (a CTRL-format 'call') should have its relocation | |
50 | * specially flagged for link-time replacement with a 'bal' or 'calls' if | |
51 | * appropriate. | |
52 | */ | |
53 | ||
54 | /* tailor gas */ | |
55 | #define SYMBOLS_NEED_BACKPOINTERS | |
56 | #define LOCAL_LABELS_FB 1 | |
57 | #define BITFIELD_CONS_EXPRESSIONS | |
58 | ||
59 | /* tailor the coff format */ | |
60 | #define BFD_ARCH bfd_arch_i960 | |
61 | #define COFF_FLAGS F_AR32WR | |
62 | #define COFF_MAGIC I960ROMAGIC | |
63 | #define OBJ_COFF_SECTION_HEADER_HAS_ALIGNMENT | |
64 | #define OBJ_COFF_MAX_AUXENTRIES (2) | |
a161fe53 AM |
65 | #define TC_COUNT_RELOC(FIX) (!(FIX)->fx_done) |
66 | #define TC_COFF_FIX2RTYPE(FIX) tc_coff_fix2rtype (FIX) | |
07726851 | 67 | #define TC_COFF_SIZEMACHDEP(FRAGP) tc_coff_sizemachdep (FRAGP) |
252b5132 | 68 | #define TC_COFF_SET_MACHINE(HDRS) tc_headers_hook (HDRS) |
a161fe53 | 69 | extern int tc_coff_sizemachdep PARAMS ((struct frag *)); |
252b5132 RH |
70 | |
71 | /* MEANING OF 'n_other' in the symbol record. | |
72 | * | |
73 | * If non-zero, the 'n_other' fields indicates either a leaf procedure or | |
74 | * a system procedure, as follows: | |
75 | * | |
76 | * 1 <= n_other <= 32 : | |
77 | * The symbol is the entry point to a system procedure. | |
78 | * 'n_value' is the address of the entry, as for any other | |
79 | * procedure. The system procedure number (which can be used in | |
80 | * a 'calls' instruction) is (n_other-1). These entries come from | |
81 | * '.sysproc' directives. | |
82 | * | |
83 | * n_other == N_CALLNAME | |
84 | * the symbol is the 'call' entry point to a leaf procedure. | |
85 | * The *next* symbol in the symbol table must be the corresponding | |
86 | * 'bal' entry point to the procedure (see following). These | |
87 | * entries come from '.leafproc' directives in which two different | |
88 | * symbols are specified (the first one is represented here). | |
89 | * | |
90 | * | |
91 | * n_other == N_BALNAME | |
92 | * the symbol is the 'bal' entry point to a leaf procedure. | |
93 | * These entries result from '.leafproc' directives in which only | |
94 | * one symbol is specified, or in which the same symbol is | |
95 | * specified twice. | |
96 | * | |
97 | * Note that an N_CALLNAME entry *must* have a corresponding N_BALNAME entry, | |
98 | * but not every N_BALNAME entry must have an N_CALLNAME entry. | |
99 | */ | |
100 | #define N_CALLNAME ((char)-1) | |
101 | #define N_BALNAME ((char)-2) | |
102 | ||
4a4f25cf | 103 | /* i960 uses a custom relocation record. */ |
252b5132 RH |
104 | |
105 | /* let obj-aout.h know */ | |
106 | #define CUSTOM_RELOC_FORMAT 1 | |
107 | /* let aout_gnu.h know */ | |
108 | #define N_RELOCATION_INFO_DECLARED 1 | |
109 | struct relocation_info | |
110 | { | |
111 | int r_address; /* File address of item to be relocated */ | |
112 | unsigned | |
113 | r_index:24, /* Index of symbol on which relocation is based*/ | |
114 | r_pcrel:1, /* 1 => relocate PC-relative; else absolute | |
115 | * On i960, pc-relative implies 24-bit | |
116 | * address, absolute implies 32-bit. | |
117 | */ | |
118 | r_length:2, /* Number of bytes to relocate: | |
119 | * 0 => 1 byte | |
120 | * 1 => 2 bytes | |
121 | * 2 => 4 bytes -- only value used for i960 | |
122 | */ | |
123 | r_extern:1, r_bsr:1, /* Something for the GNU NS32K assembler */ | |
124 | r_disp:1, /* Something for the GNU NS32K assembler */ | |
125 | r_callj:1, /* 1 if relocation target is an i960 'callj' */ | |
126 | nuthin:1; /* Unused */ | |
127 | }; | |
128 | ||
a161fe53 AM |
129 | /* No shared lib support, so we don't need to ensure externally |
130 | visible symbols can be overridden. */ | |
131 | #define EXTERN_FORCE_RELOC 0 | |
132 | ||
133 | /* Makes no sense to use the difference of 2 arbitrary symbols | |
134 | as the target of a call instruction. */ | |
135 | #define TC_FORCE_RELOCATION_SUB_SAME(FIX, SEG) \ | |
136 | ((FIX)->fx_tcbit \ | |
ae6063d4 AM |
137 | || ! SEG_NORMAL (SEG) \ |
138 | || TC_FORCE_RELOCATION (FIX)) | |
a161fe53 AM |
139 | |
140 | /* reloc_callj() may replace a 'call' with a 'calls' or a | |
141 | 'bal', in which cases it modifies *fixP as appropriate. | |
142 | In the case of a 'calls', no further work is required. */ | |
143 | extern int reloc_callj PARAMS ((struct fix *)); | |
144 | ||
145 | #define TC_FORCE_RELOCATION_ABS(FIX) \ | |
146 | (TC_FORCE_RELOCATION (FIX) \ | |
147 | || reloc_callj (FIX)) | |
148 | ||
149 | #define TC_FORCE_RELOCATION_LOCAL(FIX) \ | |
150 | (!(FIX)->fx_pcrel \ | |
151 | || (FIX)->fx_plt \ | |
152 | || TC_FORCE_RELOCATION (FIX) \ | |
153 | || reloc_callj (FIX)) | |
154 | ||
252b5132 RH |
155 | #ifdef OBJ_COFF |
156 | ||
157 | /* We store the bal information in the sy_tc field. */ | |
49309057 | 158 | #define TC_SYMFIELD_TYPE symbolS * |
252b5132 | 159 | |
a161fe53 AM |
160 | #define TC_ADJUST_RELOC_COUNT(FIX,COUNT) \ |
161 | { fixS *tcfixp = (FIX); \ | |
252b5132 RH |
162 | for (;tcfixp;tcfixp=tcfixp->fx_next) \ |
163 | if (tcfixp->fx_tcbit && tcfixp->fx_addsy != 0) \ | |
1d3b2b27 | 164 | ++(COUNT); \ |
252b5132 RH |
165 | } |
166 | #endif | |
167 | ||
a161fe53 AM |
168 | extern int i960_validate_fix PARAMS ((struct fix *, segT)); |
169 | #define TC_VALIDATE_FIX(FIX,SEGTYPE,LABEL) \ | |
170 | if (!i960_validate_fix (FIX, SEGTYPE)) goto LABEL | |
252b5132 | 171 | |
a161fe53 | 172 | #define tc_fix_adjustable(FIX) ((FIX)->fx_bsr == 0) |
bedf545c ILT |
173 | |
174 | #ifndef OBJ_ELF | |
a161fe53 AM |
175 | /* Values passed to md_apply_fix3 sometimes include symbol values. */ |
176 | #define MD_APPLY_SYM_VALUE(FIX) tc_fix_adjustable (FIX) | |
bedf545c | 177 | #else |
a161fe53 AM |
178 | /* Values passed to md_apply_fix3 don't include the symbol value. */ |
179 | #define MD_APPLY_SYM_VALUE(FIX) 0 | |
bedf545c | 180 | #endif |
252b5132 RH |
181 | |
182 | extern void brtab_emit PARAMS ((void)); | |
183 | #define md_end() brtab_emit () | |
184 | ||
49309057 | 185 | extern void tc_set_bal_of_call PARAMS ((symbolS *, symbolS *)); |
252b5132 | 186 | |
49309057 | 187 | extern struct symbol *tc_get_bal_of_call PARAMS ((symbolS *)); |
252b5132 | 188 | |
a161fe53 | 189 | extern void i960_handle_align PARAMS ((struct frag *)); |
252b5132 RH |
190 | #define HANDLE_ALIGN(FRAG) i960_handle_align (FRAG) |
191 | #define NEED_FX_R_TYPE | |
192 | #define NO_RELOC -1 | |
193 | ||
194 | #define md_operand(x) | |
195 | ||
196 | extern const struct relax_type md_relax_table[]; | |
197 | #define TC_GENERIC_RELAX_TABLE md_relax_table | |
198 | ||
199 | #define LINKER_RELAXING_SHRINKS_ONLY | |
200 | ||
201 | #define TC_FIX_TYPE struct { unsigned bsr : 1; } | |
202 | #define fx_bsr tc_fix_data.bsr | |
203 | #define TC_INIT_FIX_DATA(F) ((F)->tc_fix_data.bsr = 0) | |
204 | ||
205 | #endif |