|
FAUST compiler
0.9.9.6b8
|
The sharing analysis of tree t is the annotation of all its subtrees t' with their number of occurences in t. More...
#include <string.h>#include <stdlib.h>#include <stdio.h>#include "shlysis.hh"#include "compatibility.hh"
Go to the source code of this file.
Functions | |
| Tree | shprkey (Tree t) |
| Create a specific property key for the sharing count of subtrees of t. | |
| int | shcount (Tree key, Tree t) |
| Return the value of sharing count or 0. | |
| static void | annotate (Tree k, Tree t, barrier foo) |
| Recursively increment the occurences count of t and its subtrees. | |
| static bool | nobarrier (const Tree &t) |
| Tree | shlysis (Tree t, barrier foo) |
| Do a sharing analysis : annotates all the subtrees of t with there occurences. | |
| Tree | shlysis (Tree t) |
| Do a sharing analysis : annotates all the subtrees of t with there occurences. | |
The sharing analysis of tree t is the annotation of all its subtrees t' with their number of occurences in t.
As this annotation of t' depends of a context (the tree t for which t' is a subtree) a specific property key unique to each sharing analysis must be generated.
Definition in file shlysis.cpp.
Recursively increment the occurences count of t and its subtrees.
Definition at line 129 of file shlysis.cpp.
References CTree::arity(), CTree::branch(), isRec(), setProperty(), shcount(), and tree().
Referenced by shlysis().
{
cerr << "Annotate " << *t << endl;
int c = shcount(k,t);
if (c==0) {
// First visit
Tree var, body;
if (isRec(t, var, body)) {
// special case for recursive trees
setProperty(t, k, tree(1));
annotate(k, body, foo);
return;
} else {
int n = t->arity();
if (n>0 && ! foo(t)) {
for (int i=0; i<n; i++) annotate(k, t->branch(i), foo);
}
}
} else {
//printf(" annotate %p with %d\n", (CTree*)t, c+1);
}
setProperty(t, k, tree(c+1));
}


Definition at line 99 of file shlysis.cpp.
Referenced by shlysis().
{ return false; }

Return the value of sharing count or 0.
Definition at line 81 of file shlysis.cpp.
References Node::getInt(), getProperty(), and CTree::node().
Referenced by annotate().
{
Tree c;
if (getProperty(t, key, c)) {
return c->node().getInt();
} else {
return 0;
}
}


Do a sharing analysis : annotates all the subtrees of t with there occurences.
Definition at line 105 of file shlysis.cpp.
References annotate(), and shprkey().

Do a sharing analysis : annotates all the subtrees of t with there occurences.
Definition at line 117 of file shlysis.cpp.
References annotate(), nobarrier(), and shprkey().

Create a specific property key for the sharing count of subtrees of t.
Definition at line 69 of file shlysis.cpp.
References name(), tree(), and unique().
Referenced by ScalarCompiler::sharingAnalysis(), DocCompiler::sharingAnalysis(), and shlysis().


1.8.0