FAUST compiler  0.9.9.6b8
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
ScalarCompiler Class Reference

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

#include <compile_scal.hh>

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

Public Member Functions

 ScalarCompiler (const string &name, const string &super, int numInputs, int numOutputs)
 
 ScalarCompiler (Klass *k)
 
virtual void compileMultiSignal (Tree lsig)
 
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 string CS (Tree sig)
 Compile a signal. More...
 
virtual string generateCode (Tree sig)
 Main code generator dispatch. More...
 
virtual string generateCacheCode (Tree sig, const string &exp)
 
virtual string forceCacheCode (Tree sig, const string &exp)
 
virtual string generateVariableStore (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...
 
virtual string generateFixDelay (Tree sig, Tree arg, Tree size)
 Generate code for accessing a delayed signal. 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)
 
virtual string generateWaveform (Tree sig)
 
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)
 
virtual string generateDelayVec (Tree sig, const string &exp, const string &ctype, const string &vname, int mxd)
 Generate code for the delay mecchanism. More...
 
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...
 
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...
 
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...
 

Protected Attributes

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

static map< string, int > fIDCounters
 

Detailed Description

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

Definition at line 40 of file compile_scal.hh.

Constructor & Destructor Documentation

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

Definition at line 56 of file compile_scal.hh.

56  :
57  Compiler(name,super,numInputs,numOutputs,false),
58  fHasIota(false)
59  {}
Compiler(const string &name, const string &super, int numInputs, int numOutputs, bool vec)
Definition: compile.cpp:94
const char * name(Symbol *sym)
Returns the name of a symbol.
Definition: symbol.hh:98
ScalarCompiler::ScalarCompiler ( Klass k)
inline

Definition at line 61 of file compile_scal.hh.

61  :
62  Compiler(k),
63  fHasIota(false)
64  {}
Compiler(const string &name, const string &super, int numInputs, int numOutputs, bool vec)
Definition: compile.cpp:94

Member Function Documentation

void ScalarCompiler::compileMultiSignal ( Tree  lsig)
virtual

Implements Compiler.

Reimplemented in VectorCompiler, and SchedulerCompiler.

Definition at line 156 of file compile_scal.cpp.

References gInPlace, hd(), isList(), sigInput(), subst(), T(), tl(), xcast(), and xfloat().

157 {
158  //contextor recursivness(0);
159  L = prepare(L); // optimize, share and annotate expression
160 
161  for (int i = 0; i < fClass->inputs(); i++) {
162  fClass->addZone3(subst("$1* input$0 = input[$0];", T(i), xfloat()));
163  if (gInPlace) {
164  CS(sigInput(i));
165  }
166  }
167  for (int i = 0; i < fClass->outputs(); i++) {
168  fClass->addZone3(subst("$1* output$0 = output[$0];", T(i), xfloat()));
169  }
170 
171  for (int i = 0; isList(L); L = tl(L), i++) {
172  Tree sig = hd(L);
173  fClass->addExecCode(subst("output$0[i] = $2$1;", T(i), CS(sig), xcast()));
174  }
177  if (fDescription) {
179  }
180 }
int outputs()
Definition: klass.hh:210
virtual string CS(Tree sig)
Compile a signal.
Description * fDescription
Definition: compile.hh:56
Klass * fClass
Definition: compile.hh:53
void ui(Tree t)
Tree sigInput(int i)
Definition: signals.cpp:47
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
Tree hd(Tree l)
Definition: list.hh:133
const char * xfloat()
Definition: floats.cpp:49
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)
bool gInPlace
Definition: main.cpp:163
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 ScalarCompiler::compilePreparedSignalList ( Tree  lsig)
protected
void ScalarCompiler::compileSingleSignal ( Tree  lsig)
virtual

Implements Compiler.

Definition at line 187 of file compile_scal.cpp.

References subst().

Referenced by signal2klass().

188 {
189  //contextor recursivness(0);
190  sig = prepare2(sig); // optimize and annotate expression
191  fClass->addExecCode(subst("output[i] = $0;", CS(sig)));
194  if (fDescription) {
196  }
197 }
virtual string CS(Tree sig)
Compile a signal.
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
Tree prepare2(Tree L0)
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

Here is the call graph for this function:

Here is the caller graph for this function:

string ScalarCompiler::CS ( Tree  sig)
protectedvirtual

Compile a signal.

Parameters
sigthe signal expression to compile.
Returns
the C code translation of sig as a string

Reimplemented in VectorCompiler.

Definition at line 237 of file compile_scal.cpp.

238 {
239  //contextor contextRecursivness;
240  string code;
241 
242  if (!getCompiledExpression(sig, code)) {
243  // not compiled yet
244 /* if (getRecursivness(sig) != contextRecursivness.get()) {
245  contextRecursivness.set(getRecursivness(sig));
246  }*/
247  code = generateCode(sig);
248  setCompiledExpression(sig, code);
249  }
250  return code;
251 }
string setCompiledExpression(Tree sig, const string &name)
Set the string of a compiled expression is already compiled.
bool getCompiledExpression(Tree sig, string &name)
Test if a signal is already compiled.
virtual string generateCode(Tree sig)
Main code generator dispatch.
void ScalarCompiler::declareWaveform ( Tree  sig,
string &  vname,
int &  size 
)
protected

Generate code for a waveform.

The waveform will be declared as a static field. The name of the waveform is returned in vname and its size in size.

Definition at line 1334 of file compile_scal.cpp.

References CTree::arity(), CTree::branch(), getCertifiedSigType(), subst(), and T().

Referenced by VectorCompiler::generateWaveform().

1335 {
1336  // computes C type and unique name for the waveform
1337  string ctype;
1338  getTypedNames(getCertifiedSigType(sig), "Wave", ctype, vname);
1339 
1340  size = sig->arity();
1341 
1342  // Converts waveform into a string : "{a,b,c,...}"
1343  stringstream content;
1344 
1345  char sep = '{';
1346  for (int i = 0; i < size; i++) {
1347  content << sep << ppsig(sig->branch(i));
1348  sep = ',';
1349  }
1350  content << '}';
1351 
1352  // Declares the Waveform
1353  fClass->addDeclCode(subst("static $0 \t$1[$2];", ctype, vname, T(size)));
1354  fClass->addDeclCode(subst("int \tidx$0;", vname));
1355  fClass->addInitCode(subst("idx$0 = 0;", vname));
1357  subst("$0 \t$1::$2[$3] = ", ctype, fClass->getFullClassName(), vname, T(size) )
1358  + content.str() + ";");
1359 }
void getTypedNames(Type t, const string &prefix, string &ctype, string &vname)
Klass * fClass
Definition: compile.hh:53
string getFullClassName()
Returns the name of the class.
Definition: klass.hh:121
void addInitCode(const string &str)
Definition: klass.hh:151
Definition: ppsig.hh:48
string subst(const string &model, const vector< string > &args)
Text substitution.
Definition: Text.cpp:47
string T(char *c)
Definition: Text.cpp:158
void addStaticFields(const string &str)
Definition: klass.hh:155
Klass * getTopParentKlass()
Definition: klass.hh:120
Type getCertifiedSigType(Tree sig)
Retrieve the type of sig and check it exists.
int arity() const
return the number of branches (subtrees) of a tree
Definition: tree.hh:144
Tree branch(int i) const
return the ith branch (subtree) of a tree
Definition: tree.hh:145
void addDeclCode(const string &str)
Definition: klass.hh:149

Here is the call graph for this function:

Here is the caller graph for this function:

void ScalarCompiler::ensureIotaCode ( )
protected

Generate code for a unique IOTA variable increased at each sample and used to index ring buffers.

Definition at line 1320 of file compile_scal.cpp.

1321 {
1322  if (!fHasIota) {
1323  fHasIota = true;
1324  fClass->addDeclCode("int \tIOTA;");
1325  fClass->addInitCode("IOTA = 0;");
1326  fClass->addPostCode("IOTA = IOTA+1;");
1327  }
1328 }
Klass * fClass
Definition: compile.hh:53
void addInitCode(const string &str)
Definition: klass.hh:151
void addPostCode(const string &str)
Definition: klass.hh:176
void addDeclCode(const string &str)
Definition: klass.hh:149
string ScalarCompiler::forceCacheCode ( Tree  sig,
const string &  exp 
)
protectedvirtual

Definition at line 499 of file compile_scal.cpp.

References getCertifiedSigType(), and Occurences::getMaxDelay().

500 {
501  string vname, ctype, code;
502  Occurences* o = fOccMarkup.retrieve(sig);
503 
504  // check reentrance
505  if (getCompiledExpression(sig, code)) {
506  return code;
507  }
508 
509  // check for expression occuring in delays
510  if (o->getMaxDelay()>0) {
511 
512  getTypedNames(getCertifiedSigType(sig), "Vec", ctype, vname);
513  return generateDelayVec(sig, generateVariableStore(sig,exp), ctype, vname, o->getMaxDelay());
514 
515  } else {
516 
517  return generateVariableStore(sig, exp);
518 
519  }
520 }
void getTypedNames(Type t, const string &prefix, string &ctype, string &vname)
Occurences * retrieve(Tree t)
occurences of subtree t within root tree
Definition: occurences.cpp:81
virtual string generateDelayVec(Tree sig, const string &exp, const string &ctype, const string &vname, int mxd)
Generate code for the delay mecchanism.
bool getCompiledExpression(Tree sig, string &name)
Test if a signal is already compiled.
virtual string generateVariableStore(Tree sig, const string &exp)
Type getCertifiedSigType(Tree sig)
Retrieve the type of sig and check it exists.
OccMarkup fOccMarkup
Definition: compile_scal.hh:50
int getMaxDelay() const
return the maximal delay collected
Definition: occurences.cpp:54

Here is the call graph for this function:

string ScalarCompiler::generateBinOp ( Tree  sig,
int  opcode,
Tree  arg1,
Tree  arg2 
)
protected

Definition at line 404 of file compile_scal.cpp.

References gBinOpTable, getCertifiedSigType(), ifloat(), kDiv, kInt, kReal, and subst().

405 {
406  if (opcode == kDiv) {
407  // special handling for division, we always want a float division
408  Type t1 = getCertifiedSigType(arg1);
409  Type t2 = getCertifiedSigType(arg2);
410 
411  if (t1->nature()==kInt && t2->nature()==kInt ) {
412  return generateCacheCode(sig, subst("($3($0) $1 $3($2))", CS(arg1), gBinOpTable[opcode]->fName, CS(arg2), ifloat()));
413  } else if (t1->nature()==kInt && t2->nature()==kReal ) {
414  return generateCacheCode(sig, subst("($3($0) $1 $2)", CS(arg1), gBinOpTable[opcode]->fName, CS(arg2), ifloat()));
415  } else if (t1->nature()==kReal && t2->nature()==kInt ) {
416  return generateCacheCode(sig, subst("($0 $1 $3($2))", CS(arg1), gBinOpTable[opcode]->fName, CS(arg2), ifloat()));
417  } else {
418  return generateCacheCode(sig, subst("($0 $1 $2)", CS(arg1), gBinOpTable[opcode]->fName, CS(arg2), ifloat()));
419  }
420  } else {
421  return generateCacheCode(sig, subst("($0 $1 $2)", CS(arg1), gBinOpTable[opcode]->fName, CS(arg2)));
422  }
423 }
virtual string CS(Tree sig)
Compile a signal.
Definition: sigtype.hh:54
Definition: binop.hh:56
string subst(const string &model, const vector< string > &args)
Text substitution.
Definition: Text.cpp:47
Definition: sigtype.hh:54
Type getCertifiedSigType(Tree sig)
Retrieve the type of sig and check it exists.
virtual string generateCacheCode(Tree sig, const string &exp)
BinOp * gBinOpTable[]
Definition: binop.cpp:28
const char * ifloat()
Definition: floats.cpp:46

