ChangeLog:
[deliverable/binutils-gdb.git] / gas / frags.h
CommitLineData
252b5132 1/* frags.h - Header file for the frag concept.
09b935ac 2 Copyright 1987, 1992, 1993, 1994, 1995, 1997, 1998, 1999, 2000, 2001,
ec2655a6 3 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
252b5132
RH
4
5 This file is part of GAS, the GNU Assembler.
6
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
ec2655a6 9 the Free Software Foundation; either version 3, or (at your option)
252b5132
RH
10 any later version.
11
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.
16
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
4b4da160
NC
19 Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
20 02110-1301, USA. */
252b5132
RH
21
22#ifndef FRAGS_H
23#define FRAGS_H
24
252b5132 25struct obstack;
252b5132 26
e6c774b4
KH
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.
37
38 BUG: it may be smarter to have a single pointer off to various different
d1a6c242 39 notes for different frag kinds. See how code pans. */
e6c774b4
KH
40
41struct frag {
a01b9fa4 42 /* Object file address (as an octet offset). */
252b5132 43 addressT fr_address;
e46d99eb
AM
44 /* When relaxing multiple times, remember the address the frag had
45 in the last relax pass. */
46 addressT last_fr_address;
252b5132 47
a01b9fa4 48 /* (Fixed) number of octets we know we have. May be 0. */
252b5132 49 offsetT fr_fix;
ee7fcc42
AM
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. */
252b5132 52 offsetT fr_var;
a01b9fa4 53 /* For variable-length tail. */
252b5132 54 offsetT fr_offset;
e46d99eb
AM
55 /* For variable-length tail. */
56 symbolS *fr_symbol;
252b5132
RH
57 /* Points to opcode low addr byte, for relaxation. */
58 char *fr_opcode;
59
e46d99eb
AM
60 /* Chain forward; ascending address order. Rooted in frch_root. */
61 struct frag *fr_next;
62
63 /* Where the frag was created, or where it became a variant frag. */
64 char *fr_file;
65 unsigned int fr_line;
66
252b5132
RH
67#ifndef NO_LISTING
68 struct list_info_struct *line;
69#endif
70
38686296
AM
71 /* Flipped each relax pass so we can easily determine whether
72 fr_address has been adjusted. */
73 unsigned int relax_marker:1;
74
09b935ac
AM
75 /* Used to ensure that all insns are emitted on proper address
76 boundaries. */
77 unsigned int has_code:1;
78 unsigned int insn_addr:6;
79
252b5132
RH
80 /* What state is my tail in? */
81 relax_stateT fr_type;
82 relax_substateT fr_subtype;
83
84#ifdef USING_CGEN
85 /* Don't include this unless using CGEN to keep frag size down. */
86 struct {
87 /* CGEN_INSN entry for this instruction. */
88 const struct cgen_insn *insn;
89 /* Index into operand table. */
90 int opindex;
91 /* Target specific data, usually reloc number. */
92 int opinfo;
93 } fr_cgen;
94#endif
95
96#ifdef TC_FRAG_TYPE
97 TC_FRAG_TYPE tc_frag_data;
98#endif
99
252b5132
RH
100 /* Data begins here. */
101 char fr_literal[1];
102};
103
104#define SIZEOF_STRUCT_FRAG \
e6c774b4 105((char *) zero_address_frag.fr_literal - (char *) &zero_address_frag)
a01b9fa4 106/* We want to say fr_literal[0] above. */
252b5132
RH
107
108/* Current frag we are building. This frag is incomplete. It is,
109 however, included in frchain_now. The fr_fix field is bogus;
110 instead, use frag_now_fix (). */
111COMMON fragS *frag_now;
dd625418
KH
112extern addressT frag_now_fix (void);
113extern addressT frag_now_fix_octets (void);
252b5132 114
a01b9fa4 115/* For foreign-segment symbol fixups. */
252b5132 116COMMON fragS zero_address_frag;
a01b9fa4 117/* For local common (N_BSS segment) fixups. */
252b5132
RH
118COMMON fragS bss_address_frag;
119
dd625418 120extern void frag_append_1_char (int);
252b5132 121#define FRAG_APPEND_1_CHAR(X) frag_append_1_char (X)
252b5132 122
dd625418
KH
123void frag_init (void);
124fragS *frag_alloc (struct obstack *);
125void frag_grow (unsigned int nchars);
126char *frag_more (int nchars);
127void frag_align (int alignment, int fill_character, int max);
128void frag_align_pattern (int alignment, const char *fill_pattern,
129 int n_fill, int max);
130void frag_align_code (int alignment, int max);
131void frag_new (int old_frags_var_max_size);
132void frag_wane (fragS * fragP);
0530d30a 133int frag_room (void);
dd625418
KH
134
135char *frag_variant (relax_stateT type,
136 int max_chars,
137 int var,
138 relax_substateT subtype,
139 symbolS * symbol,
140 offsetT offset,
141 char *opcode);
142
143char *frag_var (relax_stateT type,
144 int max_chars,
145 int var,
146 relax_substateT subtype,
147 symbolS * symbol,
148 offsetT offset,
149 char *opcode);
252b5132 150
6cbe03fb 151bfd_boolean frag_offset_fixed_p (const fragS *, const fragS *, bfd_vma *);
99630778 152
252b5132 153#endif /* FRAGS_H */
This page took 0.403378 seconds and 4 git commands to generate.