]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gas/config/tc-sh64.h
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / gas / config / tc-sh64.h
CommitLineData
324bfcf3 1/* This file is tc-sh64.h
219d1afa 2 Copyright (C) 2000-2018 Free Software Foundation, Inc.
324bfcf3
AO
3
4 This file is part of GAS, the GNU Assembler.
5
6 GAS is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
ec2655a6 8 the Free Software Foundation; either version 3, or (at your option)
324bfcf3
AO
9 any later version.
10
11 GAS is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GAS; see the file COPYING. If not, write to
4b4da160
NC
18 the Free Software Foundation, 51 Franklin Street - Fifth Floor,
19 Boston, MA 02110-1301, USA. */
324bfcf3
AO
20
21#define TC_SH64
22#include "config/tc-sh.h"
23#include "elf/sh.h"
f0abc2a1 24#include "elf32-sh64.h"
324bfcf3
AO
25
26/* We need to override the tc-sh.h settings of HANDLE_ALIGN and
27 MAX_MEM_FOR_RS_ALIGN_CODE; we might need to put in SHmedia NOP:s, not
28 SHcompact NOP:s. */
29#undef HANDLE_ALIGN
30#define HANDLE_ALIGN(frag) sh64_handle_align (frag)
8edc77b9 31extern void sh64_handle_align (fragS *);
324bfcf3
AO
32
33#undef MAX_MEM_FOR_RS_ALIGN_CODE
34#define MAX_MEM_FOR_RS_ALIGN_CODE sh64_max_mem_for_rs_align_code ()
8edc77b9 35extern int sh64_max_mem_for_rs_align_code (void);
324bfcf3
AO
36
37#undef LISTING_HEADER
38#define LISTING_HEADER \
39 (target_big_endian ? \
ef230218
JR
40 "SuperH SHcompact/SHmedia Big Endian GAS" \
41 : "SuperH SHcompact/SHmedia Little Endian GAS")
324bfcf3
AO
42
43/* We need to record the new frag position after an .align. */
8edc77b9 44extern void sh64_do_align (int, const char *, int, int);
324bfcf3
AO
45#define md_do_align(n, fill, len, max, l) \
46 do { sh64_do_align (n, fill, len, max); goto l; } while (0)
47
48struct sh64_segment_info_type
49{
50 /* The type of the section is initialized when the range_start_symbol
51 member is non-NULL. */
52 symbolS *mode_start_symbol;
53 subsegT mode_start_subseg;
54
55 /* A stored symbol indicating location of last call of
56 "md_flush_pending_output". It is NULLed when we actually use it;
57 otherwise the contents is just filled in with segment, frag and
58 offset within frag. */
59 symbolS *last_contents_mark;
60
61 unsigned int emitted_ranges;
62 enum sh64_elf_cr_type contents_type;
63
64 /* This is used by the SH1-4 parts; we set it to 0 for SHmedia code and
65 data. */
66 unsigned int in_code : 1;
67};
68
69#undef TC_SEGMENT_INFO_TYPE
70#define TC_SEGMENT_INFO_TYPE struct sh64_segment_info_type
71
72#undef TARGET_FORMAT
73#define TARGET_FORMAT sh64_target_format ()
8edc77b9 74extern const char *sh64_target_format (void);
324bfcf3
AO
75
76#define TARGET_MACH sh64_target_mach ()
8edc77b9 77extern int sh64_target_mach (void);
324bfcf3 78
a161fe53
AM
79#undef TC_FORCE_RELOCATION_LOCAL
80#define TC_FORCE_RELOCATION_LOCAL(FIX) \
91cb9803 81 (GENERIC_FORCE_RELOCATION_LOCAL (FIX) \
a161fe53
AM
82 || (FIX)->fx_r_type == BFD_RELOC_32_PLT_PCREL \
83 || (FIX)->fx_r_type == BFD_RELOC_SH_PLT_LOW16 \
84 || (FIX)->fx_r_type == BFD_RELOC_SH_PLT_MEDLOW16 \
85 || (FIX)->fx_r_type == BFD_RELOC_SH_PLT_MEDHI16 \
86 || (FIX)->fx_r_type == BFD_RELOC_SH_PLT_HI16 \
87 || (FIX)->fx_r_type == BFD_RELOC_32_GOT_PCREL \
88 || (FIX)->fx_r_type == BFD_RELOC_SH_GOT_LOW16 \
89 || (FIX)->fx_r_type == BFD_RELOC_SH_GOT_MEDLOW16 \
90 || (FIX)->fx_r_type == BFD_RELOC_SH_GOT_MEDHI16 \
91 || (FIX)->fx_r_type == BFD_RELOC_SH_GOT_HI16 \
92 || (FIX)->fx_r_type == BFD_RELOC_SH_GOT10BY4 \
93 || (FIX)->fx_r_type == BFD_RELOC_SH_GOT10BY8 \
94 || (FIX)->fx_r_type == BFD_RELOC_SH_GOTPLT32 \
95 || (FIX)->fx_r_type == BFD_RELOC_SH_GOTPLT_LOW16 \
96 || (FIX)->fx_r_type == BFD_RELOC_SH_GOTPLT_MEDLOW16 \
97 || (FIX)->fx_r_type == BFD_RELOC_SH_GOTPLT_MEDHI16 \
98 || (FIX)->fx_r_type == BFD_RELOC_SH_GOTPLT_HI16 \
99 || (FIX)->fx_r_type == BFD_RELOC_SH_GOTPLT10BY4 \
100 || (FIX)->fx_r_type == BFD_RELOC_SH_GOTPLT10BY8 \
101 || (FIX)->fx_r_type == BFD_RELOC_SH_GOTPC \
102 || (FIX)->fx_r_type == BFD_RELOC_SH_GOTPC_LOW16 \
103 || (FIX)->fx_r_type == BFD_RELOC_SH_GOTPC_MEDLOW16 \
104 || (FIX)->fx_r_type == BFD_RELOC_SH_GOTPC_MEDHI16 \
91cb9803 105 || (FIX)->fx_r_type == BFD_RELOC_SH_GOTPC_HI16)
a161fe53
AM
106
107#undef TC_FORCE_RELOCATION_SUB_SAME
ae6063d4 108#define TC_FORCE_RELOCATION_SUB_SAME(FIX, SEC) \
91cb9803 109 (GENERIC_FORCE_RELOCATION_SUB_SAME (FIX, SEC) \
ae6063d4 110 || TC_FORCE_RELOCATION (FIX) \
a161fe53
AM
111 || (sh_relax && SWITCH_TABLE (FIX)) \
112 || *symbol_get_tc ((FIX)->fx_addsy) != NULL)
113
114/* Don't complain when we leave fx_subsy around. */
115#undef TC_VALIDATE_FIX_SUB
5db484ff
AM
116#define TC_VALIDATE_FIX_SUB(FIX, SEG) \
117 ((md_register_arithmetic || (SEG) != reg_section) \
118 && ((FIX)->fx_r_type == BFD_RELOC_32_PLT_PCREL \
119 || (sh_relax && SWITCH_TABLE (FIX)) \
120 || *symbol_get_tc ((FIX)->fx_addsy) != NULL))
324bfcf3
AO
121
122/* Note the kludge: we want to put back C, and we also want to consume the
123 expression, since we have handled it ourselves. FIXME: What we really
124 need is a new GAS infrastructure feature: md_qualifier. */
125#undef md_parse_name
9497f5ac
NC
126#define md_parse_name(NAME, EXP, MODE, CP) \
127 sh64_consume_datalabel (NAME, EXP, MODE, CP, operand)
128extern int sh64_consume_datalabel (const char *, expressionS *,
129 enum expr_mode, char *,
130 segT (*) (expressionS *, enum expr_mode));
324bfcf3
AO
131
132/* Saying "$" is the same as saying ".". */
133#define DOLLAR_DOT
134
a074e149 135#undef MD_PCREL_FROM_SECTION
a161fe53
AM
136#define MD_PCREL_FROM_SECTION(FIX, SEC) \
137 shmedia_md_pcrel_from_section (FIX, SEC)
324bfcf3 138
8edc77b9 139extern valueT shmedia_md_pcrel_from_section (struct fix *, segT);
324bfcf3
AO
140
141/* We need to mark this symbol as a BranchTarget; setting st_other for it
142 and adding 1 to its value (temporarily). */
8edc77b9 143extern void sh64_frob_label (symbolS *);
324bfcf3
AO
144
145#undef tc_frob_label
146#define tc_frob_label(sym) \
07a53e5c 147 do { sh_frob_label (sym); sh64_frob_label (sym); } while (0)
324bfcf3
AO
148
149#define tc_symbol_new_hook(s) sh64_frob_label (s)
150
151/* We use this to mark our "datalabel" symbol copies. The "mark" is NULL
152 for an ordinary symbol, and the pointer to the "ordinary" symbol for a
153 datalabel symbol. */
154#define TC_SYMFIELD_TYPE symbolS *
155
156#define tc_frob_symbol(symp, punt) \
157 do \
158 { \
159 punt = sh64_exclude_symbol (symp); \
160 } \
161 while (0)
162
8edc77b9 163extern int sh64_exclude_symbol (symbolS *);
324bfcf3 164
8edc77b9 165extern void sh64_adjust_symtab (void);
324bfcf3
AO
166#define tc_adjust_symtab sh64_adjust_symtab
167
168#undef md_flush_pending_output
169#define md_flush_pending_output() sh64_flush_pending_output ()
8edc77b9 170extern void sh64_flush_pending_output (void);
324bfcf3
AO
171
172/* Note that tc-sh.c has a sh_frob_section, but it's called from
173 tc_frob_file_before_adjust. */
174#define tc_frob_section(sec) shmedia_frob_section_type (sec)
8edc77b9 175extern void shmedia_frob_section_type (asection *);
324bfcf3 176
324bfcf3
AO
177/* We need to emit fixups relative to the frag in which the instruction
178 resides. Safest way without calculating max fragment growth or making
179 it a fixed number is to provide a pointer to the opcode frag.
180
181 We also need to emit the right NOP pattern in .align frags. This is
182 done after the text-to-bits assembly pass, so we need to mark it with
183 the ISA setting at the time the .align was assembled. */
184#define TC_FRAG_TYPE struct sh64_tc_frag_data
185
186enum sh64_isa_values
187 {
188 sh64_isa_unspecified,
189 sh64_isa_shcompact,
190 sh64_isa_shmedia,
191
192 /* Special guard value used in contexts when we don't know which ISA it
193 is, just that it's specified (not sh64_isa_unspecified). */
194 sh64_isa_sh5_guard
195 };
196
197struct sh64_tc_frag_data
198{
199 fragS *opc_frag;
200 enum sh64_isa_values isa;
201};
202
203extern enum sh64_isa_values sh64_isa_mode;
204
205#define TC_FRAG_INIT(FRAGP) \
206 do \
207 { \
208 (FRAGP)->tc_frag_data.opc_frag = sh64_last_insn_frag; \
209 (FRAGP)->tc_frag_data.isa = sh64_isa_mode; \
210 } \
211 while (0)
212
213/* This variable is set whenever we generate (or grow) a new opcode frag
214 in shmedia_build_Mytes. */
215extern fragS *sh64_last_insn_frag;
216
217#define md_end() shmedia_md_end ()
8edc77b9 218void shmedia_md_end (void);
324bfcf3
AO
219
220/* Because we make .debug_line hold the SHmedia instruction address | 1,
221 we have to say we only have minimum byte-size insns. */
222#undef DWARF2_LINE_MIN_INSN_LENGTH
223#define DWARF2_LINE_MIN_INSN_LENGTH 1
c9cd7160
L
224
225#define TC_FAKE_LABEL(NAME) sh64_fake_label(NAME)
226extern int sh64_fake_label (const char *);