xref: /netbsd/external/gpl3/gdb/dist/gas/config/tc-nios2.h (revision 1424dfb3)
1*1424dfb3Schristos /* Definitions for Altera Nios II assembler.
2*1424dfb3Schristos    Copyright (C) 2012-2020 Free Software Foundation, Inc.
3*1424dfb3Schristos    Contributed by Nigel Gray (ngray@altera.com).
4*1424dfb3Schristos    Contributed by Mentor Graphics, Inc.
5*1424dfb3Schristos 
6*1424dfb3Schristos    This file is part of GAS, the GNU Assembler.
7*1424dfb3Schristos 
8*1424dfb3Schristos    GAS is free software; you can redistribute it and/or modify
9*1424dfb3Schristos    it under the terms of the GNU General Public License as published by
10*1424dfb3Schristos    the Free Software Foundation; either version 3, or (at your option)
11*1424dfb3Schristos    any later version.
12*1424dfb3Schristos 
13*1424dfb3Schristos    GAS is distributed in the hope that it will be useful,
14*1424dfb3Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
15*1424dfb3Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16*1424dfb3Schristos    GNU General Public License for more details.
17*1424dfb3Schristos 
18*1424dfb3Schristos    You should have received a copy of the GNU General Public License
19*1424dfb3Schristos    along with GAS; see the file COPYING.  If not, write to the Free
20*1424dfb3Schristos    Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
21*1424dfb3Schristos    02110-1301, USA.  */
22*1424dfb3Schristos 
23*1424dfb3Schristos #ifndef TC_NIOS2
24*1424dfb3Schristos #define TC_NIOS2
25*1424dfb3Schristos 
26*1424dfb3Schristos /* If unspecified, default to little endian.  We can explicitly specify
27*1424dfb3Schristos  * a big-endian default by configuring with --target=nios2eb-elf.  We
28*1424dfb3Schristos  * can override the default with the -EB and -EL options.  */
29*1424dfb3Schristos #ifndef TARGET_BYTES_BIG_ENDIAN
30*1424dfb3Schristos #define TARGET_BYTES_BIG_ENDIAN 0
31*1424dfb3Schristos #endif
32*1424dfb3Schristos 
33*1424dfb3Schristos /* Words are big enough to hold addresses.  */
34*1424dfb3Schristos #define WORKING_DOT_WORD	1
35*1424dfb3Schristos 
36*1424dfb3Schristos #ifdef OBJ_ELF
37*1424dfb3Schristos extern const char *nios2_target_format (void);
38*1424dfb3Schristos #define TARGET_FORMAT  nios2_target_format ()
39*1424dfb3Schristos #define TARGET_ARCH    bfd_arch_nios2
40*1424dfb3Schristos #endif
41*1424dfb3Schristos 
42*1424dfb3Schristos /* A NIOS2 instruction consists of tokens and separator characters
43*1424dfb3Schristos    the tokens are things like the instruction name (add, or jmp etc),
44*1424dfb3Schristos    the register indices ($5, $7 etc), and constant expressions. The
45*1424dfb3Schristos    separator characters are commas, brackets and space.
46*1424dfb3Schristos    The instruction name is always separated from other tokens by a space
47*1424dfb3Schristos    The maximum number of tokens in an instruction is 5 (the instruction name,
48*1424dfb3Schristos    3 arguments, and a 4th string representing the expected instruct in opcode
49*1424dfb3Schristos    after assembly. The latter is only used when the assemble is running in
50*1424dfb3Schristos    self test mode, otherwise its presence will generate an error.  */
51*1424dfb3Schristos #define NIOS2_MAX_INSN_TOKENS	6
52*1424dfb3Schristos 
53*1424dfb3Schristos /* There are no machine-specific operands so we #define this to nothing.  */
54*1424dfb3Schristos #define md_operand(x)
55*1424dfb3Schristos 
56*1424dfb3Schristos /* Function prototypes exported to rest of GAS.  */
57*1424dfb3Schristos extern void md_assemble (char *op_str);
58*1424dfb3Schristos extern void md_end (void);
59*1424dfb3Schristos extern void md_begin (void);
60*1424dfb3Schristos 
61*1424dfb3Schristos #define TC_FORCE_RELOCATION(fixp) nios2_force_relocation (fixp)
62*1424dfb3Schristos extern int nios2_force_relocation (struct fix *);
63*1424dfb3Schristos 
64*1424dfb3Schristos #define tc_fix_adjustable(fixp) nios2_fix_adjustable (fixp)
65*1424dfb3Schristos extern int nios2_fix_adjustable (struct fix *);
66*1424dfb3Schristos 
67*1424dfb3Schristos #define tc_frob_label(lab)	     nios2_frob_label (lab)
68*1424dfb3Schristos extern void nios2_frob_label (symbolS *);
69*1424dfb3Schristos 
70*1424dfb3Schristos #define tc_frob_symbol(symp, punt)  punt = nios2_frob_symbol (symp) ? 1 : punt
71*1424dfb3Schristos extern int nios2_frob_symbol (symbolS * symp);
72*1424dfb3Schristos 
73*1424dfb3Schristos #define md_cons_align(nbytes) nios2_cons_align (nbytes)
74*1424dfb3Schristos extern void nios2_cons_align (int);
75*1424dfb3Schristos 
76*1424dfb3Schristos extern void md_convert_frag (bfd * headers, segT sec, fragS * fragP);
77*1424dfb3Schristos 
78*1424dfb3Schristos /* When relaxing, we need to generate relocations for alignment
79*1424dfb3Schristos    directives.  */
80*1424dfb3Schristos #define HANDLE_ALIGN(frag) nios2_handle_align (frag)
81*1424dfb3Schristos extern void nios2_handle_align (fragS *);
82*1424dfb3Schristos 
83*1424dfb3Schristos #define md_relax_frag nios2_relax_frag
84*1424dfb3Schristos extern long nios2_relax_frag (segT segment, fragS * fragP, long stretch);
85*1424dfb3Schristos 
86*1424dfb3Schristos #ifdef OBJ_ELF
87*1424dfb3Schristos #define ELF_TC_SPECIAL_SECTIONS \
88*1424dfb3Schristos   { ".sdata",   SHT_PROGBITS,   SHF_ALLOC + SHF_WRITE + SHF_NIOS2_GPREL  }, \
89*1424dfb3Schristos   { ".sbss",    SHT_NOBITS,     SHF_ALLOC + SHF_WRITE + SHF_NIOS2_GPREL  }, \
90*1424dfb3Schristos   { ".lit4",	SHT_PROGBITS,	SHF_ALLOC + SHF_WRITE + SHF_NIOS2_GPREL  }, \
91*1424dfb3Schristos   { ".lit8",	SHT_PROGBITS,	SHF_ALLOC + SHF_WRITE + SHF_NIOS2_GPREL  },
92*1424dfb3Schristos 
93*1424dfb3Schristos /* Processor-specific section directives.  */
94*1424dfb3Schristos #define md_elf_section_letter		nios2_elf_section_letter
95*1424dfb3Schristos extern int nios2_elf_section_letter (int, const char **);
96*1424dfb3Schristos #define md_elf_section_flags		nios2_elf_section_flags
97*1424dfb3Schristos extern flagword nios2_elf_section_flags (flagword, int, int);
98*1424dfb3Schristos #endif
99*1424dfb3Schristos 
100*1424dfb3Schristos #define GLOBAL_OFFSET_TABLE_NAME       "_GLOBAL_OFFSET_TABLE_"
101*1424dfb3Schristos 
102*1424dfb3Schristos #define DIFF_EXPR_OK
103*1424dfb3Schristos 
104*1424dfb3Schristos /* Don't allow the generic code to convert fixups involving the
105*1424dfb3Schristos    subtraction of a label in the current section to pc-relative if we
106*1424dfb3Schristos    don't have the necessary pc-relative relocation.  */
107*1424dfb3Schristos #define TC_FORCE_RELOCATION_SUB_LOCAL(FIX, SEG)		\
108*1424dfb3Schristos   (!((FIX)->fx_r_type == BFD_RELOC_16			\
109*1424dfb3Schristos      || (FIX)->fx_r_type == BFD_RELOC_NIOS2_LO16	\
110*1424dfb3Schristos      || (FIX)->fx_r_type == BFD_RELOC_NIOS2_HIADJ16))
111*1424dfb3Schristos 
112*1424dfb3Schristos /* Nios2 ABI doesn't have 32-bit PCREL relocation, and, as relocations for
113*1424dfb3Schristos    CFI information will be in section other than .text, we can't use PC-biased
114*1424dfb3Schristos    relocs.  */
115*1424dfb3Schristos #define CFI_DIFF_EXPR_OK 0
116*1424dfb3Schristos 
117*1424dfb3Schristos #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) nios2_cons (EXP, NBYTES)
118*1424dfb3Schristos extern bfd_reloc_code_real_type nios2_cons (expressionS *exp, int size);
119*1424dfb3Schristos 
120*1424dfb3Schristos /* We want .cfi_* pseudo-ops for generating unwind info.  */
121*1424dfb3Schristos #define TARGET_USE_CFIPOP 1
122*1424dfb3Schristos #define DWARF2_DEFAULT_RETURN_COLUMN 31
123*1424dfb3Schristos #define DWARF2_CIE_DATA_ALIGNMENT (-4)
124*1424dfb3Schristos #define tc_regname_to_dw2regnum nios2_regname_to_dw2regnum
125*1424dfb3Schristos extern int nios2_regname_to_dw2regnum (char *regname);
126*1424dfb3Schristos #define tc_cfi_frame_initial_instructions  nios2_frame_initial_instructions
127*1424dfb3Schristos extern void nios2_frame_initial_instructions (void);
128*1424dfb3Schristos 
129*1424dfb3Schristos #define elf_tc_final_processing nios2_elf_final_processing
130*1424dfb3Schristos extern void nios2_elf_final_processing (void);
131*1424dfb3Schristos 
132*1424dfb3Schristos #endif /* TC_NIOS2 */
133