FAUST compiler  0.9.9.6b8
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes
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]

List of all members.

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)

Protected Member Functions

virtual string CS (Tree sig)
 Compile a signal.
virtual string generateCode (Tree sig)
 Main code generator dispatch.
virtual string generateCacheCode (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.
string setCompiledExpression (Tree sig, const string &name)
 Set the string of a compiled expression is already compiled.
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.
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.
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
virtual string generateFixDelay (Tree sig, Tree arg, Tree size)
 Generate code for accessing a delayed signal.
string generatePrefix (Tree sig, Tree x, Tree e)
string generateIota (Tree sig, Tree arg)
string generateBinOp (Tree sig, int opcode, Tree arg1, Tree arg2)
string generateFFun (Tree sig, Tree ff, Tree largs)
string generateInput (Tree sig, const string &idx)
string generateOutput (Tree sig, const string &idx, const string &arg1)
string generateTable (Tree sig, Tree tsize, Tree content)
string generateStaticTable (Tree sig, Tree tsize, Tree content)
string generateWRTbl (Tree sig, Tree tbl, Tree idx, Tree data)
string generateRDTbl (Tree sig, Tree tbl, Tree idx)
string generateSigGen (Tree sig, Tree content)
string generateStaticSigGen (Tree sig, Tree content)
string generateSelect2 (Tree sig, Tree sel, Tree s1, Tree s2)
 Generate a select2 code.
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);.
string generateRecProj (Tree sig, Tree exp, int i)
 Generate code for a projection of a group of mutually recursive definitions.
void generateRec (Tree sig, Tree var, Tree le)
 Generate code for a group of mutually recursive definitions.
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.
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.
virtual void generateDelayLine (const string &ctype, const string &vname, int mxd, const string &exp)
 Generate code for the delay mecchanism without using temporary variables.
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.
int pow2limit (int x)
 Compute the minimal power of 2 greater than x.

Protected Attributes

property< string > fCompileProperty
property< string > fVectorProperty
property< pair< string, string > > fStaticInitProperty
property< pair< string, string > > fInstanceInitProperty
Tree fSharingKey
OccMarkup fOccMarkup
bool fHasIota

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.

                                                                                             :
        Compiler(name,super,numInputs,numOutputs,false),
        fHasIota(false)
    {}

Definition at line 61 of file compile_scal.hh.

                               : 
        Compiler(k),
        fHasIota(false)
    {}

Member Function Documentation

void ScalarCompiler::compileMultiSignal ( Tree  lsig) [virtual]

Implements Compiler.

Reimplemented in VectorCompiler, and SchedulerCompiler.

Definition at line 153 of file compile_scal.cpp.

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

{
    //contextor recursivness(0);
    L = prepare(L);     // optimize, share and annotate expression

    for (int i = 0; i < fClass->inputs(); i++) {
        fClass->addZone3(subst("$1* input$0 = input[$0];", T(i), xfloat()));
    }
    for (int i = 0; i < fClass->outputs(); i++) {
        fClass->addZone3(subst("$1* output$0 = output[$0];", T(i), xfloat()));
    }

    for (int i = 0; isList(L); L = tl(L), i++) {
        Tree sig = hd(L);
        fClass->addExecCode(subst("output$0[i] = $2$1;", T(i), CS(sig), xcast()));
    }
    generateUserInterfaceTree(prepareUserInterfaceTree(fUIRoot));
    generateMacroInterfaceTree("", prepareUserInterfaceTree(fUIRoot));
    if (fDescription) {
        fDescription->ui(prepareUserInterfaceTree(fUIRoot));
    }
}

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 181 of file compile_scal.cpp.

References subst().

Referenced by signal2klass().

