Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/flickernoise
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 6259a03
Choose a base ref
...
head repository: m-labs/flickernoise
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: a1adbc3
Choose a head ref
  • 4 commits
  • 7 files changed
  • 1 contributor

Commits on Jan 12, 2012

  1. 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.
    wpwrak committed Jan 12, 2012
    Copy the full SHA
    47c5068 View commit details
  2. 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.
    wpwrak committed Jan 12, 2012
    Copy the full SHA
    7ec58a4 View commit details
  3. compiler: also support equation numbers after per_vertex/per_pixel

    Added regression test.
    wpwrak committed Jan 12, 2012
    Copy the full SHA
    4bf4e79 View commit details
  4. Copy the full SHA
    a1adbc3 View commit details
Showing with 124 additions and 34 deletions.
  1. +9 −6 src/compiler/parser.y
  2. +0 −3 src/compiler/parser_helper.h
  3. +28 −13 src/compiler/ptest/ptest.c
  4. +7 −3 src/compiler/scanner.re
  5. +51 −0 src/compiler/test/eqnum
  6. +19 −9 src/compiler/test/not
  7. +10 −0 src/compiler/test/sections
15 changes: 9 additions & 6 deletions src/compiler/parser.y
Original file line number Diff line number Diff line change
@@ -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 changes: 0 additions & 3 deletions src/compiler/parser_helper.h
Original file line number Diff line number Diff line change
@@ -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 changes: 28 additions & 13 deletions src/compiler/ptest/ptest.c
Original file line number Diff line number Diff line change
@@ -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 changes: 7 additions & 3 deletions src/compiler/scanner.re
Original file line number Diff line number Diff line change
@@ -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 changes: 51 additions & 0 deletions src/compiler/test/eqnum
Original file line number Diff line number Diff line change
@@ -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 changes: 19 additions & 9 deletions src/compiler/test/not
Original file line number Diff line number Diff line change
@@ -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 changes: 10 additions & 0 deletions src/compiler/test/sections
Original file line number Diff line number Diff line change
@@ -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

###############################################################################