Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: m-labs/flickernoise
base: 6259a03
...
head fork: m-labs/flickernoise
compare: a1adbc3
  • 4 commits
  • 7 files changed
  • 0 commit comments
  • 1 contributor
Commits on Jan 12, 2012
Werner Almesberger wpwrak ptest.c: restored dump_regs, using new forall_syms
It's now reasonably easy to look up identifiers, so we can have code
dumps again.
47c5068
Werner Almesberger wpwrak compiler: remove "virtual ops" concept and use op_not from libfpvm
Also updated the regression test for algorithmic use of boolean not,
since this is now a valid use.
7ec58a4
Werner Almesberger wpwrak compiler: also support equation numbers after per_vertex/per_pixel
Added regression test.
4bf4e79
Werner Almesberger wpwrak compiler: disallow equation numbers and per_pixel keyword in new style a1adbc3
15 src/compiler/parser.y
View
@@ -322,20 +322,23 @@ assignment ::= context(C). {
state->comm->assign_default = C;
}
-context(C) ::= TOK_PER_FRAME TOK_ASSIGN. {
+context(C) ::= old_per_frame TOK_ASSIGN. {
IS_STYLE(old_style);
C = state->comm->assign_per_frame;
}
-context(C) ::= TOK_PER_VERTEX TOK_ASSIGN. {
+context(C) ::= old_per_vertex TOK_ASSIGN. {
IS_STYLE(old_style);
C = state->comm->assign_per_vertex;
}
-context(C) ::= TOK_PER_PIXEL TOK_ASSIGN. {
- IS_STYLE(old_style);
- C = state->comm->assign_per_vertex;
-}
+old_per_frame ::= TOK_PER_FRAME.
+old_per_frame ::= TOK_PER_FRAME_UGLY.
+
+old_per_vertex ::= TOK_PER_VERTEX.
+old_per_vertex ::= TOK_PER_VERTEX_UGLY.
+old_per_vertex ::= TOK_PER_PIXEL.
+old_per_vertex ::= TOK_PER_PIXEL_UGLY.
opt_semi ::= opt_semi TOK_SEMI.
3  src/compiler/parser_helper.h
View
@@ -24,9 +24,6 @@
#include "symtab.h"
-/* virtual operation - for use inside the parser only */
-#define op_not (op_vops+1)
-
struct compiler_sc;
struct parser_comm {
41 src/compiler/ptest/ptest.c
View
@@ -256,7 +256,27 @@ static void parse_only(const char *pgm)
}
-static void dump_regs(const int *alloc, const char (*names)[FPVM_MAXSYMLEN],
+/*
+ * "sym" and "field" are used to access a field chosen by the caller in the
+ * "struct sym". For this, the caller provides a buffer (sym) and a pointer to
+ * the respective field inside the buffer. This way, it's perfectly type-safe
+ * and we don't need offsetof acrobatics.
+ */
+
+static const char *lookup_name(int idx, struct sym *sym, const int *field)
+{
+ const struct sym *walk;
+
+ forall_syms(walk) {
+ *sym = *walk;
+ if (*field == idx)
+ return walk->fpvm_sym.name;
+ }
+ return NULL;
+}
+
+
+static void dump_regs(const int *alloc, struct sym *sym, const int *field,
const float *values, int n)
{
const char *mapped[n];
@@ -266,7 +286,7 @@ static void dump_regs(const int *alloc, const char (*names)[FPVM_MAXSYMLEN],
mapped[i] = NULL;
for (i = 0; i != n; i++)
if (alloc[i] != -1)
- mapped[alloc[i]] = names[i];
+ mapped[alloc[i]] = lookup_name(i, sym, field);
for (i = 0; i != n; i++) {
if (!values[i] && !mapped[i])
continue;
@@ -280,27 +300,22 @@ static void dump_regs(const int *alloc, const char (*names)[FPVM_MAXSYMLEN],
static void show_patch(const struct patch *patch)
{
-/*
- * @@@ Disable for now since we have no good way to get the names and the
- * mapping archtecture is still in flux.
- */
-#if 0
int i;
+ struct sym sym;
printf("global:\n");
for (i = 0; i != COMP_PFV_COUNT; i++)
if (patch->pfv_initial[i])
printf("R%03d = %f %s\n", i, patch->pfv_initial[i],
- pfv_names[i]);
+ lookup_name(i, &sym, &sym.pfv_idx));
printf("per-frame PFPU fragment:\n");
- dump_regs(patch->pfv_allocation, pfv_names, patch->perframe_regs,
- COMP_PFV_COUNT);
+ dump_regs(patch->pfv_allocation, &sym, &sym.pfv_idx,
+ patch->perframe_regs, COMP_PFV_COUNT);
pfpu_dump(patch->perframe_prog, patch->perframe_prog_length);
printf("per-vertex PFPU fragment:\n");
- dump_regs(patch->pvv_allocation, pvv_names, patch->pervertex_regs,
- COMP_PVV_COUNT);
+ dump_regs(patch->pvv_allocation, &sym, &sym.pvv_idx,
+ patch->pervertex_regs, COMP_PVV_COUNT);
pfpu_dump(patch->pervertex_prog, patch->pervertex_prog_length);
-#endif
}
10 src/compiler/scanner.re
View
@@ -118,10 +118,14 @@ int scan(struct scanner *s)
<N>"sqrt" { return TOK_SQRT; }
<N>"tsign" { return TOK_TSIGN; }
- <N>"per_frame"[a-z_0-9]*
- { return TOK_PER_FRAME; }
+ <N>"per_frame" { return TOK_PER_FRAME; }
<N>"per_vertex" { return TOK_PER_VERTEX; }
- <N>"per_pixel" { return TOK_PER_PIXEL; }
+ <N>"per_frame"[a-z_0-9]+
+ { return TOK_PER_FRAME_UGLY; }
+ <N>"per_vertex"[a-z_0-9]+
+ { return TOK_PER_VERTEX_UGLY; }
+ <N>"per_pixel"[a-z_0-9]*
+ { return TOK_PER_PIXEL_UGLY; }
<N>"imagefile"[1-9] { YYSETCONDITION(yycFNAME1);
return TOK_IMAGEFILE; }
51 src/compiler/test/eqnum
View
@@ -0,0 +1,51 @@
+#!/bin/sh
+. ./Common
+
+###############################################################################
+
+ptest "equation numbers: old-style per_frame" <<EOF
+per_frame_0 = foo = 1
+EOF
+expect <<EOF
+per_frame = foo = 1
+EOF
+
+#------------------------------------------------------------------------------
+
+ptest "equation numbers: old-style per_vertex" <<EOF
+per_vertex_20 = foo = 2
+EOF
+expect <<EOF
+per_vertex = foo = 2
+EOF
+
+#------------------------------------------------------------------------------
+
+ptest "equation numbers: old-style per_pixel" <<EOF
+per_pixel_n0 = foo = 3
+EOF
+expect <<EOF
+per_vertex = foo = 3
+EOF
+
+#------------------------------------------------------------------------------
+
+ptest_fail "equation numbers: new-style per_frame" <<EOF
+per_frame_0:
+ foo = 1
+EOF
+expect <<EOF
+FPVM, line 1: parse error near ':'
+EOF
+
+#------------------------------------------------------------------------------
+
+ptest_fail "equation numbers: new-style per_vertex" <<EOF
+per_vertex_2:
+ foo = 2
+EOF
+expect <<EOF
+FPVM, line 1: parse error near ':'
+EOF
+
+###############################################################################
28 src/compiler/test/not
View
@@ -12,15 +12,6 @@ EOF
#------------------------------------------------------------------------------
-ptest_fail "not: !a (try to generate code)" -c << EOF
-per_frame: wave_a = !a
-EOF
-expect <<EOF
-FPVM, line 2: Operation not supported: 29 near 'EOF'
-EOF
-
-#------------------------------------------------------------------------------
-
ptest "not: !0" << EOF
sx = !0
EOF
@@ -100,4 +91,23 @@ expect <<EOF
sx = c
EOF
+#------------------------------------------------------------------------------
+
+ptest "not: !sx (generate code)" -c << EOF
+per_frame: wave_a = !sx
+EOF
+sedit '/^per-frame/,/^Eff/p;d'
+expect <<EOF
+per-frame PFPU fragment:
+R003 = 1.000000 fWaveAlpha
+R004 = 1.000000 sx
+0000: EQUAL R004,R005 <L=2 E=0002>
+0001: COPY R000 <L=2 E=0003>
+0002: COPY R001 <L=2 E=0004> -> R003
+0003: NOP -> R002
+0004: NOP -> R006
+0005: VECTOUT R000,R000 <L=0 E=0005>
+Efficiency: 50%
+EOF
+
###############################################################################
10 src/compiler/test/sections
View
@@ -145,4 +145,14 @@ per_vertex = a = b
FPVM, line 3: parse error near 'c'
EOF
+#------------------------------------------------------------------------------
+
+ptest_fail "sections: new style has no per_pixel" <<EOF
+per_pixel:
+ no = junk
+EOF
+expect <<EOF
+FPVM, line 1: parse error near ':'
+EOF
+
###############################################################################

No commit comments for this range

Something went wrong with that request. Please try again.