tc-nios2.h 4.8 KB

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