xref: /openbsd-src/gnu/usr.bin/binutils/gas/config/tc-xtensa.h (revision cf2f2c5620d6d9a4fd01930983c4b9a1f76d7aa3)
1d2201f2fSdrahn /* tc-xtensa.h -- Header file for tc-xtensa.c.
2d2201f2fSdrahn    Copyright (C) 2003 Free Software Foundation, Inc.
3d2201f2fSdrahn 
4d2201f2fSdrahn    This file is part of GAS, the GNU Assembler.
5d2201f2fSdrahn 
6d2201f2fSdrahn    GAS is free software; you can redistribute it and/or modify
7d2201f2fSdrahn    it under the terms of the GNU General Public License as published by
8d2201f2fSdrahn    the Free Software Foundation; either version 2, or (at your option)
9d2201f2fSdrahn    any later version.
10d2201f2fSdrahn 
11d2201f2fSdrahn    GAS is distributed in the hope that it will be useful,
12d2201f2fSdrahn    but WITHOUT ANY WARRANTY; without even the implied warranty of
13d2201f2fSdrahn    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14d2201f2fSdrahn    GNU General Public License for more details.
15d2201f2fSdrahn 
16d2201f2fSdrahn    You should have received a copy of the GNU General Public License
17d2201f2fSdrahn    along with GAS; see the file COPYING.  If not, write to the Free
18d2201f2fSdrahn    Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19d2201f2fSdrahn    02111-1307, USA.  */
20d2201f2fSdrahn 
21d2201f2fSdrahn #ifndef TC_XTENSA
22d2201f2fSdrahn #define TC_XTENSA 1
23d2201f2fSdrahn 
24d2201f2fSdrahn #ifdef ANSI_PROTOTYPES
25d2201f2fSdrahn struct fix;
26d2201f2fSdrahn #endif
27d2201f2fSdrahn 
28d2201f2fSdrahn #ifndef BFD_ASSEMBLER
29d2201f2fSdrahn #error Xtensa support requires BFD_ASSEMBLER
30d2201f2fSdrahn #endif
31d2201f2fSdrahn 
32d2201f2fSdrahn #ifndef OBJ_ELF
33d2201f2fSdrahn #error Xtensa support requires ELF object format
34d2201f2fSdrahn #endif
35d2201f2fSdrahn 
36d2201f2fSdrahn #include "xtensa-config.h"
37d2201f2fSdrahn 
38d2201f2fSdrahn #define TARGET_BYTES_BIG_ENDIAN XCHAL_HAVE_BE
39d2201f2fSdrahn 
40d2201f2fSdrahn 
41d2201f2fSdrahn struct xtensa_frag_type
42d2201f2fSdrahn {
43d2201f2fSdrahn   unsigned is_literal:1;
44d2201f2fSdrahn   unsigned is_text:1;
45d2201f2fSdrahn   unsigned is_loop_target:1;
46d2201f2fSdrahn   unsigned is_branch_target:1;
47d2201f2fSdrahn   unsigned is_insn:1;
48d2201f2fSdrahn 
49d2201f2fSdrahn   /* Info about the current state of assembly, i.e., density, relax,
50d2201f2fSdrahn      generics, freeregs, longcalls.  These need to be passed to the
51d2201f2fSdrahn      backend and then to the linking file.  */
52d2201f2fSdrahn 
53d2201f2fSdrahn   unsigned is_no_density:1;
54d2201f2fSdrahn   unsigned is_relax:1;
55d2201f2fSdrahn   unsigned is_generics:1;
56d2201f2fSdrahn   unsigned is_longcalls:1;
57d2201f2fSdrahn 
58d2201f2fSdrahn   /* For text fragments that can generate literals at relax time, this
59d2201f2fSdrahn      variable points to the frag where the literal will be stored.  For
60d2201f2fSdrahn      literal frags, this variable points to the nearest literal pool
61d2201f2fSdrahn      location frag.  This literal frag will be moved to after this
62d2201f2fSdrahn      location.  */
63d2201f2fSdrahn 
64d2201f2fSdrahn   fragS *literal_frag;
65d2201f2fSdrahn 
66d2201f2fSdrahn   /* The destination segment for literal frags.  (Note that this is only
67d2201f2fSdrahn      valid after xtensa_move_literals.  */
68d2201f2fSdrahn 
69d2201f2fSdrahn   segT lit_seg;
70d2201f2fSdrahn 
71d2201f2fSdrahn   /* For the relaxation scheme, some literal fragments can have their
72d2201f2fSdrahn      expansions modified by an instruction that relaxes.  */
73d2201f2fSdrahn 
74d2201f2fSdrahn   unsigned text_expansion;
75d2201f2fSdrahn   unsigned literal_expansion;
76d2201f2fSdrahn   unsigned unreported_expansion;
77d2201f2fSdrahn };
78d2201f2fSdrahn 
79d2201f2fSdrahn typedef struct xtensa_block_info_struct
80d2201f2fSdrahn {
81d2201f2fSdrahn   segT sec;
82d2201f2fSdrahn   bfd_vma offset;
83d2201f2fSdrahn   size_t size;
84d2201f2fSdrahn   struct xtensa_block_info_struct *next;
85d2201f2fSdrahn } xtensa_block_info;
86d2201f2fSdrahn 
87d2201f2fSdrahn typedef enum
88d2201f2fSdrahn {
89d2201f2fSdrahn   xt_insn_sec,
90d2201f2fSdrahn   xt_literal_sec,
91d2201f2fSdrahn   max_xt_sec
92d2201f2fSdrahn } xt_section_type;
93d2201f2fSdrahn 
94d2201f2fSdrahn typedef struct xtensa_segment_info_struct
95d2201f2fSdrahn {
96d2201f2fSdrahn   fragS *literal_pool_loc;
97d2201f2fSdrahn   xtensa_block_info *blocks[max_xt_sec];
98d2201f2fSdrahn } xtensa_segment_info;
99d2201f2fSdrahn 
100d2201f2fSdrahn typedef struct xtensa_symfield_type_struct
101d2201f2fSdrahn {
102d2201f2fSdrahn   unsigned int plt : 1;
103*cf2f2c56Smiod   unsigned int is_loop_target : 1;
104*cf2f2c56Smiod   unsigned int is_branch_target : 1;
105d2201f2fSdrahn } xtensa_symfield_type;
106d2201f2fSdrahn 
107d2201f2fSdrahn 
108d2201f2fSdrahn /* Section renaming is only supported in Tensilica's version of GAS.  */
109d2201f2fSdrahn #define XTENSA_SECTION_RENAME 1
110d2201f2fSdrahn #ifdef  XTENSA_SECTION_RENAME
111d2201f2fSdrahn extern const char *xtensa_section_rename
112d2201f2fSdrahn   PARAMS ((const char *));
113d2201f2fSdrahn #else
114d2201f2fSdrahn /* Tensilica's section renaming feature is not included here.  */
115d2201f2fSdrahn #define xtensa_section_rename(name)	(name)
116d2201f2fSdrahn #endif /* XTENSA_SECTION_RENAME */
117d2201f2fSdrahn 
118d2201f2fSdrahn 
119d2201f2fSdrahn extern const char *xtensa_target_format
120d2201f2fSdrahn   PARAMS ((void));
121d2201f2fSdrahn extern void xtensa_frag_init
122d2201f2fSdrahn   PARAMS ((fragS *));
123d2201f2fSdrahn extern void xtensa_cons_fix_new
124d2201f2fSdrahn   PARAMS ((fragS *, int, int, expressionS *));
125d2201f2fSdrahn extern void xtensa_frob_label
126d2201f2fSdrahn   PARAMS ((struct symbol *));
127d2201f2fSdrahn extern void xtensa_end
128d2201f2fSdrahn   PARAMS ((void));
129d2201f2fSdrahn extern void xtensa_post_relax_hook
130d2201f2fSdrahn   PARAMS ((void));
131d2201f2fSdrahn extern void xtensa_file_arch_init
132d2201f2fSdrahn   PARAMS ((bfd *));
133d2201f2fSdrahn extern void xtensa_flush_pending_output
134d2201f2fSdrahn   PARAMS ((void));
135d2201f2fSdrahn extern bfd_boolean xtensa_fix_adjustable
136d2201f2fSdrahn   PARAMS ((struct fix *));
137d2201f2fSdrahn extern void xtensa_symbol_new_hook
138d2201f2fSdrahn   PARAMS ((symbolS *));
139d2201f2fSdrahn extern long xtensa_relax_frag
140d2201f2fSdrahn   PARAMS ((fragS *, long, int *));
141d2201f2fSdrahn 
142d2201f2fSdrahn #define TARGET_FORMAT			xtensa_target_format ()
143d2201f2fSdrahn #define TARGET_ARCH			bfd_arch_xtensa
144d2201f2fSdrahn #define TC_SEGMENT_INFO_TYPE		xtensa_segment_info
145d2201f2fSdrahn #define TC_SYMFIELD_TYPE		xtensa_symfield_type
146d2201f2fSdrahn #define TC_FRAG_TYPE			struct xtensa_frag_type
147d2201f2fSdrahn #define TC_FRAG_INIT(frag)		xtensa_frag_init (frag)
148d2201f2fSdrahn #define TC_CONS_FIX_NEW			xtensa_cons_fix_new
149d2201f2fSdrahn #define tc_canonicalize_symbol_name(s)	xtensa_section_rename (s)
150d2201f2fSdrahn #define tc_init_after_args()		xtensa_file_arch_init (stdoutput)
151d2201f2fSdrahn #define tc_fix_adjustable(fix)		xtensa_fix_adjustable (fix)
152d2201f2fSdrahn #define tc_frob_label(sym)		xtensa_frob_label (sym)
153d2201f2fSdrahn #define tc_symbol_new_hook(s)		xtensa_symbol_new_hook (s)
154d2201f2fSdrahn #define md_elf_section_rename(name)	xtensa_section_rename (name)
155d2201f2fSdrahn #define md_end				xtensa_end
156d2201f2fSdrahn #define md_flush_pending_output()	xtensa_flush_pending_output ()
157d2201f2fSdrahn #define md_operand(x)
158d2201f2fSdrahn #define TEXT_SECTION_NAME		xtensa_section_rename (".text")
159d2201f2fSdrahn #define DATA_SECTION_NAME		xtensa_section_rename (".data")
160d2201f2fSdrahn #define BSS_SECTION_NAME		xtensa_section_rename (".bss")
161d2201f2fSdrahn 
162d2201f2fSdrahn 
163d2201f2fSdrahn /* The renumber_section function must be mapped over all the sections
164d2201f2fSdrahn    after calling xtensa_post_relax_hook.  That function is static in
165d2201f2fSdrahn    write.c so it cannot be called from xtensa_post_relax_hook itself.  */
166d2201f2fSdrahn 
167d2201f2fSdrahn #define md_post_relax_hook \
168d2201f2fSdrahn   do \
169d2201f2fSdrahn     { \
170d2201f2fSdrahn       int i = 0; \
171d2201f2fSdrahn       xtensa_post_relax_hook (); \
172d2201f2fSdrahn       bfd_map_over_sections (stdoutput, renumber_sections, &i); \
173d2201f2fSdrahn     } \
174d2201f2fSdrahn   while (0)
175d2201f2fSdrahn 
176d2201f2fSdrahn 
177d2201f2fSdrahn /* Because xtensa relaxation can insert a new literal into the middle of
178d2201f2fSdrahn    fragment and thus require re-running the relaxation pass on the
179d2201f2fSdrahn    section, we need an explicit flag here.  We explicitly use the name
180d2201f2fSdrahn    "stretched" here to avoid changing the source code in write.c.  */
181d2201f2fSdrahn 
182d2201f2fSdrahn #define md_relax_frag(segment, fragP, stretch) \
183d2201f2fSdrahn   xtensa_relax_frag (fragP, stretch, &stretched)
184d2201f2fSdrahn 
185d2201f2fSdrahn 
186d2201f2fSdrahn #define LOCAL_LABELS_FB 1
187d2201f2fSdrahn #define WORKING_DOT_WORD 1
188d2201f2fSdrahn #define DOUBLESLASH_LINE_COMMENTS
189d2201f2fSdrahn #define TC_HANDLES_FX_DONE
190d2201f2fSdrahn #define TC_FINALIZE_SYMS_BEFORE_SIZE_SEG 0
191d2201f2fSdrahn 
192d2201f2fSdrahn #define MD_APPLY_SYM_VALUE(FIX) 0
193d2201f2fSdrahn 
194d2201f2fSdrahn #endif /* TC_XTENSA */
195