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