xref: /openbsd/gnu/usr.bin/binutils/gas/config/tc-frv.h (revision cf2f2c56)
1d2201f2fSdrahn /* tc-frv.h -- Header file for tc-frv.c.
2d2201f2fSdrahn    Copyright 2002 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
18d2201f2fSdrahn    the Free Software Foundation, 59 Temple Place - Suite 330,
19d2201f2fSdrahn    Boston, MA 02111-1307, USA. */
20d2201f2fSdrahn 
21d2201f2fSdrahn #define TC_FRV
22d2201f2fSdrahn 
23d2201f2fSdrahn #ifndef BFD_ASSEMBLER
24d2201f2fSdrahn /* leading space so will compile with cc */
25d2201f2fSdrahn  #error FRV support requires BFD_ASSEMBLER
26d2201f2fSdrahn #endif
27d2201f2fSdrahn 
28d2201f2fSdrahn #define LISTING_HEADER "FRV GAS "
29d2201f2fSdrahn 
30d2201f2fSdrahn /* The target BFD architecture.  */
31d2201f2fSdrahn #define TARGET_ARCH bfd_arch_frv
32d2201f2fSdrahn 
33*cf2f2c56Smiod #define TARGET_FORMAT (frv_md_fdpic_enabled () \
34*cf2f2c56Smiod 		       ? "elf32-frvfdpic" : "elf32-frv")
35*cf2f2c56Smiod extern bfd_boolean frv_md_fdpic_enabled (void);
36d2201f2fSdrahn 
37d2201f2fSdrahn #define TARGET_BYTES_BIG_ENDIAN 1
38d2201f2fSdrahn 
39d2201f2fSdrahn /* Permit temporary numeric labels.  */
40d2201f2fSdrahn #define LOCAL_LABELS_FB 1
41d2201f2fSdrahn 
42d2201f2fSdrahn #define DIFF_EXPR_OK		/* .-foo gets turned into PC relative relocs */
43d2201f2fSdrahn 
44d2201f2fSdrahn /* We don't need to handle .word strangely.  */
45d2201f2fSdrahn #define WORKING_DOT_WORD
46d2201f2fSdrahn 
47d2201f2fSdrahn /* Values passed to md_apply_fix3 don't include the symbol value.  */
48d2201f2fSdrahn #define MD_APPLY_SYM_VALUE(FIX) 0
49d2201f2fSdrahn 
50d2201f2fSdrahn extern void frv_tomcat_workaround PARAMS ((void));
51d2201f2fSdrahn #define md_cleanup frv_tomcat_workaround
52d2201f2fSdrahn 
53d2201f2fSdrahn #define md_number_to_chars frv_md_number_to_chars
54d2201f2fSdrahn 
55d2201f2fSdrahn extern long frv_relax_frag PARAMS ((fragS *, long));
56d2201f2fSdrahn #define md_relax_frag(segment, fragP, stretch) frv_relax_frag(fragP, stretch)
57d2201f2fSdrahn 
58d2201f2fSdrahn #define tc_fix_adjustable(FIX) frv_fix_adjustable (FIX)
59d2201f2fSdrahn struct fix;
60d2201f2fSdrahn extern bfd_boolean frv_fix_adjustable PARAMS ((struct fix *));
61d2201f2fSdrahn 
62d2201f2fSdrahn /* When relaxing, we need to emit various relocs we otherwise wouldn't.  */
63d2201f2fSdrahn #define TC_FORCE_RELOCATION(fix) frv_force_relocation (fix)
64d2201f2fSdrahn extern int frv_force_relocation PARAMS ((struct fix *));
65d2201f2fSdrahn 
66*cf2f2c56Smiod /* If we simplify subtractions that aren't SUB_SAME or SUB_ABS, we end
67*cf2f2c56Smiod    up with PCrel fixups, but since we don't have any PCrel relocs, we
68*cf2f2c56Smiod    crash.  Preventing simplification gets us a good, early error.  */
69*cf2f2c56Smiod #define TC_FORCE_RELOCATION_SUB_LOCAL(fixP) 1
70*cf2f2c56Smiod 
71d2201f2fSdrahn #undef GAS_CGEN_MAX_FIXUPS
72d2201f2fSdrahn #define GAS_CGEN_MAX_FIXUPS 1
73d2201f2fSdrahn 
74d2201f2fSdrahn void frv_frob_label PARAMS ((symbolS *));
75d2201f2fSdrahn #define tc_frob_label(sym) frv_frob_label(sym)
76d2201f2fSdrahn 
77d2201f2fSdrahn #define tc_gen_reloc gas_cgen_tc_gen_reloc
78d2201f2fSdrahn 
79d2201f2fSdrahn #define md_cgen_record_fixup_exp frv_cgen_record_fixup_exp
80d2201f2fSdrahn 
81d2201f2fSdrahn /* Call md_pcrel_from_section(), not md_pcrel_from().  */
82d2201f2fSdrahn #define MD_PCREL_FROM_SECTION(FIX, SEC) md_pcrel_from_section (FIX, SEC)
83d2201f2fSdrahn extern long md_pcrel_from_section PARAMS ((struct fix *, segT));
84d2201f2fSdrahn 
85d2201f2fSdrahn /* After all of the symbols have been adjusted, go over the file looking
86d2201f2fSdrahn    for any relocations that pic won't support.  */
87d2201f2fSdrahn #define tc_frob_file() frv_frob_file ()
88d2201f2fSdrahn extern void frv_frob_file	PARAMS ((void));
89*cf2f2c56Smiod 
90*cf2f2c56Smiod /* We don't want 0x00 for code alignment because this generates `add.p
91*cf2f2c56Smiod    gr0, gr0, gr0' patterns.  Although it's fine as a nop instruction,
92*cf2f2c56Smiod    it has the VLIW packing bit set, which means if you have a bunch of
93*cf2f2c56Smiod    them in a row and attempt to execute them, you'll exceed the VLIW
94*cf2f2c56Smiod    capacity and fail.  This also gets GDB confused sometimes, because
95*cf2f2c56Smiod    it won't set breakpoints in instructions other than the first of a
96*cf2f2c56Smiod    VLIW pack, so you used to be unable to set a breakpoint in the
97*cf2f2c56Smiod    initial instruction of a function that followed such
98*cf2f2c56Smiod    alignment-introduced instructions.
99*cf2f2c56Smiod 
100*cf2f2c56Smiod    We could have arranged to emit `nop' instructions (0x80880000),
101*cf2f2c56Smiod    maybe even VLIW-pack sequences of nop instructions as much as
102*cf2f2c56Smiod    possible for the selected machine type, just in case the alignment
103*cf2f2c56Smiod    code actually happens to run, but this is probably too much effort
104*cf2f2c56Smiod    for little gain.  This code is not meant to be run anyway, so just
105*cf2f2c56Smiod    emit nops.  */
106*cf2f2c56Smiod #define MAX_MEM_FOR_RS_ALIGN_CODE (3 + 4)
107*cf2f2c56Smiod #define HANDLE_ALIGN(FRAGP) do						\
108*cf2f2c56Smiod   if ((FRAGP)->fr_type == rs_align_code) 				\
109*cf2f2c56Smiod     {									\
110*cf2f2c56Smiod       valueT count = ((FRAGP)->fr_next->fr_address			\
111*cf2f2c56Smiod 		      - ((FRAGP)->fr_address + (FRAGP)->fr_fix));	\
112*cf2f2c56Smiod       unsigned char *dest = (FRAGP)->fr_literal + (FRAGP)->fr_fix;	\
113*cf2f2c56Smiod       if ((count & 3) != 0)						\
114*cf2f2c56Smiod 	{								\
115*cf2f2c56Smiod 	  memset (dest, 0, (count & 3));				\
116*cf2f2c56Smiod 	  (FRAGP)->fr_fix += (count & 3);				\
117*cf2f2c56Smiod 	  dest += (count & 3);						\
118*cf2f2c56Smiod 	  count -= (count & 3);						\
119*cf2f2c56Smiod 	}								\
120*cf2f2c56Smiod       if (count)							\
121*cf2f2c56Smiod 	{								\
122*cf2f2c56Smiod 	  (FRAGP)->fr_var = 4;						\
123*cf2f2c56Smiod 	  *dest++ = 0x80;						\
124*cf2f2c56Smiod 	  *dest++ = 0x88;						\
125*cf2f2c56Smiod 	  *dest++ = 0x00;						\
126*cf2f2c56Smiod 	  *dest++ = 0x00;						\
127*cf2f2c56Smiod 	}								\
128*cf2f2c56Smiod     }									\
129*cf2f2c56Smiod  while (0)
130