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