* frv.opc (parse_uhi16): Fix handling of %hi operator on 64-bit
[binutils.git] / gas / frags.h
blobdd247f9c535accacd61b55723080ea9ef0431ed6
1 /* frags.h - Header file for the frag concept.
2 Copyright 1987, 1992, 1993, 1994, 1995, 1997, 1998, 1999, 2000, 2001,
3 2002, 2003, 2004, 2005, 2006, 2007, 2010 Free Software Foundation, Inc.
5 This file is part of GAS, the GNU Assembler.
7 GAS is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
10 any later version.
12 GAS is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GAS; see the file COPYING. If not, write to the Free
19 Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
20 02110-1301, USA. */
22 #ifndef FRAGS_H
23 #define FRAGS_H
25 struct obstack;
27 /* A code fragment (frag) is some known number of chars, followed by some
28 unknown number of chars. Typically the unknown number of chars is an
29 instruction address whose size is yet unknown. We always know the greatest
30 possible size the unknown number of chars may become, and reserve that
31 much room at the end of the frag.
32 Once created, frags do not change address during assembly.
33 We chain the frags in (a) forward-linked list(s). The object-file address
34 of the 1st char of a frag is generally not known until after relax().
35 Many things at assembly time describe an address by {object-file-address
36 of a particular frag}+offset.
38 BUG: it may be smarter to have a single pointer off to various different
39 notes for different frag kinds. See how code pans. */
41 struct frag {
42 /* Object file address (as an octet offset). */
43 addressT fr_address;
44 /* When relaxing multiple times, remember the address the frag had
45 in the last relax pass. */
46 addressT last_fr_address;
48 /* (Fixed) number of octets we know we have. May be 0. */
49 offsetT fr_fix;
50 /* May be used for (Variable) number of octets after above.
51 The generic frag handling code no longer makes any use of fr_var. */
52 offsetT fr_var;
53 /* For variable-length tail. */
54 offsetT fr_offset;
55 /* For variable-length tail. */
56 symbolS *fr_symbol;
57 /* Points to opcode low addr byte, for relaxation. */
58 char *fr_opcode;
60 /* Chain forward; ascending address order. Rooted in frch_root. */
61 struct frag *fr_next;
63 /* Where the frag was created, or where it became a variant frag. */
64 char *fr_file;
65 unsigned int fr_line;
67 #ifndef NO_LISTING
68 struct list_info_struct *line;
69 #endif
71 /* A serial number for a sequence of frags having at most one alignment
72 or org frag, and that at the tail of the sequence. */
73 unsigned int region:16;
75 /* Flipped each relax pass so we can easily determine whether
76 fr_address has been adjusted. */
77 unsigned int relax_marker:1;
79 /* Used to ensure that all insns are emitted on proper address
80 boundaries. */
81 unsigned int has_code:1;
82 unsigned int insn_addr:6;
84 /* What state is my tail in? */
85 relax_stateT fr_type;
86 relax_substateT fr_subtype;
88 #ifdef USING_CGEN
89 /* Don't include this unless using CGEN to keep frag size down. */
90 struct {
91 /* CGEN_INSN entry for this instruction. */
92 const struct cgen_insn *insn;
93 /* Index into operand table. */
94 int opindex;
95 /* Target specific data, usually reloc number. */
96 int opinfo;
97 } fr_cgen;
98 #endif
100 #ifdef TC_FRAG_TYPE
101 TC_FRAG_TYPE tc_frag_data;
102 #endif
104 /* Data begins here. */
105 char fr_literal[1];
108 #define SIZEOF_STRUCT_FRAG \
109 ((char *) zero_address_frag.fr_literal - (char *) &zero_address_frag)
110 /* We want to say fr_literal[0] above. */
112 /* Current frag we are building. This frag is incomplete. It is,
113 however, included in frchain_now. The fr_fix field is bogus;
114 instead, use frag_now_fix (). */
115 COMMON fragS *frag_now;
116 extern addressT frag_now_fix (void);
117 extern addressT frag_now_fix_octets (void);
119 /* For foreign-segment symbol fixups. */
120 COMMON fragS zero_address_frag;
121 COMMON fragS predefined_address_frag;
123 extern void frag_append_1_char (int);
124 #define FRAG_APPEND_1_CHAR(X) frag_append_1_char (X)
126 void frag_init (void);
127 fragS *frag_alloc (struct obstack *);
128 void frag_grow (unsigned int nchars);
129 char *frag_more (int nchars);
130 void frag_align (int alignment, int fill_character, int max);
131 void frag_align_pattern (int alignment, const char *fill_pattern,
132 int n_fill, int max);
133 void frag_align_code (int alignment, int max);
134 void frag_new (int old_frags_var_max_size);
135 void frag_wane (fragS * fragP);
136 int frag_room (void);
138 char *frag_variant (relax_stateT type,
139 int max_chars,
140 int var,
141 relax_substateT subtype,
142 symbolS * symbol,
143 offsetT offset,
144 char *opcode);
146 char *frag_var (relax_stateT type,
147 int max_chars,
148 int var,
149 relax_substateT subtype,
150 symbolS * symbol,
151 offsetT offset,
152 char *opcode);
154 bfd_boolean frag_offset_fixed_p (const fragS *, const fragS *, bfd_vma *);
156 #endif /* FRAGS_H */