FAUST compiler  0.9.9.6b8
Public Member Functions | Protected Member Functions | List of all members
SchedulerCompiler Class Reference

Compile a list of FAUST signals into a vector C++ class. More...

#include <compile_sched.hh>

Inheritance diagram for SchedulerCompiler:
Inheritance graph
[legend]
Collaboration diagram for SchedulerCompiler:
Collaboration graph
[legend]

Public Member Functions

 SchedulerCompiler (const string &name, const string &super, int numInputs, int numOutputs)
 
 SchedulerCompiler (Klass *k)
 
virtual void compileMultiSignal (Tree L)
 
- Public Member Functions inherited from VectorCompiler
 VectorCompiler (const string &name, const string &super, int numInputs, int numOutputs)
 
 VectorCompiler (Klass *k)
 
- Public Member Functions inherited from ScalarCompiler
 ScalarCompiler (const string &name, const string &super, int numInputs, int numOutputs)
 
 ScalarCompiler (Klass *k)
 
virtual void compileSingleSignal (Tree lsig)
 
- Public Member Functions inherited from Compiler
 Compiler (const string &name, const string &super, int numInputs, int numOutputs, bool vec)
 
 Compiler (Klass *k)
 
virtual ~Compiler ()
 
KlassgetClass ()
 
void setDescription (Description *descr)
 
DescriptiongetDescription ()
 

Protected Member Functions

virtual void vectorLoop (const string &tname, const string &dlname, const string &cexp)
 Generate the code for a (short) delay line. More...
 
virtual void dlineLoop (const string &tname, const string &dlname, int delay, const string &cexp)
 Generate the code for a (short) delay line. More...
 
- Protected Member Functions inherited from VectorCompiler
virtual string CS (Tree sig)
 Compile a signal. More...
 
virtual string generateCode (Tree sig)
 Main code generator dispatch. More...
 
virtual void generateCodeRecursions (Tree sig)
 
virtual string generateCodeNonRec (Tree sig)
 
virtual string generateLoopCode (Tree sig)
 Compile a signal. More...
 
virtual string generateCacheCode (Tree sig, const string &exp)
 Generate cache code for a signal if needed. More...
 
virtual void generateDelayLine (const string &ctype, const string &vname, int mxd, const string &exp)
 Generate code for the delay mecchanism without using temporary variables. More...
 
virtual string generateVariableStore (Tree sig, const string &exp)
 
virtual string generateFixDelay (Tree sig, Tree exp, Tree delay)
 Generate code for accessing a delayed signal. More...
 
virtual string generateDelayVec (Tree sig, const string &exp, const string &ctype, const string &vname, int mxd)
 Generate code for the delay mecchanism. More...
 
virtual string generateWaveform (Tree sig)
 
bool needSeparateLoop (Tree sig)
 Test if a signal need to be compiled in a separate loop. More...
 
- Protected Member Functions inherited from ScalarCompiler
virtual string forceCacheCode (Tree sig, const string &exp)
 
string getFreshID (const string &prefix)
 
void compilePreparedSignalList (Tree lsig)
 
Tree prepare (Tree L0)
 
Tree prepare2 (Tree L0)
 
bool getCompiledExpression (Tree sig, string &name)
 Test if a signal is already compiled. More...
 
string setCompiledExpression (Tree sig, const string &name)
 Set the string of a compiled expression is already compiled. More...
 
void setVectorNameProperty (Tree sig, const string &vecname)
 Set the vector name property of a signal, the name of the vector used to store the previous values of the signal to implement a delay. More...
 
bool getVectorNameProperty (Tree sig, string &vecname)
 Get the vector name property of a signal, the name of the vector used to store the previous values of the signal to implement a delay. More...
 
int getSharingCount (Tree t)
 
void setSharingCount (Tree t, int count)
 
void sharingAnalysis (Tree t)
 
void sharingAnnotation (int vctxt, Tree t)
 
string generateXtended (Tree sig)
 retrieve the type annotation of sig More...
 
string generatePrefix (Tree sig, Tree x, Tree e)
 
string generateIota (Tree sig, Tree arg)
 
string generateBinOp (Tree sig, int opcode, Tree arg1, Tree arg2)
 
string generateFFun (Tree sig, Tree ff, Tree largs)
 
string generateInput (Tree sig, const string &idx)
 
string generateOutput (Tree sig, const string &idx, const string &arg1)
 
string generateTable (Tree sig, Tree tsize, Tree content)
 
string generateStaticTable (Tree sig, Tree tsize, Tree content)
 
string generateWRTbl (Tree sig, Tree tbl, Tree idx, Tree data)
 
