Skip to content

Commit

Permalink
Remove sigTable and use sigWRTbl to code rdtable and rwtable.
Browse files Browse the repository at this point in the history
  • Loading branch information
sletz committed Apr 15, 2023
1 parent a1602f1 commit 2a462ce
Show file tree
Hide file tree
Showing 32 changed files with 283 additions and 496 deletions.
1 change: 0 additions & 1 deletion architecture/faust/dsp/libfaust-signal-c.h
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,6 @@ extern "C"
LIBFAUST_API bool CisSigPrefix(Signal t, Signal* t0, Signal* t1);
LIBFAUST_API bool CisSigRDTbl(Signal s, Signal* t, Signal* i);
LIBFAUST_API bool CisSigWRTbl(Signal u, Signal* id, Signal* t, Signal* i, Signal* s);
LIBFAUST_API bool CisSigTable(Signal t, Signal* id, Signal* n, Signal* sig);
LIBFAUST_API bool CisSigGen(Signal t, Signal* x);
LIBFAUST_API bool CisSigGen1(Signal t);
LIBFAUST_API bool CisSigDocConstantTbl(Signal t, Signal* n, Signal* sig);
Expand Down
1 change: 0 additions & 1 deletion architecture/faust/dsp/libfaust-signal.h
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,6 @@ LIBFAUST_API bool isSigDelay(Signal t, Signal& t0, Signal& t1);
LIBFAUST_API bool isSigPrefix(Signal t, Signal& t0, Signal& t1);
LIBFAUST_API bool isSigRDTbl(Signal s, Signal& t, Signal& i);
LIBFAUST_API bool isSigWRTbl(Signal u, Signal& id, Signal& t, Signal& i, Signal& s);
LIBFAUST_API bool isSigTable(Signal t, Signal& id, Signal& n, Signal& sig);
LIBFAUST_API bool isSigGen(Signal t, Signal& x);
LIBFAUST_API bool isSigDocConstantTbl(Signal t, Signal& n, Signal& sig);
LIBFAUST_API bool isSigDocWriteTbl(Signal t, Signal& n, Signal& sig, Signal& widx, Signal& wsig);
Expand Down
36 changes: 12 additions & 24 deletions compiler/box_signal_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -623,37 +623,25 @@ LIBFAUST_API bool CisSigPrefix(Tree t, Tree* t0_aux, Tree* t1_aux)
return false;
}
}
LIBFAUST_API bool CisSigRDTbl(Tree s, Tree* t_aux, Tree* i_aux)
LIBFAUST_API bool CisSigRDTbl(Tree t, Tree* tbl_aux, Tree* ri_aux)
{
Tree t, i;
if (isSigRDTbl(s, t, i)) {
*t_aux = t;
*i_aux = i;
Tree tbl, ri;
if (isSigRDTbl(t, tbl, ri)) {
*tbl_aux = tbl;
*ri_aux = ri;
return true;
} else {
return false;
}
}
LIBFAUST_API bool CisSigWRTbl(Tree u, Tree* id_aux, Tree* t_aux, Tree* i_aux, Tree* s_aux)
LIBFAUST_API bool CisSigWRTbl(Tree t, Tree* size_aux, Tree* gen_aux, Tree* wi_aux, Tree* ws_aux)
{
Tree id, t, i, s;
if (isSigWRTbl(u, id, t, i, s)) {
*id_aux = id;
*t_aux = t;
*i_aux = i;
*s_aux = s;
return true;
} else {
return false;
}
}
LIBFAUST_API bool CisSigTable(Tree t, Tree* id_aux, Tree* n_aux, Tree* sig_aux)
{
Tree id, n, sig;
if (isSigTable(t, id, n, sig)) {
*id_aux = id;
*n_aux = n;
*sig_aux = sig;
Tree size, gen, wi, ws;
if (isSigWRTbl(t, size, gen, wi, ws)) {
*size_aux = size;
*gen_aux = gen;
*wi_aux = wi;
*ws_aux = ws;
return true;
} else {
return false;
Expand Down
1 change: 0 additions & 1 deletion compiler/documentator/doc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
#include "names.hh"
#include "ppbox.hh"
#include "prim2.hh"
#include "privatise.hh"
#include "propagate.hh"
#include "recursivness.hh"
#include "sigprint.hh"
Expand Down
1 change: 0 additions & 1 deletion compiler/documentator/doc_compile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
#include "names.hh"
#include "ppsig.hh"
#include "prim2.hh"
#include "privatise.hh"
#include "recursivness.hh"
#include "sigprint.hh"
#include "sigtype.hh"
Expand Down
10 changes: 4 additions & 6 deletions compiler/draw/sigToGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ static string sigLabel(Tree sig)
{
int i;
double r;
Tree x, y, z, c, type, name, file, ff, largs, id, le, sel, var, label;
Tree size, gen, wi, ws, tbl, ri, x, y, z, c, type, name, file, ff, largs, le, sel, var, label;

xtended* p = (xtended*)getUserData(sig);

Expand Down Expand Up @@ -216,11 +216,9 @@ static string sigLabel(Tree sig)
fout << *name;
}

else if (isSigTable(sig, id, x, y)) {
fout << "table:" << id;
} else if (isSigWRTbl(sig, id, x, y, z)) {
fout << "write:" << id;
} else if (isSigRDTbl(sig, x, y)) {
else if (isSigWRTbl(sig, size, gen, wi, ws)) {
fout << "write:" << sig;
} else if (isSigRDTbl(sig, tbl, ri)) {
fout << "read";
}

Expand Down
1 change: 0 additions & 1 deletion compiler/generator/compile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ Compile a list of FAUST signals into a C++ class.

#include "compile.hh"
#include "floats.hh"
#include "privatise.hh"
#include "sigprint.hh"
#include "sigtype.hh"
#include "sigtyperules.hh"
Expand Down
55 changes: 24 additions & 31 deletions compiler/generator/compile_scal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#include "floats.hh"
#include "ppsig.hh"
#include "prim2.hh"
#include "privatise.hh"
#include "recursivness.hh"
#include "sigToGraph.hh"
#include "signal2vhdlVisitor.hh"
Expand Down Expand Up @@ -99,10 +98,8 @@ Tree ScalarCompiler::prepare(Tree LS)
ppsigShared(L1, cout);
throw faustexception("Dump shared normal form finished...\n");
}

startTiming("privatise");
Tree L2 = privatise(L1); // Un-share tables with multiple writers
endTiming("privatise");
// No more table privatisation
Tree L2 = L1;

startTiming("conditionAnnotation");
conditionAnnotation(L2);
Expand Down Expand Up @@ -470,7 +467,7 @@ string ScalarCompiler::generateCode(Tree sig)
int i;
int64_t i64;
double r;
Tree c, sel, x, y, z, label, id, ff, largs, type, name, file, sf;
Tree size, gen, wi, ws, ri, c, sel, x, y, z, label, tb, ff, largs, type, name, file, sf;

// printf("compilation of %p : ", sig); print(sig); printf("\n");

Expand Down Expand Up @@ -504,12 +501,10 @@ string ScalarCompiler::generateCode(Tree sig)
return generateFVar(sig, tree2str(file), tree2str(name));
}

else if (isSigTable(sig, id, x, y)) {
return generateTable(sig, x, y);
} else if (isSigWRTbl(sig, id, x, y, z)) {
return generateWRTbl(sig, x, y, z);
} else if (isSigRDTbl(sig, x, y)) {
return generateRDTbl(sig, x, y);
else if (isSigWRTbl(sig, size, gen, wi, ws)) {
return generateWRTbl(sig, size, gen, wi, ws);
} else if (isSigRDTbl(sig, tb, ri)) {
return generateRDTbl(sig, tb, ri);
}

else if (isSigSelect2(sig, sel, x, y)) {
Expand Down Expand Up @@ -1147,51 +1142,49 @@ string ScalarCompiler::generateStaticTable(Tree sig, Tree tsize, Tree content)
sigWRTable : table assignement
----------------------------------------------------------------------------*/

string ScalarCompiler::generateWRTbl(Tree sig, Tree tbl, Tree idx, Tree data)
string ScalarCompiler::generateWRTbl(Tree sig, Tree size, Tree gen, Tree wi, Tree ws)
{
string tblName(CS(tbl));
string tblName = generateTable(sig, size, gen);

Type t2 = getCertifiedSigType(idx);
Type t3 = getCertifiedSigType(data);
Type t2 = getCertifiedSigType(wi);
Type t3 = getCertifiedSigType(ws);
// TODO : for a bug in type caching, t->variability() is not correct.
// Therefore in the meantime we compute it manually. (YO 2020/03/30)
int var = t2->variability() | t3->variability();
switch (var) {
case kKonst:
fClass->addInitCode(subst("$0[$1] = $2;", tblName, CS(idx), CS(data)));
fClass->addInitCode(subst("$0[$1] = $2;", tblName, CS(wi), CS(ws)));
break;
case kBlock:
fClass->addZone2(subst("$0[$1] = $2;", tblName, CS(idx), CS(data)));
fClass->addZone2(subst("$0[$1] = $2;", tblName, CS(wi), CS(ws)));
break;
default:
fClass->addExecCode(Statement(getConditionCode(sig), subst("$0[$1] = $2;", tblName, CS(idx), CS(data))));
fClass->addExecCode(Statement(getConditionCode(sig), subst("$0[$1] = $2;", tblName, CS(wi), CS(ws))));
break;
}

// Return table access
return tblName;
}

/*----------------------------------------------------------------------------
sigRDTable : table access
----------------------------------------------------------------------------*/

string ScalarCompiler::generateRDTbl(Tree sig, Tree tbl, Tree idx)
string ScalarCompiler::generateRDTbl(Tree sig, Tree tbl, Tree ri)
{
// YO le 21/04/05 : The reading of the tables was not put in the cache
// and so the code was duplicated (in tester.dsp for example)
// return subst("$0[$1]", CS(tEnv, tbl), CS(tEnv, idx));

// cerr << "generateRDTable " << *sig << endl;
// test the special case of a read only table that can be compiled as a static member
Tree id, size, content;
if (isSigTable(tbl, id, size, content)) {
// Test the special case of a read only table that can be compiled as a static member
Tree size, gen;
if (isSigWRTbl(tbl, size, gen)) {
// rdtable
string tblname;
if (!getCompiledExpression(tbl, tblname)) {
tblname = setCompiledExpression(tbl, generateStaticTable(tbl, size, content));
tblname = setCompiledExpression(tbl, generateStaticTable(tbl, size, gen));
}
return generateCacheCode(sig, subst("$0[$1]", tblname, CS(idx)));
return generateCacheCode(sig, subst("$0[$1]", tblname, CS(ri)));
} else {
return generateCacheCode(sig, subst("$0[$1]", CS(tbl), CS(idx)));
// rwtable
return generateCacheCode(sig, subst("$0[$1]", CS(tbl), CS(ri)));
}
}

Expand Down
4 changes: 2 additions & 2 deletions compiler/generator/compile_scal.hh
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ class ScalarCompiler : public Compiler {

std::string generateTable(Tree sig, Tree tsize, Tree content);
std::string generateStaticTable(Tree sig, Tree tsize, Tree content);
std::string generateWRTbl(Tree sig, Tree tbl, Tree idx, Tree data);
std::string generateRDTbl(Tree sig, Tree tbl, Tree idx);
std::string generateWRTbl(Tree sig, Tree size, Tree gen, Tree wi, Tree ws);
std::string generateRDTbl(Tree sig, Tree tbl, Tree ri);
std::string generateSigGen(Tree sig, Tree content);
std::string generateStaticSigGen(Tree sig, Tree content);

Expand Down
48 changes: 23 additions & 25 deletions compiler/generator/instructions_compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include "instructions_compiler1.hh"
#include "instructions_compiler_jax.hh"
#include "prim2.hh"
#include "privatise.hh"
#include "recursivness.hh"
#include "sigToGraph.hh"
#include "signal2vhdlVisitor.hh"
Expand Down Expand Up @@ -107,9 +106,8 @@ Tree InstructionsCompiler::prepare(Tree LS)
throw faustexception("Dump signal type finished...\n");
}

startTiming("privatise");
Tree L2 = privatise(L1); // Un-share tables with multiple writers
endTiming("privatise");
// No more table privatisation
Tree L2 = L1;

startTiming("conditionAnnotation");
conditionAnnotation(L2);
Expand Down Expand Up @@ -633,7 +631,7 @@ ValueInst* InstructionsCompiler::generateCode(Tree sig)
int i;
int64_t i64;
double r;
Tree c, sel, x, y, z, label, id, ff, largs, type, name, file, sf;
Tree size, gen, wi, ws, ri, c, sel, x, y, z, label, tb, ff, largs, type, name, file, sf;

// printf("compilation of %p : ", sig); print(sig); printf("\n");

Expand Down Expand Up @@ -665,12 +663,10 @@ ValueInst* InstructionsCompiler::generateCode(Tree sig)
return generateFVar(sig, type, tree2str(file), tree2str(name));
}

else if (isSigTable(sig, id, x, y)) {
return generateTable(sig, x, y);
} else if (isSigWRTbl(sig, id, x, y, z)) {
return generateWRTbl(sig, x, y, z);
} else if (isSigRDTbl(sig, x, y)) {
return generateRDTbl(sig, x, y);
else if (isSigWRTbl(sig, size, gen, wi, ws)) {
return generateWRTbl(sig, size, gen, wi, ws);
} else if (isSigRDTbl(sig, tb, ri)) {
return generateRDTbl(sig, tb, ri);
}

else if (isSigSelect2(sig, sel, x, y)) {
Expand Down Expand Up @@ -1568,29 +1564,29 @@ ValueInst* InstructionsCompiler::generateStaticTable(Tree sig, Tree tsize, Tree
sigWRTable : table assignment
----------------------------------------------------------------------------*/

ValueInst* InstructionsCompiler::generateWRTbl(Tree sig, Tree tbl, Tree idx, Tree data)
ValueInst* InstructionsCompiler::generateWRTbl(Tree sig, Tree size, Tree gen, Tree wi, Tree ws)
{
ValueInst* tblname = CS(tbl);
ValueInst* tblname = generateTable(sig, size, gen);
LoadVarInst* load_value = dynamic_cast<LoadVarInst*>(tblname);
faustassert(load_value);

ValueInst* cdata = CS(data);
ValueInst* cws = CS(ws);
string vname = load_value->fAddress->getName();

Type t2 = getCertifiedSigType(idx);
Type t3 = getCertifiedSigType(data);
Type t2 = getCertifiedSigType(wi);
Type t3 = getCertifiedSigType(ws);
// TODO : for a bug in type caching, t->variability() is not correct.
// Therefore in the meantime we compute it manually. (YO 2020/03/30)
int var = t2->variability() | t3->variability();
switch (var) {
case kKonst:
pushInitMethod(InstBuilder::genStoreArrayStructVar(vname, CS(idx), cdata));
pushInitMethod(InstBuilder::genStoreArrayStructVar(vname, CS(wi), cws));
break;
case kBlock:
pushComputeBlockMethod(InstBuilder::genStoreArrayStructVar(vname, CS(idx), cdata));
pushComputeBlockMethod(InstBuilder::genStoreArrayStructVar(vname, CS(wi), cws));
break;
default:
pushComputeDSPMethod(InstBuilder::genControlInst(getConditionCode(sig), InstBuilder::genStoreArrayStructVar(vname, CS(idx), cdata)));
pushComputeDSPMethod(InstBuilder::genControlInst(getConditionCode(sig), InstBuilder::genStoreArrayStructVar(vname, CS(wi), cws)));
break;
}

Expand All @@ -1602,27 +1598,29 @@ ValueInst* InstructionsCompiler::generateWRTbl(Tree sig, Tree tbl, Tree idx, Tre
sigRDTable : table access
----------------------------------------------------------------------------*/

ValueInst* InstructionsCompiler::generateRDTbl(Tree sig, Tree tbl, Tree idx)
ValueInst* InstructionsCompiler::generateRDTbl(Tree sig, Tree tbl, Tree ri)
{
// Test the special case of a read only table that can be compiled as a static member
Tree id, size, content;
ValueInst* tblname;
Address::AccessType access;

if (isSigTable(tbl, id, size, content)) {
Tree size, gen;
if (isSigWRTbl(tbl, size, gen)) {
// rdtable
access = Address::kStaticStruct;
if (!getCompiledExpression(tbl, tblname)) {
tblname = setCompiledExpression(tbl, generateStaticTable(tbl, size, content));
tblname = setCompiledExpression(tbl, generateStaticTable(tbl, size, gen));
}
} else {
// rwtable
access = Address::kStruct;
tblname = CS(tbl);
}

LoadVarInst* load_value1 = dynamic_cast<LoadVarInst*>(tblname);
faustassert(load_value1);

LoadVarInst* load_value2 = InstBuilder::genLoadArrayVar(load_value1->fAddress->getName(), access, CS(idx));
LoadVarInst* load_value2 = InstBuilder::genLoadArrayVar(load_value1->fAddress->getName(), access, CS(ri));
return generateCacheCode(sig, load_value2);
}

Expand Down
4 changes: 2 additions & 2 deletions compiler/generator/instructions_compiler.hh
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ class InstructionsCompiler : public virtual Garbageable {

virtual ValueInst* generateTable(Tree sig, Tree tsize, Tree content);
virtual ValueInst* generateStaticTable(Tree sig, Tree tsize, Tree content);
virtual ValueInst* generateWRTbl(Tree sig, Tree tbl, Tree idx, Tree data);
virtual ValueInst* generateRDTbl(Tree sig, Tree tbl, Tree idx);
virtual ValueInst* generateWRTbl(Tree sig, Tree size, Tree gen, Tree wi, Tree ws);
virtual ValueInst* generateRDTbl(Tree sig, Tree tbl, Tree ri);
virtual ValueInst* generateSigGen(Tree sig, Tree content);
virtual ValueInst* generateStaticSigGen(Tree sig, Tree content);

Expand Down
1 change: 0 additions & 1 deletion compiler/global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,6 @@ global::global() : TABBER(1), gLoopDetector(1024, 400), gStackOverflowDetector(M
SIGPREFIX = symbol("SigPrefix");
SIGRDTBL = symbol("SigRDTbl");
SIGWRTBL = symbol("SigWRTbl");
SIGTABLE = symbol("SigTable");
SIGGEN = symbol("SigGen");
SIGDOCONSTANTTBL = symbol("SigDocConstantTbl");
SIGDOCWRITETBL = symbol("SigDocWriteTbl");
Expand Down
1 change: 0 additions & 1 deletion compiler/global.hh
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,6 @@ struct global {
Sym SIGPREFIX;
Sym SIGRDTBL;
Sym SIGWRTBL;
Sym SIGTABLE;
Sym SIGGEN;
Sym SIGDOCONSTANTTBL;
Sym SIGDOCWRITETBL;
Expand Down
1 change: 0 additions & 1 deletion compiler/libcode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
#include "normalform.hh"
#include "ppbox.hh"
#include "ppsig.hh"
#include "privatise.hh"
#include "propagate.hh"
#include "recursivness.hh"
#include "schema.h"
Expand Down
Loading

0 comments on commit 2a462ce

Please sign in to comment.