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