diff --git a/src/Makefile.am b/src/Makefile.am index c5b9b30b4..56b724975 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -8,12 +8,10 @@ bin_SCRIPTS = guile-compile lib_LTLIBRARIES = libguilevm.la libguilevm_la_SOURCES = vm.c libguilevm_la_LDFLAGS = -version-info 0:0:0 -export-dynamic -noinst_HEADERS = vm.h vm_engine.h vm-snarf.h +noinst_HEADERS = vm.h vm_engine.h vm_expand.h EXTRA_DIST = vm_engine.c vm_system.c vm_scheme.c vm_number.c \ test.scm guile-compile.in -BUILT_SOURCES = vm_system.inst vm_scheme.inst vm_number.inst \ - vm_system.label vm_scheme.label vm_number.label \ - vm_system.opcode vm_scheme.opcode vm_number.opcode vm.x +BUILT_SOURCES = vm_system.i vm_scheme.i vm_number.i vm.x CFLAGS = -g -O2 -Wall INCLUDES = $(GUILE_CFLAGS) @@ -22,24 +20,15 @@ DISTCLEANFILES = $(BUILT_SOURCES) MAINTAINERCLEANFILES = Makefile.in config.h.in stamp-h.in SNARF = guile-snarf -SUFFIXES = .x .inst .label .opcode +SUFFIXES = .x .i .c.x: $(SNARF) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $< > $@ \ || { rm $@; false; } -.c.inst: - $(SNARF) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $< > $@ \ - || { rm $@; false; } +.c.i: + grep '^SCM_DEFINE' $< > $@ -.c.label: - $(SNARF) -DSCM_SNARF_LABEL $(DEFS) $(INCLUDES) $(CPPFLAGS) \ - $(CFLAGS) $< > $@ || { rm $@; false; } - -.c.opcode: - $(SNARF) -DSCM_SNARF_OPCODE $(DEFS) $(INCLUDES) $(CPPFLAGS) \ - $(CFLAGS) $< > $@ || { rm $@; false; } - -$(BUILT_SOURCES): config.h vm-snarf.h +$(BUILT_SOURCES): config.h vm_expand.h guile-compile: guile-compile.in sed -e 's!\@bindir\@!$(bindir)!' -e 's!\@PACKAGE\@!$(PACKAGE)!' \ diff --git a/src/vm.c b/src/vm.c index 43e554fff..a784fae0c 100644 --- a/src/vm.c +++ b/src/vm.c @@ -117,9 +117,12 @@ init_name_property () static long scm_instruction_tag; static struct scm_instruction scm_instruction_table[] = { -#include "vm_system.inst" -#include "vm_scheme.inst" -#include "vm_number.inst" +#define VM_INSTRUCTION_TO_TABLE +#include "vm_expand.h" +#include "vm_system.i" +#include "vm_scheme.i" +#include "vm_number.i" +#undef VM_INSTRUCTION_TO_TABLE {op_last} }; diff --git a/src/vm.h b/src/vm.h index a1320f1b3..80f82467a 100644 --- a/src/vm.h +++ b/src/vm.h @@ -43,6 +43,7 @@ #define VM_H #include +#include "config.h" /* @@ -51,9 +52,12 @@ /* Opcode */ enum scm_opcode { -#include "vm_system.opcode" -#include "vm_scheme.opcode" -#include "vm_number.opcode" +#define VM_INSTRUCTION_TO_OPCODE +#include "vm_expand.h" +#include "vm_system.i" +#include "vm_scheme.i" +#include "vm_number.i" +#undef VM_INSTRUCTION_TO_OPCODE op_last }; diff --git a/src/vm_engine.c b/src/vm_engine.c index 9d459b17b..ab68ce028 100644 --- a/src/vm_engine.c +++ b/src/vm_engine.c @@ -78,9 +78,12 @@ VM_NAME (SCM vm, SCM program) /* Jump talbe */ static void *jump_table[] = { -#include "vm_system.label" -#include "vm_scheme.label" -#include "vm_number.label" +#define VM_INSTRUCTION_TO_LABEL +#include "vm_expand.h" +#include "vm_system.i" +#include "vm_scheme.i" +#include "vm_number.i" +#undef VM_INSTRUCTION_TO_LABEL }; /* Initialize the VM */ @@ -101,6 +104,7 @@ VM_NAME (SCM vm, SCM program) vm_start: switch (*pc++) { #endif +#include "vm_expand.h" #include "vm_system.c" #include "vm_scheme.c" #include "vm_number.c" diff --git a/src/vm-snarf.h b/src/vm_expand.h similarity index 72% rename from src/vm-snarf.h rename to src/vm_expand.h index 8e35ac1a3..1eeea817e 100644 --- a/src/vm-snarf.h +++ b/src/vm_expand.h @@ -39,11 +39,9 @@ * whether to permit this exception to apply to your modifications. * If you do not wish that, delete this exception notice. */ -#ifndef VM_SNARF_H -#define VM_SNARF_H - #include "config.h" +#ifndef VM_LABEL #define VM_LABEL(TAG) l_##TAG## #define VM_OPCODE(TAG) op_##TAG## @@ -54,49 +52,42 @@ #define VM_TAG(TAG) case VM_OPCODE(TAG): #define VM_ADDR(TAG) NULL #endif /* not HAVE_LABELS_AS_VALUES */ +#endif /* VM_LABEL */ -#ifndef SCM_MAGIC_SNARFER +#undef SCM_DEFINE_INSTRUCTION +#undef SCM_DEFINE_VM_FUNCTION +#ifdef VM_INSTRUCTION_TO_TABLE +/* + * These will go to scm_instruction_table in vm.c + */ +#define SCM_DEFINE_INSTRUCTION(TAG,NAME,TYPE) \ + {VM_OPCODE(TAG), TYPE, NAME, SCM_PACK (0), NULL, 0, 0}, +#define SCM_DEFINE_VM_FUNCTION(TAG,SNAME,NAME,NARGS,RESTP) \ + {VM_OPCODE(TAG), INST_NONE, NAME, SCM_PACK (0), SNAME, NARGS, RESTP}, +#else +#ifdef VM_INSTRUCTION_TO_LABEL +/* + * These will go to jump_table in vm_engine.c + */ +#define SCM_DEFINE_INSTRUCTION(TAG,NAME,TYPE) VM_ADDR(TAG), +#define SCM_DEFINE_VM_FUNCTION(TAG,SNAME,NAME,NARGS,RESTP) VM_ADDR(TAG), + +#else +#ifdef VM_INSTRUCTION_TO_OPCODE +/* + * These will go to scm_opcode in vm.h + */ +#define SCM_DEFINE_INSTRUCTION(TAG,NAME,TYPE) VM_OPCODE(TAG), +#define SCM_DEFINE_VM_FUNCTION(TAG,SNAME,NAME,NARGS,RESTP) VM_OPCODE(TAG), + +#else /* Otherwise */ /* * These are directly included in vm_engine.c */ -#define SCM_DEFINE_INSTRUCTION(TAG,NAME,TYPE) VM_TAG(TAG) +#define SCM_DEFINE_INSTRUCTION(TAG,NAME,TYPE) VM_TAG(TAG) #define SCM_DEFINE_VM_FUNCTION(TAG,SNAME,NAME,NARGS,RESTP) VM_TAG(TAG) -#else /* SCM_MAGIC_SNARFER */ -#ifndef SCM_SNARF_OPCODE -#ifndef SCM_SNARF_LABEL - -/* - * These will go to *.inst - */ -#define SCM_DEFINE_INSTRUCTION(TAG,NAME,TYPE) \ - SCM_SNARF_INIT_START {VM_OPCODE(TAG), TYPE, NAME, SCM_BOOL_F, NULL, 0, 0}, -#define SCM_DEFINE_VM_FUNCTION(TAG,SNAME,NAME,NARGS,RESTP) \ - SCM_SNARF_INIT_START {VM_OPCODE(TAG), INST_NONE, NAME, SCM_BOOL_F, SNAME, NARGS, RESTP}, - -#else /* SCM_SNARF_LABEL */ - -/* - * These will go to *.label - */ -#define SCM_DEFINE_INSTRUCTION(TAG,NAME,TYPE) \ - SCM_SNARF_INIT_START VM_ADDR(TAG), -#define SCM_DEFINE_VM_FUNCTION(TAG,SNAME,NAME,NARGS,RESTP) \ - SCM_SNARF_INIT_START VM_ADDR(TAG), - -#endif /* SCM_SNARF_LABEL */ -#else /* SCM_SNARF_OPCODE */ - -/* - * These will go to *.opcode - */ -#define SCM_DEFINE_INSTRUCTION(TAG,NAME,TYPE) \ - SCM_SNARF_INIT_START VM_OPCODE(TAG), -#define SCM_DEFINE_VM_FUNCTION(TAG,SNAME,NAME,NARGS,RESTP) \ - SCM_SNARF_INIT_START VM_OPCODE(TAG), - -#endif /* SCM_SNARF_OPCODE */ -#endif /* SCM_MAGIC_SNARFER */ - -#endif /* not VM_SNARF_H */ +#endif /* VM_INSTRUCTION_TO_OPCODE */ +#endif /* VM_INSTRUCTION_TO_LABEL */ +#endif /* VM_INSTRUCTION_TO_TABLE */ diff --git a/src/vm_number.c b/src/vm_number.c index de7d7dd20..cc7b63ad0 100644 --- a/src/vm_number.c +++ b/src/vm_number.c @@ -41,8 +41,6 @@ /* This file is included in vm_engine.c */ -#include "vm-snarf.h" - #define FUNC2(CFUNC,SFUNC) \ { \ VM_SETUP_ARGS2 (); \ diff --git a/src/vm_scheme.c b/src/vm_scheme.c index 3ab57f694..3b3c6e5ab 100644 --- a/src/vm_scheme.c +++ b/src/vm_scheme.c @@ -41,8 +41,6 @@ /* This file is included in vm_engine.c */ -#include "vm-snarf.h" - SCM_DEFINE_VM_FUNCTION (null_p, "null?", "null?", 1, 0) { VM_SETUP_ARGS1 (); diff --git a/src/vm_system.c b/src/vm_system.c index a7cd19380..de8041d96 100644 --- a/src/vm_system.c +++ b/src/vm_system.c @@ -41,8 +41,6 @@ /* This file is included in vm_engine.c */ -#include "vm-snarf.h" - /* * Variable access */