tc-ia64.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. /* tc-ia64.h -- Header file for tc-ia64.c.
  2. Copyright (C) 1998-2015 Free Software Foundation, Inc.
  3. Contributed by David Mosberger-Tang <davidm@hpl.hp.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
  15. the Free Software Foundation, 51 Franklin Street - Fifth Floor,
  16. Boston, MA 02110-1301, USA. */
  17. #include "opcode/ia64.h"
  18. #include "elf/ia64.h"
  19. #define TC_IA64
  20. /* Linux is little endian by default. HPUX is big endian by default. */
  21. #ifdef TE_HPUX
  22. #define TARGET_BYTES_BIG_ENDIAN 1
  23. #define MD_FLAGS_DEFAULT EF_IA_64_BE
  24. #else
  25. #define TARGET_BYTES_BIG_ENDIAN 0
  26. #define MD_FLAGS_DEFAULT EF_IA_64_ABI64
  27. #endif /* TE_HPUX */
  28. extern void (*ia64_number_to_chars) (char *, valueT, int);
  29. #define md_number_to_chars (*ia64_number_to_chars)
  30. extern void ia64_elf_section_change_hook (void);
  31. #define md_elf_section_change_hook ia64_elf_section_change_hook
  32. /* We record the endian for this section. 0 means default, 1 means
  33. big endian and 2 means little endian. */
  34. struct ia64_segment_info_type
  35. {
  36. unsigned int endian : 2;
  37. };
  38. #define TC_SEGMENT_INFO_TYPE struct ia64_segment_info_type
  39. extern void ia64_adjust_symtab (void);
  40. #define tc_adjust_symtab() ia64_adjust_symtab ()
  41. extern void ia64_frob_file (void);
  42. #define tc_frob_file() ia64_frob_file ()
  43. /* We need to set the default object file format in ia64_init and not in
  44. md_begin. This is because parse_args is called before md_begin, and we
  45. do not want md_begin to wipe out the flag settings set by options parsed in
  46. md_parse_args. */
  47. #define HOST_SPECIAL_INIT ia64_init
  48. extern void ia64_init (int, char **);
  49. #define TARGET_FORMAT ia64_target_format()
  50. extern const char *ia64_target_format (void);
  51. #define TARGET_ARCH bfd_arch_ia64
  52. #define DOUBLESLASH_LINE_COMMENTS /* allow //-style comments */
  53. #define NEED_LITERAL_POOL /* need gp literal pool */
  54. #define RELOC_REQUIRES_SYMBOL
  55. #define DIFF_EXPR_OK /* foo-. gets turned into PC relative relocs */
  56. #define NEED_INDEX_OPERATOR /* [ ] is index operator */
  57. #define QUOTES_IN_INSN /* allow `string "foo;bar"' */
  58. #define LEX_AT (LEX_NAME|LEX_BEGIN_NAME) /* allow `@' inside name */
  59. #define LEX_QM (LEX_NAME|LEX_BEGIN_NAME) /* allow `?' inside name */
  60. #define LEX_HASH LEX_END_NAME /* allow `#' ending a name */
  61. #define TC_PREDICATE_START_CHAR '('
  62. #define TC_PREDICATE_END_CHAR ')'
  63. extern const char ia64_symbol_chars[];
  64. #define tc_symbol_chars ia64_symbol_chars
  65. #define SUB_SEGMENT_ALIGN(SEG, FRCHAIN) 0
  66. struct ia64_fix
  67. {
  68. int bigendian; /* byte order at fix location */
  69. enum ia64_opnd opnd;
  70. };
  71. extern void ia64_end_of_source (void);
  72. extern void ia64_start_line (void);
  73. extern int ia64_unrecognized_line (int);
  74. extern void ia64_frob_label (struct symbol *);
  75. #ifdef TE_HPUX
  76. extern int ia64_frob_symbol (struct symbol *);
  77. #endif
  78. extern void ia64_flush_pending_output (void);
  79. extern int ia64_parse_name (char *, expressionS *, char *);
  80. extern int ia64_optimize_expr (expressionS *, operatorT, expressionS *);
  81. extern void ia64_cons_align (int);
  82. extern void ia64_flush_insns (void);
  83. extern int ia64_fix_adjustable (struct fix *);
  84. extern int ia64_force_relocation (struct fix *);
  85. extern void ia64_cons_fix_new (fragS *, int, int, expressionS *,
  86. bfd_reloc_code_real_type);
  87. extern void ia64_validate_fix (struct fix *);
  88. extern char * ia64_canonicalize_symbol_name (char *);
  89. extern bfd_vma ia64_elf_section_letter (int, char **);
  90. extern flagword ia64_elf_section_flags (flagword, bfd_vma, int);
  91. extern int ia64_elf_section_type (const char *, size_t);
  92. extern long ia64_pcrel_from_section (struct fix *, segT);
  93. extern void ia64_md_do_align (int, const char *, int, int);
  94. extern void ia64_handle_align (fragS *);
  95. extern void ia64_after_parse_args (void);
  96. extern void ia64_dwarf2_emit_offset (symbolS *, unsigned int);
  97. extern void ia64_check_label (symbolS *);
  98. extern int ia64_estimate_size_before_relax (fragS *, asection *);
  99. extern void ia64_convert_frag (fragS *);
  100. #define md_end() ia64_end_of_source ()
  101. #define md_start_line_hook() ia64_start_line ()
  102. #define tc_unrecognized_line(ch) ia64_unrecognized_line (ch)
  103. #define tc_frob_label(s) ia64_frob_label (s)
  104. #ifdef TE_HPUX
  105. #define tc_frob_symbol(s,p) p |= ia64_frob_symbol (s)
  106. #endif /* TE_HPUX */
  107. #define md_flush_pending_output() ia64_flush_pending_output ()
  108. #define md_parse_name(s,e,m,c) ia64_parse_name (s, e, c)
  109. #define md_register_arithmetic 0
  110. #define tc_canonicalize_symbol_name(s) ia64_canonicalize_symbol_name (s)
  111. #define tc_canonicalize_section_name(s) ia64_canonicalize_symbol_name (s)
  112. #define md_optimize_expr(l,o,r) ia64_optimize_expr (l, o, r)
  113. #define md_cons_align(n) ia64_cons_align (n)
  114. #define TC_FORCE_RELOCATION(f) ia64_force_relocation (f)
  115. #define tc_fix_adjustable(f) ia64_fix_adjustable (f)
  116. #define MD_APPLY_SYM_VALUE(FIX) 0
  117. #define md_convert_frag(b,s,f) ia64_convert_frag (f)
  118. #define md_create_long_jump(p,f,t,fr,s) as_fatal ("ia64_create_long_jump")
  119. #define md_create_short_jump(p,f,t,fr,s) \
  120. as_fatal ("ia64_create_short_jump")
  121. #define md_estimate_size_before_relax(f,s) \
  122. ia64_estimate_size_before_relax(f,s)
  123. #define md_elf_section_letter ia64_elf_section_letter
  124. #define md_elf_section_flags ia64_elf_section_flags
  125. #define TC_FIX_TYPE struct ia64_fix
  126. #define TC_INIT_FIX_DATA(f) { f->tc_fix_data.opnd = 0; }
  127. #define TC_CONS_FIX_NEW(f,o,l,e,r) ia64_cons_fix_new (f, o, l, e, r)
  128. #define TC_VALIDATE_FIX(fix,seg,skip) ia64_validate_fix (fix)
  129. #define MD_PCREL_FROM_SECTION(fix,sec) ia64_pcrel_from_section (fix, sec)
  130. #define md_section_align(seg,size) (size)
  131. #define md_do_align(n,f,l,m,j) ia64_md_do_align (n,f,l,m)
  132. #define HANDLE_ALIGN(f) ia64_handle_align (f)
  133. #define md_elf_section_type(str,len) ia64_elf_section_type (str, len)
  134. #define md_after_parse_args() ia64_after_parse_args ()
  135. #define TC_DWARF2_EMIT_OFFSET ia64_dwarf2_emit_offset
  136. #define tc_check_label(l) ia64_check_label (l)
  137. #ifdef TE_VMS
  138. #define tc_init_after_args() ia64_vms_note ()
  139. void ia64_vms_note (void);
  140. #endif
  141. /* Record if an alignment frag should end with a stop bit. */
  142. #define TC_FRAG_TYPE int
  143. #define TC_FRAG_INIT(FRAGP) do {(FRAGP)->tc_frag_data = 0;}while (0)
  144. /* Give an error if a frag containing code is not aligned to a 16 byte
  145. boundary. */
  146. #define md_frag_check(FRAGP) \
  147. if ((FRAGP)->has_code \
  148. && (((FRAGP)->fr_address + (FRAGP)->insn_addr) & 15) != 0) \
  149. as_bad_where ((FRAGP)->fr_file, (FRAGP)->fr_line, \
  150. _("instruction address is not a multiple of 16"));
  151. #define MAX_MEM_FOR_RS_ALIGN_CODE (15 + 16)
  152. #define WORKING_DOT_WORD /* don't do broken word processing for now */
  153. #define DWARF2_LINE_MIN_INSN_LENGTH 1 /* so slot-multipliers can be 1 */
  154. /* This is the information required for unwind records in an ia64
  155. object file. This is required by GAS and the compiler runtime. */
  156. /* These are the starting point masks for the various types of
  157. unwind records. To create a record of type R3 for instance, one
  158. starts by using the value UNW_R3 and or-ing in any other required values.
  159. These values are also unique (in context), so they can be used to identify
  160. the various record types as well. UNW_Bx and some UNW_Px do have the
  161. same value, but Px can only occur in a prologue context, and Bx in
  162. a body context. */
  163. #define UNW_R1 0x00
  164. #define UNW_R2 0x40
  165. #define UNW_R3 0x60
  166. #define UNW_P1 0x80
  167. #define UNW_P2 0xA0
  168. #define UNW_P3 0xB0
  169. #define UNW_P4 0xB8
  170. #define UNW_P5 0xB9
  171. #define UNW_P6 0xC0
  172. #define UNW_P7 0xE0
  173. #define UNW_P8 0xF0
  174. #define UNW_P9 0xF1
  175. #define UNW_P10 0xFF
  176. #define UNW_X1 0xF9
  177. #define UNW_X2 0xFA
  178. #define UNW_X3 0xFB
  179. #define UNW_X4 0xFC
  180. #define UNW_B1 0x80
  181. #define UNW_B2 0xC0
  182. #define UNW_B3 0xE0
  183. #define UNW_B4 0xF0
  184. /* These are all the various types of unwind records. */
  185. typedef enum
  186. {
  187. prologue, prologue_gr, body, mem_stack_f, mem_stack_v, psp_gr, psp_sprel,
  188. rp_when, rp_gr, rp_br, rp_psprel, rp_sprel, pfs_when, pfs_gr, pfs_psprel,
  189. pfs_sprel, preds_when, preds_gr, preds_psprel, preds_sprel,
  190. fr_mem, frgr_mem, gr_gr, gr_mem, br_mem, br_gr, spill_base, spill_mask,
  191. unat_when, unat_gr, unat_psprel, unat_sprel, lc_when, lc_gr, lc_psprel,
  192. lc_sprel, fpsr_when, fpsr_gr, fpsr_psprel, fpsr_sprel,
  193. priunat_when_gr, priunat_when_mem, priunat_gr, priunat_psprel,
  194. priunat_sprel, bsp_when, bsp_gr, bsp_psprel, bsp_sprel, bspstore_when,
  195. bspstore_gr, bspstore_psprel, bspstore_sprel, rnat_when, rnat_gr,
  196. rnat_psprel, rnat_sprel, epilogue, label_state, copy_state,
  197. spill_psprel, spill_sprel, spill_reg, spill_psprel_p, spill_sprel_p,
  198. spill_reg_p, unwabi, endp
  199. } unw_record_type;
  200. /* These structures declare the fields that can be used in each of the
  201. 4 record formats, R, P, B and X. */
  202. typedef struct unw_r_record
  203. {
  204. unsigned long rlen;
  205. unsigned short grmask;
  206. unsigned short grsave;
  207. /* masks to represent the union of save.g, save.f, save.b, and
  208. save.gf: */
  209. unsigned long imask_size;
  210. struct
  211. {
  212. unsigned char *i;
  213. unsigned int fr_mem;
  214. unsigned char gr_mem;
  215. unsigned char br_mem;
  216. } mask;
  217. } unw_r_record;
  218. typedef struct unw_p_record
  219. {
  220. struct unw_rec_list *next;
  221. unsigned long t;
  222. unsigned long size;
  223. union
  224. {
  225. unsigned long sp;
  226. unsigned long psp;
  227. } off;
  228. union
  229. {
  230. unsigned short gr;
  231. unsigned short br;
  232. } r;
  233. unsigned char grmask;
  234. unsigned char brmask;
  235. unsigned int frmask;
  236. unsigned char abi;
  237. unsigned char context;
  238. } unw_p_record;
  239. typedef struct unw_b_record
  240. {
  241. unsigned long t;
  242. unsigned long label;
  243. unsigned short ecount;
  244. } unw_b_record;
  245. typedef struct unw_x_record
  246. {
  247. unsigned long t;
  248. union
  249. {
  250. unsigned long spoff;
  251. unsigned long pspoff;
  252. unsigned int reg;
  253. } where;
  254. unsigned short reg;
  255. unsigned short qp;
  256. unsigned short ab; /* Value of the AB field.. */
  257. unsigned short xy; /* Value of the XY field.. */
  258. } unw_x_record;
  259. /* This structure is used to determine the specific record type and
  260. its fields. */
  261. typedef struct unwind_record
  262. {
  263. unw_record_type type;
  264. union {
  265. unw_r_record r;
  266. unw_p_record p;
  267. unw_b_record b;
  268. unw_x_record x;
  269. } record;
  270. } unwind_record;
  271. /* This expression evaluates to true if the relocation is for a local
  272. object for which we still want to do the relocation at runtime.
  273. False if we are willing to perform this relocation while building
  274. the .o file. */
  275. /* If the reloc type is BFD_RELOC_UNUSED, then this is for a TAG13/TAG13b field
  276. which has no external reloc, so we must resolve the value now. */
  277. #define TC_FORCE_RELOCATION_LOCAL(FIX) \
  278. ((FIX)->fx_r_type != BFD_RELOC_UNUSED \
  279. && (!(FIX)->fx_pcrel \
  280. || (FIX)->fx_r_type == BFD_RELOC_IA64_PLTOFF22 \
  281. || TC_FORCE_RELOCATION (FIX)))
  282. /* VMS backtraces expect dwarf version 3. */
  283. #ifdef TE_VMS
  284. #define DWARF2_VERSION 3
  285. #define DWARF2_LINE_VERSION 3
  286. #endif