OccMarkup Class Reference

Occurences Markup of a root tree. More...

#include <occurences.hh>

Collaboration diagram for OccMarkup:
[legend]

List of all members.

Public Member Functions

void mark (Tree root)
 start markup of root tree with new unique key
Occurencesretrieve (Tree t)
 occurences of subtree t within root tree

Private Member Functions

void incOcc (Tree env, int v, int r, int d, Tree t)
 inc the occurence of t in context v,r
OccurencesgetOcc (Tree t)
 get Occurences property of t or null
void setOcc (Tree t, Occurences *occ)
 set Occurences property of t

Private Attributes

Tree fRootTree
 occurences computed within this tree
Tree fPropKey
 key used to store occurences property

Detailed Description

Occurences Markup of a root tree.

First create an OccMarkup om, second om.mark(root) then om.retrieve(subtree)

Definition at line 30 of file occurences.hh.


Member Function Documentation

Occurences * OccMarkup::getOcc ( Tree  t  )  [private]

get Occurences property of t or null

Definition at line 144 of file occurences.cpp.

References fPropKey, CTree::getProperty(), and tree2ptr().

Referenced by incOcc(), and retrieve().

00145 {
00146     Tree p = t->getProperty(fPropKey);
00147     if (p) {
00148         return (Occurences*) tree2ptr(p);
00149     } else {
00150         return 0;
00151     }
00152 }

Here is the call graph for this function:

Here is the caller graph for this function:

void OccMarkup::incOcc ( Tree  env,
int  v,
int  r,
int  d,
Tree  t 
) [private]

inc the occurence of t in context v,r

Definition at line 95 of file occurences.cpp.

References checkDelayInterval(), getOcc(), getRecursivness(), getSigType(), getSubSignals(), Occurences::incOccurences(), isSigFixDelay(), isSigGen(), isSigPrefix(), isSigSelect3(), and setOcc().

Referenced by mark().

00096 {
00097     // Check if we have already visited this tree
00098     Occurences* occ = getOcc(t);
00099 
00100     if (occ==0) {
00101         // 1) We build initial occurence information
00102         Type    ty = getSigType(t);
00103         int v0 = ty->variability();
00104         int r0 = getRecursivness(t);
00105 
00106         occ = new Occurences(v0,r0);
00107         setOcc(t, occ);
00108 
00109         // We mark the subtrees of t
00110         Tree c, x, y, z;
00111         if (isSigFixDelay(t,x,y)) {
00112             Type g2 = getSigType(y);
00113             int d2 = checkDelayInterval(g2);
00114             assert(d2>=0);
00115             incOcc(env, v0, r0, d2, x);
00116             incOcc(env, v0, r0, 0, y);
00117         } else if (isSigPrefix(t,y,x)) {
00118             incOcc(env, v0, r0, 1, x);
00119             incOcc(env, v0, r0, 0, y);
00120         } else if (isSigSelect3(t,c,y,x,z)) {
00121             // make a special case for select3 implemented with real if
00122             // because the c expression will be used twice in the C++
00123             // translation
00124             incOcc(env, v0, r0, 0, c);
00125             incOcc(env, v0, r0, 0, c);
00126             incOcc(env, v0, r0, 0, x);
00127             incOcc(env, v0, r0, 0, y);
00128             incOcc(env, v0, r0, 0, z);
00129         } else {
00130             vector<Tree> br;
00131             int n = getSubSignals(t, br);
00132             if (n>0 && ! isSigGen(t)) {
00133                 for (int i=0; i<n; i++) incOcc(env, v0, r0, 0, br[i]);
00134             }
00135         }
00136     }
00137 
00138     occ->incOccurences(v,r,d);
00139 
00140 }

Here is the call graph for this function:

Here is the caller graph for this function:

void OccMarkup::mark ( Tree  root  ) 

start markup of root tree with new unique key

Definition at line 63 of file occurences.cpp.

References fPropKey, fRootTree, hd(), incOcc(), isList(), kSamp, nil, tl(), tree(), and unique().

Referenced by DocCompiler::annotate(), ScalarCompiler::prepare(), and ScalarCompiler::prepare2().

00064 {
00065     fRootTree = root;
00066     fPropKey = tree(unique("OCCURENCES"));
00067 
00068     if (isList(root)) {
00069         while (isList(root)) {
00070             //incOcc(kSamp, 1, hd(root));
00071             incOcc(nil, kSamp, 0, 0, hd(root));
00072             root = tl(root);
00073         }
00074         //cerr << "END OF LIST IS " << *root << endl;
00075     } else {
00076         //incOcc(kSamp, 1, root);
00077         incOcc(nil, kSamp, 0, 0, root);
00078     }
00079 }

Here is the call graph for this function:

Here is the caller graph for this function:

Occurences * OccMarkup::retrieve ( Tree  t  ) 

occurences of subtree t within root tree

Definition at line 81 of file occurences.cpp.

References getOcc().

Referenced by DocCompiler::generateCacheCode(), VectorCompiler::generateCacheCode(), ScalarCompiler::generateCacheCode(), DocCompiler::generateFConst(), ScalarCompiler::generateFConst(), VectorCompiler::generateFixDelay(), ScalarCompiler::generateFixDelay(), DocCompiler::generateFVar(), DocCompiler::generateNumber(), ScalarCompiler::generateNumber(), DocCompiler::generateRec(), ScalarCompiler::generateRec(), and VectorCompiler::needSeparateLoop().

00082 {
00083     Occurences* p = getOcc(t);
00084     if (p == 0) {
00085         //cerr << "No Occurences info attached to : " << *t << endl;
00086         //exit(1);
00087     }
00088     return p;
00089 }

Here is the call graph for this function:

Here is the caller graph for this function:

void OccMarkup::setOcc ( Tree  t,
Occurences occ 
) [private]

set Occurences property of t

Definition at line 155 of file occurences.cpp.

References fPropKey, CTree::setProperty(), and tree().

Referenced by incOcc().

00156 {
00157     t->setProperty(fPropKey, tree(occ));
00158 }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

key used to store occurences property

Definition at line 33 of file occurences.hh.

Referenced by getOcc(), mark(), and setOcc().

occurences computed within this tree

Definition at line 32 of file occurences.hh.

Referenced by mark().


The documentation for this class was generated from the following files:
Generated on Thu Jul 15 16:15:59 2010 for FAUST compiler by  doxygen 1.6.3