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