1/* macro.h - header file for macro support for gas
2   Copyright (C) 1994-2017 Free Software Foundation, Inc.
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
11   the Free Software Foundation; either version 3, or (at your option)
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
21   Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
22   02110-1301, USA.  */
23
24#ifndef MACRO_H
25
26#define MACRO_H
27
28/* Structures used to store macros.
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
34   formals get the actual values attached to them.  */
35
36enum formal_type
37  {
38    FORMAL_OPTIONAL,
39    FORMAL_REQUIRED,
40    FORMAL_VARARG
41  };
42
43/* Describe the formal arguments to a macro.  */
44
45typedef struct formal_struct {
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.  */
51  enum formal_type type;	/* The kind of the formal.  */
52} formal_entry;
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
59/* Describe the macro.  */
60
61typedef 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.  */
67  const char *name;			/* Macro name.  */
68  const char *file;				/* File the macro was defined in.  */
69  unsigned int line;			/* Line number of definition.  */
70} macro_entry;
71
72/* Whether any macros have been defined.  */
73
74extern int macro_defined;
75
76/* The macro nesting level.  */
77
78extern int macro_nest;
79
80/* The macro hash table.  */
81
82extern struct hash_control *macro_hash;
83
84extern int buffer_and_nest (const char *, const char *, sb *,
85			    size_t (*) (sb *));
86extern void macro_init (int, int, int,
87			size_t (*) (const char *, size_t, sb *, offsetT *));
88extern void macro_set_alternate (int);
89extern void macro_mri_mode (int);
90extern const char *define_macro (size_t, sb *, sb *, size_t (*) (sb *),
91				 const char *, unsigned int, const char **);
92extern int check_macro (const char *, sb *, const char **, macro_entry **);
93extern void delete_macro (const char *);
94extern const char *expand_irp (int, size_t, sb *, sb *, size_t (*) (sb *));
95
96#endif
97