string generateRDTbl (Tree sig, Tree tbl, Tree idx)
 
string generateSigGen (Tree sig, Tree content)
 
string generateStaticSigGen (Tree sig, Tree content)
 
string generateSelect2 (Tree sig, Tree sel, Tree s1, Tree s2)
 Generate a select2 code. More...
 
string generateSelect3 (Tree sig, Tree sel, Tree s1, Tree s2, Tree s3)
 Generate a select3 code (using if-then-else) ((int n = sel==0)? s0 : ((sel==1)? s1 : s2)) int nn; ((nn=sel) ? ((nn==1)? s1 : s2) : s0);. More...
 
string generateRecProj (Tree sig, Tree exp, int i)
 Generate code for a projection of a group of mutually recursive definitions. More...
 
void generateRec (Tree sig, Tree var, Tree le)
 Generate code for a group of mutually recursive definitions. More...
 
string generateIntCast (Tree sig, Tree x)
 
string generateFloatCast (Tree sig, Tree x)
 
string generateButton (Tree sig, Tree label)
 
string generateCheckbox (Tree sig, Tree label)
 
string generateVSlider (Tree sig, Tree label, Tree cur, Tree min, Tree max, Tree step)
 
string generateHSlider (Tree sig, Tree label, Tree cur, Tree min, Tree max, Tree step)
 
string generateNumEntry (Tree sig, Tree label, Tree cur, Tree min, Tree max, Tree step)
 
string generateVBargraph (Tree sig, Tree label, Tree min, Tree max, const string &exp)
 
string generateHBargraph (Tree sig, Tree label, Tree min, Tree max, const string &exp)
 
string generateNumber (Tree sig, const string &exp)
 
string generateFConst (Tree sig, const string &file, const string &name)
 
string generateFVar (Tree sig, const string &file, const string &name)
 
string generateDelayVecNoTemp (Tree sig, const string &exp, const string &ctype, const string &vname, int mxd)
 Generate code for the delay mecchanism without using temporary variables. More...
 
void getTypedNames (Type t, const string &prefix, string &ctype, string &vname)
 
void ensureIotaCode ()
 Generate code for a unique IOTA variable increased at each sample and used to index ring buffers. More...
 
int pow2limit (int x)
 Compute the minimal power of 2 greater than x. More...
 
void declareWaveform (Tree sig, string &vname, int &size)
 Generate code for a waveform. More...
 
- Protected Member Functions inherited from Compiler
void addIncludeFile (const string &str)
 
void addLibrary (const string &str)
 
void addUIWidget (Tree path, Tree widget)
 Add a widget with a certain path to the user interface tree. More...
 
void generateWidgetCode (Tree fulllabel, Tree varname, Tree sig)
 Generate buildUserInterface C++ lines of code corresponding to user interface widget t. More...
 
void generateUserInterfaceTree (Tree t)
 Generate buildUserInterface C++ lines of code corresponding to user interface element t. More...
 
void generateUserInterfaceElements (Tree elements)
 Iterate generateUserInterfaceTree on a list of user interface elements. More...
 
