1130561Sobrien/* macro.h - header file for macro support for gas 2218822Sdim Copyright 1994, 1995, 1996, 1997, 1998, 2000, 2002, 2003, 2004, 2006 378828Sobrien Free Software Foundation, Inc. 433965Sjdp 533965Sjdp Written by Steve and Judy Chamberlain of Cygnus Support, 633965Sjdp sac@cygnus.com 733965Sjdp 833965Sjdp This file is part of GAS, the GNU Assembler. 933965Sjdp 1033965Sjdp GAS is free software; you can redistribute it and/or modify 1133965Sjdp it under the terms of the GNU General Public License as published by 1233965Sjdp the Free Software Foundation; either version 2, or (at your option) 1333965Sjdp any later version. 1433965Sjdp 1533965Sjdp GAS is distributed in the hope that it will be useful, 1633965Sjdp but WITHOUT ANY WARRANTY; without even the implied warranty of 1733965Sjdp MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1833965Sjdp GNU General Public License for more details. 1933965Sjdp 2033965Sjdp You should have received a copy of the GNU General Public License 2133965Sjdp along with GAS; see the file COPYING. If not, write to the Free 22218822Sdim Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 23218822Sdim 02110-1301, USA. */ 2433965Sjdp 2533965Sjdp#ifndef MACRO_H 2633965Sjdp 2733965Sjdp#define MACRO_H 2833965Sjdp 2977298Sobrien/* Structures used to store macros. 3060484Sobrien 3160484Sobrien Each macro knows its name and included text. It gets built with a 3260484Sobrien list of formal arguments, and also keeps a hash table which points 3360484Sobrien into the list to speed up formal search. Each formal knows its 3460484Sobrien name and its default value. Each time the macro is expanded, the 35130561Sobrien formals get the actual values attached to them. */ 3660484Sobrien 37130561Sobrien/* Describe the formal arguments to a macro. */ 3860484Sobrien 3977298Sobrientypedef struct formal_struct { 40130561Sobrien struct formal_struct *next; /* Next formal in list. */ 41130561Sobrien sb name; /* Name of the formal. */ 42130561Sobrien sb def; /* The default value. */ 43130561Sobrien sb actual; /* The actual argument (changed on each expansion). */ 44130561Sobrien int index; /* The index of the formal 0..formal_count - 1. */ 45218822Sdim enum formal_type 46218822Sdim { 47218822Sdim FORMAL_OPTIONAL, 48218822Sdim FORMAL_REQUIRED, 49218822Sdim FORMAL_VARARG 50218822Sdim } type; /* The kind of the formal. */ 5177298Sobrien} formal_entry; 5260484Sobrien 5360484Sobrien/* Other values found in the index field of a formal_entry. */ 5460484Sobrien#define QUAL_INDEX (-1) 5560484Sobrien#define NARG_INDEX (-2) 5660484Sobrien#define LOCAL_INDEX (-3) 5760484Sobrien 58130561Sobrien/* Describe the macro. */ 5960484Sobrien 60130561Sobrientypedef struct macro_struct 61130561Sobrien{ 62130561Sobrien sb sub; /* Substitution text. */ 63130561Sobrien int formal_count; /* Number of formal args. */ 64130561Sobrien formal_entry *formals; /* Pointer to list of formal_structs. */ 65130561Sobrien struct hash_control *formal_hash; /* Hash table of formals. */ 66218822Sdim const char *name; /* Macro name. */ 67218822Sdim char *file; /* File the macro was defined in. */ 68218822Sdim unsigned int line; /* Line number of definition. */ 6977298Sobrien} macro_entry; 7060484Sobrien 7133965Sjdp/* Whether any macros have been defined. */ 7233965Sjdp 7333965Sjdpextern int macro_defined; 7433965Sjdp 7533965Sjdp/* The macro nesting level. */ 7633965Sjdp 7733965Sjdpextern int macro_nest; 7833965Sjdp 79218822Sdim/* The macro hash table. */ 80218822Sdim 81218822Sdimextern struct hash_control *macro_hash; 82218822Sdim 83130561Sobrienextern int buffer_and_nest (const char *, const char *, sb *, int (*) (sb *)); 8433965Sjdpextern void macro_init 85130561Sobrien (int, int, int, int (*) (const char *, int, sb *, int *)); 86218822Sdimextern void macro_set_alternate (int); 87130561Sobrienextern void macro_mri_mode (int); 8833965Sjdpextern const char *define_macro 89218822Sdim (int, sb *, sb *, int (*) (sb *), char *, unsigned int, const char **); 90130561Sobrienextern int check_macro (const char *, sb *, const char **, macro_entry **); 91130561Sobrienextern void delete_macro (const char *); 92130561Sobrienextern const char *expand_irp (int, int, sb *, sb *, int (*) (sb *)); 9333965Sjdp 9433965Sjdp#endif 95