-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Introduce CounterExpressionBuilder::subst(C, Map) #112698
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
618e639
209ea4c
f0afd04
631bc35
ed700c2
28c568a
d92a9d9
b548e71
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -135,6 +135,38 @@ Counter CounterExpressionBuilder::subtract(Counter LHS, Counter RHS, | |
return Simplify ? simplify(Cnt) : Cnt; | ||
} | ||
|
||
Counter CounterExpressionBuilder::replace(Counter C, const ReplaceMap &Map) { | ||
ornata marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
auto I = Map.find(C); | ||
|
||
// Replace C with the Map even if C is Expression. | ||
|
||
if (I != Map.end()) | ||
return I->second; | ||
|
||
// Traverse only Expression. | ||
|
||
if (!C.isExpression()) | ||
ornata marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return C; | ||
|
||
auto CE = Expressions[C.getExpressionID()]; | ||
auto NewLHS = replace(CE.LHS, Map); | ||
|
||
auto NewRHS = replace(CE.RHS, Map); | ||
|
||
// Reconstruct Expression with induced subexpressions. | ||
switch (CE.Kind) { | ||
ornata marked this conversation as resolved.
Show resolved
Hide resolved
|
||
case CounterExpression::Add: | ||
C = add(NewLHS, NewRHS); | ||
break; | ||
case CounterExpression::Subtract: | ||
C = subtract(NewLHS, NewRHS); | ||
break; | ||
} | ||
|
||
// Reconfirm if the reconstructed expression would hit the Map. | ||
if ((I = Map.find(C)) != Map.end()) | ||
return I->second; | ||
|
||
return C; | ||
} | ||
|
||
void CounterMappingContext::dump(const Counter &C, raw_ostream &OS) const { | ||
switch (C.getKind()) { | ||
case Counter::Zero: | ||
|
Uh oh!
There was an error while loading. Please reload this page.