From cbf0c7befdecd2da9bf4f866c3b25bb0f6b173f0 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Fri, 9 May 2008 06:46:02 +0000 Subject: Split NASM preprocessor standard macro set between various modules. Standard macro sets are looked up based on parser and preprocessor keyword from individual modules. The "standard" NASM parser macros now reside in the NASM parser, so when the GAS parser is used with the NASM preprocessor, the NASM-specific macros are no longer defined. Object-format specific macros are now individually defined by each object formatm module. This allows for the object formats to be independent of the NASM preprocessor module and yields a small optimization benefit as unused object format macros don't need to be skipped over. Also add GAS macro equivalents for the Win64 SEH more complex directives [1]. [1] Requested by Brian Gladman svn path=/trunk/yasm/; revision=2082 --- frontends/yasm/yasm.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'frontends') diff --git a/frontends/yasm/yasm.c b/frontends/yasm/yasm.c index 8c24d285..b5f47080 100644 --- a/frontends/yasm/yasm.c +++ b/frontends/yasm/yasm.c @@ -120,6 +120,7 @@ static void print_yasm_warning(const char *filename, unsigned long line, const char *msg); static void apply_preproc_builtins(void); +static void apply_preproc_standard_macros(const yasm_stdmac *stdmacs); static void apply_preproc_saved_options(void); static void print_list_keyword_desc(const char *name, const char *keyword); @@ -264,13 +265,17 @@ do_preproc_only(void) return EXIT_FAILURE; } - /* Pre-process until done */ + /* Create preprocessor */ cur_preproc = yasm_preproc_create(cur_preproc_module, in_filename, NULL, linemap, errwarns); + /* Apply macros */ apply_preproc_builtins(); + apply_preproc_standard_macros(cur_parser_module->stdmacs); + apply_preproc_standard_macros(cur_objfmt_module->stdmacs); apply_preproc_saved_options(); + /* Pre-process until done */ if (generate_make_dependencies) { size_t totlen; @@ -429,6 +434,8 @@ do_assemble(void) object->symtab, linemap, errwarns); apply_preproc_builtins(); + apply_preproc_standard_macros(cur_parser_module->stdmacs); + apply_preproc_standard_macros(cur_objfmt_module->stdmacs); apply_preproc_saved_options(); /* Get initial x86 BITS setting from object format */ @@ -1125,6 +1132,25 @@ apply_preproc_builtins() yasm_xfree(predef); } +static void +apply_preproc_standard_macros(const yasm_stdmac *stdmacs) +{ + int i, matched; + + if (!stdmacs) + return; + + matched = -1; + for (i=0; stdmacs[i].parser; i++) + if (yasm__strcasecmp(stdmacs[i].parser, + cur_parser_module->keyword) == 0 && + yasm__strcasecmp(stdmacs[i].preproc, + cur_preproc_module->keyword) == 0) + matched = i; + if (matched >= 0 && stdmacs[matched].macros) + yasm_preproc_add_standard(cur_preproc, stdmacs[matched].macros); +} + static void apply_preproc_saved_options() { -- cgit v1.2.1