tc-ia64.h revision 130561
184865Sobrien/* tc-ia64.h -- Header file for tc-ia64.c.
289857Sobrien   Copyright 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
384865Sobrien   Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
484865Sobrien
584865Sobrien   This file is part of GAS, the GNU Assembler.
684865Sobrien
784865Sobrien   GAS is free software; you can redistribute it and/or modify
884865Sobrien   it under the terms of the GNU General Public License as published by
984865Sobrien   the Free Software Foundation; either version 2, or (at your option)
1084865Sobrien   any later version.
1184865Sobrien
1284865Sobrien   GAS is distributed in the hope that it will be useful,
1384865Sobrien   but WITHOUT ANY WARRANTY; without even the implied warranty of
1484865Sobrien   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1584865Sobrien   GNU General Public License for more details.
1684865Sobrien
1784865Sobrien   You should have received a copy of the GNU General Public License
1884865Sobrien   along with GAS; see the file COPYING.  If not, write to
1984865Sobrien   the Free Software Foundation, 59 Temple Place - Suite 330,
2084865Sobrien   Boston, MA 02111-1307, USA.  */
2184865Sobrien
22104834Sobrien#include "opcode/ia64.h"
23104834Sobrien#include "elf/ia64.h"
2484865Sobrien
2584865Sobrien#define TC_IA64
2684865Sobrien
2784865Sobrien/* Linux is little endian by default.  HPUX is big endian by default.  */
2884865Sobrien#ifdef TE_HPUX
2984865Sobrien#define TARGET_BYTES_BIG_ENDIAN		1
3089857Sobrien#define MD_FLAGS_DEFAULT		EF_IA_64_BE
3184865Sobrien#else
3284865Sobrien#define TARGET_BYTES_BIG_ENDIAN		0
3389857Sobrien#define MD_FLAGS_DEFAULT		EF_IA_64_ABI64
3484865Sobrien#endif /* TE_HPUX */
3584865Sobrien
36130561Sobrienextern void (*ia64_number_to_chars) PARAMS ((char *, valueT, int));
37130561Sobrien#define md_number_to_chars		(*ia64_number_to_chars)
38130561Sobrien
39130561Sobrienextern void ia64_elf_section_change_hook PARAMS ((void));
40130561Sobrien#define md_elf_section_change_hook	ia64_elf_section_change_hook
41130561Sobrien
42130561Sobrien/* We record the endian for this section. 0 means default, 1 means
43130561Sobrien   big endian and 2 means little endian.  */
44130561Sobrienstruct ia64_segment_info_type
45130561Sobrien{
46130561Sobrien  unsigned int endian : 2;
47130561Sobrien};
48130561Sobrien
49130561Sobrien#define TC_SEGMENT_INFO_TYPE		struct ia64_segment_info_type
50130561Sobrien
51130561Sobrienextern void ia64_adjust_symtab PARAMS ((void));
52130561Sobrien#define tc_adjust_symtab()	ia64_adjust_symtab ()
53130561Sobrien
54130561Sobrienextern void ia64_frob_file PARAMS ((void));
55130561Sobrien#define tc_frob_file()		ia64_frob_file ()
56130561Sobrien
5784865Sobrien/* We need to set the default object file format in ia64_init and not in
5884865Sobrien   md_begin.  This is because parse_args is called before md_begin, and we
5984865Sobrien   do not want md_begin to wipe out the flag settings set by options parsed in
6084865Sobrien   md_parse_args.  */
6184865Sobrien
6284865Sobrien#define HOST_SPECIAL_INIT ia64_init
6384865Sobrienextern void ia64_init PARAMS ((int, char **));
6484865Sobrien
6584865Sobrien#define TARGET_FORMAT ia64_target_format()
6684865Sobrienextern const char *ia64_target_format PARAMS ((void));
6784865Sobrien
6884865Sobrien#define TARGET_ARCH			bfd_arch_ia64
6984865Sobrien#define DOUBLESLASH_LINE_COMMENTS	/* allow //-style comments */
7084865Sobrien
7184865Sobrien#define NEED_LITERAL_POOL		/* need gp literal pool */
7284865Sobrien#define RELOC_REQUIRES_SYMBOL
7384865Sobrien#define DIFF_EXPR_OK   /* foo-. gets turned into PC relative relocs */
7484865Sobrien#define NEED_INDEX_OPERATOR		/* [ ] is index operator */
7584865Sobrien
7684865Sobrien#define QUOTES_IN_INSN			/* allow `string "foo;bar"' */
7784865Sobrien#define LEX_AT		LEX_NAME	/* allow `@' inside name */
7884865Sobrien#define LEX_QM		LEX_NAME	/* allow `?' inside name */
7984865Sobrien#define LEX_HASH	LEX_END_NAME	/* allow `#' ending a name */
8084865Sobrien
81130561Sobrien#define SUB_SEGMENT_ALIGN(SEG, FRCHAIN) 0
82130561Sobrien
8384865Sobrienstruct ia64_fix
8484865Sobrien  {
8584865Sobrien    int bigendian;			/* byte order at fix location */
8684865Sobrien    enum ia64_opnd opnd;
8784865Sobrien  };
8884865Sobrien
8984865Sobrienextern void ia64_end_of_source PARAMS((void));
9084865Sobrienextern void ia64_start_line PARAMS((void));
9184865Sobrienextern int ia64_unrecognized_line PARAMS((int ch));
9284865Sobrienextern void ia64_frob_label PARAMS((struct symbol *sym));
93130561Sobrien#ifdef TE_HPUX
94130561Sobrienextern int ia64_frob_symbol PARAMS((struct symbol *sym));
95130561Sobrien#endif
9684865Sobrienextern void ia64_flush_pending_output PARAMS((void));
9784865Sobrienextern int ia64_parse_name (char *name, expressionS *e);
9884865Sobrienextern int ia64_optimize_expr PARAMS((expressionS *l, operatorT op,
9984865Sobrien				      expressionS *r));
10084865Sobrienextern void ia64_cons_align PARAMS((int));
10184865Sobrienextern void ia64_flush_insns PARAMS((void));
10284865Sobrienextern int ia64_fix_adjustable PARAMS((struct fix *fix));
10384865Sobrienextern int ia64_force_relocation PARAMS((struct fix *));
10484865Sobrienextern void ia64_cons_fix_new PARAMS ((fragS *f, int where, int nbytes,
10584865Sobrien				       expressionS *exp));
10684865Sobrienextern void ia64_validate_fix PARAMS ((struct fix *fix));
10784865Sobrienextern char * ia64_canonicalize_symbol_name PARAMS ((char *));
10889857Sobrienextern int ia64_elf_section_letter PARAMS ((int, char **));
10984865Sobrienextern flagword ia64_elf_section_flags PARAMS ((flagword, int, int));
11084865Sobrienextern int ia64_elf_section_type PARAMS ((const char *, size_t len));
11184865Sobrienextern long ia64_pcrel_from_section PARAMS ((struct fix *fix, segT sec));
11284865Sobrienextern void ia64_md_do_align PARAMS ((int, const char *, int, int));
11384865Sobrienextern void ia64_handle_align PARAMS ((fragS *f));
11489857Sobrienextern void ia64_after_parse_args PARAMS ((void));
115130561Sobrienextern void ia64_dwarf2_emit_offset PARAMS ((symbolS *, unsigned int));
116130561Sobrienextern void ia64_check_label PARAMS ((symbolS *));
117130561Sobrienextern int ia64_estimate_size_before_relax (fragS *, asection *);
118130561Sobrienextern void ia64_convert_frag (fragS *);
11984865Sobrien
12084865Sobrien#define md_end()       			ia64_end_of_source ()
12184865Sobrien#define md_start_line_hook()		ia64_start_line ()
12284865Sobrien#define tc_unrecognized_line(ch)	ia64_unrecognized_line (ch)
12384865Sobrien#define tc_frob_label(s)		ia64_frob_label (s)
124130561Sobrien#ifdef TE_HPUX
125130561Sobrien#define tc_frob_symbol(s,p)		p |= ia64_frob_symbol (s)
126130561Sobrien#endif /* TE_HPUX */
12784865Sobrien#define md_flush_pending_output()	ia64_flush_pending_output ()
12889857Sobrien#define md_parse_name(s,e,c)		ia64_parse_name (s, e)
12984865Sobrien#define tc_canonicalize_symbol_name(s)	ia64_canonicalize_symbol_name (s)
130130561Sobrien#define tc_canonicalize_section_name(s)	ia64_canonicalize_symbol_name (s)
13184865Sobrien#define md_optimize_expr(l,o,r)		ia64_optimize_expr (l, o, r)
13284865Sobrien#define md_cons_align(n)		ia64_cons_align (n)
13384865Sobrien#define TC_FORCE_RELOCATION(f)		ia64_force_relocation (f)
13484865Sobrien#define tc_fix_adjustable(f)		ia64_fix_adjustable (f)
135130561Sobrien#define MD_APPLY_SYM_VALUE(FIX)		0
136130561Sobrien#define md_convert_frag(b,s,f)		ia64_convert_frag (f)
13789857Sobrien#define md_create_long_jump(p,f,t,fr,s)	as_fatal ("ia64_create_long_jump")
13884865Sobrien#define md_create_short_jump(p,f,t,fr,s) \
13989857Sobrien					as_fatal ("ia64_create_short_jump")
14084865Sobrien#define md_estimate_size_before_relax(f,s) \
141130561Sobrien					ia64_estimate_size_before_relax(f,s)
14289857Sobrien#define md_elf_section_letter		ia64_elf_section_letter
14384865Sobrien#define md_elf_section_flags		ia64_elf_section_flags
14484865Sobrien#define TC_FIX_TYPE			struct ia64_fix
14584865Sobrien#define TC_INIT_FIX_DATA(f)		{ f->tc_fix_data.opnd = 0; }
14684865Sobrien#define TC_CONS_FIX_NEW(f,o,l,e)	ia64_cons_fix_new (f, o, l, e)
14784865Sobrien#define TC_VALIDATE_FIX(fix,seg,skip)	ia64_validate_fix (fix)
14884865Sobrien#define MD_PCREL_FROM_SECTION(fix,sec)	ia64_pcrel_from_section (fix, sec)
149130561Sobrien#define md_section_align(seg,size)	(size)
15084865Sobrien#define md_do_align(n,f,l,m,j)		ia64_md_do_align (n,f,l,m)
15184865Sobrien#define HANDLE_ALIGN(f)			ia64_handle_align (f)
15284865Sobrien#define md_elf_section_type(str,len)	ia64_elf_section_type (str, len)
15389857Sobrien#define md_after_parse_args()		ia64_after_parse_args ()
154130561Sobrien#define TC_DWARF2_EMIT_OFFSET		ia64_dwarf2_emit_offset
155130561Sobrien#define tc_check_label(l)		ia64_check_label (l)
15684865Sobrien
157130561Sobrien/* Record if an alignment frag should end with a stop bit.  */
158130561Sobrien#define TC_FRAG_TYPE			int
159130561Sobrien#define TC_FRAG_INIT(FRAGP)		do {(FRAGP)->tc_frag_data = 0;}while (0)
160130561Sobrien
16184865Sobrien#define MAX_MEM_FOR_RS_ALIGN_CODE  (15 + 16)
16284865Sobrien
16384865Sobrien#define WORKING_DOT_WORD	/* don't do broken word processing for now */
16484865Sobrien
16584865Sobrien#define DWARF2_LINE_MIN_INSN_LENGTH 1	/* so slot-multipliers can be 1 */
16684865Sobrien
16784865Sobrien/* This is the information required for unwind records in an ia64
16884865Sobrien   object file. This is required by GAS and the compiler runtime.  */
16984865Sobrien
17084865Sobrien/* These are the starting point masks for the various types of
17184865Sobrien   unwind records. To create a record of type R3 for instance, one
17284865Sobrien   starts by using the value UNW_R3 and or-ing in any other required values.
17384865Sobrien   These values are also unique (in context), so they can be used to identify
17484865Sobrien   the various record types as well. UNW_Bx and some UNW_Px do have the
17584865Sobrien   same value, but Px can only occur in a prologue context, and Bx in
17684865Sobrien   a body context.  */
17784865Sobrien
17884865Sobrien#define UNW_R1	0x00
17984865Sobrien#define UNW_R2	0x40
18084865Sobrien#define UNW_R3	0x60
18184865Sobrien#define UNW_P1	0x80
18284865Sobrien#define UNW_P2	0xA0
18384865Sobrien#define UNW_P3	0xB0
18484865Sobrien#define UNW_P4	0xB8
18584865Sobrien#define UNW_P5	0xB9
18684865Sobrien#define UNW_P6	0xC0
18784865Sobrien#define UNW_P7	0xE0
18884865Sobrien#define UNW_P8	0xF0
18984865Sobrien#define UNW_P9	0xF1
19084865Sobrien#define UNW_P10	0xFF
19184865Sobrien#define UNW_X1	0xF9
19284865Sobrien#define UNW_X2	0xFA
19384865Sobrien#define UNW_X3	0xFB
19484865Sobrien#define UNW_X4	0xFC
19584865Sobrien#define UNW_B1	0x80
19684865Sobrien#define UNW_B2	0xC0
19784865Sobrien#define UNW_B3	0xE0
19884865Sobrien#define UNW_B4	0xF0
19984865Sobrien
20084865Sobrien/* These are all the various types of unwind records.  */
20184865Sobrien
20284865Sobrientypedef enum
20384865Sobrien{
20484865Sobrien  prologue, prologue_gr, body, mem_stack_f, mem_stack_v, psp_gr, psp_sprel,
20584865Sobrien  rp_when, rp_gr, rp_br, rp_psprel, rp_sprel, pfs_when, pfs_gr, pfs_psprel,
20684865Sobrien  pfs_sprel, preds_when, preds_gr, preds_psprel, preds_sprel,
20784865Sobrien  fr_mem, frgr_mem, gr_gr, gr_mem, br_mem, br_gr, spill_base, spill_mask,
20884865Sobrien  unat_when, unat_gr, unat_psprel, unat_sprel, lc_when, lc_gr, lc_psprel,
20984865Sobrien  lc_sprel, fpsr_when, fpsr_gr, fpsr_psprel, fpsr_sprel,
21084865Sobrien  priunat_when_gr, priunat_when_mem, priunat_gr, priunat_psprel,
21184865Sobrien  priunat_sprel, bsp_when, bsp_gr, bsp_psprel, bsp_sprel, bspstore_when,
21284865Sobrien  bspstore_gr, bspstore_psprel, bspstore_sprel, rnat_when, rnat_gr,
21384865Sobrien  rnat_psprel, rnat_sprel, epilogue, label_state, copy_state,
21484865Sobrien  spill_psprel, spill_sprel, spill_reg, spill_psprel_p, spill_sprel_p,
215130561Sobrien  spill_reg_p, unwabi, endp
21684865Sobrien} unw_record_type;
21784865Sobrien
21884865Sobrien/* These structures declare the fields that can be used in each of the
21984865Sobrien   4 record formats, R, P, B and X.  */
22084865Sobrien
22184865Sobrientypedef struct unw_r_record
22284865Sobrien{
22384865Sobrien  unsigned long rlen;
22484865Sobrien  unsigned short grmask;
22584865Sobrien  unsigned short grsave;
22684865Sobrien  /* masks to represent the union of save.g, save.f, save.b, and
22784865Sobrien     save.gf: */
22884865Sobrien  unsigned long imask_size;
22984865Sobrien  struct
23084865Sobrien  {
23184865Sobrien    unsigned char *i;
23284865Sobrien    unsigned long fr_mem;
23384865Sobrien    unsigned char gr_mem;
23484865Sobrien    unsigned char br_mem;
23584865Sobrien  } mask;
23684865Sobrien} unw_r_record;
23784865Sobrien
23884865Sobrientypedef struct unw_p_record
23984865Sobrien{
24084865Sobrien  void *imask;
24184865Sobrien  unsigned long t;
24284865Sobrien  unsigned long size;
24384865Sobrien  unsigned long spoff;
24484865Sobrien  unsigned long br;
24584865Sobrien  unsigned long pspoff;
24684865Sobrien  unsigned short gr;
24784865Sobrien  unsigned short rmask;
24884865Sobrien  unsigned short grmask;
24984865Sobrien  unsigned long frmask;
25084865Sobrien  unsigned short brmask;
25184865Sobrien  unsigned char abi;
25284865Sobrien  unsigned char context;
25384865Sobrien} unw_p_record;
25484865Sobrien
25584865Sobrientypedef struct unw_b_record
25684865Sobrien{
25784865Sobrien  unsigned long t;
25884865Sobrien  unsigned long label;
25984865Sobrien  unsigned short ecount;
26084865Sobrien} unw_b_record;
26184865Sobrien
26284865Sobrientypedef struct unw_x_record
26384865Sobrien{
26484865Sobrien  unsigned long t;
26584865Sobrien  unsigned long spoff;
26684865Sobrien  unsigned long pspoff;
26784865Sobrien  unsigned short reg;
26884865Sobrien  unsigned short treg;
26984865Sobrien  unsigned short qp;
27084865Sobrien  unsigned short ab;	/* Value of the AB field..  */
27184865Sobrien  unsigned short xy;	/* Value of the XY field..  */
27284865Sobrien} unw_x_record;
27384865Sobrien
27484865Sobrien/* This structure is used to determine the specific record type and
27584865Sobrien   its fields.  */
27684865Sobrientypedef struct unwind_record
27784865Sobrien{
27884865Sobrien  unw_record_type type;
27984865Sobrien  union {
28084865Sobrien    unw_r_record r;
28184865Sobrien    unw_p_record p;
28284865Sobrien    unw_b_record b;
28384865Sobrien    unw_x_record x;
28484865Sobrien  } record;
28584865Sobrien} unwind_record;
28684865Sobrien
287130561Sobrien/* This expression evaluates to true if the relocation is for a local
28884865Sobrien   object for which we still want to do the relocation at runtime.
289130561Sobrien   False if we are willing to perform this relocation while building
290130561Sobrien   the .o file.  */
29184865Sobrien
29289857Sobrien/* If the reloc type is BFD_RELOC_UNUSED, then this is for a TAG13/TAG13b field
29389857Sobrien   which has no external reloc, so we must resolve the value now.  */
29489857Sobrien
295130561Sobrien#define TC_FORCE_RELOCATION_LOCAL(FIX)			\
296130561Sobrien  ((FIX)->fx_r_type != BFD_RELOC_UNUSED			\
297130561Sobrien   && (!(FIX)->fx_pcrel					\
298130561Sobrien       || (FIX)->fx_plt					\
299130561Sobrien       || TC_FORCE_RELOCATION (FIX)))
300