tc-mmix.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. /* tc-mmix.h -- Header file for tc-mmix.c.
  2. Copyright (C) 2001-2015 Free Software Foundation, Inc.
  3. Written by Hans-Peter Nilsson (hp@bitrange.com).
  4. This file is part of GAS, the GNU Assembler.
  5. GAS is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 3, or (at your option)
  8. any later version.
  9. GAS is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with GAS; see the file COPYING. If not, write to the Free
  15. Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
  16. 02110-1301, USA. */
  17. #define TC_MMIX
  18. /* See gas/doc/internals.texi for explanation of these macros. */
  19. #define TARGET_FORMAT "elf64-mmix"
  20. #define TARGET_ARCH bfd_arch_mmix
  21. #define TARGET_BYTES_BIG_ENDIAN 1
  22. extern const char mmix_comment_chars[];
  23. #define tc_comment_chars mmix_comment_chars
  24. extern const char mmix_symbol_chars[];
  25. #define tc_symbol_chars mmix_symbol_chars
  26. extern const char mmix_exp_chars[];
  27. #define EXP_CHARS mmix_exp_chars
  28. extern const char mmix_flt_chars[];
  29. #define FLT_CHARS mmix_flt_chars
  30. /* "@" is a synonym for ".". */
  31. #define LEX_AT (LEX_BEGIN_NAME)
  32. extern int mmix_label_without_colon_this_line (void);
  33. #define LABELS_WITHOUT_COLONS mmix_label_without_colon_this_line ()
  34. extern int mmix_next_semicolon_is_eoln;
  35. #define TC_EOL_IN_INSN(p) (*(p) == ';' && ! mmix_next_semicolon_is_eoln)
  36. /* This is one direction we can get mmixal compatibility. */
  37. extern void mmix_handle_mmixal (void);
  38. #define md_start_line_hook mmix_handle_mmixal
  39. extern void mmix_md_begin (void);
  40. #define md_begin mmix_md_begin
  41. extern void mmix_md_end (void);
  42. #define md_end mmix_md_end
  43. extern int mmix_current_location \
  44. (void (*fn) (expressionS *), expressionS *);
  45. extern int mmix_parse_predefined_name (char *, expressionS *);
  46. extern char *mmix_current_prefix;
  47. /* A bit ugly, since we "know" that there's a static function
  48. current_location that does what we want. We also strip off a leading
  49. ':' in another ugly way.
  50. The [DVWIOUZX]_Handler symbols are provided when-used. */
  51. extern int mmix_gnu_syntax;
  52. #define md_parse_name(name, exp, mode, cpos) \
  53. (! mmix_gnu_syntax \
  54. && (name[0] == '@' \
  55. ? (! is_part_of_name (name[1]) \
  56. && mmix_current_location (current_location, exp)) \
  57. : ((name[0] == ':' || ISUPPER (name[0])) \
  58. && mmix_parse_predefined_name (name, exp))))
  59. extern char *mmix_prefix_name (char *);
  60. /* We implement when *creating* a symbol, we also need to strip a ':' or
  61. prepend a prefix. */
  62. #define tc_canonicalize_symbol_name(x) \
  63. (mmix_current_prefix == NULL && (x)[0] != ':' ? (x) : mmix_prefix_name (x))
  64. #define md_undefined_symbol(x) NULL
  65. extern void mmix_fb_label (expressionS *);
  66. /* Since integer_constant is local to expr.c, we have to make this a
  67. macro. FIXME: Do it cleaner. */
  68. #define md_operand(exp) \
  69. do \
  70. { \
  71. if (input_line_pointer[0] == '#') \
  72. { \
  73. input_line_pointer++; \
  74. integer_constant (16, (exp)); \
  75. } \
  76. else if (input_line_pointer[0] == '&' \
  77. && input_line_pointer[1] != '&') \
  78. as_bad (_("`&' serial number operator is not supported")); \
  79. else \
  80. mmix_fb_label (exp); \
  81. } \
  82. while (0)
  83. /* Gas dislikes the 2ADD, 8ADD etc. insns, so we have to assemble them in
  84. the error-recovery loop. Hopefully there are no significant
  85. differences. Also, space on a line isn't gracefully handled. */
  86. extern int mmix_assemble_return_nonzero (char *);
  87. #define tc_unrecognized_line(c) \
  88. ((c) == ' ' \
  89. || (((c) == '1' || (c) == '2' || (c) == '4' || (c) == '8') \
  90. && mmix_assemble_return_nonzero (input_line_pointer - 1)))
  91. #define md_number_to_chars number_to_chars_bigendian
  92. #define WORKING_DOT_WORD
  93. extern const struct relax_type mmix_relax_table[];
  94. #define TC_GENERIC_RELAX_TABLE mmix_relax_table
  95. /* We use the relax table for everything except the GREG frags and PUSHJ. */
  96. extern long mmix_md_relax_frag (segT, fragS *, long);
  97. #define md_relax_frag mmix_md_relax_frag
  98. #define tc_fix_adjustable(FIX) \
  99. (((FIX)->fx_addsy == NULL \
  100. || S_GET_SEGMENT ((FIX)->fx_addsy) != reg_section) \
  101. && (FIX)->fx_r_type != BFD_RELOC_VTABLE_INHERIT \
  102. && (FIX)->fx_r_type != BFD_RELOC_VTABLE_ENTRY \
  103. && (FIX)->fx_r_type != BFD_RELOC_MMIX_LOCAL)
  104. /* Adjust symbols which are registers. */
  105. #define tc_adjust_symtab() mmix_adjust_symtab ()
  106. extern void mmix_adjust_symtab (void);
  107. /* Here's where we make all symbols global, when so requested.
  108. We must avoid doing that for expression symbols or section symbols,
  109. though. */
  110. extern int mmix_globalize_symbols;
  111. #define tc_frob_symbol(sym, punt) \
  112. do \
  113. { \
  114. if (S_GET_SEGMENT (sym) == reg_section) \
  115. { \
  116. if (S_GET_NAME (sym)[0] != '$' \
  117. && S_GET_VALUE (sym) < 256) \
  118. { \
  119. if (mmix_globalize_symbols) \
  120. S_SET_EXTERNAL (sym); \
  121. else \
  122. symbol_mark_used_in_reloc (sym); \
  123. } \
  124. } \
  125. else if (mmix_globalize_symbols \
  126. && ! symbol_section_p (sym) \
  127. && sym != section_symbol (absolute_section) \
  128. && ! S_IS_LOCAL (sym)) \
  129. S_SET_EXTERNAL (sym); \
  130. } \
  131. while (0)
  132. /* No shared lib support, so we don't need to ensure externally
  133. visible symbols can be overridden. */
  134. #define EXTERN_FORCE_RELOC 0
  135. /* When relaxing, we need to emit various relocs we otherwise wouldn't. */
  136. #define TC_FORCE_RELOCATION(fix) mmix_force_relocation (fix)
  137. extern int mmix_force_relocation (struct fix *);
  138. /* Call md_pcrel_from_section(), not md_pcrel_from(). */
  139. #define MD_PCREL_FROM_SECTION(FIX, SEC) md_pcrel_from_section (FIX, SEC)
  140. extern long md_pcrel_from_section (struct fix *, segT);
  141. #define md_section_align(seg, size) (size)
  142. #define LISTING_HEADER "GAS for MMIX"
  143. /* The default of 4 means Bcc expansion looks like it's missing a line. */
  144. #define LISTING_LHS_CONT_LINES 5
  145. extern fragS *mmix_opcode_frag;
  146. #define TC_FRAG_TYPE fragS *
  147. #define TC_FRAG_INIT(frag) (frag)->tc_frag_data = mmix_opcode_frag
  148. /* We need to associate each section symbol with a list of GREGs defined
  149. for that section/segment and sorted on offset, between the point where
  150. all symbols have been evaluated and all frags mapped, and when the
  151. fixups are done and relocs are output. Similarly for each unknown
  152. symbol. */
  153. extern void mmix_frob_file (void);
  154. #define tc_frob_file_before_fix() \
  155. do \
  156. { \
  157. int i = 0; \
  158. \
  159. /* It's likely mmix_frob_file changed (removed) sections, so make \
  160. sure sections are correctly numbered as per renumber_sections, \
  161. (static to write.c where this macro is called). */ \
  162. mmix_frob_file (); \
  163. bfd_map_over_sections (stdoutput, renumber_sections, &i); \
  164. } \
  165. while (0)
  166. /* Used by mmix_frob_file. Hangs on section symbols and unknown symbols. */
  167. struct mmix_symbol_gregs;
  168. #define TC_SYMFIELD_TYPE struct mmix_symbol_gregs *
  169. /* Used by relaxation, counting maximum needed PUSHJ stubs for a section. */
  170. struct mmix_segment_info_type
  171. {
  172. /* We only need to keep track of the last stubbable frag because
  173. there's no less hackish way to keep track of different relaxation
  174. rounds. */
  175. fragS *last_stubfrag;
  176. bfd_size_type nstubs;
  177. };
  178. #define TC_SEGMENT_INFO_TYPE struct mmix_segment_info_type
  179. extern void mmix_md_elf_section_change_hook (void);
  180. #define md_elf_section_change_hook mmix_md_elf_section_change_hook
  181. extern void mmix_md_do_align (int, char *, int, int);
  182. #define md_do_align(n, fill, len, max, label) \
  183. mmix_md_do_align (n, fill, len, max)
  184. /* Each insn is a tetrabyte (4 bytes) long, but if there are BYTE
  185. sequences sprinkled in, we can get unaligned DWARF2 offsets, so let's
  186. explicitly say one byte. */
  187. #define DWARF2_LINE_MIN_INSN_LENGTH 1
  188. /* This target is buggy, and sets fix size too large. */
  189. #define TC_FX_SIZE_SLACK(FIX) 6
  190. /* MMIX has global register symbols. */
  191. #define TC_GLOBAL_REGISTER_SYMBOL_OK