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