summaryrefslogtreecommitdiff
path: root/frontends
diff options
context:
space:
mode:
authorPeter Johnson <peter@tortall.net>2008-05-09 06:46:02 +0000
committerPeter Johnson <peter@tortall.net>2008-05-09 06:46:02 +0000
commitcbf0c7befdecd2da9bf4f866c3b25bb0f6b173f0 (patch)
tree9c826aade374450549a3aca820112a5c71fc7c05 /frontends
parentd8a6f8c3765cbbd8f2908965cb4b2adee1499c56 (diff)
downloadyasm-cbf0c7befdecd2da9bf4f866c3b25bb0f6b173f0.tar.gz
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 <brg@gladman.plus.com> svn path=/trunk/yasm/; revision=2082
Diffstat (limited to 'frontends')
-rw-r--r--frontends/yasm/yasm.c28
1 files changed, 27 insertions, 1 deletions
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 */
@@ -1126,6 +1133,25 @@ apply_preproc_builtins()
}
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()
{
constcharparam *cp, *cpnext;