xref: /netbsd/external/gpl3/gdb/dist/gas/config/tc-cris.h (revision 1424dfb3)
1*1424dfb3Schristos /* tc-cris.h -- Header file for tc-cris.c, the CRIS GAS port.
2*1424dfb3Schristos    Copyright (C) 2000-2020 Free Software Foundation, Inc.
3*1424dfb3Schristos 
4*1424dfb3Schristos    Contributed by Axis Communications AB, Lund, Sweden.
5*1424dfb3Schristos    Originally written for GAS 1.38.1 by Mikael Asker.
6*1424dfb3Schristos    Updates, BFDizing, GNUifying and ELF by Hans-Peter Nilsson.
7*1424dfb3Schristos 
8*1424dfb3Schristos    This file is part of GAS, the GNU Assembler.
9*1424dfb3Schristos 
10*1424dfb3Schristos    GAS is free software; you can redistribute it and/or modify
11*1424dfb3Schristos    it under the terms of the GNU General Public License as published by
12*1424dfb3Schristos    the Free Software Foundation; either version 3, or (at your option)
13*1424dfb3Schristos    any later version.
14*1424dfb3Schristos 
15*1424dfb3Schristos    GAS is distributed in the hope that it will be useful,
16*1424dfb3Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
17*1424dfb3Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*1424dfb3Schristos    GNU General Public License for more details.
19*1424dfb3Schristos 
20*1424dfb3Schristos    You should have received a copy of the GNU General Public License
21*1424dfb3Schristos    along with GAS; see the file COPYING.  If not, write to the
22*1424dfb3Schristos    Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston,
23*1424dfb3Schristos    MA 02110-1301, USA.  */
24*1424dfb3Schristos 
25*1424dfb3Schristos /* See the GAS "internal" document for general documentation on this.
26*1424dfb3Schristos    It is called internals.texi (internals.info when makeinfo:d), but is
27*1424dfb3Schristos    not installed or makeinfo:d by "make info".  */
28*1424dfb3Schristos 
29*1424dfb3Schristos /* Functions and variables that aren't declared in tc.h are declared here,
30*1424dfb3Schristos    with the type/prototype that is used in the local extern-declaration of
31*1424dfb3Schristos    their usage.  */
32*1424dfb3Schristos 
33*1424dfb3Schristos #ifndef TC_CRIS
34*1424dfb3Schristos #define TC_CRIS
35*1424dfb3Schristos 
36*1424dfb3Schristos /* Multi-target support is always on.  */
37*1424dfb3Schristos extern const char *cris_target_format (void);
38*1424dfb3Schristos #define TARGET_FORMAT cris_target_format ()
39*1424dfb3Schristos 
40*1424dfb3Schristos #define TARGET_ARCH bfd_arch_cris
41*1424dfb3Schristos 
42*1424dfb3Schristos extern unsigned int cris_mach (void);
43*1424dfb3Schristos #define TARGET_MACH (cris_mach ())
44*1424dfb3Schristos 
45*1424dfb3Schristos #define TARGET_BYTES_BIG_ENDIAN 0
46*1424dfb3Schristos 
47*1424dfb3Schristos extern const char *md_shortopts;
48*1424dfb3Schristos extern struct option md_longopts[];
49*1424dfb3Schristos extern size_t md_longopts_size;
50*1424dfb3Schristos 
51*1424dfb3Schristos extern const pseudo_typeS md_pseudo_table[];
52*1424dfb3Schristos 
53*1424dfb3Schristos #define tc_comment_chars cris_comment_chars
54*1424dfb3Schristos extern const char cris_comment_chars[];
55*1424dfb3Schristos extern const char line_comment_chars[];
56*1424dfb3Schristos extern const char line_separator_chars[];
57*1424dfb3Schristos 
58*1424dfb3Schristos /* This should be optional, since it is ignored as an escape (assumed to
59*1424dfb3Schristos    be itself) if it is not recognized.  */
60*1424dfb3Schristos #define ONLY_STANDARD_ESCAPES
61*1424dfb3Schristos 
62*1424dfb3Schristos /* Note that we do not define TC_EQUAL_IN_INSN, since its current use is
63*1424dfb3Schristos    in the instruction rather than the operand, and thus does not come to
64*1424dfb3Schristos    use for side-effect assignments such as "and.d [r0 = r1 + 42], r3".  */
65*1424dfb3Schristos #define md_operand(x)
66*1424dfb3Schristos 
67*1424dfb3Schristos #define md_number_to_chars number_to_chars_littleendian
68*1424dfb3Schristos extern const struct relax_type md_cris_relax_table[];
69*1424dfb3Schristos #define TC_GENERIC_RELAX_TABLE md_cris_relax_table
70*1424dfb3Schristos 
71*1424dfb3Schristos long cris_relax_frag (segT, fragS *, long);
72*1424dfb3Schristos 
73*1424dfb3Schristos /* GAS only handles relaxations for pc-relative data targeting addresses
74*1424dfb3Schristos    in the same segment, so we have to handle the rest on our own.  */
75*1424dfb3Schristos #define md_relax_frag(SEG, FRAGP, STRETCH)		\
76*1424dfb3Schristos  ((FRAGP)->fr_symbol != NULL				\
77*1424dfb3Schristos   && S_GET_SEGMENT ((FRAGP)->fr_symbol) == (SEG)	\
78*1424dfb3Schristos   ? relax_frag (SEG, FRAGP, STRETCH)			\
79*1424dfb3Schristos   : cris_relax_frag (SEG, FRAGP, STRETCH))
80*1424dfb3Schristos 
81*1424dfb3Schristos #define TC_FORCE_RELOCATION(FIX) md_cris_force_relocation (FIX)
82*1424dfb3Schristos extern int md_cris_force_relocation (struct fix *);
83*1424dfb3Schristos 
84*1424dfb3Schristos #define IS_CRIS_PIC_RELOC(RTYPE)			\
85*1424dfb3Schristos   ((RTYPE) == BFD_RELOC_CRIS_16_GOT			\
86*1424dfb3Schristos    || (RTYPE) == BFD_RELOC_CRIS_32_GOT			\
87*1424dfb3Schristos    || (RTYPE) == BFD_RELOC_CRIS_16_GOTPLT		\
88*1424dfb3Schristos    || (RTYPE) == BFD_RELOC_CRIS_32_GOTPLT		\
89*1424dfb3Schristos    || (RTYPE) == BFD_RELOC_CRIS_32_GOTREL		\
90*1424dfb3Schristos    || (RTYPE) == BFD_RELOC_CRIS_32_PLT_GOTREL		\
91*1424dfb3Schristos    || (RTYPE) == BFD_RELOC_CRIS_32_PLT_PCREL)
92*1424dfb3Schristos 
93*1424dfb3Schristos /* Make sure we don't resolve fixups for which we want to emit dynamic
94*1424dfb3Schristos    relocations.  */
95*1424dfb3Schristos #define TC_FORCE_RELOCATION_LOCAL(FIX)			\
96*1424dfb3Schristos   (GENERIC_FORCE_RELOCATION_LOCAL (FIX)			\
97*1424dfb3Schristos    || IS_CRIS_PIC_RELOC ((FIX)->fx_r_type))
98*1424dfb3Schristos 
99*1424dfb3Schristos /* For some reloc types, don't adjust fixups by reducing to a section
100*1424dfb3Schristos    symbol.  */
101*1424dfb3Schristos #define tc_fix_adjustable(FIX)				\
102*1424dfb3Schristos  ((FIX)->fx_r_type != BFD_RELOC_VTABLE_INHERIT		\
103*1424dfb3Schristos   && (FIX)->fx_r_type != BFD_RELOC_VTABLE_ENTRY		\
104*1424dfb3Schristos   && (! IS_CRIS_PIC_RELOC ((FIX)->fx_r_type)		\
105*1424dfb3Schristos       || (FIX)->fx_r_type == BFD_RELOC_CRIS_32_GOTREL))
106*1424dfb3Schristos 
107*1424dfb3Schristos /* FIXME: This *should* be a redundant definition, as the
108*1424dfb3Schristos    TC_FORCE_RELOCATION* definitions already told about the cases where
109*1424dfb3Schristos    we *don't* want the symbol value calculated.  Here we seem to answer
110*1424dfb3Schristos    the "are you sure" question.  It certainly has very little to do with
111*1424dfb3Schristos    whether the symbol value is passed to md_apply_fix.  */
112*1424dfb3Schristos #define MD_APPLY_SYM_VALUE(FIX) 0
113*1424dfb3Schristos 
114*1424dfb3Schristos /* When we have fixups against constant expressions, we get a GAS-specific
115*1424dfb3Schristos    section symbol at no extra charge for obscure reasons in
116*1424dfb3Schristos    adjust_reloc_syms.  Since ELF outputs section symbols, it gladly
117*1424dfb3Schristos    outputs this "*ABS*" symbol in every object.  Avoid that.
118*1424dfb3Schristos    Also, don't emit undefined symbols (that aren't used in relocations).
119*1424dfb3Schristos    They pop up when tentatively parsing register names as symbols.  */
120*1424dfb3Schristos #define tc_frob_symbol(symp, punt)			\
121*1424dfb3Schristos  do {							\
122*1424dfb3Schristos   if ((OUTPUT_FLAVOR == bfd_target_elf_flavour		\
123*1424dfb3Schristos        && (symp) == section_symbol (absolute_section))	\
124*1424dfb3Schristos       || ! S_IS_DEFINED (symp))				\
125*1424dfb3Schristos     (punt) = 1;						\
126*1424dfb3Schristos  } while (0)
127*1424dfb3Schristos 
128*1424dfb3Schristos #define LISTING_HEADER "GAS for CRIS"
129*1424dfb3Schristos 
130*1424dfb3Schristos #if 0
131*1424dfb3Schristos /* The testsuite does not let me define these, although they IMHO should
132*1424dfb3Schristos    be preferred over the default.  */
133*1424dfb3Schristos #define LISTING_WORD_SIZE 2
134*1424dfb3Schristos #define LISTING_LHS_WIDTH 4
135*1424dfb3Schristos #define LISTING_LHS_WIDTH_SECOND 4
136*1424dfb3Schristos #endif
137*1424dfb3Schristos 
138*1424dfb3Schristos /* END of declaration and definitions described in the "internals"
139*1424dfb3Schristos    document.  */
140*1424dfb3Schristos 
141*1424dfb3Schristos /* Do this, or we will never know what hit us when the
142*1424dfb3Schristos    broken-word-fixes break.  Do _not_ use WARN_SIGNED_OVERFLOW_WORD,
143*1424dfb3Schristos    it is only for use with WORKING_DOT_WORD and warns about most stuff.
144*1424dfb3Schristos    (still in 2.9.1).  */
145*1424dfb3Schristos struct broken_word;
146*1424dfb3Schristos extern void tc_cris_check_adjusted_broken_word (offsetT,
147*1424dfb3Schristos 						struct broken_word *);
148*1424dfb3Schristos #define TC_CHECK_ADJUSTED_BROKEN_DOT_WORD(new_offset, brokw) \
149*1424dfb3Schristos  tc_cris_check_adjusted_broken_word ((offsetT) (new_offset), brokw)
150*1424dfb3Schristos 
151*1424dfb3Schristos /* We don't want any implicit alignment, so we do nothing.  */
152*1424dfb3Schristos #define TC_IMPLICIT_LCOMM_ALIGNMENT(SIZE, P2VAR) do { } while (0)
153*1424dfb3Schristos 
154*1424dfb3Schristos /* CRIS instructions, with operands and prefixes included, are a multiple
155*1424dfb3Schristos    of two bytes long.  */
156*1424dfb3Schristos #define DWARF2_LINE_MIN_INSN_LENGTH 2
157*1424dfb3Schristos 
158*1424dfb3Schristos /* Make port immune to unwanted difference in te-generic.h vs. te-linux.h.  */
159*1424dfb3Schristos #define LOCAL_LABELS_DOLLAR 1
160*1424dfb3Schristos 
161*1424dfb3Schristos #endif /* TC_CRIS */
162*1424dfb3Schristos /*
163*1424dfb3Schristos  * Local variables:
164*1424dfb3Schristos  * eval: (c-set-style "gnu")
165*1424dfb3Schristos  * indent-tabs-mode: t
166*1424dfb3Schristos  * End:
167*1424dfb3Schristos  */
168