ns32k: remove dupplicate definition of input_line_pointer
[external/binutils.git] / bfd / elf32-nds32.h
1 /* NDS32-specific support for 32-bit ELF.
2    Copyright (C) 2012-2016 Free Software Foundation, Inc.
3    Contributed by Andes Technology Corporation.
4
5    This file is part of BFD, the Binary File Descriptor library.
6
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 3 of the License, or
10    (at your option) any later version.
11
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with this program; if not, write to the Free Software
19    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
20    02110-1301, USA.*/
21
22 #ifndef ELF32_NDS32_H
23 #define ELF32_NDS32_H
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29 /* Relocation flags encoded in r_addend.  */
30
31 /* Relocation flags for R_NDS32_ERLAX_ENTRY.  */
32
33 /* Set if relax on this section is done or disabled.  */
34 #define R_NDS32_RELAX_ENTRY_DISABLE_RELAX_FLAG                  (1 << 31)
35 /* Optimize for performance.  */
36 #define R_NDS32_RELAX_ENTRY_OPTIMIZE_FLAG                       (1 << 30)
37 /* Optimize for size.  Branch destination 4-byte adjustment
38    may be disabled.  */
39 #define R_NDS32_RELAX_ENTRY_OPTIMIZE_FOR_SPACE_FLAG             (1 << 29)
40 /* To distinguish the assembly code generated by compiler
41    or written manually.  */
42 #define R_NDS32_RELAX_ENTRY_VERBATIM_FLAG                       (1 << 28)
43 /* EX9 and link-time IFC must be explicitly enabled, so we
44    won't mess up handcraft assembly code.  */
45 /* Enable EX9 optimization for this section.  */
46 #define R_NDS32_RELAX_ENTRY_EX9_FLAG                            (1 << 2)
47 /* Enable IFC optimization for this section.  */
48 #define R_NDS32_RELAX_ENTRY_IFC_FLAG                            (1 << 3)
49
50
51 /* Relocation flags for R_NDS32_INSN16.  */
52
53 /* Tag the nop16 can be removed.  */
54 #define R_NDS32_INSN16_CONVERT_FLAG                             (1 << 0)
55 /* Convert a gp-relative access (e.g., lwi.gp)
56    to fp-as-gp access (lwi37.fp).
57    This value is used by linker internally only.
58    It's fine to change the vlaue.  */
59 #define R_NDS32_INSN16_FP7U2_FLAG                               (1 << 1)
60
61 /* Relocation flags for R_NDS32_RELAX_REGION_OMIT_FP_START/END.  */
62
63 /* OMIT_FP_FLAG marks the region for applying fp-as-gp
64    optimization.  */
65 #define R_NDS32_RELAX_REGION_OMIT_FP_FLAG                       (1 << 0)
66 /* NOT_OMIT_FP_FLAG is set if this region is not worth
67    for fp-as-gp.  */
68 #define R_NDS32_RELAX_REGION_NOT_OMIT_FP_FLAG                   (1 << 1)
69 /* Suppress EX9 optimization in the region.  */
70 #define R_NDS32_RELAX_REGION_NO_EX9_FLAG                        (1 << 2)
71 /* A Innermost loop region.  Some optimizations is suppressed
72    in this region due to performance drop.  */
73 #define R_NDS32_RELAX_REGION_INNERMOST_LOOP_FLAG                (1 << 4)
74
75 /* Tag range for LOADSTORE relocation.  */
76 enum
77 {
78   NDS32_LOADSTORE_NONE = 0x0,
79   NDS32_LOADSTORE_BYTE = 0x1,
80   NDS32_LOADSTORE_HALF = 0x2,
81   NDS32_LOADSTORE_WORD = 0x4,
82   NDS32_LOADSTORE_FLOAT_S = 0x8,
83   NDS32_LOADSTORE_FLOAT_D = 0x10,
84   NDS32_LOADSTORE_IMM = 0x20
85 };
86
87 /* Relax tag for nds32_elf_relax_section, we have to specify which
88    optimization do in this round.  */
89 enum
90 {
91   NDS32_RELAX_NONE_ROUND = 0,
92   NDS32_RELAX_NORMAL_ROUND,
93   NDS32_RELAX_JUMP_IFC_ROUND,
94   NDS32_RELAX_EX9_BUILD_ROUND,
95   NDS32_RELAX_EX9_REPLACE_ROUND,
96   NDS32_RELAX_EMPTY_ROUND
97 };
98
99 /* Optimization status mask.  */
100 #define NDS32_RELAX_JUMP_IFC_DONE       (1 << 0)
101 #define NDS32_RELAX_EX9_DONE            (1 << 1)
102
103 /* Optimization turn on mask.  */
104 #define NDS32_RELAX_JUMP_IFC_ON         (1 << 0)
105 #define NDS32_RELAX_EX9_ON              (1 << 1)
106 \f
107 extern void nds32_insertion_sort
108   (void *, size_t, size_t, int (*) (const void *, const void *));
109
110 extern int         nds32_elf_ex9_init (void);
111 extern int         nds32_convert_32_to_16 (bfd *, uint32_t, uint16_t *, int *);
112 extern int         nds32_convert_16_to_32 (bfd *, uint16_t, uint32_t *);
113 extern void        bfd_elf32_nds32_set_target_option (struct bfd_link_info *,
114                                                       int, int, FILE *, int,
115                                                       int, int, int, FILE *,
116                                                       FILE *, int, int,
117                                                       bfd_boolean, bfd_boolean);
118
119 #define nds32_elf_hash_table(info) \
120   (elf_hash_table_id ((struct elf_link_hash_table *) ((info)->hash)) \
121    == NDS32_ELF_DATA ? \
122    ((struct elf_nds32_link_hash_table *) ((info)->hash)) : NULL)
123
124 /* Hash table structure for target nds32.  There are some members to
125    save target options passed from nds32elf.em to bfd.  */
126
127 struct elf_nds32_link_hash_table
128 {
129   struct elf_link_hash_table root;
130
131   /* Short-cuts to get to dynamic linker sections.  */
132   asection *sgot;
133   asection *sgotplt;
134   asection *srelgot;
135   asection *splt;
136   asection *srelplt;
137   asection *sdynbss;
138   asection *srelbss;
139
140   /* Small local sym to section mapping cache.  */
141   struct sym_cache sym_cache;
142
143   /* Target dependent options.  */
144   int relax_fp_as_gp;           /* --mrelax-omit-fp  */
145   int eliminate_gc_relocs;      /* --meliminate-gc-relocs  */
146   FILE *sym_ld_script;          /* --mgen-symbol-ld-script=<file>  */
147   /* Disable if linking a dynamically linked executable.  */
148   int load_store_relax;
149   int target_optimize;          /* Switch optimization.  */
150   int relax_status;             /* Finished optimization.  */
151   int relax_round;              /* Going optimization.  */
152   FILE *ex9_export_file;        /* --mexport-ex9=<file>  */
153   FILE *ex9_import_file;        /* --mimport-ex9=<file>  */
154   int update_ex9_table;         /* --mupdate-ex9.  */
155   int ex9_limit;
156   bfd_boolean ex9_loop_aware;   /* Ignore ex9 if inside a loop.  */
157   bfd_boolean ifc_loop_aware;   /* Ignore ifc if inside a loop.  */
158 };
159
160 #ifdef __cplusplus
161 }
162 #endif
163
164 #endif