|
FAUST compiler
0.9.9.6b8
|
Compile a list of FAUST signals into a vector C++ class. More...
#include <compile_sched.hh>


Public Member Functions | |
| SchedulerCompiler (const string &name, const string &super, int numInputs, int numOutputs) | |
| SchedulerCompiler (Klass *k) | |
| virtual void | compileMultiSignal (Tree L) |
Protected Member Functions | |
| virtual void | vectorLoop (const string &tname, const string &dlname, const string &cexp) |
| Generate the code for a (short) delay line. | |
| virtual void | dlineLoop (const string &tname, const string &dlname, int delay, const string &cexp) |
| Generate the code for a (short) delay line. | |
Compile a list of FAUST signals into a vector C++ class.
Definition at line 37 of file compile_sched.hh.
| SchedulerCompiler::SchedulerCompiler | ( | const string & | name, |
| const string & | super, | ||
| int | numInputs, | ||
| int | numOutputs | ||
| ) | [inline] |
Definition at line 42 of file compile_sched.hh.
: VectorCompiler(name,super,numInputs,numOutputs) {}
| SchedulerCompiler::SchedulerCompiler | ( | Klass * | k | ) | [inline] |
Definition at line 46 of file compile_sched.hh.
: VectorCompiler(k) {}
| void SchedulerCompiler::compileMultiSignal | ( | Tree | L | ) | [virtual] |
Reimplemented from VectorCompiler.
Definition at line 30 of file compile_sched.cpp.
References Klass::addExecCode(), Klass::addSharedDecl(), Klass::addZone3(), Klass::buildTasksList(), Klass::closeLoop(), VectorCompiler::CS(), Compiler::fClass, Compiler::fDescription, Compiler::fUIRoot, Compiler::generateMacroInterfaceTree(), Compiler::generateUserInterfaceTree(), hd(), Klass::inputs(), isList(), Klass::openLoop(), Klass::outputs(), ScalarCompiler::prepare(), Compiler::prepareUserInterfaceTree(), subst(), T(), tl(), Description::ui(), xcast(), and xfloat().
{
//contextor recursivness(0);
L = prepare(L); // optimize, share and annotate expression
for (int i = 0; i < fClass->inputs(); i++) {
fClass->addZone3(subst("$1* input$0 = &input[$0][fIndex];", T(i), xfloat()));
}
for (int i = 0; i < fClass->outputs(); i++) {
fClass->addZone3(subst("$1* output$0 = &output[$0][fIndex];", T(i), xfloat()));
}
fClass->addSharedDecl("fullcount");
fClass->addSharedDecl("input");
fClass->addSharedDecl("output");
for (int i = 0; isList(L); L = tl(L), i++) {
Tree sig = hd(L);
fClass->openLoop("count");
fClass->addExecCode(subst("output$0[i] = $2$1;", T(i), CS(sig), xcast()));
fClass->closeLoop(sig);
}
// Build tasks list
fClass->buildTasksList();
generateUserInterfaceTree(prepareUserInterfaceTree(fUIRoot));
generateMacroInterfaceTree("", prepareUserInterfaceTree(fUIRoot));
if (fDescription) {
fDescription->ui(prepareUserInterfaceTree(fUIRoot));
}
}

