Commit | Line | Data |
---|---|---|
fea17916 | 1 | /* macro.h - header file for macro support for gas |
6f2750fe | 2 | Copyright (C) 1994-2016 Free Software Foundation, Inc. |
252b5132 RH |
3 | |
4 | Written by Steve and Judy Chamberlain of Cygnus Support, | |
5 | sac@cygnus.com | |
6 | ||
7 | This file is part of GAS, the GNU Assembler. | |
8 | ||
9 | GAS is free software; you can redistribute it and/or modify | |
10 | it under the terms of the GNU General Public License as published by | |
ec2655a6 | 11 | the Free Software Foundation; either version 3, or (at your option) |
252b5132 RH |
12 | any later version. |
13 | ||
14 | GAS is distributed in the hope that it will be useful, | |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | GNU General Public License for more details. | |
18 | ||
19 | You should have received a copy of the GNU General Public License | |
20 | along with GAS; see the file COPYING. If not, write to the Free | |
4b4da160 NC |
21 | Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA |
22 | 02110-1301, USA. */ | |
252b5132 RH |
23 | |
24 | #ifndef MACRO_H | |
25 | ||
26 | #define MACRO_H | |
27 | ||
a01b9fa4 | 28 | /* Structures used to store macros. |
9f10757c TW |
29 | |
30 | Each macro knows its name and included text. It gets built with a | |
31 | list of formal arguments, and also keeps a hash table which points | |
32 | into the list to speed up formal search. Each formal knows its | |
33 | name and its default value. Each time the macro is expanded, the | |
47eebc20 | 34 | formals get the actual values attached to them. */ |
9f10757c | 35 | |
1e9cc1c2 NC |
36 | enum formal_type |
37 | { | |
38 | FORMAL_OPTIONAL, | |
39 | FORMAL_REQUIRED, | |
40 | FORMAL_VARARG | |
41 | }; | |
42 | ||
fea17916 | 43 | /* Describe the formal arguments to a macro. */ |
9f10757c | 44 | |
ef99799a | 45 | typedef struct formal_struct { |
fea17916 NC |
46 | struct formal_struct *next; /* Next formal in list. */ |
47 | sb name; /* Name of the formal. */ | |
48 | sb def; /* The default value. */ | |
49 | sb actual; /* The actual argument (changed on each expansion). */ | |
50 | int index; /* The index of the formal 0..formal_count - 1. */ | |
1e9cc1c2 | 51 | enum formal_type type; /* The kind of the formal. */ |
ef99799a | 52 | } formal_entry; |
9f10757c TW |
53 | |
54 | /* Other values found in the index field of a formal_entry. */ | |
55 | #define QUAL_INDEX (-1) | |
56 | #define NARG_INDEX (-2) | |
57 | #define LOCAL_INDEX (-3) | |
58 | ||
fea17916 | 59 | /* Describe the macro. */ |
9f10757c | 60 | |
fea17916 NC |
61 | typedef struct macro_struct |
62 | { | |
63 | sb sub; /* Substitution text. */ | |
64 | int formal_count; /* Number of formal args. */ | |
65 | formal_entry *formals; /* Pointer to list of formal_structs. */ | |
66 | struct hash_control *formal_hash; /* Hash table of formals. */ | |
02ddf156 | 67 | const char *name; /* Macro name. */ |
3b4dbbbf | 68 | const char *file; /* File the macro was defined in. */ |
02ddf156 | 69 | unsigned int line; /* Line number of definition. */ |
ef99799a | 70 | } macro_entry; |
9f10757c | 71 | |
252b5132 RH |
72 | /* Whether any macros have been defined. */ |
73 | ||
74 | extern int macro_defined; | |
75 | ||
76 | /* The macro nesting level. */ | |
77 | ||
78 | extern int macro_nest; | |
79 | ||
c1d05a60 NC |
80 | /* The macro hash table. */ |
81 | ||
82 | extern struct hash_control *macro_hash; | |
83 | ||
39a45edc AM |
84 | extern int buffer_and_nest (const char *, const char *, sb *, |
85 | size_t (*) (sb *)); | |
86 | extern void macro_init (int, int, int, | |
87 | size_t (*) (const char *, size_t, sb *, offsetT *)); | |
caa32fe5 | 88 | extern void macro_set_alternate (int); |
254d758c | 89 | extern void macro_mri_mode (int); |
39a45edc | 90 | extern const char *define_macro (size_t, sb *, sb *, size_t (*) (sb *), |
3b4dbbbf | 91 | const char *, unsigned int, const char **); |
254d758c KH |
92 | extern int check_macro (const char *, sb *, const char **, macro_entry **); |
93 | extern void delete_macro (const char *); | |
39a45edc | 94 | extern const char *expand_irp (int, size_t, sb *, sb *, size_t (*) (sb *)); |
252b5132 RH |
95 | |
96 | #endif |