Here is the call graph for this function:

string ScalarCompiler::generateButton ( Tree  sig,
Tree  label 
)
protected

Definition at line 573 of file compile_scal.cpp.

References hd(), ifloat(), reverse(), subst(), tl(), tree(), uiWidget(), and xfloat().

574 {
575  string varname = getFreshID("fbutton");
576  fClass->addDeclCode(subst("$1 \t$0;", varname, xfloat()));
577  fClass->addInitCode(subst("$0 = 0.0;", varname));
578  addUIWidget(reverse(tl(path)), uiWidget(hd(path), tree(varname), sig));
579 
580  //return generateCacheCode(sig, varname);
581  return generateCacheCode(sig, subst("$1($0)", varname, ifloat()));
582 }
Tree reverse(Tree l)
Definition: list.cpp:240
Klass * fClass
Definition: compile.hh:53
void addUIWidget(Tree path, Tree widget)
Add a widget with a certain path to the user interface tree.
Definition: compile.cpp:123
Tree hd(Tree l)
Definition: list.hh:133
const char * xfloat()
Definition: floats.cpp:49
Tree uiWidget(Tree label, Tree varname, Tree sig)
Definition: uitree.cpp:140
void addInitCode(const string &str)
Definition: klass.hh:151
string getFreshID(const string &prefix)
string subst(const string &model, const vector< string > &args)
Text substitution.
Definition: Text.cpp:47
Tree tree(const Node &n)
Definition: tree.hh:186
virtual string generateCacheCode(Tree sig, const string &exp)
Tree tl(Tree l)
Definition: list.hh:134
const char * ifloat()
Definition: floats.cpp:46
void addDeclCode(const string &str)
Definition: klass.hh:149

Here is the call graph for this function:

string ScalarCompiler::generateCacheCode ( Tree  sig,
const string &  exp 
)
protectedvirtual

Reimplemented in VectorCompiler.

Definition at line 461 of file compile_scal.cpp.

References getCertifiedSigType(), and Occurences::getMaxDelay().

Referenced by VectorCompiler::generateCacheCode().

462 {
463  string vname, ctype, code;
464  int sharing = getSharingCount(sig);
465  Occurences* o = fOccMarkup.retrieve(sig);
466 
467  // check reentrance
468  if (getCompiledExpression(sig, code)) {
469  return code;
470  }
471 
472  // check for expression occuring in delays
473  if (o->getMaxDelay()>0) {
474 
475  getTypedNames(getCertifiedSigType(sig), "Vec", ctype, vname);
476  if (sharing>1) {
477  return generateDelayVec(sig, generateVariableStore(sig,exp), ctype, vname, o->getMaxDelay());
478  } else {
479  return generateDelayVec(sig, exp, ctype, vname, o->getMaxDelay());
480  }
481 
482  } else if (sharing == 1) {
483 
484  return exp;
485 
486  } else if (sharing > 1) {
487 
488  return generateVariableStore(sig, exp);
489 
490  } else {
491  cerr << "Error in sharing count (" << sharing << ") for " << *sig << endl;
492  exit(1);
493  }
494 
495  return "Error in generateCacheCode";
496 }
void getTypedNames(Type t, const string &prefix, string &ctype, string &vname)
Occurences * retrieve(Tree t)
occurences of subtree t within root tree
Definition: occurences.cpp:81
virtual string generateDelayVec(Tree sig, const string &exp, const string &ctype, const string &vname, int mxd)
Generate code for the delay mecchanism.
int getSharingCount(Tree t)
Definition: sharing.cpp:62
bool getCompiledExpression(Tree sig, string &name)
Test if a signal is already compiled.
virtual string generateVariableStore(Tree sig, const string &exp)
Type getCertifiedSigType(Tree sig)
Retrieve the type of sig and check it exists.
OccMarkup fOccMarkup
Definition: compile_scal.hh:50
int getMaxDelay() const
return the maximal delay collected
Definition: occurences.cpp:54

Here is the call graph for this function:

Here is the caller graph for this function:

string ScalarCompiler::generateCheckbox ( Tree  sig,
Tree  label 
)
protected

Definition at line 584 of file compile_scal.cpp.

References hd(), ifloat(), reverse(), subst(), tl(), tree(), uiWidget(), and xfloat().

585 {
586  string varname = getFreshID("fcheckbox");
587  fClass->addDeclCode(subst("$1 \t$0;", varname, xfloat()));
588  fClass->addInitCode(subst("$0 = 0.0;", varname));
589  addUIWidget(reverse(tl(path)), uiWidget(hd(path), tree(varname), sig));
590 
591  //return generateCacheCode(sig, varname);
592  return generateCacheCode(sig, subst("$1($0)", varname, ifloat()));
593 }
Tree reverse(Tree l)
Definition: list.cpp:240
Klass * fClass
Definition: compile.hh:53
void addUIWidget(Tree path, Tree widget)
Add a widget with a certain path to the user interface tree.
Definition: compile.cpp:123
Tree hd(Tree l)
Definition: list.hh:133
const char * xfloat()
Definition: floats.cpp:49
Tree uiWidget(Tree label, Tree varname, Tree sig)
Definition: uitree.cpp:140
void addInitCode(const string &str)
Definition: klass.hh:151
string getFreshID(const string &prefix)
string subst(const string &model, const vector< string > &args)
Text substitution.
Definition: Text.cpp:47
Tree tree(const Node &n)
Definition: tree.hh:186
virtual string generateCacheCode(Tree sig, const string &exp)
Tree tl(Tree l)
Definition: list.hh:134
const char * ifloat()
Definition: floats.cpp:46
void addDeclCode(const string &str)
Definition: klass.hh:149

Here is the call graph for this function:

string ScalarCompiler::generateCode ( Tree  sig)
protectedvirtual

Main code generator dispatch.

Parameters
sigthe signal expression to compile.
Returns
the C code translation of sig

Reimplemented in VectorCompiler.

Definition at line 262 of file compile_scal.cpp.

References getUserData(), isProj(), isSigAttach(), isSigBinOp(), isSigButton(), isSigCheckbox(), isSigFConst(), isSigFFun(), isSigFixDelay(), isSigFloatCast(), isSigFVar(), isSigGen(), isSigHBargraph(), isSigHSlider(), isSigInput(), isSigInt(), isSigIntCast(), isSigIota(), isSigNumEntry(), isSigOutput(), isSigPrefix(), isSigRDTbl(), isSigReal(), isSigSelect2(), isSigSelect3(), isSigTable(), isSigVBargraph(), isSigVSlider(), isSigWaveform(), isSigWRTbl(), name(), print(), printSignal(), T(), and tree2str().

Referenced by VectorCompiler::generateLoopCode().

