2000-10-17 Kazu Hirata <kazu@hxi.com>
[deliverable/binutils-gdb.git] / gas / frags.h
CommitLineData
252b5132 1/* frags.h - Header file for the frag concept.
5a327c7a 2 Copyright (C) 1987, 92, 93, 94, 95, 97, 98, 99, 2000
252b5132
RH
3 Free Software Foundation, Inc.
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
9 the Free Software Foundation; either version 2, or (at your option)
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
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
20 02111-1307, USA. */
21
22#ifndef FRAGS_H
23#define FRAGS_H
24
25#ifdef ANSI_PROTOTYPES
26struct obstack;
27#endif
28
e6c774b4
KH
29/* A code fragment (frag) is some known number of chars, followed by some
30 unknown number of chars. Typically the unknown number of chars is an
31 instruction address whose size is yet unknown. We always know the greatest
32 possible size the unknown number of chars may become, and reserve that
33 much room at the end of the frag.
34 Once created, frags do not change address during assembly.
35 We chain the frags in (a) forward-linked list(s). The object-file address
36 of the 1st char of a frag is generally not known until after relax().
37 Many things at assembly time describe an address by {object-file-address
38 of a particular frag}+offset.
39
40 BUG: it may be smarter to have a single pointer off to various different
41 notes for different frag kinds. See how code pans. */
42
43struct frag {
a01b9fa4 44 /* Object file address (as an octet offset). */
252b5132 45 addressT fr_address;
a01b9fa4 46 /* Chain forward; ascending address order. Rooted in frch_root. */
252b5132
RH
47 struct frag *fr_next;
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. */
49309057 55 symbolS *fr_symbol;
a01b9fa4 56 /* For variable-length tail. */
252b5132
RH
57 offsetT fr_offset;
58 /* Points to opcode low addr byte, for relaxation. */
59 char *fr_opcode;
60
61#ifndef NO_LISTING
62 struct list_info_struct *line;
63#endif
64
65 /* What state is my tail in? */
66 relax_stateT fr_type;
67 relax_substateT fr_subtype;
68
69#ifdef USING_CGEN
70 /* Don't include this unless using CGEN to keep frag size down. */
71 struct {
72 /* CGEN_INSN entry for this instruction. */
73 const struct cgen_insn *insn;
74 /* Index into operand table. */
75 int opindex;
76 /* Target specific data, usually reloc number. */
77 int opinfo;
78 } fr_cgen;
79#endif
80
81#ifdef TC_FRAG_TYPE
82 TC_FRAG_TYPE tc_frag_data;
83#endif
84
85 /* Where the frag was created, or where it became a variant frag. */
86 char *fr_file;
87 unsigned int fr_line;
88
89 /* Data begins here. */
90 char fr_literal[1];
91};
92
93#define SIZEOF_STRUCT_FRAG \
e6c774b4 94((char *) zero_address_frag.fr_literal - (char *) &zero_address_frag)
a01b9fa4 95/* We want to say fr_literal[0] above. */
252b5132
RH
96
97/* Current frag we are building. This frag is incomplete. It is,
98 however, included in frchain_now. The fr_fix field is bogus;
99 instead, use frag_now_fix (). */
100COMMON fragS *frag_now;
101extern addressT frag_now_fix PARAMS ((void));
bea9907b 102extern addressT frag_now_fix_octets PARAMS ((void));
252b5132 103
a01b9fa4 104/* For foreign-segment symbol fixups. */
252b5132 105COMMON fragS zero_address_frag;
a01b9fa4 106/* For local common (N_BSS segment) fixups. */
252b5132
RH
107COMMON fragS bss_address_frag;
108
109#if 0
e6c774b4
KH
110/* A macro to speed up appending exactly 1 char to current frag. */
111/* JF changed < 1 to <= 1 to avoid a race conditon. */
112#define FRAG_APPEND_1_CHAR(datum) \
113{ \
114 if (obstack_room (&frags) <= 1) \
115 { \
116 frag_wane (frag_now); \
117 frag_new (0); \
118 } \
119 obstack_1grow (&frags, datum); \
252b5132
RH
120}
121#else
122extern void frag_append_1_char PARAMS ((int));
123#define FRAG_APPEND_1_CHAR(X) frag_append_1_char (X)
124#endif
125
252b5132
RH
126void frag_init PARAMS ((void));
127fragS *frag_alloc PARAMS ((struct obstack *));
128void frag_grow PARAMS ((unsigned int nchars));
129char *frag_more PARAMS ((int nchars));
130void frag_align PARAMS ((int alignment, int fill_character, int max));
131void frag_align_pattern PARAMS ((int alignment,
132 const char *fill_pattern,
133 int n_fill,
134 int max));
135void frag_new PARAMS ((int old_frags_var_max_size));
136void frag_wane PARAMS ((fragS * fragP));
137
138char *frag_variant PARAMS ((relax_stateT type,
139 int max_chars,
140 int var,
141 relax_substateT subtype,
142 symbolS * symbol,
143 offsetT offset,
144 char *opcode));
145
146char *frag_var PARAMS ((relax_stateT type,
147 int max_chars,
148 int var,
149 relax_substateT subtype,
150 symbolS * symbol,
151 offsetT offset,
152 char *opcode));
153
154#endif /* FRAGS_H */
This page took 0.08708 seconds and 4 git commands to generate.