1235783Skib/* macro.h - header file for macro support for gas
2235783Skib   Copyright 1994, 1995, 1996, 1997, 1998, 2000, 2002, 2003, 2004, 2006
3235783Skib   Free Software Foundation, Inc.
4235783Skib
5235783Skib   Written by Steve and Judy Chamberlain of Cygnus Support,
6235783Skib      sac@cygnus.com
7235783Skib
8235783Skib   This file is part of GAS, the GNU Assembler.
9235783Skib
10235783Skib   GAS is free software; you can redistribute it and/or modify
11235783Skib   it under the terms of the GNU General Public License as published by
12235783Skib   the Free Software Foundation; either version 2, or (at your option)
13235783Skib   any later version.
14235783Skib
15235783Skib   GAS is distributed in the hope that it will be useful,
16235783Skib   but WITHOUT ANY WARRANTY; without even the implied warranty of
17235783Skib   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18235783Skib   GNU General Public License for more details.
19235783Skib
20235783Skib   You should have received a copy of the GNU General Public License
21235783Skib   along with GAS; see the file COPYING.  If not, write to the Free
22235783Skib   Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
23235783Skib   02110-1301, USA.  */
24235783Skib
25235783Skib#ifndef MACRO_H
26235783Skib
27235783Skib#define MACRO_H
28235783Skib
29235783Skib/* Structures used to store macros.
30235783Skib
31235783Skib   Each macro knows its name and included text.  It gets built with a
32235783Skib   list of formal arguments, and also keeps a hash table which points
33235783Skib   into the list to speed up formal search.  Each formal knows its
34235783Skib   name and its default value.  Each time the macro is expanded, the
35279961Sjhb   formals get the actual values attached to them.  */
36279961Sjhb
37279961Sjhb/* Describe the formal arguments to a macro.  */
38235783Skib
39235783Skibtypedef struct formal_struct {
40235783Skib  struct formal_struct *next;	/* Next formal in list.  */
41235783Skib  sb name;			/* Name of the formal.  */
42235783Skib  sb def;			/* The default value.  */
43235783Skib  sb actual;			/* The actual argument (changed on each expansion).  */
44235783Skib  int index;			/* The index of the formal 0..formal_count - 1.  */
45235783Skib  enum formal_type
46235783Skib    {
47235783Skib      FORMAL_OPTIONAL,
48235783Skib      FORMAL_REQUIRED,
49235783Skib      FORMAL_VARARG
50235783Skib    } type;			/* The kind of the formal.  */
51235783Skib} formal_entry;
52235783Skib
53235783Skib/* Other values found in the index field of a formal_entry.  */
54235783Skib#define QUAL_INDEX (-1)
55235783Skib#define NARG_INDEX (-2)
56235783Skib#define LOCAL_INDEX (-3)
57235783Skib
58235783Skib/* Describe the macro.  */
59235783Skib
60235783Skibtypedef struct macro_struct
61235783Skib{
62235783Skib  sb sub;				/* Substitution text.  */
63235783Skib  int formal_count;			/* Number of formal args.  */
64235783Skib  formal_entry *formals;		/* Pointer to list of formal_structs.  */
65235783Skib  struct hash_control *formal_hash;	/* Hash table of formals.  */
66235783Skib  const char *name;			/* Macro name.  */
67235783Skib  char *file;				/* File the macro was defined in.  */
68235783Skib  unsigned int line;			/* Line number of definition.  */
69235783Skib} macro_entry;
70235783Skib
71235783Skib/* Whether any macros have been defined.  */
72235783Skib
73235783Skibextern int macro_defined;
74235783Skib
75235783Skib/* The macro nesting level.  */
76235783Skib
77235783Skibextern int macro_nest;
78235783Skib
79235783Skib/* The macro hash table.  */
80235783Skib
81235783Skibextern struct hash_control *macro_hash;
82235783Skib
83235783Skibextern int buffer_and_nest (const char *, const char *, sb *, int (*) (sb *));
84235783Skibextern void macro_init
85235783Skib  (int, int, int, int (*) (const char *, int, sb *, int *));
86235783Skibextern void macro_set_alternate (int);
87235783Skibextern void macro_mri_mode (int);
88235783Skibextern const char *define_macro
89235783Skib  (int, sb *, sb *, int (*) (sb *), char *, unsigned int, const char **);
90235783Skibextern int check_macro (const char *, sb *, const char **, macro_entry **);
91235783Skibextern void delete_macro (const char *);
92235783Skibextern const char *expand_irp (int, int, sb *, sb *, int (*) (sb *));
93235783Skib
94235783Skib#endif
95235783Skib