263 {
264 #if 0
265  fprintf(stderr, "CALL generateCode(");
266  printSignal(sig, stderr);
267  fprintf(stderr, ")\n");
268 #endif
269 
270  int i;
271  double r;
272  Tree c, sel, x, y, z, label, id, ff, largs, type, name, file;
273 
274  //printf("compilation of %p : ", sig); print(sig); printf("\n");
275 
276  if ( getUserData(sig) ) { return generateXtended(sig); }
277  else if ( isSigInt(sig, &i) ) { return generateNumber(sig, T(i)); }
278  else if ( isSigReal(sig, &r) ) { return generateNumber(sig, T(r)); }
279  else if ( isSigWaveform(sig) ) { return generateWaveform(sig); }
280  else if ( isSigInput(sig, &i) ) { return generateInput (sig, T(i)); }
281  else if ( isSigOutput(sig, &i, x) ) { return generateOutput (sig, T(i), CS(x));}
282 
283  else if ( isSigFixDelay(sig, x, y) ) { return generateFixDelay (sig, x, y); }
284  else if ( isSigPrefix(sig, x, y) ) { return generatePrefix (sig, x, y); }
285  else if ( isSigIota(sig, x) ) { return generateIota (sig, x); }
286 
287  else if ( isSigBinOp(sig, &i, x, y) ) { return generateBinOp (sig, i, x, y); }
288  else if ( isSigFFun(sig, ff, largs) ) { return generateFFun (sig, ff, largs); }
289  else if ( isSigFConst(sig, type, name, file) ) { return generateFConst(sig, tree2str(file), tree2str(name)); }
290  else if ( isSigFVar(sig, type, name, file) ) { return generateFVar(sig, tree2str(file), tree2str(name)); }
291 
292  else if ( isSigTable(sig, id, x, y) ) { return generateTable (sig, x, y); }
293  else if ( isSigWRTbl(sig, id, x, y, z) ) { return generateWRTbl (sig, x, y, z); }
294  else if ( isSigRDTbl(sig, x, y) ) { return generateRDTbl (sig, x, y); }
295 
296  else if ( isSigSelect2(sig, sel, x, y) ) { return generateSelect2 (sig, sel, x, y); }
297  else if ( isSigSelect3(sig, sel, x, y, z) ) { return generateSelect3 (sig, sel, x, y, z); }
298 
299  else if ( isSigGen(sig, x) ) { return generateSigGen (sig, x); }
300 
301  else if ( isProj(sig, &i, x) ) { return generateRecProj (sig, x, i); }
302 
303  else if ( isSigIntCast(sig, x) ) { return generateIntCast (sig, x); }
304  else if ( isSigFloatCast(sig, x) ) { return generateFloatCast (sig, x); }
305 
306  else if ( isSigButton(sig, label) ) { return generateButton (sig, label); }
307  else if ( isSigCheckbox(sig, label) ) { return generateCheckbox (sig, label); }
308  else if ( isSigVSlider(sig, label,c,x,y,z) ) { return generateVSlider (sig, label, c,x,y,z); }
309  else if ( isSigHSlider(sig, label,c,x,y,z) ) { return generateHSlider (sig, label, c,x,y,z); }
310  else if ( isSigNumEntry(sig, label,c,x,y,z) ) { return generateNumEntry (sig, label, c,x,y,z); }
311 
312  else if ( isSigVBargraph(sig, label,x,y,z) ) { return generateVBargraph (sig, label, x, y, CS(z)); }
313  else if ( isSigHBargraph(sig, label,x,y,z) ) { return generateHBargraph (sig, label, x, y, CS(z)); }
314  else if ( isSigAttach(sig, x, y) ) { CS(y); return generateCacheCode(sig, CS(x)); }
315 
316  else {
317  printf("Error in compiling signal, unrecognized signal : ");
318  print(sig);
319  printf("\n");
320  exit(1);
321  }
322  return "error in generate code";
323 }
bool isSigHSlider(Tree s)
Definition: signals.cpp:217
bool isSigRDTbl(Tree s, Tree &t, Tree &i)
Definition: signals.cpp:77
bool isSigFConst(Tree s)
Definition: signals.cpp:138
bool isSigPrefix(Tree t, Tree &t0, Tree &t1)
Definition: signals.cpp:66
virtual string CS(Tree sig)
Compile a signal.
bool isSigCheckbox(Tree s)
Definition: signals.cpp:205
string generateHBargraph(Tree sig, Tree label, Tree min, Tree max, const string &exp)
bool isSigFFun(Tree s, Tree &ff, Tree &largs)
Definition: signals.cpp:133
bool isSigNumEntry(Tree s)
Definition: signals.cpp:257
bool isSigSelect2(Tree t, Tree &selector, Tree &s1, Tree &s2)
Definition: signals.cpp:116
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; ((n...
bool isSigIota(Tree t, Tree &t0)
Definition: signals.cpp:70
virtual string generateWaveform(Tree sig)
string generatePrefix(Tree sig, Tree x, Tree e)
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition: tree.hh:109
string generateSelect2(Tree sig, Tree sel, Tree s1, Tree s2)
Generate a select2 code.
bool isSigInput(Tree t, int *i)
Definition: signals.cpp:48
bool isSigFixDelay(Tree t, Tree &t0, Tree &t1)
Definition: signals.cpp:62
string generateSigGen(Tree sig, Tree content)
string generateHSlider(Tree sig, Tree label, Tree cur, Tree min, Tree max, Tree step)
string generateFVar(Tree sig, const string &file, const string &name)
string generateIota(Tree sig, Tree arg)
bool isSigVBargraph(Tree s)
Definition: signals.cpp:285
bool isSigSelect3(Tree t, Tree &selector, Tree &s1, Tree &s2, Tree &s3)
Definition: signals.cpp:119
string generateRecProj(Tree sig, Tree exp, int i)
Generate code for a projection of a group of mutually recursive definitions.
bool isSigVSlider(Tree s)
Definition: signals.cpp:237
string generateBinOp(Tree sig, int opcode, Tree arg1, Tree arg2)
bool isSigGen(Tree t, Tree &x)
Definition: signals.cpp:91
string generateRDTbl(Tree sig, Tree tbl, Tree idx)
string generateNumEntry(Tree sig, Tree label, Tree cur, Tree min, Tree max, Tree step)
bool isSigReal(Tree t, double *r)
Definition: signals.cpp:44
string generateButton(Tree sig, Tree label)
string generateFloatCast(Tree sig, Tree x)
string generateVSlider(Tree sig, Tree label, Tree cur, Tree min, Tree max, Tree step)
bool isSigHBargraph(Tree s)
Definition: signals.cpp:279
bool isSigTable(Tree t, Tree &id, Tree &n, Tree &sig)
Definition: signals.cpp:85
string T(char *c)
Definition: Text.cpp:158
void printSignal(Tree sig, FILE *out, int prec)
Definition: sigprint.cpp:85
bool isSigBinOp(Tree s, int *op, Tree &x, Tree &y)
Definition: signals.cpp:126
bool isSigAttach(Tree t, Tree &t0, Tree &t1)
Definition: signals.cpp:291
string generateCheckbox(Tree sig, Tree label)
bool isSigWRTbl(Tree u, Tree &id, Tree &t, Tree &i, Tree &s)
Definition: signals.cpp:81
string generateInput(Tree sig, const string &idx)
const char * name(Symbol *sym)
Returns the name of a symbol.
Definition: symbol.hh:98
bool isSigWaveform(Tree s)
Definition: signals.cpp:211
string generateIntCast(Tree sig, Tree x)
string generateXtended(Tree sig)
retrieve the type annotation of sig
bool isSigInt(Tree t, int *i)
Definition: signals.cpp:41
string generateOutput(Tree sig, const string &idx, const string &arg1)
virtual string generateCacheCode(Tree sig, const string &exp)
string generateWRTbl(Tree sig, Tree tbl, Tree idx, Tree data)
string generateNumber(Tree sig, const string &exp)
virtual string generateFixDelay(Tree sig, Tree arg, Tree size)
Generate code for accessing a delayed signal.
bool isSigFloatCast(Tree t)
Definition: signals.cpp:187
string generateFFun(Tree sig, Tree ff, Tree largs)
bool isSigFVar(Tree s)
Definition: signals.cpp:144
void * getUserData(Symbol *sym)
Returns user data.
Definition: symbol.hh:100
bool isSigIntCast(Tree t)
Definition: signals.cpp:184
string generateFConst(Tree sig, const string &file, const string &name)
bool isProj(Tree t, int *i, Tree &rgroup)
Definition: signals.cpp:151
string generateVBargraph(Tree sig, Tree label, Tree min, Tree max, const string &exp)
const char * tree2str(Tree t)
if t has a node of type symbol, return its name otherwise error
Definition: tree.cpp:278
bool isSigOutput(Tree t, int *i, Tree &t0)
Definition: signals.cpp:52
bool isSigButton(Tree s)
Definition: signals.cpp:199
string generateTable(Tree sig, Tree tsize, Tree content)
void print(Tree t, FILE *out)
Definition: list.cpp:154

Here is the call graph for this function:

Here is the caller graph for this function:

void ScalarCompiler::generateDelayLine ( const string &  ctype,
const string &  vname,
int  mxd,
const string &  exp 
)
protectedvirtual

Generate code for the delay mecchanism without using temporary variables.

Reimplemented in VectorCompiler.

Definition at line 1273 of file compile_scal.cpp.

References gMaxCopyDelay, subst(), and T().

1274 {
1275  //assert(mxd > 0);
1276  if (mxd == 0) {
1277  // cerr << "MXD==0 : " << vname << " := " << exp << endl;
1278  // no need for a real vector
1279  fClass->addExecCode(subst("$0 \t$1 = $2;", ctype, vname, exp));
1280 
1281 
1282  } else if (mxd < gMaxCopyDelay) {
1283  // cerr << "small delay : " << vname << "[" << mxd << "]" << endl;
1284 
1285  // short delay : we copy
1286  fClass->addDeclCode(subst("$0 \t$1[$2];", ctype, vname, T(mxd+1)));
1287  fClass->addInitCode(subst("for (int i=0; i<$1; i++) $0[i] = 0;", vname, T(mxd+1)));
1288  fClass->addExecCode(subst("$0[0] = $1;", vname, exp));
1289 
1290  // generate post processing copy code to update delay values
1291  if (mxd == 1) {
1292  fClass->addPostCode(subst("$0[1] = $0[0];", vname));
1293  } else if (mxd == 2) {
1294  fClass->addPostCode(subst("$0[2] = $0[1]; $0[1] = $0[0];", vname));
1295  } else {
1296  fClass->addPostCode(subst("for (int i=$0; i>0; i--) $1[i] = $1[i-1];", T(mxd), vname));
1297  }
1298 
1299  } else {
1300 
1301  // generate code for a long delay : we use a ring buffer of size N = 2**x > mxd
1302  int N = pow2limit(mxd+1);
1303 
1304  // we need a iota index
1305  ensureIotaCode();
1306 
1307  // declare and init
1308  fClass->addDeclCode(subst("$0 \t$1[$2];", ctype, vname, T(N)));
1309  fClass->addInitCode(subst("for (int i=0; i<$1; i++) $0[i] = 0;", vname, T(N)));
1310 
1311  // execute
1312  fClass->addExecCode(subst("$0[IOTA&$1] = $2;", vname, T(N-1), exp));
1313  }
1314 }
void ensureIotaCode()
Generate code for a unique IOTA variable increased at each sample and used to index ring buffers...
int gMaxCopyDelay
Definition: main.cpp:131
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
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
void addDeclCode(const string &str)
Definition: klass.hh:149

Here is the call graph for this function:

string ScalarCompiler::generateDelayVec ( Tree  sig,
const string &  exp,
const string &  ctype,
const string &  vname,
int  mxd 
)
protectedvirtual

Generate code for the delay mecchanism.

The generated code depend of the maximum delay attached to exp and the "less temporaries" switch

Reimplemented in VectorCompiler.

Definition at line 1211 of file compile_scal.cpp.

References getCertifiedSigType(), and kSamp.

1212 {
1213  string s = generateDelayVecNoTemp(sig, exp, ctype, vname, mxd);
1214  if (getCertifiedSigType(sig)->variability() < kSamp) {
1215  return exp;
1216  } else {
1217  return s;
1218  }
1219 }
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.
Definition: sigtype.hh:56
Type getCertifiedSigType(Tree sig)
Retrieve the type of sig and check it exists.

Here is the call graph for this function:

string ScalarCompiler::generateDelayVecNoTemp ( Tree  sig,
const string &  exp,
const string &  ctype,
const string &  vname,
int  mxd 
)
protected

Generate code for the delay mecchanism without using temporary variables.

Definition at line 1225 of file compile_scal.cpp.

References gMaxCopyDelay, subst(), and T().

1226 {
1227  assert(mxd > 0);
1228 
1229  //bool odocc = fOccMarkup.retrieve(sig)->hasOutDelayOccurences();
1230 
1231  if (mxd < gMaxCopyDelay) {
1232 
1233  // short delay : we copy
1234  fClass->addDeclCode(subst("$0 \t$1[$2];", ctype, vname, T(mxd+1)));
1235  fClass->addInitCode(subst("for (int i=0; i<$1; i++) $0[i] = 0;", vname, T(mxd+1)));
1236  fClass->addExecCode(subst("$0[0] = $1;", vname, exp));
1237 
1238  // generate post processing copy code to update delay values
1239  if (mxd == 1) {
1240  fClass->addPostCode(subst("$0[1] = $0[0];", vname));
1241  } else if (mxd == 2) {
1242  //fClass->addPostCode(subst("$0[2] = $0[1];", vname));
1243  fClass->addPostCode(subst("$0[2] = $0[1]; $0[1] = $0[0];", vname));
1244  } else {
1245  fClass->addPostCode(subst("for (int i=$0; i>0; i--) $1[i] = $1[i-1];", T(mxd), vname));
1246  }
1247  setVectorNameProperty(sig, vname);
1248  return subst("$0[0]", vname);
1249 
1250  } else {
1251 
1252  // generate code for a long delay : we use a ring buffer of size N = 2**x > mxd
1253  int N = pow2limit(mxd+1);
1254 
1255  // we need a iota index
1256  ensureIotaCode();
1257 
1258  // declare and init
1259  fClass->addDeclCode(subst("$0 \t$1[$2];", ctype, vname, T(N)));
1260  fClass->addInitCode(subst("for (int i=0; i<$1; i++) $0[i] = 0;", vname, T(N)));
1261 
1262  // execute
1263  fClass->addExecCode(subst("$0[IOTA&$1] = $2;", vname, T(N-1), exp));
1264  setVectorNameProperty(sig, vname);
1265  return subst("$0[IOTA&$1]", vname, T(N-1));
1266  }
1267 }
void ensureIotaCode()
Generate code for a unique IOTA variable increased at each sample and used to index ring buffers...
int gMaxCopyDelay
Definition: main.cpp:131
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
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
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...
void addDeclCode(const string &str)
Definition: klass.hh:149

Here is the call graph for this function:

string ScalarCompiler::generateFConst ( Tree  sig,
const string &  file,
const string &  name 
)
protected

Definition at line 349 of file compile_scal.cpp.

References getCertifiedSigType(), and Occurences::getMaxDelay().

350 {
351  string ctype, vname;
352  Occurences* o = fOccMarkup.retrieve(sig);
353 
354  addIncludeFile(file);
355 
356  if (o->getMaxDelay()>0) {
357  getTypedNames(getCertifiedSigType(sig), "Vec", ctype, vname);
358  generateDelayVec(sig, exp, ctype, vname, o->getMaxDelay());
359  }
360  return exp;
361 }
void addIncludeFile(const string &str)
Definition: compile.hh:77
void getTypedNames(Type t, const string &prefix, string &ctype, string &vname)
Occurences * retrieve(Tree t)
occurences of subtree t within root tree
Definition: occurences.cpp:81
virtual string generateDelayVec(Tree sig, const string &exp, const string &ctype, const string &vname, int mxd)
Generate code for the delay mecchanism.
Type getCertifiedSigType(Tree sig)
Retrieve the type of sig and check it exists.
OccMarkup fOccMarkup
Definition: compile_scal.hh:50
int getMaxDelay() const
return the maximal delay collected
Definition: occurences.cpp:54

Here is the call graph for this function:

string ScalarCompiler::generateFFun ( Tree  sig,
Tree  ff,
Tree  largs 
)
protected

Definition at line 430 of file compile_scal.cpp.

References ffarity(), ffincfile(), fflibfile(), ffname(), and nth().

431 {
432  addIncludeFile(ffincfile(ff)); //printf("inc file %s\n", ffincfile(ff));
433  addLibrary(fflibfile(ff)); //printf("lib file %s\n", fflibfile(ff));
434 
435  string code = ffname(ff);
436  code += '(';
437  string sep = "";
438  for (int i = 0; i< ffarity(ff); i++) {
439  code += sep;
440  code += CS(nth(largs, i));
441  sep = ", ";
442  }
443  code += ')';
444  return generateCacheCode(sig, code);
445 }
virtual string CS(Tree sig)
Compile a signal.
void addIncludeFile(const string &str)
Definition: compile.hh:77
const char * ffname(Tree t)
Definition: prim2.cpp:60
int ffarity(Tree t)
Definition: prim2.cpp:67
const char * ffincfile(Tree ff)
Definition: prim2.cpp:45
void addLibrary(const string &str)
Definition: compile.hh:78
virtual string generateCacheCode(Tree sig, const string &exp)
const char * fflibfile(Tree ff)
Definition: prim2.cpp:50
Tree nth(Tree l, int i)
Definition: list.cpp:182

Here is the call graph for this function:

string ScalarCompiler::generateFixDelay ( Tree  sig,
Tree  exp,
Tree  delay 
)
protectedvirtual

Generate code for accessing a delayed signal.

The generated code depend of the maximum delay attached to exp and the gLessTempSwitch.

Reimplemented in VectorCompiler.

Definition at line 1168 of file compile_scal.cpp.

References gMaxCopyDelay, isSigInt(), subst(), and T().

1169 {
1170  int mxd, d;
1171  string vecname;
1172 
1173  //cerr << "ScalarCompiler::generateFixDelay sig = " << *sig << endl;
1174  //cerr << "ScalarCompiler::generateFixDelay exp = " << *exp << endl;
1175  //cerr << "ScalarCompiler::generateFixDelay del = " << *delay << endl;
1176 
1177  CS(exp); // ensure exp is compiled to have a vector name
1178 
1179  mxd = fOccMarkup.retrieve(exp)->getMaxDelay();
1180 
1181  if (! getVectorNameProperty(exp, vecname)) {
1182  cerr << "No vector name for : " << ppsig(exp) << endl;
1183  assert(0);
1184  }
1185 
1186  if (mxd == 0) {
1187  // not a real vector name but a scalar name
1188  return vecname;
1189 
1190  } else if (mxd < gMaxCopyDelay) {
1191  if (isSigInt(delay, &d)) {
1192  return subst("$0[$1]", vecname, CS(delay));
1193  } else {
1194  return generateCacheCode(sig, subst("$0[$1]", vecname, CS(delay)));
1195  }
1196 
1197  } else {
1198 
1199  // long delay : we use a ring buffer of size 2^x
1200  int N = pow2limit( mxd+1 );
1201  return generateCacheCode(sig, subst("$0[(IOTA-$1)&$2]", vecname, CS(delay), T(N-1)));
1202  }
1203 }
virtual string CS(Tree sig)
Compile a signal.
int gMaxCopyDelay
Definition: main.cpp:131
int pow2limit(int x)
Compute the minimal power of 2 greater than x.
Occurences * retrieve(Tree t)
occurences of subtree t within root tree
Definition: occurences.cpp:81
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...
Definition: ppsig.hh:48
string subst(const string &model, const vector< string > &args)
Text substitution.
Definition: Text.cpp:47
string T(char *c)
Definition: Text.cpp:158
bool isSigInt(Tree t, int *i)
Definition: signals.cpp:41
OccMarkup fOccMarkup
Definition: compile_scal.hh:50
virtual string generateCacheCode(Tree sig, const string &exp)
int getMaxDelay() const
return the maximal delay collected
Definition: occurences.cpp:54

Here is the call graph for this function:

string ScalarCompiler::generateFloatCast ( Tree  sig,
Tree  x 
)
protected

Definition at line 564 of file compile_scal.cpp.

References ifloat(), and subst().

565 {
566  return generateCacheCode(sig, subst("$1($0)", CS(x), ifloat()));
567 }
virtual string CS(Tree sig)
Compile a signal.
string subst(const string &model, const vector< string > &args)
Text substitution.
Definition: Text.cpp:47
virtual string generateCacheCode(Tree sig, const string &exp)
const char * ifloat()
Definition: floats.cpp:46

Here is the call graph for this function:

string ScalarCompiler::generateFVar ( Tree  sig,
const string &  file,
const string &  name 
)
protected

Definition at line 368 of file compile_scal.cpp.

369 {
370  string ctype, vname;
371 
372  addIncludeFile(file);
373  return generateCacheCode(sig, exp);
374 }
void addIncludeFile(const string &str)
Definition: compile.hh:77
virtual string generateCacheCode(Tree sig, const string &exp)
string ScalarCompiler::generateHBargraph ( Tree  sig,
Tree  label,
Tree  min,
Tree  max,
const string &  exp 
)
protected

Definition at line 657 of file compile_scal.cpp.

References getCertifiedSigType(), hd(), kBlock, kKonst, kSamp, reverse(), subst(), tl(), tree(), uiWidget(), and xfloat().

658 {
659  string varname = getFreshID("fbargraph");
660  fClass->addDeclCode(subst("$1 \t$0;", varname, xfloat()));
661  addUIWidget(reverse(tl(path)), uiWidget(hd(path), tree(varname), sig));
662 
663  Type t = getCertifiedSigType(sig);
664  switch (t->variability()) {
665 
666  case kKonst :
667  fClass->addInitCode(subst("$0 = $1;", varname, exp));
668  break;
669 
670  case kBlock :
671  fClass->addZone2(subst("$0 = $1;", varname, exp));
672  break;
673 
674  case kSamp :
675  fClass->addExecCode(subst("$0 = $1;", varname, exp));
676  break;
677  }
678 
679  //return varname;
680  return generateCacheCode(sig, varname);
681 }
Tree reverse(Tree l)
Definition: list.cpp:240
Klass * fClass
Definition: compile.hh:53
void addUIWidget(Tree path, Tree widget)
Add a widget with a certain path to the user interface tree.
Definition: compile.cpp:123
void addExecCode(const string &str)
Definition: klass.hh:175
Tree hd(Tree l)
Definition: list.hh:133
const char * xfloat()
Definition: floats.cpp:49
Tree uiWidget(Tree label, Tree varname, Tree sig)
Definition: uitree.cpp:140
void addInitCode(const string &str)
Definition: klass.hh:151
void addZone2(const string &str)
Definition: klass.hh:169
string getFreshID(const string &prefix)
string subst(const string &model, const vector< string > &args)
Text substitution.
Definition: Text.cpp:47
Definition: sigtype.hh:56
Type getCertifiedSigType(Tree sig)
Retrieve the type of sig and check it exists.
Tree tree(const Node &n)
Definition: tree.hh:186
virtual string generateCacheCode(Tree sig, const string &exp)
Tree tl(Tree l)
Definition: list.hh:134
void addDeclCode(const string &str)
Definition: klass.hh:149

Here is the call graph for this function:

string ScalarCompiler::generateHSlider ( Tree  sig,
Tree  label,
Tree  cur,
Tree  min,
Tree  max,
Tree  step 
)
protected

Definition at line 607 of file compile_scal.cpp.

References hd(), ifloat(), reverse(), subst(), T(), tl(), tree(), tree2float(), uiWidget(), and xfloat().

608 {
609  string varname = getFreshID("fslider");
610  fClass->addDeclCode(subst("$1 \t$0;", varname, xfloat()));
611  fClass->addInitCode(subst("$0 = $1;", varname, T(tree2float(cur))));
612  addUIWidget(reverse(tl(path)), uiWidget(hd(path), tree(varname), sig));
613 
614  //return generateCacheCode(sig, varname);
615  return generateCacheCode(sig, subst("$1($0)", varname, ifloat()));
616 }
Tree reverse(Tree l)
Definition: list.cpp:240
Klass * fClass
Definition: compile.hh:53
void addUIWidget(Tree path, Tree widget)
Add a widget with a certain path to the user interface tree.
Definition: compile.cpp:123
Tree hd(Tree l)
Definition: list.hh:133
const char * xfloat()
Definition: floats.cpp:49
Tree uiWidget(Tree label, Tree varname, Tree sig)
Definition: uitree.cpp:140
void addInitCode(const string &str)
Definition: klass.hh:151
string getFreshID(const string &prefix)
string subst(const string &model, const vector< string > &args)
Text substitution.
Definition: Text.cpp:47
string T(char *c)
Definition: Text.cpp:158
Tree tree(const Node &n)
Definition: tree.hh:186
virtual string generateCacheCode(Tree sig, const string &exp)
double tree2float(Tree t)
if t has a node of type float, return it otherwise error
Definition: tree.cpp:246
Tree tl(Tree l)
Definition: list.hh:134
const char * ifloat()
Definition: floats.cpp:46
void addDeclCode(const string &str)
Definition: klass.hh:149

Here is the call graph for this function:

string ScalarCompiler::generateInput ( Tree  sig,
const string &  idx 
)
protected

Definition at line 381 of file compile_scal.cpp.

References gInPlace, icast(), and subst().

382 {
383  if (gInPlace) {
384  // inputs must be cached for in-place transformations
385  return forceCacheCode(sig, subst("$1input$0[i]", idx, icast()));
386  } else {
387  return generateCacheCode(sig, subst("$1input$0[i]", idx, icast()));
388  }
389 }
const char * icast()
Definition: floats.cpp:47
string subst(const string &model, const vector< string > &args)
Text substitution.
Definition: Text.cpp:47
virtual string generateCacheCode(Tree sig, const string &exp)
bool gInPlace
Definition: main.cpp:163
virtual string forceCacheCode(Tree sig, const string &exp)

Here is the call graph for this function:

string ScalarCompiler::generateIntCast ( Tree  sig,
Tree  x 
)
protected

Definition at line 559 of file compile_scal.cpp.

References subst().

560 {
561  return generateCacheCode(sig, subst("int($0)", CS(x)));
562 }
virtual string CS(Tree sig)
Compile a signal.
string subst(const string &model, const vector< string > &args)
Text substitution.
Definition: Text.cpp:47
virtual string generateCacheCode(Tree sig, const string &exp)

Here is the call graph for this function:

string ScalarCompiler::generateIota ( Tree  sig,
Tree  arg 
)
protected

Definition at line 959 of file compile_scal.cpp.

References isPowerOf2(), isSigInt(), subst(), and T().

960 {
961  int size;
962  if (!isSigInt(n, &size)) { fprintf(stderr, "error in generateIota\n"); exit(1); }
963 
964  string vperm = getFreshID("iota");
965 
966  fClass->addDeclCode(subst("int \t$0;", vperm));
967  fClass->addInitCode(subst("$0 = 0;", vperm));
968 
969  if (isPowerOf2(size)) {
970  fClass->addExecCode(subst("$0 = ($0+1)&$1;", vperm, T(size-1)));
971  } else {
972  fClass->addExecCode(subst("if (++$0 == $1) $0=0;", vperm, T(size)));
973  }
974  return vperm;
975 }
Klass * fClass
Definition: compile.hh:53
void addExecCode(const string &str)
Definition: klass.hh:175
void addInitCode(const string &str)
Definition: klass.hh:151
string getFreshID(const string &prefix)
string subst(const string &model, const vector< string > &args)
Text substitution.
Definition: Text.cpp:47
string T(char *c)
Definition: Text.cpp:158
bool isSigInt(Tree t, int *i)
Definition: signals.cpp:41
static bool isPowerOf2(int n)
void addDeclCode(const string &str)
Definition: klass.hh:149

Here is the call graph for this function:

string ScalarCompiler::generateNumber ( Tree  sig,
const string &  exp 
)
protected

Definition at line 331 of file compile_scal.cpp.

References getCertifiedSigType(), and Occurences::getMaxDelay().

332 {
333  string ctype, vname;
334  Occurences* o = fOccMarkup.retrieve(sig);
335 
336  // check for number occuring in delays
337  if (o->getMaxDelay()>0) {
338  getTypedNames(getCertifiedSigType(sig), "Vec", ctype, vname);
339  generateDelayVec(sig, exp, ctype, vname, o->getMaxDelay());
340  }
341  return exp;
342 }
void getTypedNames(Type t, const string &prefix, string &ctype, string &vname)
Occurences * retrieve(Tree t)
occurences of subtree t within root tree
Definition: occurences.cpp:81
virtual string generateDelayVec(Tree sig, const string &exp, const string &ctype, const string &vname, int mxd)
Generate code for the delay mecchanism.
Type getCertifiedSigType(Tree sig)
Retrieve the type of sig and check it exists.
OccMarkup fOccMarkup
Definition: compile_scal.hh:50
int getMaxDelay() const
return the maximal delay collected
Definition: occurences.cpp:54

Here is the call graph for this function:

string ScalarCompiler::generateNumEntry ( Tree  sig,
Tree  label,
Tree  cur,
Tree  min,
Tree  max,
Tree  step 
)
protected

Definition at line 618 of file compile_scal.cpp.

References hd(), ifloat(), reverse(), subst(), T(), tl(), tree(), tree2float(), uiWidget(), and xfloat().

619 {
620  string varname = getFreshID("fentry");
621  fClass->addDeclCode(subst("$1 \t$0;", varname, xfloat()));
622  fClass->addInitCode(subst("$0 = $1;", varname, T(tree2float(cur))));
623  addUIWidget(reverse(tl(path)), uiWidget(hd(path), tree(varname), sig));
624 
625  //return generateCacheCode(sig, varname);
626  return generateCacheCode(sig, subst("$1($0)", varname, ifloat()));
627 }
Tree reverse(Tree l)
Definition: list.cpp:240
Klass * fClass
Definition: compile.hh:53
void addUIWidget(Tree path, Tree widget)
Add a widget with a certain path to the user interface tree.
Definition: compile.cpp:123
Tree hd(Tree l)
Definition: list.hh:133
const char * xfloat()
Definition: floats.cpp:49
Tree uiWidget(Tree label, Tree varname, Tree sig)
Definition: uitree.cpp:140
void addInitCode(const string &str)
Definition: klass.hh:151
string getFreshID(const string &prefix)
string subst(const string &model, const vector< string > &args)
Text substitution.
Definition: Text.cpp:47
string T(char *c)
Definition: Text.cpp:158
Tree tree(const Node &n)
Definition: tree.hh:186
virtual string generateCacheCode(Tree sig, const string &exp)
double tree2float(Tree t)
if t has a node of type float, return it otherwise error
Definition: tree.cpp:246
Tree tl(Tree l)
Definition: list.hh:134
const char * ifloat()
Definition: floats.cpp:46
void addDeclCode(const string &str)
Definition: klass.hh:149

Here is the call graph for this function:

string ScalarCompiler::generateOutput ( Tree  sig,
const string &  idx,
const string &  arg1 
)
protected

Definition at line 392 of file compile_scal.cpp.

References subst(), and xcast().

393 {
394  string dst = subst("output$0[i]", idx);
395  fClass->addExecCode(subst("$0 = $2$1;", dst, arg, xcast()));
396  return dst;
397 }
Klass * fClass
Definition: compile.hh:53
void addExecCode(const string &str)
Definition: klass.hh:175
const char * xcast()
Definition: floats.cpp:50
string subst(const string &model, const vector< string > &args)
Text substitution.
Definition: Text.cpp:47

Here is the call graph for this function:

string ScalarCompiler::generatePrefix ( Tree  sig,
Tree  x,
Tree  e 
)
protected

Definition at line 933 of file compile_scal.cpp.

References cType(), getCertifiedSigType(), and subst().

934 {
935  Type te = getCertifiedSigType(sig);//, tEnv);
936 
937  string vperm = getFreshID("M");
938  string vtemp = getFreshID("T");
939 
940  string type = cType(te);
941 
942  fClass->addDeclCode(subst("$0 \t$1;", type, vperm));
943  fClass->addInitCode(subst("$0 = $1;", vperm, CS(x)));
944 
945  fClass->addExecCode(subst("$0 $1 = $2;", type, vtemp, vperm));
946  fClass->addExecCode(subst("$0 = $1;", vperm, CS(e)));
947  return vtemp;
948 }
virtual string CS(Tree sig)
Compile a signal.
Klass * fClass
Definition: compile.hh:53
void addExecCode(const string &str)
Definition: klass.hh:175
void addInitCode(const string &str)
Definition: klass.hh:151
string cType(Type t)
Definition: sigtype.cpp:340
string getFreshID(const string &prefix)
string subst(const string &model, const vector< string > &args)
Text substitution.
Definition: Text.cpp:47
Type getCertifiedSigType(Tree sig)
Retrieve the type of sig and check it exists.
void addDeclCode(const string &str)
Definition: klass.hh:149

Here is the call graph for this function:

string ScalarCompiler::generateRDTbl ( Tree  sig,
Tree  tbl,
Tree  idx 
)
protected

Definition at line 847 of file compile_scal.cpp.

References isSigTable(), and subst().

848 {
849  // YO le 21/04/05 : La lecture des tables n'�ait pas mise dans le cache
850  // et donc le code �ait dupliqu�(dans tester.dsp par exemple)
851  //return subst("$0[$1]", CS(tEnv, tbl), CS(tEnv, idx));
852 
853  //cerr << "generateRDTable " << *sig << endl;
854  // test the special case of a read only table that can be compiled
855  // has a static member
856  Tree id, size, content;
857  if( isSigTable(tbl, id, size, content) ) {
858  string tblname;
859  if (!getCompiledExpression(tbl, tblname)) {
860  tblname = setCompiledExpression(tbl, generateStaticTable(tbl, size, content));
861  }
862  return generateCacheCode(sig, subst("$0[$1]", tblname, CS(idx)));
863  } else {
864  return generateCacheCode(sig, subst("$0[$1]", CS(tbl), CS(idx)));
865  }
866 }
string setCompiledExpression(Tree sig, const string &name)
Set the string of a compiled expression is already compiled.
virtual string CS(Tree sig)
Compile a signal.
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition: tree.hh:109
string generateStaticTable(Tree sig, Tree tsize, Tree content)
string subst(const string &model, const vector< string > &args)
Text substitution.
Definition: Text.cpp:47
bool getCompiledExpression(Tree sig, string &name)
Test if a signal is already compiled.
bool isSigTable(Tree t, Tree &id, Tree &n, Tree &sig)
Definition: signals.cpp:85
virtual string generateCacheCode(Tree sig, const string &exp)

Here is the call graph for this function:

void ScalarCompiler::generateRec ( Tree  sig,
Tree  var,
Tree  le 
)
protected

Generate code for a group of mutually recursive definitions.

Definition at line 895 of file compile_scal.cpp.

References getCertifiedSigType(), len(), nth(), and sigProj().

Referenced by VectorCompiler::generateCodeRecursions().

896 {
897  int N = len(le);
898 
899  vector<bool> used(N);
900  vector<int> delay(N);
901  vector<string> vname(N);
902  vector<string> ctype(N);
903 
904  // prepare each element of a recursive definition
905  for (int i=0; i<N; i++) {
906  Tree e = sigProj(i,sig); // recreate each recursive definition
907  if (fOccMarkup.retrieve(e)) {
908  // this projection is used
909  used[i] = true;
910  getTypedNames(getCertifiedSigType(e), "Rec", ctype[i], vname[i]);
911  setVectorNameProperty(e, vname[i]);
912  delay[i] = fOccMarkup.retrieve(e)->getMaxDelay();
913  } else {
914  // this projection is not used therefore
915  // we should not generate code for it
916  used[i] = false;
917  }
918  }
919 
920  // generate delayline for each element of a recursive definition
921  for (int i=0; i<N; i++) {
922  if (used[i]) {
923  generateDelayLine(ctype[i], vname[i], delay[i], CS(nth(le,i)));
924  }
925  }
926 }
virtual string CS(Tree sig)
Compile a signal.
void getTypedNames(Type t, const string &prefix, string &ctype, string &vname)
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition: tree.hh:109
Occurences * retrieve(Tree t)
occurences of subtree t within root tree
Definition: occurences.cpp:81
Tree sigProj(int i, Tree rgroup)
Definition: signals.cpp:150
Type getCertifiedSigType(Tree sig)
Retrieve the type of sig and check it exists.
OccMarkup fOccMarkup
Definition: compile_scal.hh:50
int getMaxDelay() const
return the maximal delay collected
Definition: occurences.cpp:54
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...
int len(Tree l)
Definition: list.cpp:198
Tree nth(Tree l, int i)
Definition: list.cpp:182
virtual void generateDelayLine(const string &ctype, const string &vname, int mxd, const string &exp)
Generate code for the delay mecchanism without using temporary variables.

Here is the call graph for this function:

Here is the caller graph for this function:

string ScalarCompiler::generateRecProj ( Tree  sig,
Tree  exp,
int  i 
)
protected

Generate code for a projection of a group of mutually recursive definitions.

Definition at line 878 of file compile_scal.cpp.

References isRec().

879 {
880  string vname;
881  Tree var, le;
882 
883  if ( ! getVectorNameProperty(sig, vname)) {
884  assert(isRec(r, var, le));
885  generateRec(r, var, le);
886  assert(getVectorNameProperty(sig, vname));
887  }
888  return "[[UNUSED EXP]]"; // make sure the resulting expression is never used in the generated code
889 }
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition: tree.hh:109
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...
void generateRec(Tree sig, Tree var, Tree le)
Generate code for a group of mutually recursive definitions.
bool isRec(Tree t, Tree &body)
is t a de Bruijn recursive tree

Here is the call graph for this function:

string ScalarCompiler::generateSelect2 ( Tree  sig,
Tree  sel,
Tree  s1,
Tree  s2 
)
protected

Generate a select2 code.

Definition at line 986 of file compile_scal.cpp.

References subst().

987 {
988  return generateCacheCode(sig, subst( "(($0)?$1:$2)", CS(sel), CS(s2), CS(s1) ) );
989 }
virtual string CS(Tree sig)
Compile a signal.
string subst(const string &model, const vector< string > &args)
Text substitution.
Definition: Text.cpp:47
virtual string generateCacheCode(Tree sig, const string &exp)

Here is the call graph for this function:

string ScalarCompiler::generateSelect3 ( Tree  sig,
Tree  sel,
Tree  s1,
Tree  s2,
Tree  s3 
)
protected

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

Definition at line 997 of file compile_scal.cpp.

References subst().

998 {
999  return generateCacheCode(sig, subst( "(($0==0)? $1 : (($0==1)?$2:$3) )", CS(sel), CS(s1), CS(s2), CS(s3) ) );
1000 }
virtual string CS(Tree sig)
Compile a signal.
string subst(const string &model, const vector< string > &args)
Text substitution.
Definition: Text.cpp:47
virtual string generateCacheCode(Tree sig, const string &exp)

Here is the call graph for this function:

string ScalarCompiler::generateSigGen ( Tree  sig,
Tree  content 
)
protected

Definition at line 696 of file compile_scal.cpp.

References signal2klass(), and subst().

697 {
698  string klassname = getFreshID("SIG");
699  string signame = getFreshID("sig");
700 
701  fClass->addSubKlass(signal2klass(fClass, klassname, content));
702  fClass->addInitCode(subst("$0 $1;", klassname, signame));
703  fInstanceInitProperty.set(content, pair<string,string>(klassname,signame));
704 
705  return signame;
706 }
Klass * fClass
Definition: compile.hh:53
void addInitCode(const string &str)
Definition: klass.hh:151
void set(Tree t, const P &data)
Definition: property.hh:22
void addSubKlass(Klass *son)
Definition: klass.hh:147
string getFreshID(const string &prefix)
string subst(const string &model, const vector< string > &args)
Text substitution.
Definition: Text.cpp:47
property< pair< string, string > > fInstanceInitProperty
Definition: compile_scal.hh:46
static Klass * signal2klass(Klass *parent, const string &name, Tree sig)

Here is the call graph for this function:

string ScalarCompiler::generateStaticSigGen ( Tree  sig,
Tree  content 
)
protected

Definition at line 708 of file compile_scal.cpp.

References signal2klass(), and subst().

709 {
710  string klassname = getFreshID("SIG");
711  string signame = getFreshID("sig");
712 
713  fClass->addSubKlass(signal2klass(fClass, klassname, content));
714  fClass->addStaticInitCode(subst("$0 $1;", klassname, signame));
715  fStaticInitProperty.set(content, pair<string,string>(klassname,signame));
716 
717  return signame;
718 }
Klass * fClass
Definition: compile.hh:53
void addStaticInitCode(const string &str)
Definition: klass.hh:153
void set(Tree t, const P &data)
Definition: property.hh:22
void addSubKlass(Klass *son)
Definition: klass.hh:147
string getFreshID(const string &prefix)
string subst(const string &model, const vector< string > &args)
Text substitution.
Definition: Text.cpp:47
property< pair< string, string > > fStaticInitProperty
Definition: compile_scal.hh:45
static Klass * signal2klass(Klass *parent, const string &name, Tree sig)

Here is the call graph for this function:

string ScalarCompiler::generateStaticTable ( Tree  sig,
Tree  tsize,
Tree  content 
)
protected

Definition at line 775 of file compile_scal.cpp.

References getCertifiedSigType(), ifloat(), isSigGen(), isSigInt(), kInt, subst(), and T().

776 {
777  //string generator(CS(content));
778  Tree g;
779  string cexp;
780  string ctype, vname;
781  int size;
782 
783  assert ( isSigGen(content, g) );
784 
785  if (!getCompiledExpression(content, cexp)) {
786  cexp = setCompiledExpression(content, generateStaticSigGen(content, g));
787  } else {
788  // already compiled but check if we need to add declarations
789  pair<string,string> kvnames;
790  if ( ! fStaticInitProperty.get(g, kvnames)) {
791  // not declared here, we add a declaration
792  bool b = fInstanceInitProperty.get(g, kvnames);
793  assert(b);
794  fClass->addStaticInitCode(subst("$0 $1;", kvnames.first, kvnames.second));
795  }
796  }
797 
798  if (!isSigInt(tsize, &size)) {
799  //fprintf(stderr, "error in ScalarCompiler::generateTable()\n"); exit(1);
800  cerr << "error in ScalarCompiler::generateTable() : "
801  << *tsize
802  << " is not a constant integer table size expression "
803  << endl;
804  exit(1);
805  }
806  // definition du nom et du type de la table
807  // A REVOIR !!!!!!!!!
808  Type t = getCertifiedSigType(content);//, tEnv);
809  if (t->nature() == kInt) {
810  vname = getFreshID("itbl");
811  ctype = "int";
812  } else {
813  vname = getFreshID("ftbl");
814  ctype = ifloat();
815  }
816 
817  // declaration de la table
818  fClass->addDeclCode(subst("static $0 \t$1[$2];", ctype, vname, T(size)));
819  fClass->addStaticFields(subst("$0 \t$1::$2[$3];", ctype, fClass->getClassName(), vname, T(size) ));
820 
821  // initialisation du generateur de contenu
822  fClass->addStaticInitCode(subst("$0.init(samplingFreq);", cexp));
823  // remplissage de la table
824  fClass->addStaticInitCode(subst("$0.fill($1,$2);", cexp, T(size), vname));
825 
826  // on retourne le nom de la table
827  return vname;
828 }
string setCompiledExpression(Tree sig, const string &name)
Set the string of a compiled expression is already compiled.
Klass * fClass
Definition: compile.hh:53
Definition: sigtype.hh:54
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition: tree.hh:109
void addStaticInitCode(const string &str)
Definition: klass.hh:153
bool isSigGen(Tree t, Tree &x)
Definition: signals.cpp:91
const string & getClassName() const
Returns the name of the class.
Definition: klass.hh:131
string getFreshID(const string &prefix)
string subst(const string &model, const vector< string > &args)
Text substitution.
Definition: Text.cpp:47
bool getCompiledExpression(Tree sig, string &name)
Test if a signal is already compiled.
string T(char *c)
Definition: Text.cpp:158
property< pair< string, string > > fInstanceInitProperty
Definition: compile_scal.hh:46
void addStaticFields(const string &str)
Definition: klass.hh:155
bool get(Tree t, P &data)
Definition: property.hh:32
Type getCertifiedSigType(Tree sig)
Retrieve the type of sig and check it exists.
property< pair< string, string > > fStaticInitProperty
Definition: compile_scal.hh:45
bool isSigInt(Tree t, int *i)
Definition: signals.cpp:41
string generateStaticSigGen(Tree sig, Tree content)
const char * ifloat()
Definition: floats.cpp:46
void addDeclCode(const string &str)
Definition: klass.hh:149

Here is the call graph for this function:

string ScalarCompiler::generateTable ( Tree  sig,
Tree  tsize,
Tree  content 
)
protected

Definition at line 725 of file compile_scal.cpp.

References getCertifiedSigType(), ifloat(), isSigGen(), isSigInt(), kInt, subst(), and T().

726 {
727  string generator(CS(content));
728  Tree g;
729  string cexp;
730  string ctype, vname;
731  int size;
732 
733  // already compiled but check if we need to add declarations
734 
735  assert ( isSigGen(content, g) );
736  pair<string,string> kvnames;
737  if ( ! fInstanceInitProperty.get(g, kvnames)) {
738  // not declared here, we add a declaration
739  bool b = fStaticInitProperty.get(g, kvnames);
740  assert(b);
741  fClass->addInitCode(subst("$0 $1;", kvnames.first, kvnames.second));
742  }
743 
744  if (!isSigInt(tsize, &size)) {
745  //fprintf(stderr, "error in ScalarCompiler::generateTable()\n"); exit(1);
746  cerr << "error in ScalarCompiler::generateTable() : "
747  << *tsize
748  << " is not a constant integer table size expression "
749  << endl;
750  exit(1);
751  }
752  // definition du nom et du type de la table
753  // A REVOIR !!!!!!!!!
754  Type t = getCertifiedSigType(content);//, tEnv);
755  if (t->nature() == kInt) {
756  vname = getFreshID("itbl");
757  ctype = "int";
758  } else {
759  vname = getFreshID("ftbl");
760  ctype = ifloat();
761  }
762 
763  // declaration de la table
764  fClass->addDeclCode(subst("$0 \t$1[$2];", ctype, vname, T(size)));
765 
766  // initialisation du generateur de contenu
767  fClass->addInitCode(subst("$0.init(samplingFreq);", generator));
768  // remplissage de la table
769  fClass->addInitCode(subst("$0.fill($1,$2);", generator, T(size), vname));
770 
771  // on retourne le nom de la table
772  return vname;
773 }
virtual string CS(Tree sig)
Compile a signal.
Klass * fClass
Definition: compile.hh:53
Definition: sigtype.hh:54
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition: tree.hh:109
bool isSigGen(Tree t, Tree &x)
Definition: signals.cpp:91
void addInitCode(const string &str)
Definition: klass.hh:151
string getFreshID(const string &prefix)
string subst(const string &model, const vector< string > &args)
Text substitution.
Definition: Text.cpp:47
string T(char *c)
Definition: Text.cpp:158
property< pair< string, string > > fInstanceInitProperty
Definition: compile_scal.hh:46
bool get(Tree t, P &data)
Definition: property.hh:32
Type getCertifiedSigType(Tree sig)
Retrieve the type of sig and check it exists.
property< pair< string, string > > fStaticInitProperty
Definition: compile_scal.hh:45
bool isSigInt(Tree t, int *i)
Definition: signals.cpp:41
const char * ifloat()
Definition: floats.cpp:46
void addDeclCode(const string &str)
Definition: klass.hh:149

Here is the call graph for this function:

string ScalarCompiler::generateVariableStore ( Tree  sig,
const string &  exp 
)
protectedvirtual

Reimplemented in VectorCompiler.

Definition at line 523 of file compile_scal.cpp.

References getCertifiedSigType(), kBlock, kKonst, kSamp, and subst().

Referenced by VectorCompiler::generateVariableStore().

524 {
525  string vname, ctype;
526  Type t = getCertifiedSigType(sig);
527 
528  switch (t->variability()) {
529 
530  case kKonst :
531 
532  getTypedNames(t, "Const", ctype, vname);
533  fClass->addDeclCode(subst("$0 \t$1;", ctype, vname));
534  fClass->addInitCode(subst("$0 = $1;", vname, exp));
535  break;
536 
537  case kBlock :
538 
539  getTypedNames(t, "Slow", ctype, vname);
540  fClass->addFirstPrivateDecl(vname);
541  fClass->addZone2(subst("$0 \t$1 = $2;", ctype, vname, exp));
542  break;
543 
544  case kSamp :
545 
546  getTypedNames(t, "Temp", ctype, vname);
547  fClass->addExecCode(subst("$0 $1 = $2;", ctype, vname, exp));
548  break;
549  }
550  return vname;
551 }
void getTypedNames(Type t, const string &prefix, string &ctype, string &vname)
Klass * fClass
Definition: compile.hh:53
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 addZone2(const string &str)
Definition: klass.hh:169
string subst(const string &model, const vector< string > &args)
Text substitution.
Definition: Text.cpp:47
Definition: sigtype.hh:56
Type getCertifiedSigType(Tree sig)
Retrieve the type of sig and check it exists.
void addDeclCode(const string &str)
Definition: klass.hh:149

Here is the call graph for this function:

Here is the caller graph for this function:

string ScalarCompiler::generateVBargraph ( Tree  sig,
Tree  label,
Tree  min,
Tree  max,
const string &  exp 
)
protected

Definition at line 630 of file compile_scal.cpp.

References getCertifiedSigType(), hd(), kBlock, kKonst, kSamp, reverse(), subst(), tl(), tree(), uiWidget(), and xfloat().

631 {
632  string varname = getFreshID("fbargraph");
633  fClass->addDeclCode(subst("$1 \t$0;", varname, xfloat()));
634  addUIWidget(reverse(tl(path)), uiWidget(hd(path), tree(varname), sig));
635 
636  Type t = getCertifiedSigType(sig);
637  switch (t->variability()) {
638 
639  case kKonst :
640  fClass->addInitCode(subst("$0 = $1;", varname, exp));
641  break;
642 
643  case kBlock :
644  fClass->addZone2(subst("$0 = $1;", varname, exp));
645  break;
646 
647  case kSamp :
648  fClass->addExecCode(subst("$0 = $1;", varname, exp));
649  break;
650  }
651 
652  //return varname;
653  return generateCacheCode(sig, varname);
654 }
Tree reverse(Tree l)
Definition: list.cpp:240
Klass * fClass
Definition: compile.hh:53
void addUIWidget(Tree path, Tree widget)
Add a widget with a certain path to the user interface tree.
Definition: compile.cpp:123
void addExecCode(const string &str)
Definition: klass.hh:175
Tree hd(Tree l)
Definition: list.hh:133
const char * xfloat()
Definition: floats.cpp:49
Tree uiWidget(Tree label, Tree varname, Tree sig)
Definition: uitree.cpp:140
void addInitCode(const string &str)
Definition: klass.hh:151
void addZone2(const string &str)
Definition: klass.hh:169
string getFreshID(const string &prefix)
string subst(const string &model, const vector< string > &args)
Text substitution.
Definition: Text.cpp:47
Definition: sigtype.hh:56
Type getCertifiedSigType(Tree sig)
Retrieve the type of sig and check it exists.
Tree tree(const Node &n)
Definition: tree.hh:186
virtual string generateCacheCode(Tree sig, const string &exp)
Tree tl(Tree l)
Definition: list.hh:134
void addDeclCode(const string &str)
Definition: klass.hh:149

Here is the call graph for this function:

string ScalarCompiler::generateVSlider ( Tree  sig,
Tree  label,
Tree  cur,
Tree  min,
Tree  max,
Tree  step 
)
protected

Definition at line 596 of file compile_scal.cpp.

References hd(), ifloat(), reverse(), subst(), T(), tl(), tree(), tree2float(), uiWidget(), and xfloat().

597 {
598  string varname = getFreshID("fslider");
599  fClass->addDeclCode(subst("$1 \t$0;", varname, xfloat()));
600  fClass->addInitCode(subst("$0 = $1;", varname, T(tree2float(cur))));
601  addUIWidget(reverse(tl(path)), uiWidget(hd(path), tree(varname), sig));
602 
603  //return generateCacheCode(sig, varname);
604  return generateCacheCode(sig, subst("$1($0)", varname, ifloat()));
605 }
Tree reverse(Tree l)
Definition: list.cpp:240
Klass * fClass
Definition: compile.hh:53
void addUIWidget(Tree path, Tree widget)
Add a widget with a certain path to the user interface tree.
Definition: compile.cpp:123
Tree hd(Tree l)
Definition: list.hh:133
const char * xfloat()
Definition: floats.cpp:49
Tree uiWidget(Tree label, Tree varname, Tree sig)
Definition: uitree.cpp:140
void addInitCode(const string &str)
Definition: klass.hh:151
string getFreshID(const string &prefix)
string subst(const string &model, const vector< string > &args)
Text substitution.
Definition: Text.cpp:47
string T(char *c)
Definition: Text.cpp:158
Tree tree(const Node &n)
Definition: tree.hh:186
virtual string generateCacheCode(Tree sig, const string &exp)
double tree2float(Tree t)
if t has a node of type float, return it otherwise error
Definition: tree.cpp:246
Tree tl(Tree l)
Definition: list.hh:134
const char * ifloat()
Definition: floats.cpp:46
void addDeclCode(const string &str)
Definition: klass.hh:149

Here is the call graph for this function:

string ScalarCompiler::generateWaveform ( Tree  sig)
protectedvirtual

Reimplemented in VectorCompiler.

Definition at line 1361 of file compile_scal.cpp.

References subst(), and T().

1362 {
1363  string vname;
1364  int size;
1365 
1366  declareWaveform(sig, vname, size);
1367  fClass->addPostCode(subst("idx$0 = (idx$0 + 1) % $1;", vname, T(size)));
1368  return generateCacheCode(sig, subst("$0[idx$0]", vname));
1369 }
Klass * fClass
Definition: compile.hh:53
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
virtual string generateCacheCode(Tree sig, const string &exp)
void declareWaveform(Tree sig, string &vname, int &size)
Generate code for a waveform.

Here is the call graph for this function:

string ScalarCompiler::generateWRTbl ( Tree  sig,
Tree  tbl,
Tree  idx,
Tree  data 
)
protected

Definition at line 835 of file compile_scal.cpp.

References subst().

836 {
837  string tblName(CS(tbl));
838  fClass->addExecCode(subst("$0[$1] = $2;", tblName, CS(idx), CS(data)));
839  return tblName;
840 }
virtual string CS(Tree sig)
Compile a signal.
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

Here is the call graph for this function:

string ScalarCompiler::generateXtended ( Tree  sig)
protected

retrieve the type annotation of sig

Parameters
sigthe signal we want to know the type

Definition at line 1077 of file compile_scal.cpp.

References CTree::arity(), CTree::branch(), xtended::generateCode(), getCertifiedSigType(), getUserData(), and xtended::needCache().

1078 {
1079  xtended* p = (xtended*) getUserData(sig);
1080  vector<string> args;
1081  vector<Type> types;
1082 
1083  for (int i=0; i<sig->arity(); i++) {
1084  args.push_back(CS(sig->branch(i)));
1085  types.push_back(getCertifiedSigType(sig->branch(i)));
1086  }
1087 
1088  if (p->needCache()) {
1089  return generateCacheCode(sig, p->generateCode(fClass, args, types));
1090  } else {
1091  return p->generateCode(fClass, args, types);
1092  }
1093 }
virtual string CS(Tree sig)
Compile a signal.
Klass * fClass
Definition: compile.hh:53
virtual bool needCache()=0
Type getCertifiedSigType(Tree sig)
Retrieve the type of sig and check it exists.
int arity() const
return the number of branches (subtrees) of a tree
Definition: tree.hh:144
virtual string generateCacheCode(Tree sig, const string &exp)
virtual string generateCode(Klass *klass, const vector< string > &args, const vector< Type > &types)=0
void * getUserData(Symbol *sym)
Returns user data.
Definition: symbol.hh:100
Tree branch(int i) const
return the ith branch (subtree) of a tree
Definition: tree.hh:145

Here is the call graph for this function:

bool ScalarCompiler::getCompiledExpression ( Tree  sig,
string &  cexp 
)
protected

Test if a signal is already compiled.

Parameters
sigthe signal expression to compile.
namethe string representing the compiled expression.
Returns
true is already compiled

Definition at line 210 of file compile_scal.cpp.

Referenced by VectorCompiler::CS(), VectorCompiler::generateCodeNonRec(), and VectorCompiler::generateCodeRecursions().

211 {
212  return fCompileProperty.get(sig, cexp);
213 }
bool get(Tree t, P &data)
Definition: property.hh:32
property< string > fCompileProperty
Definition: compile_scal.hh:43

Here is the caller graph for this function:

string ScalarCompiler::getFreshID ( const string &  prefix)
protected

Definition at line 90 of file compile_scal.cpp.

References subst(), and T().

91 {
92  if (fIDCounters.find(prefix) == fIDCounters.end()) {
93  fIDCounters[prefix]=0;
94  }
95  int n = fIDCounters[prefix];
96  fIDCounters[prefix] = n+1;
97  return subst("$0$1", prefix, T(n));
98 }
string subst(const string &model, const vector< string > &args)
Text substitution.
Definition: Text.cpp:47
string T(char *c)
Definition: Text.cpp:158
static map< string, int > fIDCounters
Definition: compile_scal.hh:48

Here is the call graph for this function:

int ScalarCompiler::getSharingCount ( Tree  t)
protected

Definition at line 62 of file sharing.cpp.

References fSharingKey, Node::getInt(), getProperty(), and CTree::node().

Referenced by VectorCompiler::generateCacheCode(), VectorCompiler::needSeparateLoop(), and sharingAnnotation().

63 {
64  //cerr << "getSharingCount of : " << *sig << " = ";
65  Tree c;
66  if (getProperty(sig, fSharingKey, c)) {
67  //cerr << c->node().getInt() << endl;
68  return c->node().getInt();
69  } else {
70  //cerr << 0 << endl;
71  return 0;
72  }
73 }
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition: tree.hh:109
const Node & node() const
return the content of the tree
Definition: tree.hh:143
int getInt() const
Definition: node.hh:104
bool getProperty(Tree t, Tree key, Tree &val)
Definition: list.cpp:423

Here is the call graph for this function:

Here is the caller graph for this function:

void ScalarCompiler::getTypedNames ( Type  t,
const string &  prefix,
string &  ctype,
string &  vname 
)
protected

Definition at line 452 of file compile_scal.cpp.

References ifloat(), kInt, and subst().

Referenced by VectorCompiler::generateCacheCode(), and VectorCompiler::generateVariableStore().

453 {
454  if (t->nature() == kInt) {
455  ctype = "int"; vname = subst("i$0", getFreshID(prefix));
456  } else {
457  ctype = ifloat(); vname = subst("f$0", getFreshID(prefix));
458  }
459 }
Definition: sigtype.hh:54
string getFreshID(const string &prefix)
string subst(const string &model, const vector< string > &args)
Text substitution.
Definition: Text.cpp:47
const char * ifloat()
Definition: floats.cpp:46

Here is the call graph for this function:

Here is the caller graph for this function:

bool ScalarCompiler::getVectorNameProperty ( Tree  sig,
string &  vecname 
)
protected

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.

Parameters
sigthe signal expression.
vecnamethe string where to store the vector name.
Returns
true if the signal has this property, false otherwise

Definition at line 1125 of file compile_scal.cpp.

Referenced by VectorCompiler::generateFixDelay().

1126 {
1127  return fVectorProperty.get(sig, vecname);
1128 }
property< string > fVectorProperty
Definition: compile_scal.hh:44
bool get(Tree t, P &data)
Definition: property.hh:32

Here is the caller graph for this function:

int ScalarCompiler::pow2limit ( int  x)
protected

Compute the minimal power of 2 greater than x.

Definition at line 1135 of file compile_scal.cpp.

Referenced by SchedulerCompiler::dlineLoop(), VectorCompiler::dlineLoop(), VectorCompiler::generateCacheCode(), and VectorCompiler::generateFixDelay().

1136 {
1137  int n = 2;
1138  while (n < x) { n = 2*n; }
1139  return n;
1140 }

Here is the caller graph for this function:

Tree ScalarCompiler::prepare ( Tree  L0)
protectedvirtual

Implements Compiler.

Definition at line 107 of file compile_scal.cpp.

References deBruijn2Sym(), endTiming(), gDrawSignals, gDumpNorm, makeDrawPath(), privatise(), recursivnessAnnotation(), sigToGraph(), simplify(), startTiming(), subst(), and typeAnnotation().

Referenced by SchedulerCompiler::compileMultiSignal(), and VectorCompiler::compileMultiSignal().

108 {
109 startTiming("ScalarCompiler::prepare");
110  startTiming("deBruijn2Sym");
111  Tree L1 = deBruijn2Sym(LS); // convert debruijn recursion into symbolic recursion
112  endTiming("deBruijn2Sym");
113  Tree L2 = simplify(L1); // simplify by executing every computable operation
114  Tree L3 = privatise(L2); // Un-share tables with multiple writers
115 
116  // dump normal form
117  if (gDumpNorm) {
118  cout << ppsig(L3) << endl;
119  exit(0);
120  }
121 
122  recursivnessAnnotation(L3); // Annotate L3 with recursivness information
123 
124  startTiming("typeAnnotation");
125  typeAnnotation(L3); // Annotate L3 with type information
126  endTiming("typeAnnotation");
127 
128  sharingAnalysis(L3); // annotate L3 with sharing count
129  fOccMarkup.mark(L3); // annotate L3 with occurences analysis
130  //annotationStatistics();
131 endTiming("ScalarCompiler::prepare");
132 
133  if (gDrawSignals) {
134  ofstream dotfile(subst("$0-sig.dot", makeDrawPath()).c_str());
135  sigToGraph(L3, dotfile);
136  }
137  return L3;
138 }
void sigToGraph(Tree L, ofstream &fout)
Draw a list of signals as a directed graph using graphviz's dot language.
Definition: sigToGraph.cpp:50
Tree deBruijn2Sym(Tree t)
bool gDumpNorm
Definition: main.cpp:149
void endTiming(const char *msg)
Definition: timing.cpp:43
void mark(Tree root)
start markup of root tree with new unique key
Definition: occurences.cpp:63
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition: tree.hh:109
void typeAnnotation(Tree sig)
Fully annotate every subtree of term with type information.
Tree simplify(Tree sig)
Definition: simplify.cpp:76
bool gDrawSignals
Definition: main.cpp:116
Tree privatise(const Tree &t)
Definition: privatise.cpp:45
Definition: ppsig.hh:48
string subst(const string &model, const vector< string > &args)
Text substitution.
Definition: Text.cpp:47
void sharingAnalysis(Tree t)
Definition: sharing.cpp:88
void startTiming(const char *msg)
Definition: timing.cpp:34
string makeDrawPath()
Definition: main.cpp:177
void recursivnessAnnotation(Tree sig)
Annotate a signal with recursivness.
OccMarkup fOccMarkup
Definition: compile_scal.hh:50

Here is the call graph for this function:

Here is the caller graph for this function:

Tree ScalarCompiler::prepare2 ( Tree  L0)
protectedvirtual

Implements Compiler.

Definition at line 140 of file compile_scal.cpp.

References endTiming(), recursivnessAnnotation(), startTiming(), and typeAnnotation().

141 {
142 startTiming("ScalarCompiler::prepare2");
143  recursivnessAnnotation(L0); // Annotate L0 with recursivness information
144  typeAnnotation(L0); // Annotate L0 with type information
145  sharingAnalysis(L0); // annotate L0 with sharing count
146  fOccMarkup.mark(L0); // annotate L0 with occurences analysis
147 endTiming("ScalarCompiler::prepare2");
148 
149  return L0;
150 }
void endTiming(const char *msg)
Definition: timing.cpp:43
void mark(Tree root)
start markup of root tree with new unique key
Definition: occurences.cpp:63
void typeAnnotation(Tree sig)
Fully annotate every subtree of term with type information.
void sharingAnalysis(Tree t)
Definition: sharing.cpp:88
void startTiming(const char *msg)
Definition: timing.cpp:34
void recursivnessAnnotation(Tree sig)
Annotate a signal with recursivness.
OccMarkup fOccMarkup
Definition: compile_scal.hh:50

Here is the call graph for this function:

string ScalarCompiler::setCompiledExpression ( Tree  sig,
const string &  cexp 
)
protected

Set the string of a compiled expression is already compiled.

Parameters
sigthe signal expression to compile.
cexpthe string representing the compiled expression.
Returns
the cexp (for commodity)

Definition at line 221 of file compile_scal.cpp.

Referenced by VectorCompiler::CS(), VectorCompiler::generateCodeNonRec(), and VectorCompiler::generateCodeRecursions().

222 {
223  //cerr << "ScalarCompiler::setCompiledExpression : " << cexp << " ==> " << ppsig(sig) << endl;
224  string old; if (fCompileProperty.get(sig, old) && (old != cexp)) {
225  cerr << "ERROR already a compiled expression attached : " << old << " replaced by " << cexp << endl;
226  exit(1);
227  }
228  fCompileProperty.set(sig, cexp);
229  return cexp;
230 }
void set(Tree t, const P &data)
Definition: property.hh:22
bool get(Tree t, P &data)
Definition: property.hh:32
property< string > fCompileProperty
Definition: compile_scal.hh:43

Here is the caller graph for this function:

void ScalarCompiler::setSharingCount ( Tree  t,
int  count 
)
protected

Definition at line 75 of file sharing.cpp.

References fSharingKey, setProperty(), and tree().

Referenced by sharingAnnotation().

76 {
77  //cerr << "setSharingCount of : " << *sig << " <- " << count << endl;
78  setProperty(sig, fSharingKey, tree(count));
79 }
Tree tree(const Node &n)
Definition: tree.hh:186
void setProperty(Tree t, Tree key, Tree val)
Definition: list.cpp:418

Here is the call graph for this function:

Here is the caller graph for this function:

void ScalarCompiler::setVectorNameProperty ( Tree  sig,
const string &  vecname 
)
protected

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.

Parameters
sigthe signal expression.
vecnamethe string representing the vector name.
Returns
true is already compiled

Definition at line 1111 of file compile_scal.cpp.

Referenced by VectorCompiler::generateCacheCode(), and VectorCompiler::generateDelayVec().

1112 {
1113  fVectorProperty.set(sig, vecname);
1114 }
property< string > fVectorProperty
Definition: compile_scal.hh:44
void set(Tree t, const P &data)
Definition: property.hh:22

Here is the caller graph for this function:

void ScalarCompiler::sharingAnalysis ( Tree  t)
protected

Definition at line 88 of file sharing.cpp.

References fSharingKey, hd(), isList(), kSamp, sharingAnnotation(), shprkey(), and tl().

89 {
90  fSharingKey = shprkey(t);
91  if (isList(t)) {
92  while (isList(t)) {
94  t = tl(t);
95  }
96  } else {
98  }
99 }
Tree shprkey(Tree t)
Create a specific property key for the sharing count of subtrees of t.
Definition: shlysis.cpp:69
Tree hd(Tree l)
Definition: list.hh:133
bool isList(Tree l)
Definition: list.hh:138
Definition: sigtype.hh:56
void sharingAnnotation(int vctxt, Tree t)
Definition: sharing.cpp:106
Tree tl(Tree l)
Definition: list.hh:134

Here is the call graph for this function:

void ScalarCompiler::sharingAnnotation ( int  vctxt,
Tree  t 
)
protected

Definition at line 106 of file sharing.cpp.

References getCertifiedSigType(), getSharingCount(), getSubSignals(), isSigGen(), isSigSelect3(), and setSharingCount().

Referenced by sharingAnalysis().

107 {
108  Tree c, x, y, z;
109 
110  //cerr << "START sharing annotation of " << *sig << endl;
111  int count = getSharingCount(sig);
112 
113  if (count > 0) {
114  // it is not our first visit
115  setSharingCount(sig, count+1);
116 
117  } else {
118  // it is our first visit,
119  int v = getCertifiedSigType(sig)->variability();
120 
121  // check "time sharing" cases
122  if (v < vctxt) {
123  setSharingCount(sig, 2); // time sharing occurence : slower expression in faster context
124  } else {
125  setSharingCount(sig, 1); // regular occurence
126  }
127 
128  if (isSigSelect3(sig,c,y,x,z)) {
129  // make a special case for select3 implemented with real if
130  // because the c expression will be used twice in the C++
131  // translation
132  sharingAnnotation(v, c);
133  sharingAnnotation(v, c);
134  sharingAnnotation(v, x);
135  sharingAnnotation(v, y);
136  sharingAnnotation(v, z);
137  } else {
138  // Annotate the sub signals
139  vector<Tree> subsig;
140  int n = getSubSignals(sig, subsig);
141  if (n>0 && ! isSigGen(sig)) {
142  for (int i=0; i<n; i++) sharingAnnotation(v, subsig[i]);
143  }
144  }
145  }
146  //cerr << "END sharing annotation of " << *sig << endl;
147 }
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition: tree.hh:109
bool isSigSelect3(Tree t, Tree &selector, Tree &s1, Tree &s2, Tree &s3)
Definition: signals.cpp:119
bool isSigGen(Tree t, Tree &x)
Definition: signals.cpp:91
int getSharingCount(Tree t)
Definition: sharing.cpp:62
Type getCertifiedSigType(Tree sig)
Retrieve the type of sig and check it exists.
void sharingAnnotation(int vctxt, Tree t)
Definition: sharing.cpp:106
int getSubSignals(Tree sig, vector< Tree > &vsigs, bool visitgen=true)
Extract the sub signals of a signal expression, that is not necesseraly all the subtrees.
Definition: subsignals.cpp:12
void setSharingCount(Tree t, int count)
Definition: sharing.cpp:75

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

property<string> ScalarCompiler::fCompileProperty
protected

Definition at line 43 of file compile_scal.hh.

bool ScalarCompiler::fHasIota
protected

Definition at line 51 of file compile_scal.hh.

map< string, int > ScalarCompiler::fIDCounters
staticprotected

Definition at line 48 of file compile_scal.hh.

property<pair<string,string> > ScalarCompiler::fInstanceInitProperty
protected

Definition at line 46 of file compile_scal.hh.

OccMarkup ScalarCompiler::fOccMarkup
protected
Tree ScalarCompiler::fSharingKey
protected

Definition at line 49 of file compile_scal.hh.

Referenced by getSharingCount(), setSharingCount(), and sharingAnalysis().

property<pair<string,string> > ScalarCompiler::fStaticInitProperty
protected

Definition at line 45 of file compile_scal.hh.

property<string> ScalarCompiler::fVectorProperty
protected

Definition at line 44 of file compile_scal.hh.


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