start using new texinfo stuff -- variables, conditionals. far from complete
[deliverable/binutils-gdb.git] / gas / as.h
1 /* as.h - global header file
2 Copyright (C) 1987, 1990, 1991, 1992 Free Software Foundation, Inc.
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
8 the Free Software Foundation; either version 2, or (at your option)
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
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20 #define GAS 1
21 #include <ansidecl.h>
22 #include "host.h"
23 #include "flonum.h"
24
25 #ifndef __STDC__
26 #define volatile /**/
27 #ifndef const
28 #define const /**/
29 #endif /* const */
30 #endif /* __STDC__ */
31
32 #ifndef __LINE__
33 #define __LINE__ "unknown"
34 #endif /* __LINE__ */
35
36 #ifndef __FILE__
37 #define __FILE__ "unknown"
38 #endif /* __FILE__ */
39
40 /*
41 * I think this stuff is largely out of date. xoxorich.
42 *
43 * CAPITALISED names are #defined.
44 * "lowercaseH" is #defined if "lowercase.h" has been #include-d.
45 * "lowercaseT" is a typedef of "lowercase" objects.
46 * "lowercaseP" is type "pointer to object of type 'lowercase'".
47 * "lowercaseS" is typedef struct ... lowercaseS.
48 *
49 * #define DEBUG to enable all the "know" assertion tests.
50 * #define SUSPECT when debugging.
51 * #define COMMON as "extern" for all modules except one, where you #define
52 * COMMON as "".
53 * If TEST is #defined, then we are testing a module: #define COMMON as "".
54 */
55
56 /* These #defines are for parameters of entire assembler. */
57
58 /* #define SUSPECT JF remove for speed testing */
59 /* These #includes are for type definitions etc. */
60
61 #include <stdio.h>
62 #include <assert.h>
63
64 #define obstack_chunk_alloc xmalloc
65 #define obstack_chunk_free xfree
66
67 #define xfree free
68
69 #define BAD_CASE(value) \
70 { \
71 as_fatal("Case value %d unexpected at line %d of file \"%s\"\n", \
72 value, __LINE__, __FILE__); \
73 }
74 \f
75
76 /* These are assembler-wide concepts */
77
78
79 #ifndef COMMON
80 #ifdef TEST
81 #define COMMON /* declare our COMMONs storage here. */
82 #else
83 #define COMMON extern /* our commons live elswhere */
84 #endif
85 #endif
86 /* COMMON now defined */
87 #define DEBUG /* temporary */
88
89 #ifdef BROKEN_ASSERT
90 /* Turn off all assertion checks, on machines where the assert macro
91 is buggy. (For example, on the RS/6000, Reiser-cpp substitution is
92 done to put the condition into a string, so if the condition contains
93 a string, parse errors result.) */
94 #undef DEBUG
95 #define NDEBUG
96 #endif
97
98 #ifdef DEBUG
99 #undef NDEBUG
100 #ifndef know
101 #define know(p) assert(p) /* Verify our assumptions! */
102 #endif /* not yet defined */
103 #else
104 #define know(p) /* know() checks are no-op.ed */
105 #endif
106 \f
107 /* input_scrub.c */
108
109 /*
110 * Supplies sanitised buffers to read.c.
111 * Also understands printing line-number part of error messages.
112 */
113 \f
114
115 /* subsegs.c Sub-segments. Also, segment(=expression type)s.*/
116
117 /*
118 * This table describes the use of segments as EXPRESSION types.
119 *
120 * X_seg X_add_symbol X_subtract_symbol X_add_number
121 * SEG_ABSENT no (legal) expression
122 * SEG_PASS1 no (defined) "
123 * SEG_BIG * > 32 bits const.
124 * SEG_ABSOLUTE 0
125 * SEG_DATA * 0
126 * SEG_TEXT * 0
127 * SEG_BSS * 0
128 * SEG_UNKNOWN * 0
129 * SEG_DIFFERENCE 0 * 0
130 * SEG_REGISTER *
131 *
132 * The blank fields MUST be 0, and are nugatory.
133 * The '0' fields MAY be 0. The '*' fields MAY NOT be 0.
134 *
135 * SEG_BIG: X_add_number is < 0 if the result is in
136 * generic_floating_point_number. The value is -'c' where c is the
137 * character that introduced the constant. e.g. "0f6.9" will have -'f'
138 * as a X_add_number value.
139 * X_add_number > 0 is a count of how many littlenums it took to
140 * represent a bignum.
141 * SEG_DIFFERENCE:
142 * If segments of both symbols are known, they are the same segment.
143 * X_add_symbol != X_sub_symbol (then we just cancel them, => SEG_ABSOLUTE).
144 */
145
146
147 #ifdef MANY_SEGMENTS
148 #include "bfd.h"
149 #define N_SEGMENTS 10
150 #define SEG_NORMAL(x) ((x) >= SEG_E0 && (x) <= SEG_E9)
151 #define SEG_LIST SEG_E0,SEG_E1,SEG_E2,SEG_E3,SEG_E4,SEG_E5,SEG_E6,SEG_E7,SEG_E8,SEG_E9
152 #define SEG_DATA SEG_E1
153 #define SEG_TEXT SEG_E0
154 #define SEG_BSS SEG_E2
155 #else
156 #define N_SEGMENTS 3
157 #define SEG_NORMAL(x) ((x) == SEG_TEXT || (x) == SEG_DATA || (x) == SEG_BSS)
158 #define SEG_LIST SEG_TEXT,SEG_DATA,SEG_BSS
159 #endif
160
161 typedef enum _segT
162 {
163 SEG_ABSOLUTE = 0,
164 SEG_LIST,
165 SEG_UNKNOWN,
166 SEG_ABSENT, /* Mythical Segment (absent): NO expression seen. */
167 SEG_PASS1, /* Mythical Segment: Need another pass. */
168 SEG_GOOF, /* Only happens if AS has a logic error. */
169 /* Invented so we don't crash printing */
170 /* error message involving weird segment. */
171 SEG_BIG, /* Bigger than 32 bits constant. */
172 SEG_DIFFERENCE, /* Mythical Segment: absolute difference. */
173 SEG_DEBUG, /* Debug segment */
174 SEG_NTV, /* Transfert vector preload segment */
175 SEG_PTV, /* Transfert vector postload segment */
176 SEG_REGISTER, /* Mythical: a register-valued expression */
177 } segT;
178
179 #define SEG_MAXIMUM_ORDINAL (SEG_REGISTER)
180
181 typedef int subsegT;
182
183 /* What subseg we are accreting now? */
184 COMMON subsegT now_subseg;
185
186 /* Segment our instructions emit to. */
187 /* Only OK values are SEG_TEXT or SEG_DATA. */
188 COMMON segT now_seg;
189
190 extern char *const seg_name[];
191 extern int section_alignment[];
192
193
194 /* relax() */
195
196 typedef enum _relax_state
197 {
198 /* Variable chars to be repeated fr_offset times.
199 Fr_symbol unused. Used with fr_offset == 0 for a
200 constant length frag. */
201 rs_fill = 1,
202
203 /* Align: Fr_offset: power of 2. 1 variable char: fill character. */
204 rs_align,
205
206 /* Org: Fr_offset, fr_symbol: address. 1 variable char: fill
207 character. */
208 rs_org,
209
210 rs_machine_dependent,
211
212 #ifndef WORKING_DOT_WORD
213 /* JF: gunpoint */
214 rs_broken_word,
215 #endif
216 } relax_stateT;
217
218 /* typedef unsigned char relax_substateT; */
219 /* JF this is more likely to leave the end of a struct frag on an align
220 boundry. Be very careful with this. */
221 typedef unsigned long relax_substateT;
222
223 /* Enough bits for address, but still an integer type.
224 Could be a problem, cross-assembling for 64-bit machines. */
225 typedef unsigned long relax_addressT;
226 \f
227
228 /* frags.c */
229
230 /*
231 * A code fragment (frag) is some known number of chars, followed by some
232 * unknown number of chars. Typically the unknown number of chars is an
233 * instruction address whose size is yet unknown. We always know the greatest
234 * possible size the unknown number of chars may become, and reserve that
235 * much room at the end of the frag.
236 * Once created, frags do not change address during assembly.
237 * We chain the frags in (a) forward-linked list(s). The object-file address
238 * of the 1st char of a frag is generally not known until after relax().
239 * Many things at assembly time describe an address by {object-file-address
240 * of a particular frag}+offset.
241
242 BUG: it may be smarter to have a single pointer off to various different
243 notes for different frag kinds. See how code pans
244 */
245 struct frag /* a code fragment */
246 {
247 /* Object file address. */
248 unsigned long fr_address;
249 /* Chain forward; ascending address order. */
250 /* Rooted in frch_root. */
251 struct frag *fr_next;
252
253 /* (Fixed) number of chars we know we have. */
254 /* May be 0. */
255 long fr_fix;
256 /* (Variable) number of chars after above. */
257 /* May be 0. */
258 long fr_var;
259 /* For variable-length tail. */
260 struct symbol *fr_symbol;
261 /* For variable-length tail. */
262 long fr_offset;
263 /*->opcode low addr byte,for relax()ation*/
264 char *fr_opcode;
265 /* What state is my tail in? */
266 relax_stateT fr_type;
267 relax_substateT fr_subtype;
268
269 /* These are needed only on the NS32K machines */
270 char fr_pcrel_adjust;
271 char fr_bsr;
272 #ifndef NO_LISTING
273 struct list_info_struct *line;
274 #endif
275 /* Chars begin here.
276 One day we will compile fr_literal[0]. */
277 char fr_literal[1];
278 };
279
280 #define SIZEOF_STRUCT_FRAG \
281 ((int)zero_address_frag.fr_literal-(int)&zero_address_frag)
282 /* We want to say fr_literal[0] above. */
283
284 typedef struct frag fragS;
285
286 /* Current frag we are building. This frag is incomplete. It is, however,
287 included in frchain_now. The fr_fix field is bogus; instead, use:
288 obstack_next_free(&frags)-frag_now->fr_literal. */
289 COMMON fragS *frag_now;
290
291 /* For foreign-segment symbol fixups. */
292 COMMON fragS zero_address_frag;
293 /* For local common (N_BSS segment) fixups. */
294 COMMON fragS bss_address_frag;
295
296 /* main program "as.c" (command arguments etc) */
297
298 /* ['x'] TRUE if "-x" seen. */
299 COMMON char flagseen[128];
300 COMMON unsigned char flag_readonly_data_in_text;
301 COMMON unsigned char flag_suppress_warnings;
302 COMMON unsigned char flag_always_generate_output;
303
304 /* name of emitted object file */
305 COMMON char *out_file_name;
306
307 /* TRUE if we need a second pass. */
308 COMMON int need_pass_2;
309
310 /* TRUE if we should do no relaxing, and
311 leave lots of padding. */
312 COMMON int linkrelax;
313
314 struct _pseudo_type
315 {
316 /* assembler mnemonic, lower case, no '.' */
317 char *poc_name;
318 /* Do the work */
319 void (*poc_handler) ();
320 /* Value to pass to handler */
321 int poc_val;
322 };
323
324 typedef struct _pseudo_type pseudo_typeS;
325
326 #ifndef NO_STDARG
327
328 int had_errors PARAMS ((void));
329 int had_warnings PARAMS ((void));
330 void as_bad PARAMS ((const char *Format,...));
331 void as_fatal PARAMS ((const char *Format,...));
332 void as_tsktsk PARAMS ((const char *Format,...));
333 void as_warn PARAMS ((const char *Format,...));
334
335 #else
336
337 int had_errors ();
338 int had_warnings ();
339 void as_bad ();
340 void as_fatal ();
341 void as_tsktsk ();
342 void as_warn ();
343
344 #endif /* __STDC__ & !NO_STDARG */
345
346 char *app_push PARAMS ((void));
347 char *atof_ieee PARAMS ((char *str, int what_kind, LITTLENUM_TYPE * words));
348 char *input_scrub_include_file PARAMS ((char *filename, char *position));
349 char *input_scrub_new_file PARAMS ((char *filename));
350 char *input_scrub_next_buffer PARAMS ((char **bufp));
351 char *strstr PARAMS ((const char *s, const char *wanted));
352 char *xmalloc PARAMS ((long size));
353 char *xrealloc PARAMS ((char *ptr, long n));
354 int do_scrub_next_char PARAMS ((int (*get) (), void (*unget) ()));
355 int gen_to_words PARAMS ((LITTLENUM_TYPE * words, int precision,
356 long exponent_bits));
357 int had_err PARAMS ((void));
358 int had_errors PARAMS ((void));
359 int had_warnings PARAMS ((void));
360 int ignore_input PARAMS ((void));
361 int scrub_from_file PARAMS ((void));
362 int scrub_from_file PARAMS ((void));
363 int scrub_from_string PARAMS ((void));
364 int seen_at_least_1_file PARAMS ((void));
365 void app_pop PARAMS ((char *arg));
366 void as_howmuch PARAMS ((FILE * stream));
367 void as_perror PARAMS ((char *gripe, char *filename));
368 void as_where PARAMS ((void));
369 void bump_line_counters PARAMS ((void));
370 void do_scrub_begin PARAMS ((void));
371 void input_scrub_begin PARAMS ((void));
372 void input_scrub_close PARAMS ((void));
373 void input_scrub_end PARAMS ((void));
374 void int_to_gen PARAMS ((long x));
375 void new_logical_line PARAMS ((char *fname, int line_number));
376 void scrub_to_file PARAMS ((int ch));
377 void scrub_to_string PARAMS ((int ch));
378 void subseg_change PARAMS ((segT seg, int subseg));
379 void subseg_new PARAMS ((segT seg, subsegT subseg));
380 void subsegs_begin PARAMS ((void));
381
382 /* this one starts the chain of target dependant headers */
383 #include "targ-env.h"
384
385 /* these define types needed by the interfaces */
386 #include "struc-symbol.h"
387
388 #include "write.h"
389 #include "expr.h"
390 #include "frags.h"
391 #include "hash.h"
392 #include "read.h"
393 #include "symbols.h"
394
395 #include "tc.h"
396 #include "obj.h"
397
398 #include "listing.h"
399
400 /* end of as.h */
This page took 0.037128 seconds and 5 git commands to generate.