{
    //contextor recursivness(0);
    sig = prepare2(sig);        // optimize and annotate expression
    fClass->addExecCode(subst("output[i] = $0;", CS(sig)));
    generateUserInterfaceTree(prepareUserInterfaceTree(fUIRoot));
    generateMacroInterfaceTree("", prepareUserInterfaceTree(fUIRoot));
    if (fDescription) {
        fDescription->ui(prepareUserInterfaceTree(fUIRoot));
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

string ScalarCompiler::CS ( Tree  sig) [protected, virtual]

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 231 of file compile_scal.cpp.

{
    //contextor   contextRecursivness;
    string      code;

    if (!getCompiledExpression(sig, code)) {
        // not compiled yet
/*        if (getRecursivness(sig) != contextRecursivness.get()) {
            contextRecursivness.set(getRecursivness(sig));
        }*/
        code = generateCode(sig);
        setCompiledExpression(sig, code);
    }
    return code;
}
void ScalarCompiler::ensureIotaCode ( ) [protected]

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

Definition at line 1258 of file compile_scal.cpp.

{
    if (!fHasIota) {
        fHasIota = true;
        fClass->addDeclCode("int \tIOTA;");
        fClass->addInitCode("IOTA = 0;");
        fClass->addPostCode("IOTA = IOTA+1;");
    }
}
string ScalarCompiler::generateBinOp ( Tree  sig,
int  opcode,
Tree  arg1,
Tree  arg2 
) [protected]

Definition at line 392 of file compile_scal.cpp.

References gBinOpTable, and subst().

{
    return generateCacheCode(sig, subst("($0 $1 $2)", CS(arg1), gBinOpTable[opcode]->fName, CS(arg2)));
}

Here is the call graph for this function:

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

Definition at line 521 of file compile_scal.cpp.

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

{
    string varname = getFreshID("fbutton");
    fClass->addDeclCode(subst("$1 \t$0;", varname, xfloat()));
    fClass->addInitCode(subst("$0 = 0.0;", varname));
    addUIWidget(reverse(tl(path)), uiWidget(hd(path), tree(varname), sig));
    return generateCacheCode(sig, varname);
}

Here is the call graph for this function:

string ScalarCompiler::generateCacheCode ( Tree  sig,
const string &  exp 
) [protected, virtual]

Reimplemented in VectorCompiler.

Definition at line 433 of file compile_scal.cpp.

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

{
    string      vname, ctype, code;
    int         sharing = getSharingCount(sig);
    Occurences* o = fOccMarkup.retrieve(sig);

    // check reentrance
    if (getCompiledExpression(sig, code)) {
        return code;
    }

    // check for expression occuring in delays
    if (o->getMaxDelay()>0) {

        getTypedNames(getCertifiedSigType(sig), "Vec", ctype, vname);
        if (sharing>1) {
            return generateDelayVec(sig, generateVariableStore(sig,exp), ctype, vname, o->getMaxDelay());
        } else {
            return generateDelayVec(sig, exp, ctype, vname, o->getMaxDelay());
        }

    } else if (sharing == 1) {

        return exp;

    } else if (sharing > 1) {

        return generateVariableStore(sig, exp);

    } else {
        cerr << "Error in sharing count (" << sharing << ") for " << *sig << endl;
        exit(1);
    }

    return "Error in generateCacheCode";
}

Here is the call graph for this function:

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

Definition at line 530 of file compile_scal.cpp.

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

{
    string varname = getFreshID("fcheckbox");
    fClass->addDeclCode(subst("$1 \t$0;", varname, xfloat()));
    fClass->addInitCode(subst("$0 = 0.0;", varname));
    addUIWidget(reverse(tl(path)), uiWidget(hd(path), tree(varname), sig));
    return generateCacheCode(sig, varname);
}

Here is the call graph for this function:

string ScalarCompiler::generateCode ( Tree  sig) [protected, virtual]

Main code generator dispatch.

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

Reimplemented in VectorCompiler.

Definition at line 256 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(), isSigWRTbl(), name(), print(), printSignal(), T(), and tree2str().

{
#if 0
    fprintf(stderr, "CALL generateCode(");
        printSignal(sig, stderr);
    fprintf(stderr, ")\n");
#endif

    int     i;
    double  r;
    Tree    c, sel, x, y, z, label, id, ff, largs, type, name, file;

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

         if ( getUserData(sig) )                    { return generateXtended(sig); }
    else if ( isSigInt(sig, &i) )                   { return generateNumber(sig, T(i)); }
    else if ( isSigReal(sig, &r) )                  { return generateNumber(sig, T(r)); }
    else if ( isSigInput(sig, &i) )                 { return generateInput  (sig, T(i));            }
    else if ( isSigOutput(sig, &i, x) )             { return generateOutput     (sig, T(i), CS(x));}

    else if ( isSigFixDelay(sig, x, y) )            { return generateFixDelay   (sig, x, y);            }
    else if ( isSigPrefix(sig, x, y) )              { return generatePrefix     (sig, x, y);            }
    else if ( isSigIota(sig, x) )                   { return generateIota       (sig, x);               }

    else if ( isSigBinOp(sig, &i, x, y) )           { return generateBinOp  (sig, i, x, y);         }
    else if ( isSigFFun(sig, ff, largs) )           { return generateFFun       (sig, ff, largs);       }
    else if ( isSigFConst(sig, type, name, file) )  { return generateFConst(sig, tree2str(file), tree2str(name)); }
    else if ( isSigFVar(sig, type, name, file) )    { return generateFVar(sig, tree2str(file), tree2str(name)); }

    else if ( isSigTable(sig, id, x, y) )           { return generateTable  (sig, x, y);            }
    else if ( isSigWRTbl(sig, id, x, y, z) )        { return generateWRTbl  (sig, x, y, z);         }
    else if ( isSigRDTbl(sig, x, y) )               { return generateRDTbl  (sig, x, y);            }

    else if ( isSigSelect2(sig, sel, x, y) )        { return generateSelect2    (sig, sel, x, y);       }
    else if ( isSigSelect3(sig, sel, x, y, z) )     { return generateSelect3    (sig, sel, x, y, z);    }

    else if ( isSigGen(sig, x) )                    { return generateSigGen     (sig, x);               }

    else if ( isProj(sig, &i, x) )                  { return generateRecProj    (sig, x, i);    }

    else if ( isSigIntCast(sig, x) )                { return generateIntCast   (sig, x);                }
    else if ( isSigFloatCast(sig, x) )              { return generateFloatCast (sig, x);                }

    else if ( isSigButton(sig, label) )             { return generateButton     (sig, label);           }
    else if ( isSigCheckbox(sig, label) )           { return generateCheckbox   (sig, label);           }
    else if ( isSigVSlider(sig, label,c,x,y,z) )    { return generateVSlider    (sig, label, c,x,y,z); }
    else if ( isSigHSlider(sig, label,c,x,y,z) )    { return generateHSlider    (sig, label, c,x,y,z); }
    else if ( isSigNumEntry(sig, label,c,x,y,z) )   { return generateNumEntry   (sig, label, c,x,y,z); }

    else if ( isSigVBargraph(sig, label,x,y,z) )    { return generateVBargraph  (sig, label, x, y, CS(z)); }
    else if ( isSigHBargraph(sig, label,x,y,z) )    { return generateHBargraph  (sig, label, x, y, CS(z)); }
    else if ( isSigAttach(sig, x, y) )              { CS(y); return generateCacheCode(sig, CS(x)); }

    else {
        printf("Error in compiling signal, unrecognized signal : ");
        print(sig);
        printf("\n");
        exit(1);
    }
    return "error in generate code";
}

Here is the call graph for this function:

void ScalarCompiler::generateDelayLine ( const string &  ctype,
const string &  vname,
int  mxd,
const string &  exp 
) [protected, virtual]

Generate code for the delay mecchanism without using temporary variables.

Reimplemented in VectorCompiler.

Definition at line 1211 of file compile_scal.cpp.

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

{
    //assert(mxd > 0);
    if (mxd == 0) {
        // cerr << "MXD==0 :  " << vname << " := " << exp << endl;
        // no need for a real vector
        fClass->addExecCode(subst("$0 \t$1 = $2;", ctype, vname, exp));


    } else if (mxd < gMaxCopyDelay) {
        // cerr << "small delay : " << vname << "[" << mxd << "]" << endl;

        // short delay : we copy
        fClass->addDeclCode(subst("$0 \t$1[$2];", ctype, vname, T(mxd+1)));
        fClass->addInitCode(subst("for (int i=0; i<$1; i++) $0[i] = 0;", vname, T(mxd+1)));
        fClass->addExecCode(subst("$0[0] = $1;", vname, exp));

        // generate post processing copy code to update delay values
        if (mxd == 1) {
            fClass->addPostCode(subst("$0[1] = $0[0];", vname));
        } else if (mxd == 2) {
            fClass->addPostCode(subst("$0[2] = $0[1]; $0[1] = $0[0];", vname));
        } else {
            fClass->addPostCode(subst("for (int i=$0; i>0; i--) $1[i] = $1[i-1];", T(mxd), vname));
        }

    } else {

        // generate code for a long delay : we use a ring buffer of size N = 2**x > mxd
        int     N = pow2limit(mxd+1);

        // we need a iota index
        ensureIotaCode();

        // declare and init
        fClass->addDeclCode(subst("$0 \t$1[$2];", ctype, vname, T(N)));
        fClass->addInitCode(subst("for (int i=0; i<$1; i++) $0[i] = 0;", vname, T(N)));

        // execute
        fClass->addExecCode(subst("$0[IOTA&$1] = $2;", vname, T(N-1), exp));
    }
}

Here is the call graph for this function:

string ScalarCompiler::generateDelayVec ( Tree  sig,
const string &  exp,
const string &  ctype,
const string &  vname,
int  mxd 
) [protected, virtual]

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 1149 of file compile_scal.cpp.

References getCertifiedSigType(), and kSamp.

{
    string s = generateDelayVecNoTemp(sig, exp, ctype, vname, mxd);
    if (getCertifiedSigType(sig)->variability() < kSamp) {
        return exp;
    } else {
        return s;
    }
}

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 1163 of file compile_scal.cpp.

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

{
    assert(mxd > 0);

    //bool odocc = fOccMarkup.retrieve(sig)->hasOutDelayOccurences();

    if (mxd < gMaxCopyDelay) {

        // short delay : we copy
        fClass->addDeclCode(subst("$0 \t$1[$2];", ctype, vname, T(mxd+1)));
        fClass->addInitCode(subst("for (int i=0; i<$1; i++) $0[i] = 0;", vname, T(mxd+1)));
        fClass->addExecCode(subst("$0[0] = $1;", vname, exp));

        // generate post processing copy code to update delay values
        if (mxd == 1) {
            fClass->addPostCode(subst("$0[1] = $0[0];", vname));
        } else if (mxd == 2) {
            //fClass->addPostCode(subst("$0[2] = $0[1];", vname));
            fClass->addPostCode(subst("$0[2] = $0[1]; $0[1] = $0[0];", vname));
        } else {
            fClass->addPostCode(subst("for (int i=$0; i>0; i--) $1[i] = $1[i-1];", T(mxd), vname));
        }
        setVectorNameProperty(sig, vname);
        return subst("$0[0]", vname);

    } else {

        // generate code for a long delay : we use a ring buffer of size N = 2**x > mxd
        int     N = pow2limit(mxd+1);

        // we need a iota index
        ensureIotaCode();

        // declare and init
        fClass->addDeclCode(subst("$0 \t$1[$2];", ctype, vname, T(N)));
        fClass->addInitCode(subst("for (int i=0; i<$1; i++) $0[i] = 0;", vname, T(N)));

        // execute
        fClass->addExecCode(subst("$0[IOTA&$1] = $2;", vname, T(N-1), exp));
        setVectorNameProperty(sig, vname);
        return subst("$0[IOTA&$1]", vname, T(N-1));
    }
}

Here is the call graph for this function:

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

Definition at line 342 of file compile_scal.cpp.

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

{
    string      ctype, vname;
    Occurences* o = fOccMarkup.retrieve(sig);

    addIncludeFile(file);

    if (o->getMaxDelay()>0) {
        getTypedNames(getCertifiedSigType(sig), "Vec", ctype, vname);
        generateDelayVec(sig, exp, ctype, vname, o->getMaxDelay());
    }
    return exp;
}

Here is the call graph for this function:

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

Definition at line 402 of file compile_scal.cpp.

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

{
    addIncludeFile(ffincfile(ff));  //printf("inc file %s\n", ffincfile(ff));
    addLibrary(fflibfile(ff));      //printf("lib file %s\n", fflibfile(ff));

    string code = ffname(ff);
    code += '(';
    string sep = "";
    for (int i = 0; i< ffarity(ff); i++) {
        code += sep;
        code += CS(nth(largs, i));
        sep = ", ";
    }
    code += ')';
    return generateCacheCode(sig, code);
}

Here is the call graph for this function:

string ScalarCompiler::generateFixDelay ( Tree  sig,
Tree  exp,
Tree  delay 
) [protected, virtual]

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 1106 of file compile_scal.cpp.

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

{
    int     mxd, d;
    string  vecname;

    //cerr << "ScalarCompiler::generateFixDelay sig = " << *sig << endl;
    //cerr << "ScalarCompiler::generateFixDelay exp = " << *exp << endl;
    //cerr << "ScalarCompiler::generateFixDelay del = " << *delay << endl;

    CS(exp); // ensure exp is compiled to have a vector name

    mxd = fOccMarkup.retrieve(exp)->getMaxDelay();

    if (! getVectorNameProperty(exp, vecname)) {
        cerr << "No vector name for : " << ppsig(exp) << endl;
        assert(0);
    }

    if (mxd == 0) {
        // not a real vector name but a scalar name
        return vecname;

    } else if (mxd < gMaxCopyDelay) {
        if (isSigInt(delay, &d)) {
            return subst("$0[$1]", vecname, CS(delay));
        } else {
            return generateCacheCode(sig, subst("$0[$1]", vecname, CS(delay)));
        }

    } else {

        // long delay : we use a ring buffer of size 2^x
        int     N   = pow2limit( mxd+1 );
        return generateCacheCode(sig, subst("$0[(IOTA-$1)&$2]", vecname, CS(delay), T(N-1)));
    }
}

Here is the call graph for this function:

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

Definition at line 512 of file compile_scal.cpp.

References ifloat(), and subst().

{
    return generateCacheCode(sig, subst("$1($0)", CS(x), ifloat()));
}

Here is the call graph for this function:

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

Definition at line 361 of file compile_scal.cpp.

{
    string      ctype, vname;

    addIncludeFile(file);
    return generateCacheCode(sig, exp);
}
string ScalarCompiler::generateHBargraph ( Tree  sig,
Tree  label,
Tree  min,
Tree  max,
const string &  exp 
) [protected]

Definition at line 595 of file compile_scal.cpp.

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

{
    string varname = getFreshID("fbargraph");
    fClass->addDeclCode(subst("$1 \t$0;", varname, xfloat()));
    addUIWidget(reverse(tl(path)), uiWidget(hd(path), tree(varname), sig));

    Type t = getCertifiedSigType(sig);
    switch (t->variability()) {

        case kKonst :
            fClass->addInitCode(subst("$0 = $1;", varname, exp));
            break;

        case kBlock :
            fClass->addZone2(subst("$0 = $1;", varname, exp));
            break;

        case kSamp :
            fClass->addExecCode(subst("$0 = $1;", varname, exp));
            break;
    }

    //return varname;
    return generateCacheCode(sig, varname);
}

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 549 of file compile_scal.cpp.

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

{
    string varname = getFreshID("fslider");
    fClass->addDeclCode(subst("$1 \t$0;", varname, xfloat()));
    fClass->addInitCode(subst("$0 = $1;", varname, T(tree2float(cur))));
    addUIWidget(reverse(tl(path)), uiWidget(hd(path), tree(varname), sig));
    return generateCacheCode(sig, varname);
}

Here is the call graph for this function:

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

Definition at line 374 of file compile_scal.cpp.

References icast(), and subst().

{
    return generateCacheCode(sig, subst("$1input$0[i]", idx, icast()));
}

Here is the call graph for this function:

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

Definition at line 507 of file compile_scal.cpp.

References subst().

{
    return generateCacheCode(sig, subst("int($0)", CS(x)));
}

Here is the call graph for this function:

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

Definition at line 897 of file compile_scal.cpp.

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

{
    int size;
    if (!isSigInt(n, &size)) { fprintf(stderr, "error in generateIota\n"); exit(1); }

    string vperm = getFreshID("iota");

    fClass->addDeclCode(subst("int \t$0;",  vperm));
    fClass->addInitCode(subst("$0 = 0;", vperm));

    if (isPowerOf2(size)) {
        fClass->addExecCode(subst("$0 = ($0+1)&$1;", vperm, T(size-1)));
    } else {
        fClass->addExecCode(subst("if (++$0 == $1) $0=0;", vperm, T(size)));
    }
    return vperm;
}

Here is the call graph for this function:

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

Definition at line 324 of file compile_scal.cpp.

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

{
    string      ctype, vname;
    Occurences* o = fOccMarkup.retrieve(sig);

    // check for number occuring in delays
    if (o->getMaxDelay()>0) {
        getTypedNames(getCertifiedSigType(sig), "Vec", ctype, vname);
        generateDelayVec(sig, exp, ctype, vname, o->getMaxDelay());
    }
    return exp;
}

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 558 of file compile_scal.cpp.

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

{
    string varname = getFreshID("fentry");
    fClass->addDeclCode(subst("$1 \t$0;", varname, xfloat()));
    fClass->addInitCode(subst("$0 = $1;", varname, T(tree2float(cur))));
    addUIWidget(reverse(tl(path)), uiWidget(hd(path), tree(varname), sig));
    return generateCacheCode(sig, varname);
}

Here is the call graph for this function:

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

Definition at line 380 of file compile_scal.cpp.

References subst(), and xcast().

{
    string dst = subst("output$0[i]", idx);
    fClass->addExecCode(subst("$0 = $2$1;", dst, arg, xcast()));
    return dst;
}

Here is the call graph for this function:

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

Definition at line 871 of file compile_scal.cpp.

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

{
    Type te = getCertifiedSigType(sig);//, tEnv);

    string vperm = getFreshID("M");
    string vtemp = getFreshID("T");

    string type = cType(te);

    fClass->addDeclCode(subst("$0 \t$1;", type, vperm));
    fClass->addInitCode(subst("$0 = $1;", vperm, CS(x)));

    fClass->addExecCode(subst("$0 $1 = $2;", type, vtemp, vperm));
    fClass->addExecCode(subst("$0 = $1;", vperm, CS(e)));
    return vtemp;
}

Here is the call graph for this function:

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

Definition at line 785 of file compile_scal.cpp.

References isSigTable(), and subst().

{
    // YO le 21/04/05 : La lecture des tables n'�ait pas mise dans le cache
    // et donc le code �ait dupliqu�(dans tester.dsp par exemple)
    //return subst("$0[$1]", CS(tEnv, tbl), CS(tEnv, idx));

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

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 833 of file compile_scal.cpp.

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

Referenced by VectorCompiler::generateCodeRecursions().

{
    int             N = len(le);

    vector<bool>    used(N);
    vector<int>     delay(N);
    vector<string>  vname(N);
    vector<string>  ctype(N);

    // prepare each element of a recursive definition
    for (int i=0; i<N; i++) {
        Tree    e = sigProj(i,sig);     // recreate each recursive definition
        if (fOccMarkup.retrieve(e)) {
            // this projection is used
            used[i] = true;
            getTypedNames(getCertifiedSigType(e), "Rec", ctype[i],  vname[i]);
            setVectorNameProperty(e, vname[i]);
            delay[i] = fOccMarkup.retrieve(e)->getMaxDelay();
        } else {
            // this projection is not used therefore
            // we should not generate code for it
            used[i] = false;
        }
    }

    // generate delayline for each element of a recursive definition
    for (int i=0; i<N; i++) {
        if (used[i]) {
            generateDelayLine(ctype[i], vname[i], delay[i], CS(nth(le,i)));
        }
    }
}

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 816 of file compile_scal.cpp.

References isRec().

{
    string  vname;
    Tree    var, le;

    if ( ! getVectorNameProperty(sig, vname)) {
        assert(isRec(r, var, le));
        generateRec(r, var, le);
        assert(getVectorNameProperty(sig, vname));
    }
    return "[[UNUSED EXP]]";    // make sure the resulting expression is never used in the generated code
}

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 924 of file compile_scal.cpp.

References subst().

{
    return generateCacheCode(sig, subst( "(($0)?$1:$2)", CS(sel), CS(s2), CS(s1) ) );
}

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 935 of file compile_scal.cpp.

References subst().

{
    return generateCacheCode(sig, subst( "(($0==0)? $1 : (($0==1)?$2:$3) )", CS(sel), CS(s1), CS(s2), CS(s3) ) );
}

Here is the call graph for this function:

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

Definition at line 634 of file compile_scal.cpp.

References signal2klass(), and subst().

{
    string klassname = getFreshID("SIG");
    string signame = getFreshID("sig");

    fClass->addSubKlass(signal2klass(klassname, content));
    fClass->addInitCode(subst("$0 $1;", klassname, signame));
    fInstanceInitProperty.set(content, pair<string,string>(klassname,signame));

    return signame;
}

Here is the call graph for this function:

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

Definition at line 646 of file compile_scal.cpp.

References signal2klass(), and subst().

{
    string klassname = getFreshID("SIG");
    string signame = getFreshID("sig");

    fClass->addSubKlass(signal2klass(klassname, content));
    fClass->addStaticInitCode(subst("$0 $1;", klassname, signame));
    fStaticInitProperty.set(content, pair<string,string>(klassname,signame));

    return signame;
}

Here is the call graph for this function:

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

Definition at line 713 of file compile_scal.cpp.

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

{
    //string        generator(CS(content));
    Tree        g;
    string      cexp;
    string      ctype, vname;
    int         size;

    assert ( isSigGen(content, g) );

    if (!getCompiledExpression(content, cexp)) {
        cexp = setCompiledExpression(content, generateStaticSigGen(content, g));
    } else {
        // already compiled but check if we need to add declarations
        pair<string,string> kvnames;
        if ( ! fStaticInitProperty.get(g, kvnames)) {
            // not declared here, we add a declaration
            bool b = fInstanceInitProperty.get(g, kvnames);
            assert(b);
            fClass->addStaticInitCode(subst("$0 $1;", kvnames.first, kvnames.second));
        }
    }

    if (!isSigInt(tsize, &size)) {
        //fprintf(stderr, "error in ScalarCompiler::generateTable()\n"); exit(1);
        cerr << "error in ScalarCompiler::generateTable() : "
             << *tsize
             << " is not a constant integer table size expression "
             << endl;
        exit(1);
    }
    // definition du nom et du type de la table
    // A REVOIR !!!!!!!!!
    Type t = getCertifiedSigType(content);//, tEnv);
    if (t->nature() == kInt) {
        vname = getFreshID("itbl");
        ctype = "int";
    } else {
        vname = getFreshID("ftbl");
        ctype = ifloat();
    }

    // declaration de la table
    fClass->addDeclCode(subst("static $0 \t$1[$2];", ctype, vname, T(size)));
    fClass->addStaticFields(subst("$0 \t$1::$2[$3];", ctype, fClass->getClassName(), vname, T(size) ));

    // initialisation du generateur de contenu
    fClass->addStaticInitCode(subst("$0.init(samplingFreq);", cexp));
    // remplissage de la table
    fClass->addStaticInitCode(subst("$0.fill($1,$2);", cexp, T(size), vname));

    // on retourne le nom de la table
    return vname;
}

Here is the call graph for this function:

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

Definition at line 663 of file compile_scal.cpp.

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

{
    string      generator(CS(content));
    Tree        g;
    string      cexp;
    string      ctype, vname;
    int         size;

    // already compiled but check if we need to add declarations

    assert ( isSigGen(content, g) );
    pair<string,string> kvnames;
    if ( ! fInstanceInitProperty.get(g, kvnames)) {
        // not declared here, we add a declaration
        bool b = fStaticInitProperty.get(g, kvnames);
        assert(b);
        fClass->addInitCode(subst("$0 $1;", kvnames.first, kvnames.second));
    }

    if (!isSigInt(tsize, &size)) {
        //fprintf(stderr, "error in ScalarCompiler::generateTable()\n"); exit(1);
        cerr << "error in ScalarCompiler::generateTable() : "
             << *tsize
             << " is not a constant integer table size expression "
             << endl;
        exit(1);
    }
    // definition du nom et du type de la table
    // A REVOIR !!!!!!!!!
    Type t = getCertifiedSigType(content);//, tEnv);
    if (t->nature() == kInt) {
        vname = getFreshID("itbl");
        ctype = "int";
    } else {
        vname = getFreshID("ftbl");
        ctype = ifloat();
    }

    // declaration de la table
    fClass->addDeclCode(subst("$0 \t$1[$2];", ctype, vname, T(size)));

    // initialisation du generateur de contenu
    fClass->addInitCode(subst("$0.init(samplingFreq);", generator));
    // remplissage de la table
    fClass->addInitCode(subst("$0.fill($1,$2);", generator, T(size), vname));

    // on retourne le nom de la table
    return vname;
}

Here is the call graph for this function:

string ScalarCompiler::generateVariableStore ( Tree  sig,
const string &  exp 
) [protected, virtual]

Reimplemented in VectorCompiler.

Definition at line 471 of file compile_scal.cpp.

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

{
    string      vname, ctype;
    Type        t = getCertifiedSigType(sig);

    switch (t->variability()) {

        case kKonst :

            getTypedNames(t, "Const", ctype, vname);
            fClass->addDeclCode(subst("$0 \t$1;", ctype, vname));
            fClass->addInitCode(subst("$0 = $1;", vname, exp));
            break;

        case kBlock :

            getTypedNames(t, "Slow", ctype, vname);
            fClass->addFirstPrivateDecl(vname);
            fClass->addZone2(subst("$0 \t$1 = $2;", ctype, vname, exp));
            break;

        case kSamp :

            getTypedNames(t, "Temp", ctype, vname);
            fClass->addExecCode(subst("$0 $1 = $2;", ctype, vname, exp));
            break;
    }
    return vname;
}

Here is the call graph for this function:

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

Definition at line 568 of file compile_scal.cpp.

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

{
    string varname = getFreshID("fbargraph");
    fClass->addDeclCode(subst("$1 \t$0;", varname, xfloat()));
    addUIWidget(reverse(tl(path)), uiWidget(hd(path), tree(varname), sig));

    Type t = getCertifiedSigType(sig);
    switch (t->variability()) {

        case kKonst :
            fClass->addInitCode(subst("$0 = $1;", varname, exp));
            break;

        case kBlock :
            fClass->addZone2(subst("$0 = $1;", varname, exp));
            break;

        case kSamp :
            fClass->addExecCode(subst("$0 = $1;", varname, exp));
            break;
    }

    //return varname;
    return generateCacheCode(sig, varname);
}

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 540 of file compile_scal.cpp.

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

{
    string varname = getFreshID("fslider");
    fClass->addDeclCode(subst("$1 \t$0;", varname, xfloat()));
    fClass->addInitCode(subst("$0 = $1;", varname, T(tree2float(cur))));
    addUIWidget(reverse(tl(path)), uiWidget(hd(path), tree(varname), sig));
    return generateCacheCode(sig, varname);
}

Here is the call graph for this function:

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

Definition at line 773 of file compile_scal.cpp.

References subst().

{
    string tblName(CS(tbl));
    fClass->addExecCode(subst("$0[$1] = $2;", tblName, CS(idx), CS(data)));
    return tblName;
}

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 1015 of file compile_scal.cpp.

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

{
    xtended*        p = (xtended*) getUserData(sig);
    vector<string>  args;
    vector<Type>    types;

    for (int i=0; i<sig->arity(); i++) {
        args.push_back(CS(sig->branch(i)));
        types.push_back(getCertifiedSigType(sig->branch(i)));
    }

    if (p->needCache()) {
        return generateCacheCode(sig, p->generateCode(fClass, args, types));
    } else {
        return p->generateCode(fClass, args, types);
    }
}

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 204 of file compile_scal.cpp.

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

{
    return fCompileProperty.get(sig, cexp);
}

Here is the caller graph for this function:

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

Definition at line 87 of file compile_scal.cpp.

References subst(), and T().

{
    if (fIDCounters.find(prefix) == fIDCounters.end()) {
        fIDCounters[prefix]=0;
    }
    int n = fIDCounters[prefix];
    fIDCounters[prefix] = n+1;
    return subst("$0$1", prefix, T(n));
}

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

{
    //cerr << "getSharingCount of : " << *sig << " = ";
    Tree c;
    if (getProperty(sig, fSharingKey, c)) {
        //cerr << c->node().getInt() << endl;
        return c->node().getInt();
    } else {
        //cerr << 0 << endl;
        return 0;
    }
}

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 424 of file compile_scal.cpp.

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

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

{
    if (t->nature() == kInt) {
        ctype = "int"; vname = subst("i$0", getFreshID(prefix));
    } else {
        ctype = ifloat(); vname = subst("f$0", getFreshID(prefix));
    }
}

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 1063 of file compile_scal.cpp.

Referenced by VectorCompiler::generateFixDelay().

{
    return fVectorProperty.get(sig, vecname);
}

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 1073 of file compile_scal.cpp.

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

{
    int n = 2;
    while (n < x) { n = 2*n; }
    return n;
}

Here is the caller graph for this function:

Tree ScalarCompiler::prepare ( Tree  L0) [protected, virtual]

Implements Compiler.

Definition at line 104 of file compile_scal.cpp.

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

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

{
startTiming("ScalarCompiler::prepare");
 startTiming("deBruijn2Sym");
    Tree L1 = deBruijn2Sym(LS);     // convert debruijn recursion into symbolic recursion
 endTiming("deBruijn2Sym");
    Tree L2 = simplify(L1);         // simplify by executing every computable operation
    Tree L3 = privatise(L2);        // Un-share tables with multiple writers

    // dump normal form
    if (gDumpNorm) {
        cout << ppsig(L3) << endl;
        exit(0);
    }

    recursivnessAnnotation(L3);     // Annotate L3 with recursivness information

    startTiming("typeAnnotation");
        typeAnnotation(L3);             // Annotate L3 with type information
    endTiming("typeAnnotation");

    sharingAnalysis(L3);            // annotate L3 with sharing count
    fOccMarkup.mark(L3);            // annotate L3 with occurences analysis
    //annotationStatistics();
endTiming("ScalarCompiler::prepare");

    if (gDrawSignals) {
        ofstream dotfile(subst("$0-sig.dot", gMasterDocument).c_str());
        sigToGraph(L3, dotfile);
    }
    return L3;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Tree ScalarCompiler::prepare2 ( Tree  L0) [protected, virtual]

Implements Compiler.

Definition at line 137 of file compile_scal.cpp.

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

{
startTiming("ScalarCompiler::prepare2");
    recursivnessAnnotation(L0);     // Annotate L0 with recursivness information
    typeAnnotation(L0);             // Annotate L0 with type information
    sharingAnalysis(L0);            // annotate L0 with sharing count
    fOccMarkup.mark(L0);            // annotate L0 with occurences analysis
endTiming("ScalarCompiler::prepare2");

    return L0;
}

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 215 of file compile_scal.cpp.

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

{
    //cerr << "ScalarCompiler::setCompiledExpression : " << cexp << " ==> " << ppsig(sig) << endl;
    string old; if (fCompileProperty.get(sig, old) && (old != cexp)) {
        cerr << "ERROR already a compiled expression attached : " << old << " replaced by " << cexp << endl;
        exit(1);
    }
    fCompileProperty.set(sig, cexp);
    return cexp;
}

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

{
    //cerr << "setSharingCount of : " << *sig << " <- " << count << endl;
    setProperty(sig, fSharingKey, tree(count));
}

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 1049 of file compile_scal.cpp.

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

{
        fVectorProperty.set(sig, vecname);
}

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

{
    fSharingKey = shprkey(t);
    if (isList(t)) {
        while (isList(t)) {
            sharingAnnotation(kSamp, hd(t));
            t = tl(t);
        }
    } else {
        sharingAnnotation(kSamp, t);
    }
}

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

{
    Tree    c, x, y, z;

    //cerr << "START sharing annotation of " << *sig << endl;
    int count = getSharingCount(sig);

    if (count > 0) {
        // it is not our first visit
        setSharingCount(sig, count+1);

    } else {
        // it is our first visit,
        int v = getCertifiedSigType(sig)->variability();

        // check "time sharing" cases
        if (v < vctxt) {
            setSharingCount(sig, 2);    // time sharing occurence : slower expression in faster context
        } else {
            setSharingCount(sig, 1);    // regular occurence
        }

        if (isSigSelect3(sig,c,y,x,z)) {
            // make a special case for select3 implemented with real if
            // because the c expression will be used twice in the C++
            // translation
            sharingAnnotation(v, c);
            sharingAnnotation(v, c);
            sharingAnnotation(v, x);
            sharingAnnotation(v, y);
            sharingAnnotation(v, z);
        } else {
            // Annotate the sub signals
            vector<Tree> subsig;
            int n = getSubSignals(sig, subsig);
            if (n>0 && ! isSigGen(sig)) {
                for (int i=0; i<n; i++) sharingAnnotation(v, subsig[i]);
            }
        }
    }
    //cerr << "END sharing annotation of " << *sig << endl;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

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 [static, protected]

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.

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.

Definition at line 44 of file compile_scal.hh.


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