1440a403fSchristos /* tc-cris.h -- Header file for tc-cris.c, the CRIS GAS port.
2*b88e3e88Schristos    Copyright (C) 2000-2020 Free Software Foundation, Inc.
3440a403fSchristos 
4440a403fSchristos    Contributed by Axis Communications AB, Lund, Sweden.
5440a403fSchristos    Originally written for GAS 1.38.1 by Mikael Asker.
6440a403fSchristos    Updates, BFDizing, GNUifying and ELF by Hans-Peter Nilsson.
7440a403fSchristos 
8440a403fSchristos    This file is part of GAS, the GNU Assembler.
9440a403fSchristos 
10440a403fSchristos    GAS is free software; you can redistribute it and/or modify
11440a403fSchristos    it under the terms of the GNU General Public License as published by
12440a403fSchristos    the Free Software Foundation; either version 3, or (at your option)
13440a403fSchristos    any later version.
14440a403fSchristos 
15440a403fSchristos    GAS is distributed in the hope that it will be useful,
16440a403fSchristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
17440a403fSchristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18440a403fSchristos    GNU General Public License for more details.
19440a403fSchristos 
20440a403fSchristos    You should have received a copy of the GNU General Public License
21440a403fSchristos    along with GAS; see the file COPYING.  If not, write to the
22440a403fSchristos    Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston,
23440a403fSchristos    MA 02110-1301, USA.  */
24440a403fSchristos 
25440a403fSchristos /* See the GAS "internal" document for general documentation on this.
26440a403fSchristos    It is called internals.texi (internals.info when makeinfo:d), but is
27440a403fSchristos    not installed or makeinfo:d by "make info".  */
28440a403fSchristos 
29440a403fSchristos /* Functions and variables that aren't declared in tc.h are declared here,
30440a403fSchristos    with the type/prototype that is used in the local extern-declaration of
31440a403fSchristos    their usage.  */
32440a403fSchristos 
33440a403fSchristos #ifndef TC_CRIS
34440a403fSchristos #define TC_CRIS
35440a403fSchristos 
36440a403fSchristos /* Multi-target support is always on.  */
37440a403fSchristos extern const char *cris_target_format (void);
38440a403fSchristos #define TARGET_FORMAT cris_target_format ()
39440a403fSchristos 
40440a403fSchristos #define TARGET_ARCH bfd_arch_cris
41440a403fSchristos 
42440a403fSchristos extern unsigned int cris_mach (void);
43440a403fSchristos #define TARGET_MACH (cris_mach ())
44440a403fSchristos 
45440a403fSchristos #define TARGET_BYTES_BIG_ENDIAN 0
46440a403fSchristos 
47440a403fSchristos extern const char *md_shortopts;
48440a403fSchristos extern struct option md_longopts[];
49440a403fSchristos extern size_t md_longopts_size;
50440a403fSchristos 
51440a403fSchristos extern const pseudo_typeS md_pseudo_table[];
52440a403fSchristos 
53440a403fSchristos #define tc_comment_chars cris_comment_chars
54440a403fSchristos extern const char cris_comment_chars[];
55440a403fSchristos extern const char line_comment_chars[];
56440a403fSchristos extern const char line_separator_chars[];
57440a403fSchristos 
58440a403fSchristos /* This should be optional, since it is ignored as an escape (assumed to
59440a403fSchristos    be itself) if it is not recognized.  */
60440a403fSchristos #define ONLY_STANDARD_ESCAPES
61440a403fSchristos 
62440a403fSchristos /* Note that we do not define TC_EQUAL_IN_INSN, since its current use is
63440a403fSchristos    in the instruction rather than the operand, and thus does not come to
64440a403fSchristos    use for side-effect assignments such as "and.d [r0 = r1 + 42], r3".  */
65440a403fSchristos #define md_operand(x)
66440a403fSchristos 
67440a403fSchristos #define md_number_to_chars number_to_chars_littleendian
68440a403fSchristos extern const struct relax_type md_cris_relax_table[];
69440a403fSchristos #define TC_GENERIC_RELAX_TABLE md_cris_relax_table
70440a403fSchristos 
71440a403fSchristos long cris_relax_frag (segT, fragS *, long);
72440a403fSchristos 
73440a403fSchristos /* GAS only handles relaxations for pc-relative data targeting addresses
74440a403fSchristos    in the same segment, so we have to handle the rest on our own.  */
75440a403fSchristos #define md_relax_frag(SEG, FRAGP, STRETCH)		\
76440a403fSchristos  ((FRAGP)->fr_symbol != NULL				\
77440a403fSchristos   && S_GET_SEGMENT ((FRAGP)->fr_symbol) == (SEG)	\
78440a403fSchristos   ? relax_frag (SEG, FRAGP, STRETCH)			\
79440a403fSchristos   : cris_relax_frag (SEG, FRAGP, STRETCH))
80440a403fSchristos 
81440a403fSchristos #define TC_FORCE_RELOCATION(FIX) md_cris_force_relocation (FIX)
82440a403fSchristos extern int md_cris_force_relocation (struct fix *);
83440a403fSchristos 
84440a403fSchristos #define IS_CRIS_PIC_RELOC(RTYPE)			\
85440a403fSchristos   ((RTYPE) == BFD_RELOC_CRIS_16_GOT			\
86440a403fSchristos    || (RTYPE) == BFD_RELOC_CRIS_32_GOT			\
87440a403fSchristos    || (RTYPE) == BFD_RELOC_CRIS_16_GOTPLT		\
88440a403fSchristos    || (RTYPE) == BFD_RELOC_CRIS_32_GOTPLT		\
89440a403fSchristos    || (RTYPE) == BFD_RELOC_CRIS_32_GOTREL		\
90440a403fSchristos    || (RTYPE) == BFD_RELOC_CRIS_32_PLT_GOTREL		\
91440a403fSchristos    || (RTYPE) == BFD_RELOC_CRIS_32_PLT_PCREL)
92440a403fSchristos 
93440a403fSchristos /* Make sure we don't resolve fixups for which we want to emit dynamic
94440a403fSchristos    relocations.  */
95440a403fSchristos #define TC_FORCE_RELOCATION_LOCAL(FIX)			\
9606324dcfSchristos   (GENERIC_FORCE_RELOCATION_LOCAL (FIX)			\
9706324dcfSchristos    || IS_CRIS_PIC_RELOC ((FIX)->fx_r_type))
98440a403fSchristos 
99440a403fSchristos /* For some reloc types, don't adjust fixups by reducing to a section
100440a403fSchristos    symbol.  */
101440a403fSchristos #define tc_fix_adjustable(FIX)				\
102440a403fSchristos  ((FIX)->fx_r_type != BFD_RELOC_VTABLE_INHERIT		\
103440a403fSchristos   && (FIX)->fx_r_type != BFD_RELOC_VTABLE_ENTRY		\
104440a403fSchristos   && (! IS_CRIS_PIC_RELOC ((FIX)->fx_r_type)		\
105440a403fSchristos       || (FIX)->fx_r_type == BFD_RELOC_CRIS_32_GOTREL))
106440a403fSchristos 
107440a403fSchristos /* FIXME: This *should* be a redundant definition, as the
108440a403fSchristos    TC_FORCE_RELOCATION* definitions already told about the cases where
109440a403fSchristos    we *don't* want the symbol value calculated.  Here we seem to answer
110440a403fSchristos    the "are you sure" question.  It certainly has very little to do with
111440a403fSchristos    whether the symbol value is passed to md_apply_fix.  */
112440a403fSchristos #define MD_APPLY_SYM_VALUE(FIX) 0
113440a403fSchristos 
114440a403fSchristos /* When we have fixups against constant expressions, we get a GAS-specific
115440a403fSchristos    section symbol at no extra charge for obscure reasons in
116440a403fSchristos    adjust_reloc_syms.  Since ELF outputs section symbols, it gladly
117440a403fSchristos    outputs this "*ABS*" symbol in every object.  Avoid that.
118440a403fSchristos    Also, don't emit undefined symbols (that aren't used in relocations).
119440a403fSchristos    They pop up when tentatively parsing register names as symbols.  */
120440a403fSchristos #define tc_frob_symbol(symp, punt)			\
121440a403fSchristos  do {							\
122440a403fSchristos   if ((OUTPUT_FLAVOR == bfd_target_elf_flavour		\
123440a403fSchristos        && (symp) == section_symbol (absolute_section))	\
124440a403fSchristos       || ! S_IS_DEFINED (symp))				\
125440a403fSchristos     (punt) = 1;						\
126440a403fSchristos  } while (0)
127440a403fSchristos 
128440a403fSchristos #define LISTING_HEADER "GAS for CRIS"
129440a403fSchristos 
130440a403fSchristos #if 0
131440a403fSchristos /* The testsuite does not let me define these, although they IMHO should
132440a403fSchristos    be preferred over the default.  */
133440a403fSchristos #define LISTING_WORD_SIZE 2
134440a403fSchristos #define LISTING_LHS_WIDTH 4
135440a403fSchristos #define LISTING_LHS_WIDTH_SECOND 4
136440a403fSchristos #endif
137440a403fSchristos 
138440a403fSchristos /* END of declaration and definitions described in the "internals"
139440a403fSchristos    document.  */
140440a403fSchristos 
141440a403fSchristos /* Do this, or we will never know what hit us when the
142440a403fSchristos    broken-word-fixes break.  Do _not_ use WARN_SIGNED_OVERFLOW_WORD,
143440a403fSchristos    it is only for use with WORKING_DOT_WORD and warns about most stuff.
144440a403fSchristos    (still in 2.9.1).  */
145440a403fSchristos struct broken_word;
146440a403fSchristos extern void tc_cris_check_adjusted_broken_word (offsetT,
147440a403fSchristos 						struct broken_word *);
148440a403fSchristos #define TC_CHECK_ADJUSTED_BROKEN_DOT_WORD(new_offset, brokw) \
149440a403fSchristos  tc_cris_check_adjusted_broken_word ((offsetT) (new_offset), brokw)
150440a403fSchristos 
151440a403fSchristos /* We don't want any implicit alignment, so we do nothing.  */
152440a403fSchristos #define TC_IMPLICIT_LCOMM_ALIGNMENT(SIZE, P2VAR) do { } while (0)
153440a403fSchristos 
154440a403fSchristos /* CRIS instructions, with operands and prefixes included, are a multiple
155440a403fSchristos    of two bytes long.  */
156440a403fSchristos #define DWARF2_LINE_MIN_INSN_LENGTH 2
157440a403fSchristos 
158440a403fSchristos /* Make port immune to unwanted difference in te-generic.h vs. te-linux.h.  */
159440a403fSchristos #define LOCAL_LABELS_DOLLAR 1
160440a403fSchristos 
161440a403fSchristos #endif /* TC_CRIS */
162440a403fSchristos /*
163440a403fSchristos  * Local variables:
164440a403fSchristos  * eval: (c-set-style "gnu")
165440a403fSchristos  * indent-tabs-mode: t
166440a403fSchristos  * End:
167440a403fSchristos  */
168