* config/tc-mips.c (mips_emit_delays): Make call to
[deliverable/binutils-gdb.git] / gas / as.h
CommitLineData
fecd2382 1/* as.h - global header file
3340f7e5 2 Copyright (C) 1987, 1990, 1991, 1992 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
RP
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. */
fecd2382 19
7f955c18 20#ifndef GAS
fecd2382 21#define GAS 1
fecd2382
RP
22/*
23 * I think this stuff is largely out of date. xoxorich.
24 *
25 * CAPITALISED names are #defined.
26 * "lowercaseH" is #defined if "lowercase.h" has been #include-d.
27 * "lowercaseT" is a typedef of "lowercase" objects.
28 * "lowercaseP" is type "pointer to object of type 'lowercase'".
29 * "lowercaseS" is typedef struct ... lowercaseS.
30 *
31 * #define DEBUG to enable all the "know" assertion tests.
68878ef1 32 * #define SUSPECT when debugging hash code.
fecd2382
RP
33 * #define COMMON as "extern" for all modules except one, where you #define
34 * COMMON as "".
35 * If TEST is #defined, then we are testing a module: #define COMMON as "".
36 */
37
38/* These #defines are for parameters of entire assembler. */
39
fecd2382
RP
40/* These #includes are for type definitions etc. */
41
7f955c18
KR
42#include "config.h"
43
fecd2382 44#include <stdio.h>
68878ef1
KR
45#ifdef DEBUG
46#undef NDEBUG
47#endif
fecd2382 48#include <assert.h>
c593cf41 49
68878ef1
KR
50#include <ansidecl.h>
51#ifdef BFD_ASSEMBLER
52#include <bfd.h>
53#endif
54#include "host.h"
55#include "flonum.h"
56
b17c891e
KR
57/* Make Saber happier on obstack.h. */
58#ifdef SABER
59#undef __PTR_TO_INT
60#define __PTR_TO_INT(P) ((int)(P))
61#undef __INT_TO_PTR
62#define __INT_TO_PTR(P) ((char *)(P))
63#endif
64
68878ef1
KR
65#ifndef __LINE__
66#define __LINE__ "unknown"
67#endif /* __LINE__ */
68
69#ifndef __FILE__
70#define __FILE__ "unknown"
71#endif /* __FILE__ */
72
b17c891e
KR
73#ifndef __STDC__
74#ifndef const
75#define const
76#endif
77#ifndef volatile
78#define volatile
79#endif
80#endif /* ! __STDC__ */
81
98c6bbbe
KR
82#if !defined (__GNUC__) && !defined (inline)
83#define inline
84#endif
85
7f955c18
KR
86#ifndef FOPEN_WB
87#include "fopen-same.h"
88#endif
89
3340f7e5
RP
90#define obstack_chunk_alloc xmalloc
91#define obstack_chunk_free xfree
fecd2382 92
a39116f1
RP
93#define xfree free
94
b17c891e 95#define BAD_CASE(val) \
a39116f1 96{ \
58d4951d
ILT
97 as_fatal("Case value %ld unexpected at line %d of file \"%s\"\n", \
98 (long) val, __LINE__, __FILE__); \
a39116f1 99 }
fecd2382 100\f
6efd877d 101
fecd2382
RP
102/* These are assembler-wide concepts */
103
68878ef1
KR
104#ifdef BFD_ASSEMBLER
105extern bfd *stdoutput;
b17c891e
KR
106typedef bfd_vma addressT;
107typedef bfd_signed_vma offsetT;
108#else
109typedef unsigned long addressT;
110typedef long offsetT;
68878ef1 111#endif
fecd2382 112
b17c891e
KR
113/* Type of symbol value, etc. For use in prototypes. */
114typedef addressT valueT;
115
fecd2382
RP
116#ifndef COMMON
117#ifdef TEST
118#define COMMON /* declare our COMMONs storage here. */
119#else
120#define COMMON extern /* our commons live elswhere */
121#endif
122#endif
a39116f1 123/* COMMON now defined */
c8c7e0bf 124
fecd2382 125#ifdef DEBUG
ace68c4e 126#ifndef know
fecd2382 127#define know(p) assert(p) /* Verify our assumptions! */
ace68c4e 128#endif /* not yet defined */
fecd2382
RP
129#else
130#define know(p) /* know() checks are no-op.ed */
131#endif
68878ef1
KR
132
133#if defined (BROKEN_ASSERT) && !defined (NDEBUG)
134/* Used on machines where the "assert" macro is buggy. (For example, on the
135 RS/6000, Reiser-cpp substitution is done to put the condition into a
136 string, so if the condition contains a string, parse errors result.) If
137 the condition fails, just drop core file. */
138#undef assert
139#define assert(p) ((p) ? 0 : (abort (), 0))
140#endif
fecd2382
RP
141\f
142/* input_scrub.c */
143
144/*
145 * Supplies sanitised buffers to read.c.
146 * Also understands printing line-number part of error messages.
147 */
fecd2382 148\f
6efd877d 149
fecd2382
RP
150/* subsegs.c Sub-segments. Also, segment(=expression type)s.*/
151
68878ef1 152#ifndef BFD_ASSEMBLER
ace68c4e 153
58721107 154#ifdef MANY_SEGMENTS
c8c7e0bf 155#include "bfd.h"
ace68c4e 156#define N_SEGMENTS 10
58721107 157#define SEG_NORMAL(x) ((x) >= SEG_E0 && (x) <= SEG_E9)
ace68c4e 158#define SEG_LIST SEG_E0,SEG_E1,SEG_E2,SEG_E3,SEG_E4,SEG_E5,SEG_E6,SEG_E7,SEG_E8,SEG_E9
ada269da 159#define SEG_TEXT SEG_E0
68878ef1 160#define SEG_DATA SEG_E1
ada269da 161#define SEG_BSS SEG_E2
58721107 162#else
ace68c4e 163#define N_SEGMENTS 3
58721107 164#define SEG_NORMAL(x) ((x) == SEG_TEXT || (x) == SEG_DATA || (x) == SEG_BSS)
ace68c4e 165#define SEG_LIST SEG_TEXT,SEG_DATA,SEG_BSS
58721107
SC
166#endif
167
6efd877d
KR
168typedef enum _segT
169 {
170 SEG_ABSOLUTE = 0,
171 SEG_LIST,
172 SEG_UNKNOWN,
6efd877d
KR
173 SEG_GOOF, /* Only happens if AS has a logic error. */
174 /* Invented so we don't crash printing */
175 /* error message involving weird segment. */
58d4951d 176 SEG_EXPR, /* Intermediate expression values. */
6efd877d
KR
177 SEG_DEBUG, /* Debug segment */
178 SEG_NTV, /* Transfert vector preload segment */
179 SEG_PTV, /* Transfert vector postload segment */
b17c891e 180 SEG_REGISTER /* Mythical: a register-valued expression */
6efd877d 181 } segT;
fecd2382
RP
182
183#define SEG_MAXIMUM_ORDINAL (SEG_REGISTER)
68878ef1
KR
184#else
185typedef asection *segT;
186#define SEG_NORMAL(SEG) ((SEG) != absolute_section \
187 && (SEG) != undefined_section \
68878ef1 188 && (SEG) != reg_section \
58d4951d 189 && (SEG) != expr_section)
68878ef1 190#endif
fecd2382
RP
191typedef int subsegT;
192
a39116f1 193/* What subseg we are accreting now? */
7f2cb270 194COMMON subsegT now_subseg;
fecd2382 195
a39116f1 196/* Segment our instructions emit to. */
7f2cb270 197COMMON segT now_seg;
fecd2382 198
68878ef1
KR
199#ifdef BFD_ASSEMBLER
200#define segment_name(SEG) bfd_get_section_name (stdoutput, SEG)
201#else
b17c891e 202extern char *const seg_name[];
68878ef1
KR
203#define segment_name(SEG) seg_name[(int) (SEG)]
204#endif
205
206#ifndef BFD_ASSEMBLER
fecd2382 207extern int section_alignment[];
68878ef1 208#endif
fecd2382 209
68878ef1 210#ifdef BFD_ASSEMBLER
58d4951d 211extern segT reg_section, expr_section;
68878ef1
KR
212/* Shouldn't these be eliminated someday? */
213extern segT text_section, data_section, bss_section;
214#define absolute_section (&bfd_abs_section)
215#define undefined_section (&bfd_und_section)
216#else
68878ef1 217#define reg_section SEG_REGISTER
58d4951d 218#define expr_section SEG_EXPR
68878ef1
KR
219#define text_section SEG_TEXT
220#define data_section SEG_DATA
221#define bss_section SEG_BSS
222#define absolute_section SEG_ABSOLUTE
223#define undefined_section SEG_UNKNOWN
224#endif
fecd2382
RP
225
226/* relax() */
227
6efd877d
KR
228typedef enum _relax_state
229 {
7f2cb270
KR
230 /* Variable chars to be repeated fr_offset times.
231 Fr_symbol unused. Used with fr_offset == 0 for a
232 constant length frag. */
233 rs_fill = 1,
6efd877d 234
98c6bbbe 235 /* Align: Fr_offset: power of 2. Variable chars: fill pattern. */
7f2cb270 236 rs_align,
6efd877d 237
7f2cb270
KR
238 /* Org: Fr_offset, fr_symbol: address. 1 variable char: fill
239 character. */
240 rs_org,
6efd877d 241
b17c891e 242 rs_machine_dependent
6efd877d 243
fecd2382 244#ifndef WORKING_DOT_WORD
7f2cb270 245 /* JF: gunpoint */
b17c891e 246 , rs_broken_word
fecd2382 247#endif
6efd877d 248 } relax_stateT;
fecd2382
RP
249
250/* typedef unsigned char relax_substateT; */
251/* JF this is more likely to leave the end of a struct frag on an align
252 boundry. Be very careful with this. */
253typedef unsigned long relax_substateT;
254
7f2cb270
KR
255/* Enough bits for address, but still an integer type.
256 Could be a problem, cross-assembling for 64-bit machines. */
b17c891e 257typedef addressT relax_addressT;
fecd2382 258\f
6efd877d 259
fecd2382
RP
260/* frags.c */
261
262/*
263 * A code fragment (frag) is some known number of chars, followed by some
264 * unknown number of chars. Typically the unknown number of chars is an
265 * instruction address whose size is yet unknown. We always know the greatest
266 * possible size the unknown number of chars may become, and reserve that
267 * much room at the end of the frag.
268 * Once created, frags do not change address during assembly.
269 * We chain the frags in (a) forward-linked list(s). The object-file address
270 * of the 1st char of a frag is generally not known until after relax().
271 * Many things at assembly time describe an address by {object-file-address
272 * of a particular frag}+offset.
6efd877d 273
fecd2382 274 BUG: it may be smarter to have a single pointer off to various different
6efd877d 275 notes for different frag kinds. See how code pans
fecd2382 276 */
68878ef1 277struct frag
fecd2382 278{
7f2cb270 279 /* Object file address. */
b17c891e 280 addressT fr_address;
68878ef1 281 /* Chain forward; ascending address order. Rooted in frch_root. */
7f2cb270 282 struct frag *fr_next;
6efd877d 283
68878ef1 284 /* (Fixed) number of chars we know we have. May be 0. */
b17c891e 285 offsetT fr_fix;
68878ef1 286 /* (Variable) number of chars after above. May be 0. */
b17c891e 287 offsetT fr_var;
7f2cb270
KR
288 /* For variable-length tail. */
289 struct symbol *fr_symbol;
290 /* For variable-length tail. */
b17c891e 291 offsetT fr_offset;
68878ef1 292 /* Points to opcode low addr byte, for relaxation. */
7f2cb270 293 char *fr_opcode;
68878ef1
KR
294
295#ifndef NO_LISTING
296 struct list_info_struct *line;
297#endif
298
7f2cb270
KR
299 /* What state is my tail in? */
300 relax_stateT fr_type;
6efd877d 301 relax_substateT fr_subtype;
7f2cb270 302
6efd877d
KR
303 /* These are needed only on the NS32K machines */
304 char fr_pcrel_adjust;
305 char fr_bsr;
68878ef1 306
7f2cb270
KR
307 /* Chars begin here.
308 One day we will compile fr_literal[0]. */
309 char fr_literal[1];
fecd2382 310};
6efd877d 311
fecd2382 312#define SIZEOF_STRUCT_FRAG \
a39116f1
RP
313((int)zero_address_frag.fr_literal-(int)&zero_address_frag)
314/* We want to say fr_literal[0] above. */
fecd2382
RP
315
316typedef struct frag fragS;
317
7f2cb270
KR
318/* Current frag we are building. This frag is incomplete. It is, however,
319 included in frchain_now. The fr_fix field is bogus; instead, use:
320 obstack_next_free(&frags)-frag_now->fr_literal. */
321COMMON fragS *frag_now;
b17c891e 322#define frag_now_fix() ((char*)obstack_next_free (&frags) - frag_now->fr_literal)
fecd2382 323
7f2cb270
KR
324/* For foreign-segment symbol fixups. */
325COMMON fragS zero_address_frag;
326/* For local common (N_BSS segment) fixups. */
327COMMON fragS bss_address_frag;
fecd2382
RP
328
329/* main program "as.c" (command arguments etc) */
330
7f2cb270
KR
331/* ['x'] TRUE if "-x" seen. */
332COMMON char flagseen[128];
333COMMON unsigned char flag_readonly_data_in_text;
334COMMON unsigned char flag_suppress_warnings;
335COMMON unsigned char flag_always_generate_output;
fecd2382 336
7f2cb270
KR
337/* name of emitted object file */
338COMMON char *out_file_name;
fecd2382 339
7f2cb270
KR
340/* TRUE if we need a second pass. */
341COMMON int need_pass_2;
09952cd9 342
7f2cb270
KR
343/* TRUE if we should do no relaxing, and
344 leave lots of padding. */
345COMMON int linkrelax;
fecd2382 346
7f955c18
KR
347/* TRUE if we should produce a listing. */
348extern int listing;
349
7f2cb270 350struct _pseudo_type
6efd877d 351 {
7f2cb270
KR
352 /* assembler mnemonic, lower case, no '.' */
353 char *poc_name;
354 /* Do the work */
604633ae 355 void (*poc_handler) PARAMS ((int));
7f2cb270
KR
356 /* Value to pass to handler */
357 int poc_val;
358 };
6efd877d 359
7f2cb270 360typedef struct _pseudo_type pseudo_typeS;
fecd2382 361
68878ef1
KR
362#ifdef BFD_ASSEMBLER_xxx
363struct lineno_struct
364 {
365 alent line;
366 fragS *frag;
367 struct lineno_struct *next;
368 };
369typedef struct lineno_struct lineno;
370#endif
fecd2382 371
68878ef1 372#if defined (__STDC__) && !defined(NO_STDARG)
fecd2382 373
68878ef1
KR
374#if __GNUC__ >= 2
375/* for use with -Wformat */
7f955c18 376#define PRINTF_LIKE(FCN) void FCN (const char *format, ...) \
68878ef1 377 __attribute__ ((format (printf, 1, 2)))
a57180ad
ILT
378#define PRINTF_WHERE_LIKE(FCN) void FCN (char *file, unsigned int line, \
379 const char *format, ...) \
380 __attribute__ ((format (printf, 3, 4)))
68878ef1 381#else /* ANSI C with stdarg, but not GNU C */
7f955c18 382#define PRINTF_LIKE(FCN) void FCN (const char *format, ...)
a57180ad
ILT
383#define PRINTF_WHERE_LIKE(FCN) void FCN (char *file, unsigned int line, \
384 const char *format, ...)
68878ef1
KR
385#endif
386#else /* not ANSI C, or not stdarg */
387#define PRINTF_LIKE(FCN) void FCN ()
a57180ad 388#define PRINTF_WHERE_LIKE(FCN) void FCN ()
68878ef1 389#endif
fecd2382 390
68878ef1
KR
391PRINTF_LIKE (as_bad);
392PRINTF_LIKE (as_fatal);
393PRINTF_LIKE (as_tsktsk);
394PRINTF_LIKE (as_warn);
a57180ad
ILT
395PRINTF_WHERE_LIKE (as_bad_where);
396PRINTF_WHERE_LIKE (as_warn_where);
7f955c18 397
b17c891e
KR
398void fprint_value PARAMS ((FILE *file, addressT value));
399void sprint_value PARAMS ((char *buf, addressT value));
fecd2382 400
68878ef1
KR
401int had_errors PARAMS ((void));
402int had_warnings PARAMS ((void));
fecd2382 403
604633ae 404void print_version_id PARAMS ((void));
7f2cb270
KR
405char *app_push PARAMS ((void));
406char *atof_ieee PARAMS ((char *str, int what_kind, LITTLENUM_TYPE * words));
407char *input_scrub_include_file PARAMS ((char *filename, char *position));
408char *input_scrub_new_file PARAMS ((char *filename));
409char *input_scrub_next_buffer PARAMS ((char **bufp));
b17c891e 410#if 0 /* incompatible with solaris 2 native cc */
7f2cb270 411char *strstr PARAMS ((const char *s, const char *wanted));
b17c891e 412#endif
604633ae
ILT
413char *xmalloc PARAMS ((unsigned long size));
414char *xrealloc PARAMS ((char *ptr, unsigned long n));
415int do_scrub_next_char PARAMS ((int (*get) (void), void (*unget) (int)));
7f2cb270
KR
416int gen_to_words PARAMS ((LITTLENUM_TYPE * words, int precision,
417 long exponent_bits));
418int had_err PARAMS ((void));
7f2cb270
KR
419int ignore_input PARAMS ((void));
420int scrub_from_file PARAMS ((void));
7f2cb270
KR
421int scrub_from_string PARAMS ((void));
422int seen_at_least_1_file PARAMS ((void));
423void app_pop PARAMS ((char *arg));
424void as_howmuch PARAMS ((FILE * stream));
425void as_perror PARAMS ((char *gripe, char *filename));
7f955c18 426void as_where PARAMS ((char **namep, unsigned int *linep));
7f2cb270
KR
427void bump_line_counters PARAMS ((void));
428void do_scrub_begin PARAMS ((void));
429void input_scrub_begin PARAMS ((void));
430void input_scrub_close PARAMS ((void));
431void input_scrub_end PARAMS ((void));
7f2cb270
KR
432void new_logical_line PARAMS ((char *fname, int line_number));
433void scrub_to_file PARAMS ((int ch));
434void scrub_to_string PARAMS ((int ch));
68878ef1 435void subsegs_begin PARAMS ((void));
7f2cb270 436void subseg_change PARAMS ((segT seg, int subseg));
b17c891e 437segT subseg_new PARAMS ((const char *name, subsegT subseg));
e7501ac7 438segT subseg_force_new PARAMS ((const char *name, subsegT subseg));
68878ef1 439void subseg_set PARAMS ((segT seg, subsegT subseg));
fecd2382 440
7f955c18
KR
441struct expressionS;
442struct fix;
443struct symbol;
444
445#ifdef BFD_ASSEMBLER
446/* literal.c */
447valueT add_to_literal_pool PARAMS ((struct symbol *, valueT, segT, int));
448#endif
449
a39116f1 450/* this one starts the chain of target dependant headers */
fecd2382
RP
451#include "targ-env.h"
452
85051959 453#include "expr.h"
fecd2382 454#include "struc-symbol.h"
fecd2382 455#include "write.h"
fecd2382
RP
456#include "frags.h"
457#include "hash.h"
458#include "read.h"
459#include "symbols.h"
460
461#include "tc.h"
462#include "obj.h"
463
c593cf41
SC
464#include "listing.h"
465
b17c891e
KR
466#ifdef BFD_ASSEMBLER
467/* Someday perhaps this will be selectable at run-time. */
468#if defined (OBJ_AOUT) || defined (OBJ_BOUT)
469#define OUTPUT_FLAVOR bfd_target_aout_flavour
470#endif
471#ifdef OBJ_COFF
472#define OUTPUT_FLAVOR bfd_target_coff_flavour
473#endif
474#ifdef OBJ_ECOFF
475#define OUTPUT_FLAVOR bfd_target_ecoff_flavour
476#endif
477#ifdef OBJ_ELF
478#define OUTPUT_FLAVOR bfd_target_elf_flavour
479#endif
480#endif /* BFD_ASSEMBLER */
481
7f955c18
KR
482#endif /* GAS */
483
a39116f1 484/* end of as.h */
This page took 0.128125 seconds and 4 git commands to generate.