Commit | Line | Data |
---|---|---|
252b5132 | 1 | /* tc-arc.h - Macros and type defines for the ARC. |
b3adc24a | 2 | Copyright (C) 2014-2020 Free Software Foundation, Inc. |
886a2506 NC |
3 | |
4 | Contributed by Claudiu Zissulescu (claziss@synopsys.com) | |
252b5132 RH |
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 | |
ec2655a6 | 10 | published by the Free Software Foundation; either version 3, |
252b5132 RH |
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 | |
4b4da160 NC |
20 | Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA |
21 | 02110-1301, USA. */ | |
252b5132 | 22 | |
5e4f7e05 | 23 | #ifndef TC_ARC |
886a2506 NC |
24 | /* By convention, you should define this macro in the `.h' file. For |
25 | example, `tc-m68k.h' defines `TC_M68K'. You might have to use this | |
26 | if it is necessary to add CPU specific code to the object format | |
27 | file. */ | |
28 | #define TC_ARC | |
252b5132 | 29 | |
5e4f7e05 CZ |
30 | #include "opcode/arc.h" |
31 | ||
886a2506 | 32 | /* We want local label support. */ |
252b5132 RH |
33 | #define LOCAL_LABELS_FB 1 |
34 | ||
886a2506 NC |
35 | /* This macro is the BFD architecture to pass to |
36 | `bfd_set_arch_mach'. */ | |
252b5132 RH |
37 | #define TARGET_ARCH bfd_arch_arc |
38 | ||
886a2506 NC |
39 | /* The `extsym - .' expressions can be emitted using PC-relative |
40 | relocs. */ | |
0d2bcfaf | 41 | #define DIFF_EXPR_OK |
4a314ec8 | 42 | |
886a2506 | 43 | #define REGISTER_PREFIX '%' |
4a314ec8 | 44 | |
886a2506 | 45 | #undef LITTLE_ENDIAN |
252b5132 | 46 | #define LITTLE_ENDIAN 1234 |
0d2bcfaf | 47 | |
886a2506 | 48 | #undef BIG_ENDIAN |
252b5132 RH |
49 | #define BIG_ENDIAN 4321 |
50 | ||
886a2506 NC |
51 | #ifdef TARGET_BYTES_BIG_ENDIAN |
52 | ||
53 | # define DEFAULT_TARGET_FORMAT "elf32-bigarc" | |
54 | # define DEFAULT_BYTE_ORDER BIG_ENDIAN | |
55 | ||
56 | #else | |
57 | /* You should define this macro to be non-zero if the target is big | |
58 | endian, and zero if the target is little endian. */ | |
59 | # define TARGET_BYTES_BIG_ENDIAN 0 | |
60 | ||
61 | # define DEFAULT_TARGET_FORMAT "elf32-littlearc" | |
62 | # define DEFAULT_BYTE_ORDER LITTLE_ENDIAN | |
63 | ||
64 | #endif /* TARGET_BYTES_BIG_ENDIAN. */ | |
65 | ||
252b5132 RH |
66 | /* The endianness of the target format may change based on command |
67 | line arguments. */ | |
886a2506 NC |
68 | extern const char *arc_target_format; |
69 | ||
70 | /* This macro is the BFD target name to use when creating the output | |
71 | file. This will normally depend upon the `OBJ_FMT' macro. */ | |
72 | #define TARGET_FORMAT arc_target_format | |
73 | ||
74 | /* `md_short_jump_size' | |
75 | `md_long_jump_size' | |
76 | `md_create_short_jump' | |
77 | `md_create_long_jump' | |
78 | ||
79 | If `WORKING_DOT_WORD' is defined, GAS will not do broken word | |
80 | processing (*note Broken words::.). Otherwise, you should set | |
81 | `md_short_jump_size' to the size of a short jump (a jump that is | |
82 | just long enough to jump around a long jmp) and `md_long_jump_size' | |
83 | to the size of a long jump (a jump that can go anywhere in the | |
84 | function). You should define `md_create_short_jump' to create a | |
85 | short jump around a long jump, and define `md_create_long_jump' to | |
86 | create a long jump. */ | |
252b5132 | 87 | #define WORKING_DOT_WORD |
252b5132 | 88 | |
886a2506 | 89 | #define LISTING_HEADER "ARC GAS " |
252b5132 | 90 | |
886a2506 NC |
91 | /* The number of bytes to put into a word in a listing. This affects |
92 | the way the bytes are clumped together in the listing. For | |
93 | example, a value of 2 might print `1234 5678' where a value of 1 | |
94 | would print `12 34 56 78'. The default value is 4. */ | |
95 | #define LISTING_WORD_SIZE 2 | |
252b5132 | 96 | |
886a2506 NC |
97 | /* If you define this macro, it should return the position from which |
98 | the PC relative adjustment for a PC relative fixup should be made. | |
99 | On many processors, the base of a PC relative instruction is the | |
100 | next instruction, so this macro would return the length of an | |
101 | instruction, plus the address of the PC relative fixup. The latter | |
102 | can be calculated as fixp->fx_where + | |
103 | fixp->fx_frag->fr_address. */ | |
104 | extern long md_pcrel_from_section (struct fix *, segT); | |
105 | #define MD_PCREL_FROM_SECTION(FIX, SEC) md_pcrel_from_section (FIX, SEC) | |
106 | ||
107 | /* [ ] is index operator. */ | |
108 | #define NEED_INDEX_OPERATOR | |
bcee8eb8 | 109 | |
886a2506 | 110 | #define MAX_MEM_FOR_RS_ALIGN_CODE (1+2) |
a161fe53 | 111 | |
886a2506 NC |
112 | /* HANDLE_ALIGN called after all the assembly has been done, |
113 | so we can fill in all the rs_align_code type frags with | |
114 | nop instructions. */ | |
115 | #define HANDLE_ALIGN(FRAGP) arc_handle_align (FRAGP) | |
116 | ||
117 | /* Values passed to md_apply_fix3 don't include the symbol value. */ | |
a161fe53 AM |
118 | #define MD_APPLY_SYM_VALUE(FIX) 0 |
119 | ||
120 | /* No shared lib support, so we don't need to ensure externally | |
121 | visible symbols can be overridden. */ | |
122 | #define EXTERN_FORCE_RELOC 0 | |
886a2506 NC |
123 | |
124 | /* You may define this macro to generate a fixup for a data allocation | |
125 | pseudo-op. */ | |
126 | #define TC_CONS_FIX_NEW(FRAG, OFF, LEN, EXP, RELOC) \ | |
127 | arc_cons_fix_new ((FRAG), (OFF), (LEN), (EXP), (RELOC)) | |
128 | ||
129 | /* We don't want gas to fixup the following program memory related | |
24b368f8 CZ |
130 | relocations. Check also that fx_addsy is not NULL, in order to |
131 | make sure that the fixup refers to some sort of label. */ | |
132 | #define TC_VALIDATE_FIX(FIXP,SEG,SKIP) \ | |
133 | if ((FIXP->fx_r_type == BFD_RELOC_ARC_GOTPC32 \ | |
134 | || FIXP->fx_r_type == BFD_RELOC_ARC_PLT32 \ | |
135 | || FIXP->fx_r_type == BFD_RELOC_ARC_S25W_PCREL_PLT \ | |
136 | || FIXP->fx_r_type == BFD_RELOC_ARC_S25H_PCREL_PLT \ | |
137 | || FIXP->fx_r_type == BFD_RELOC_ARC_S21W_PCREL_PLT \ | |
138 | || FIXP->fx_r_type == BFD_RELOC_ARC_S21H_PCREL_PLT) \ | |
139 | && FIXP->fx_addsy != NULL \ | |
140 | && FIXP->fx_subsy == NULL) \ | |
141 | { \ | |
142 | symbol_mark_used_in_reloc (FIXP->fx_addsy); \ | |
143 | goto SKIP; \ | |
886a2506 NC |
144 | } |
145 | ||
146 | /* BFD_RELOC_ARC_TLS_GD_LD may use fx_subsy to store a label that is | |
147 | later turned into fx_offset. */ | |
148 | #define TC_FORCE_RELOCATION_SUB_LOCAL(FIX, SEG) \ | |
149 | ((FIX)->fx_r_type == BFD_RELOC_ARC_TLS_GD_LD) | |
150 | ||
151 | #define TC_VALIDATE_FIX_SUB(FIX, SEG) \ | |
152 | ((md_register_arithmetic || (SEG) != reg_section) \ | |
153 | && ((FIX)->fx_r_type == BFD_RELOC_GPREL32 \ | |
154 | || (FIX)->fx_r_type == BFD_RELOC_GPREL16 \ | |
155 | || (FIX)->fx_r_type == BFD_RELOC_ARC_TLS_DTPOFF \ | |
156 | || (FIX)->fx_r_type == BFD_RELOC_ARC_TLS_DTPOFF_S9 \ | |
157 | || TC_FORCE_RELOCATION_SUB_LOCAL (FIX, SEG))) | |
158 | ||
159 | /* We use this to mark the end-loop label. We use this mark for ZOL | |
160 | validity checks. */ | |
161 | #define TC_SYMFIELD_TYPE unsigned int | |
162 | #define ARC_GET_FLAG(s) (*symbol_get_tc (s)) | |
163 | #define ARC_SET_FLAG(s,v) (*symbol_get_tc (s) |= (v)) | |
164 | ||
165 | /* The symbol is a ZOL's end loop label. */ | |
166 | #define ARC_FLAG_ZOL (1 << 0) | |
37ab9779 CZ |
167 | /* The symbol is an AUX register. */ |
168 | #define ARC_FLAG_AUX (1 << 1) | |
886a2506 NC |
169 | |
170 | /* We use this hook to check the validity of the last to instructions | |
171 | of a ZOL. */ | |
172 | #define tc_frob_label(S) arc_frob_label (S) | |
173 | ||
174 | #define GLOBAL_OFFSET_TABLE_NAME "_GLOBAL_OFFSET_TABLE_" | |
886a2506 NC |
175 | |
176 | /* We need to take care of not having section relative fixups for the | |
177 | fixups with respect to Position Independent Code. */ | |
178 | #define tc_fix_adjustable(FIX) tc_arc_fix_adjustable(FIX) | |
179 | ||
180 | /* This hook is required to parse register names as operands. */ | |
181 | #define md_parse_name(name, exp, m, c) arc_parse_name (name, exp) | |
182 | ||
4670103e CZ |
183 | /* Used within frags to pass some information to some relaxation |
184 | machine dependent values. */ | |
185 | #define TC_FRAG_TYPE struct arc_relax_type | |
186 | ||
187 | /* Adjust non PC-rel values at relaxation time. */ | |
188 | #define TC_PCREL_ADJUST(F) arc_pcrel_adjust (F) | |
189 | ||
37ab9779 CZ |
190 | /* Adjust symbol table. */ |
191 | #define obj_adjust_symtab() arc_adjust_symtab () | |
192 | ||
53a346d8 CZ |
193 | /* Object attribute hooks. */ |
194 | #define md_end arc_md_end | |
195 | #define CONVERT_SYMBOLIC_ATTRIBUTE(name) arc_convert_symbolic_attribute (name) | |
196 | #ifndef TC_COPY_SYMBOL_ATTRIBUTES | |
197 | #define TC_COPY_SYMBOL_ATTRIBUTES(DEST, SRC) \ | |
198 | (arc_copy_symbol_attributes (DEST, SRC)) | |
199 | #endif | |
200 | ||
201 | extern void arc_copy_symbol_attributes (symbolS *, symbolS *); | |
202 | extern int arc_convert_symbolic_attribute (const char *); | |
203 | extern void arc_md_end (void); | |
37ab9779 | 204 | extern void arc_adjust_symtab (void); |
4670103e | 205 | extern int arc_pcrel_adjust (fragS *); |
886a2506 NC |
206 | extern bfd_boolean arc_parse_name (const char *, struct expressionS *); |
207 | extern int tc_arc_fix_adjustable (struct fix *); | |
208 | extern void arc_handle_align (fragS *); | |
209 | extern void arc_cons_fix_new (fragS *, int, int, expressionS *, | |
210 | bfd_reloc_code_real_type); | |
211 | extern void arc_frob_label (symbolS *); | |
726c18e1 CZ |
212 | extern void tc_arc_frame_initial_instructions (void); |
213 | extern int tc_arc_regname_to_dw2regnum (char *regname); | |
886a2506 NC |
214 | |
215 | /* The blink register is r31. */ | |
216 | #define DWARF2_DEFAULT_RETURN_COLUMN 31 | |
217 | /* Registers are generally saved at negative offsets to the CFA. */ | |
218 | #define DWARF2_CIE_DATA_ALIGNMENT (-4) | |
219 | ||
726c18e1 CZ |
220 | /* We want .cfi_* pseudo-ops for generating unwind info. */ |
221 | #define TARGET_USE_CFIPOP 1 | |
222 | ||
223 | /* CFI hooks. */ | |
224 | #define tc_cfi_frame_initial_instructions tc_arc_frame_initial_instructions | |
225 | #define tc_regname_to_dw2regnum tc_arc_regname_to_dw2regnum | |
226 | ||
886a2506 NC |
227 | /* Define the NOPs. */ |
228 | #define NOP_OPCODE_S 0x000078E0 | |
229 | #define NOP_OPCODE_L 0x264A7000 /* mov 0,0. */ | |
230 | ||
a42a4f84 | 231 | #define MAX_FLAG_NAME_LENGTH 7 |
4670103e CZ |
232 | |
233 | struct arc_flags | |
234 | { | |
235 | /* Name of the parsed flag. */ | |
83cda17b | 236 | char name[MAX_FLAG_NAME_LENGTH + 1]; |
4670103e | 237 | |
f36e33da | 238 | /* Pointer to arc flags. */ |
38cd8a0d | 239 | const struct arc_flag_operand *flgp; |
4670103e CZ |
240 | }; |
241 | ||
4670103e CZ |
242 | extern const relax_typeS md_relax_table[]; |
243 | #define TC_GENERIC_RELAX_TABLE md_relax_table | |
244 | ||
245 | /* Used to construct instructions at md_convert_frag stage of | |
246 | relaxation. */ | |
247 | struct arc_relax_type | |
248 | { | |
249 | /* Dictates whether the pc-relativity should be kept in mind when | |
250 | relax_frag is called or whether the pc-relativity should be | |
251 | solved outside of relaxation. For clarification: BL(_S) and | |
252 | B(_S) use pcrel == 1 and ADD with a solvable expression as 3rd | |
253 | operand use pcrel == 0. */ | |
254 | unsigned char pcrel; | |
255 | ||
256 | /* Expressions that dictate the operands. Used for re-assembling in | |
257 | md_convert_frag. */ | |
258 | expressionS tok[MAX_INSN_ARGS]; | |
259 | ||
260 | /* Number of tok (i.e. number of operands). Used for re-assembling | |
261 | in md_convert_frag. */ | |
262 | int ntok; | |
263 | ||
264 | /* Flags of instruction. Used for re-assembling in | |
265 | md_convert_frag. */ | |
266 | struct arc_flags pflags[MAX_INSN_FLGS]; | |
267 | ||
268 | /* Number of flags. Used for re-assembling in md_convert_frag. */ | |
269 | int nflg; | |
270 | }; | |
5e4f7e05 CZ |
271 | |
272 | #endif |