| void SchedulerCompiler::dlineLoop | ( | const string & | tname, |
| const string & | dlname, | ||
| int | delay, | ||
| const string & | cexp | ||
| ) | [protected, virtual] |
Generate the code for a (short) delay line.
| k | the c++ class where the delay line will be placed. |
| l | the loop where the code will be placed. |
| tname | the name of the C++ type (float or int) |
| dlname | the name of the delay line (vector) to be used. |
| delay | the maximum delay |
| cexp | the content of the signal as a C++ expression |
Reimplemented from VectorCompiler.
Definition at line 95 of file compile_sched.cpp.
References Klass::addDeclCode(), Klass::addExecCode(), Klass::addFirstPrivateDecl(), Klass::addInitCode(), Klass::addPostCode(), Klass::addPreCode(), Klass::addSharedDecl(), Klass::addZone2(), Compiler::fClass, gMaxCopyDelay, gVecSize, ScalarCompiler::pow2limit(), subst(), and T().
{
if (delay < gMaxCopyDelay) {
// Implementation of a copy based delayline
// create names for temporary and permanent storage
string buf = subst("$0_tmp", dlname);
string pmem= subst("$0_perm", dlname);
// constraints delay size to be multiple of 4
delay = (delay+3)&-4;
// allocate permanent storage for delayed samples
string dsize = T(delay);
fClass->addDeclCode(subst("$0 \t$1[$2];", tname, pmem, dsize));
// init permanent memory
fClass->addInitCode(subst("for (int i=0; i<$1; i++) $0[i]=0;", pmem, dsize));
// compute method
// -- declare a buffer and a "shifted" vector
fClass->addSharedDecl(buf);
// -- variables moved as class fields...
fClass->addDeclCode(subst("$0 \t$1[$2+$3];", tname, buf, T(gVecSize), dsize));
fClass->addFirstPrivateDecl(dlname);
fClass->addZone2(subst("$0* \t$1 = &$2[$3];", tname, dlname, buf, dsize));
// -- copy the stored samples to the delay line
fClass->addPreCode(subst("for (int i=0; i<$2; i++) $0[i]=$1[i];", buf, pmem, dsize));
// -- compute the new samples
fClass->addExecCode(subst("$0[i] = $1;", dlname, cexp));
// -- copy back to stored samples
fClass->addPostCode(subst("for (int i=0; i<$2; i++) $0[i]=$1[count+i];", pmem, buf, dsize));
} else {
// Implementation of a ring-buffer delayline
// the size should be large enough and aligned on a power of two
delay = pow2limit(delay + gVecSize);
string dsize = T(delay);
string mask = T(delay-1);
// create names for temporary and permanent storage
string idx = subst("$0_idx", dlname);
string idx_save = subst("$0_idx_save", dlname);
// allocate permanent storage for delayed samples
fClass->addDeclCode(subst("$0 \t$1[$2];", tname, dlname, dsize));
fClass->addDeclCode(subst("int \t$0;", idx));
fClass->addDeclCode(subst("int \t$0;", idx_save));
// init permanent memory
fClass->addInitCode(subst("for (int i=0; i<$1; i++) $0[i]=0;", dlname, dsize));
fClass->addInitCode(subst("$0 = 0;", idx));
fClass->addInitCode(subst("$0 = 0;", idx_save));
// -- update index
fClass->addPreCode(subst("$0 = ($0+$1)&$2;", idx, idx_save, mask));
// -- compute the new samples
fClass->addExecCode(subst("$0[($2+i)&$3] = $1;", dlname, cexp, idx, mask));
// -- save index
fClass->addPostCode(subst("$0 = count;", idx_save));
}
}

| void SchedulerCompiler::vectorLoop | ( | const string & | tname, |
| const string & | vecname, | ||
| const string & | cexp | ||
| ) | [protected, virtual] |
Generate the code for a (short) delay line.
| k | the c++ class where the delay line will be placed. |
| l | the loop where the code will be placed. |
| tname | the name of the C++ type (float or int) |
| dlname | the name of the delay line (vector) to be used. |
| delay | the maximum delay |
| cexp | the content of the signal as a C++ expression |
Reimplemented from VectorCompiler.
Definition at line 73 of file compile_sched.cpp.
References Klass::addDeclCode(), Klass::addExecCode(), Klass::addSharedDecl(), Compiler::fClass, gVecSize, subst(), and T().
{
// -- declare the vector
fClass->addSharedDecl(vecname);
// -- variables moved as class fields...
fClass->addDeclCode(subst("$0 \t$1[$2];", tname, vecname, T(gVecSize)));
// -- compute the new samples
fClass->addExecCode(subst("$0[i] = $1;", vecname, cexp));
}

1.8.0