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