We don't need the fpvm.c "bridge" anymore. Also, since these elements are no longer in libfpvm, the old names would be confusing. --- src/Makefile | 3 +- src/compiler/compiler.c | 57 +++++++++++++++++++++++++++--- src/compiler/fpvm.c | 80 ------------------------------------------- src/compiler/fpvm.h | 34 ------------------ src/compiler/ptest/Makefile | 2 +- src/compiler/ptest/ptest.c | 1 - 6 files changed, 53 insertions(+), 124 deletions(-) delete mode 100644 src/compiler/fpvm.c delete mode 100644 src/compiler/fpvm.h
diff --git a/src/Makefile b/src/Makefile index 4293f42..79de657 100644 --- a/src/Makefile +++ b/src/Makefile @@ -62,7 +62,7 @@ OBJS += $(addprefix translations/,french.o german.o) OBJS += $(addprefix renderer/,framedescriptor.o analyzer.o sampler.o \ eval.o line.o wave.o font.o osd.o raster.o renderer.o \ videoinreconf.o) -OBJS += $(addprefix compiler/,compiler.o fpvm.o parser_helper.o scanner.o \ +OBJS += $(addprefix compiler/,compiler.o parser_helper.o scanner.o \ parser.o unique.o) POBJS=$(addprefix $(OBJDIR)/,$(OBJS)) @@ -99,7 +99,6 @@ compiler/infra-fnp.h: \ compiler/parser.h: compiler/parser.c obj/compiler/scanner.o: compiler/parser.h obj/compiler/parser_helper.o: compiler/parser.h -obj/compiler/fpvm.o: compiler/parser.h obj/compiler/unique.o: compiler/fnp.inc obj/compiler/compiler.o: compiler/infra-fnp.h compiler/parser.h diff --git a/src/compiler/compiler.c b/src/compiler/compiler.c index dfe6287..355eb75 100644 --- a/src/compiler/compiler.c +++ b/src/compiler/compiler.c @@ -23,11 +23,11 @@ #include <string.h> #include <fpvm/fpvm.h> +#include <fpvm/ast.h> #include <fpvm/schedulers.h> #include <fpvm/pfpu.h> #include "../pixbuf/pixbuf.h" -#include "fpvm.h" #include "unique.h" #include "parser_helper.h" #include "parser.h" @@ -58,6 +58,51 @@ static void comp_report(struct compiler_sc *sc, const char *format, ...) sc->rmc(outbuf); } +static void init_fpvm(struct fpvm_fragment *fragment, int vector_mode) +{ + /* + * We need to pass these through unique() because the parser does + * the same. We can get rid of these calls to unique() later. + */ + + _Xi = unique("_Xi"); + _Xo = unique("_Xo"); + _Yi = unique("_Yi"); + _Yo = unique("_Yo"); + fpvm_do_init(fragment, vector_mode); +} + +/* ----- Compilation of internal per-fragment setup code ------------------- */ + + +static const char *assign_chunk(struct parser_comm *comm, + const char *label, struct ast_node *node) +{ + if(fpvm_do_assign(comm->u.fragment, label, node)) + return NULL; + else + return strdup(fpvm_get_last_error(comm->u.fragment)); +} + +static int compile_chunk(struct fpvm_fragment *fragment, const char *chunk) +{ + struct parser_comm comm = { + .u.fragment = fragment, + .assign_default = assign_chunk, + .assign_per_frame = NULL, /* crash ... */ + .assign_per_vertex = NULL, /* and burn */ + }; + const char *error; + + error = parse(chunk, TOK_START_ASSIGN, &comm); + if(error) { + snprintf(fragment->last_error, FPVM_MAXERRLEN, "%s", error); + free((void *) error); + } + return !error; +} + + /****************************************************************/ /* PER-FRAME VARIABLES */ /****************************************************************/ @@ -285,7 +330,7 @@ static bool init_pfv(struct compiler_sc *sc) { int i; - fpvm_init(&sc->pfv_fragment, 0); + init_fpvm(&sc->pfv_fragment, 0); fpvm_set_bind_mode(&sc->pfv_fragment, FPVM_BIND_ALL); for(i=0;i<COMP_PFV_COUNT;i++) sc->p->pfv_allocation[i] = -1; @@ -296,7 +341,7 @@ static bool init_pfv(struct compiler_sc *sc) static bool finalize_pfv(struct compiler_sc *sc) { /* assign dummy values for output */ - if(!fpvm_chunk(&sc->pfv_fragment, FINISH_PFV_FNP)) + if(!compile_chunk(&sc->pfv_fragment, FINISH_PFV_FNP)) goto fail_fpvm; #ifdef COMP_DEBUG printf("per-frame FPVM fragment:\n"); @@ -430,13 +475,13 @@ static bool init_pvv(struct compiler_sc *sc) { int i; - fpvm_init(&sc->pvv_fragment, 1); + init_fpvm(&sc->pvv_fragment, 1); for(i=0;i<COMP_PVV_COUNT;i++) sc->p->pvv_allocation[i] = -1; fpvm_set_bind_callback(&sc->pvv_fragment, pvv_bind_callback, sc); fpvm_set_bind_mode(&sc->pvv_fragment, FPVM_BIND_SOURCE); - if(!fpvm_chunk(&sc->pvv_fragment, INIT_PVV_FNP)) + if(!compile_chunk(&sc->pvv_fragment, INIT_PVV_FNP)) goto fail_assign; fpvm_set_bind_mode(&sc->pvv_fragment, FPVM_BIND_ALL); @@ -452,7 +497,7 @@ static int finalize_pvv(struct compiler_sc *sc) { fpvm_set_bind_mode(&sc->pvv_fragment, FPVM_BIND_SOURCE); - if(!fpvm_chunk(&sc->pvv_fragment, FINISH_PVV_FNP)) + if(!compile_chunk(&sc->pvv_fragment, FINISH_PVV_FNP)) goto fail_assign; if(!fpvm_finalize(&sc->pvv_fragment)) goto fail_finalize; #ifdef COMP_DEBUG diff --git a/src/compiler/fpvm.c b/src/compiler/fpvm.c deleted file mode 100644 index d8c1df4..0000000 --- a/src/compiler/fpvm.c +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Milkymist SoC (Software) - * Copyright (C) 2007, 2008, 2009, 2010, 2011 Sebastien Bourdeauducq - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, version 3 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> - -#include <fpvm/fpvm.h> -#include <fpvm/ast.h> - -#include "unique.h" -#include "parser.h" -#include "parser_helper.h" -#include "fpvm.h" - - -void fpvm_init(struct fpvm_fragment *fragment, int vector_mode) -{ - /* - * We need to pass these through unique() because fpvm_assign does - * the same. Once things are in Flickernoise, we can get rid of these - * calls to unique(). - */ - - _Xi = unique("_Xi"); - _Xo = unique("_Xo"); - _Yi = unique("_Yi"); - _Yo = unique("_Yo"); - fpvm_do_init(fragment, vector_mode); -} - - -static const char *assign_default(struct parser_comm *comm, - const char *label, struct ast_node *node) -{ - if(fpvm_do_assign(comm->u.fragment, label, node)) - return NULL; - else - return strdup(fpvm_get_last_error(comm->u.fragment)); -} - - -static const char *assign_unsupported(struct parser_comm *comm, - const char *label, struct ast_node *node) -{ - return strdup("assignment mode not supported yet"); -} - - -int fpvm_chunk(struct fpvm_fragment *fragment, const char *chunk) -{ - struct parser_comm comm = { - .u.fragment = fragment, - .assign_default = assign_default, - .assign_per_frame = assign_unsupported, - .assign_per_vertex = assign_unsupported, - }; - const char *error; - - error = parse(chunk, TOK_START_ASSIGN, &comm); - if(error) { - snprintf(fragment->last_error, FPVM_MAXERRLEN, "%s", error); - free((void *) error); - } - return !error; -} diff --git a/src/compiler/fpvm.h b/src/compiler/fpvm.h deleted file mode 100644 index cfee613..0000000 --- a/src/compiler/fpvm.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Milkymist SoC (Software) - * Copyright (C) 2007, 2008, 2009, 2010, 2011 Sebastien Bourdeauducq - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, version 3 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -/* - * Floating Point Virtual Machine compiler. - * This library takes a series of equations and turn them into - * FPVM code that evaluates them. - */ - -#ifndef __FPVM_H -#define __FPVM_H - -#include <fpvm/fpvm.h> - - -void fpvm_init(struct fpvm_fragment *fragment, int vector_mode); - -int fpvm_chunk(struct fpvm_fragment *fragment, const char *chunk); - -#endif /* __FPVM_H */ diff --git a/src/compiler/ptest/Makefile b/src/compiler/ptest/Makefile index d89bc0a..7d3fca6 100644 --- a/src/compiler/ptest/Makefile +++ b/src/compiler/ptest/Makefile @@ -4,7 +4,7 @@ LIBFPVM_X86 = $(MMDIR)/software/libfpvm/x86-linux CFLAGS_STANDALONE = -DSTANDALONE=\"standalone.h\" CFLAGS = -Wall -g -I.. -I. $(CFLAGS_STANDALONE) -OBJS = ptest.o scanner.o parser.o parser_helper.o unique.o compiler.o fpvm.o \ +OBJS = ptest.o scanner.o parser.o parser_helper.o unique.o compiler.o \ libfpvm.a # ----- Verbosity control ----------------------------------------------------- diff --git a/src/compiler/ptest/ptest.c b/src/compiler/ptest/ptest.c index a6f269b..62e19e7 100644 --- a/src/compiler/ptest/ptest.c +++ b/src/compiler/ptest/ptest.c @@ -16,7 +16,6 @@ #include "fpvm/pfpu.h" -#include "../fpvm.h" #include "../parser_helper.h" #include "../parser.h" #include "../compiler.h" -- 1.7.1 _______________________________________________ http://lists.milkymist.org/listinfo.cgi/devel-milkymist.org IRC: #milkymist@Freenode