Skip to content

Commit

Permalink
Occurrences: don't always expand variability
Browse files Browse the repository at this point in the history
don't take variablity into consideration for hasMultiOccurrences
if it happens in the second arm of a attachment binop
  • Loading branch information
crop2000 committed Dec 15, 2024
1 parent 443fbeb commit b57237a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
18 changes: 13 additions & 5 deletions compiler/generator/occurrences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,16 @@ Occurrences::Occurrences(int v, int r, Tree xc) : fXVariability(xVariability(v,
fExecCondition = xc;
}

Occurrences* Occurrences::incOccurrences(int v, int r, int d, Tree xc)
Occurrences* Occurrences::incOccurrences(int v, int r, int d, Tree xc, bool is_not_attached)
{
int ctxt = xVariability(v, r);
// assert (ctxt >= fXVariability);
fOccurrences[ctxt] += 1;
fMultiOcc = fMultiOcc | (ctxt > fXVariability) | (fOccurrences[ctxt] > 1);
if (is_not_attached){
fMultiOcc = fMultiOcc | (fOccurrences[ctxt] > 1);
} else {
fMultiOcc = fMultiOcc | (ctxt > fXVariability) | (fOccurrences[ctxt] > 1);
}
if (d == 0) {
// cerr << "Occurence outside a delay " << endl;
fOutDelayOcc = true;
Expand Down Expand Up @@ -156,7 +160,7 @@ Occurrences* OccMarkup::retrieve(Tree t)
// xc : exec condition expression
//------------------------------------------------------------------------------

void OccMarkup::incOcc(Tree env, int v, int r, int d, Tree xc, Tree t)
void OccMarkup::incOcc(Tree env, int v, int r, int d, Tree xc, Tree t, bool is_not_attached)
{
// Check if we have already visited this tree
Occurrences* occ = getOcc(t);
Expand Down Expand Up @@ -187,13 +191,17 @@ void OccMarkup::incOcc(Tree env, int v, int r, int d, Tree xc, Tree t)
int n = getSubSignals(t, br);
if (n > 0 && !isSigGen(t)) {
for (int i = 0; i < n; i++) {
incOcc(env, v0, r0, 0, c0, br[i]);
if (t->node() == gGlobal->SIGATTACH && i==1){//count second not attached arm differently
incOcc(env, v0, r0, 0, c0, br[i], true);
} else {
incOcc(env, v0, r0, 0, c0, br[i], is_not_attached);
}
}
}
}
}

occ->incOccurrences(v, r, d, xc);
occ->incOccurrences(v, r, d, xc, is_not_attached);

if (!firstVisit) {
// Special case for -1*y. Because the sharing of -1*y will be ignored
Expand Down
4 changes: 2 additions & 2 deletions compiler/generator/occurrences.hh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Occurrences : public virtual Garbageable {
public:
Occurrences(int v, int r, Tree xc);
Occurrences* incOccurrences(int v, int r, int d,
Tree xc); ///< inc occurrences in context v,r,d,xc
Tree xc, bool is_not_attached = false); ///< inc occurrences in context v,r,d,xc

bool hasMultiOccurrences() const; ///< true if multiple occurrences or occ. in higher ctxt
bool hasOutDelayOccurrences() const; ///< true if has occurrences outside a a delay
Expand All @@ -62,7 +62,7 @@ class OccMarkup : public virtual Garbageable {
std::map<Tree, Tree> fConditions; ///< condition associated to each tree

void incOcc(Tree env, int v, int r, int d, Tree xc,
Tree t); ///< inc the occurrence of t in context v,r
Tree t, bool is_not_attached = false); ///< inc the occurrence of t in context v,r
Occurrences* getOcc(Tree t); ///< get Occurrences property of t or null
void setOcc(Tree t, Occurrences* occ); ///< set Occurrences property of t

Expand Down

0 comments on commit b57237a

Please sign in to comment.