Tree prepareUserInterfaceTree (Tree t)
 Remove fake root folder if not needed (that is if the UI is completely enclosed in one folder. More...
 
void generateMacroInterfaceTree (const string &pathname, Tree t)
 Generate user interface macros corresponding to user interface element t. More...
 
void generateMacroInterfaceElements (const string &pathname, Tree elements)
 Iterate generateMacroInterfaceTree on a list of user interface elements. More...
 
void generateWidgetMacro (const string &pathname, Tree fulllabel, Tree varname, Tree sig)
 Generate user interface macros corresponding to a user interface widget. More...
 

Additional Inherited Members

- Protected Attributes inherited from ScalarCompiler
property< string > fCompileProperty
 
property< string > fVectorProperty
 
property< pair< string, string > > fStaticInitProperty
 
property< pair< string, string > > fInstanceInitProperty
 
Tree fSharingKey
 
OccMarkup fOccMarkup
 
bool fHasIota
 
- Protected Attributes inherited from Compiler
KlassfClass
 
bool fNeedToDeleteClass
 
Tree fUIRoot
 
DescriptionfDescription
 
- Static Protected Attributes inherited from ScalarCompiler
static map< string, int > fIDCounters
 

Detailed Description

Compile a list of FAUST signals into a vector C++ class.

Definition at line 37 of file compile_sched.hh.

Constructor & Destructor Documentation

SchedulerCompiler::SchedulerCompiler ( const string &  name,
const string &  super,
int  numInputs,
int  numOutputs 
)
inline

Definition at line 42 of file compile_sched.hh.

43  : VectorCompiler(name,super,numInputs,numOutputs)
44  {}
VectorCompiler(const string &name, const string &super, int numInputs, int numOutputs)
Definition: compile_vect.hh:44
const char * name(Symbol *sym)
Returns the name of a symbol.
Definition: symbol.hh:98
SchedulerCompiler::SchedulerCompiler ( Klass k)
inline

Definition at line 46 of file compile_sched.hh.

46  : VectorCompiler(k)
47  {}
VectorCompiler(const string &name, const string &super, int numInputs, int numOutputs)
Definition: compile_vect.hh:44

Member Function Documentation

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().

31 {
32  //contextor recursivness(0);
33  L = prepare(L); // optimize, share and annotate expression
34 
35  for (int i = 0; i < fClass->inputs(); i++) {
36  fClass->addZone3(subst("$1* input$0 = &input[$0][fIndex];", T(i), xfloat()));
37  }
38  for (int i = 0; i < fClass->outputs(); i++) {
39  fClass->addZone3(subst("$1* output$0 = &output[$0][fIndex];", T(i), xfloat()));
40  }
41 
42  fClass->addSharedDecl("fullcount");
43  fClass->addSharedDecl("input");
44  fClass->addSharedDecl("output");
45 
46  for (int i = 0; isList(L); L = tl(L), i++) {
47  Tree sig = hd(L);
48  fClass->openLoop("count");
49  fClass->addExecCode(subst("output$0[i] = $2$1;", T(i), CS(sig), xcast()));
50  fClass->closeLoop(sig);
51  }
52 
53  // Build tasks list
55 
58  if (fDescription) {
60  }
61 }
void addSharedDecl(const string &str)
Definition: klass.hh:165
int outputs()
Definition: klass.hh:210
virtual string CS(Tree sig)
Compile a signal.
void buildTasksList()
Definition: klass.cpp:328
Description * fDescription
Definition: compile.hh:56
Klass * fClass
Definition: compile.hh:53
void ui(Tree t)
void addExecCode(const string &str)
Definition: klass.hh:175
Tree prepareUserInterfaceTree(Tree t)
Remove fake root folder if not needed (that is if the UI is completely enclosed in one folder...
Definition: compile.cpp:133
void generateUserInterfaceTree(Tree t)
Generate buildUserInterface C++ lines of code corresponding to user interface element t...
Definition: compile.cpp:164
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition: tree.hh:109
const char * xcast()
Definition: floats.cpp:50
void openLoop(const string &size)
Open a non-recursive loop on top of the stack of open loops.
Definition: klass.cpp:96
Tree hd(Tree l)
Definition: list.hh:133
const char * xfloat()
Definition: floats.cpp:49
void closeLoop(Tree sig)
Close the top loop and either keep it or absorb it within its enclosing loop.
Definition: klass.cpp:117
Tree fUIRoot
Definition: compile.hh:55
void generateMacroInterfaceTree(const string &pathname, Tree t)
Generate user interface macros corresponding to user interface element t.
Definition: compile.cpp:312
string subst(const string &model, const vector< string > &args)
Text substitution.
Definition: Text.cpp:47
bool isList(Tree l)
Definition: list.hh:138
string T(char *c)
Definition: Text.cpp:158
Tree prepare(Tree L0)
int inputs()
Definition: klass.hh:209
Tree tl(Tree l)
Definition: list.hh:134
void addZone3(const string &str)
Definition: klass.hh:172

Here is the call graph for this function:

void SchedulerCompiler::dlineLoop ( const string &  tname,
const string &  dlname,
int  delay,
const string &  cexp 
)
protectedvirtual

Generate the code for a (short) delay line.

Parameters
kthe c++ class where the delay line will be placed.
lthe loop where the code will be placed.
tnamethe name of the C++ type (float or int)
dlnamethe name of the delay line (vector) to be used.
delaythe maximum delay
cexpthe 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().

96 {
97  if (delay < gMaxCopyDelay) {
98 
99  // Implementation of a copy based delayline
100 
101  // create names for temporary and permanent storage
102  string buf = subst("$0_tmp", dlname);
103  string pmem= subst("$0_perm", dlname);
104 
105  // constraints delay size to be multiple of 4
106  delay = (delay+3)&-4;
107 
108  // allocate permanent storage for delayed samples
109  string dsize = T(delay);
110  fClass->addDeclCode(subst("$0 \t$1[$2];", tname, pmem, dsize));
111 
112  // init permanent memory
113  fClass->addInitCode(subst("for (int i=0; i<$1; i++) $0[i]=0;", pmem, dsize));
114 
115  // compute method
116 
117  // -- declare a buffer and a "shifted" vector
118  fClass->addSharedDecl(buf);
119 
120  // -- variables moved as class fields...
121  fClass->addDeclCode(subst("$0 \t$1[$2+$3];", tname, buf, T(gVecSize), dsize));
122 
123  fClass->addFirstPrivateDecl(dlname);
124  fClass->addZone2(subst("$0* \t$1 = &$2[$3];", tname, dlname, buf, dsize));
125 
126  // -- copy the stored samples to the delay line
127  fClass->addPreCode(subst("for (int i=0; i<$2; i++) $0[i]=$1[i];", buf, pmem, dsize));
128 
129  // -- compute the new samples
130  fClass->addExecCode(subst("$0[i] = $1;", dlname, cexp));
131 
132  // -- copy back to stored samples
133  fClass->addPostCode(subst("for (int i=0; i<$2; i++) $0[i]=$1[count+i];", pmem, buf, dsize));
134 
135  } else {
136 
137  // Implementation of a ring-buffer delayline
138 
139  // the size should be large enough and aligned on a power of two
140  delay = pow2limit(delay + gVecSize);
141  string dsize = T(delay);
142  string mask = T(delay-1);
143 
144  // create names for temporary and permanent storage
145  string idx = subst("$0_idx", dlname);
146  string idx_save = subst("$0_idx_save", dlname);
147 
148  // allocate permanent storage for delayed samples
149  fClass->addDeclCode(subst("$0 \t$1[$2];", tname, dlname, dsize));
150  fClass->addDeclCode(subst("int \t$0;", idx));
151  fClass->addDeclCode(subst("int \t$0;", idx_save));
152 
153  // init permanent memory
154  fClass->addInitCode(subst("for (int i=0; i<$1; i++) $0[i]=0;", dlname, dsize));
155  fClass->addInitCode(subst("$0 = 0;", idx));
156  fClass->addInitCode(subst("$0 = 0;", idx_save));
157 
158  // -- update index
159  fClass->addPreCode(subst("$0 = ($0+$1)&$2;", idx, idx_save, mask));
160 
161  // -- compute the new samples
162  fClass->addExecCode(subst("$0[($2+i)&$3] = $1;", dlname, cexp, idx, mask));
163 
164  // -- save index
165  fClass->addPostCode(subst("$0 = count;", idx_save));
166  }
167 }
void addSharedDecl(const string &str)
Definition: klass.hh:165
int gVecSize
Definition: main.cpp:140
Klass * fClass
Definition: compile.hh:53
int pow2limit(int x)
Compute the minimal power of 2 greater than x.
void addExecCode(const string &str)
Definition: klass.hh:175
void addInitCode(const string &str)
Definition: klass.hh:151
void addFirstPrivateDecl(const string &str)
Definition: klass.hh:166
void addPreCode(const string &str)
Definition: klass.hh:174
void addZone2(const string &str)
Definition: klass.hh:169
string subst(const string &model, const vector< string > &args)
Text substitution.
Definition: Text.cpp:47
string T(char *c)
Definition: Text.cpp:158
void addPostCode(const string &str)
Definition: klass.hh:176
int gMaxCopyDelay
Definition: main.cpp:131
void addDeclCode(const string &str)
Definition: klass.hh:149

Here is the call graph for this function:

void SchedulerCompiler::vectorLoop ( const string &  tname,
const string &  vecname,
const string &  cexp 
)
protectedvirtual

Generate the code for a (short) delay line.

Parameters
kthe c++ class where the delay line will be placed.
lthe loop where the code will be placed.
tnamethe name of the C++ type (float or int)
dlnamethe name of the delay line (vector) to be used.
delaythe maximum delay
cexpthe 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().

74 {
75  // -- declare the vector
76  fClass->addSharedDecl(vecname);
77 
78  // -- variables moved as class fields...
79  fClass->addDeclCode(subst("$0 \t$1[$2];", tname, vecname, T(gVecSize)));
80 
81  // -- compute the new samples
82  fClass->addExecCode(subst("$0[i] = $1;", vecname, cexp));
83 }
void addSharedDecl(const string &str)
Definition: klass.hh:165
int gVecSize
Definition: main.cpp:140
Klass * fClass
Definition: compile.hh:53
void addExecCode(const string &str)
Definition: klass.hh:175
string subst(const string &model, const vector< string > &args)
Text substitution.
Definition: Text.cpp:47
string T(char *c)
Definition: Text.cpp:158
void addDeclCode(const string &str)
Definition: klass.hh:149

Here is the call graph for this function:


The documentation for this class was generated from the following files: