public class RangeDomain extends java.lang.Object implements java.lang.Cloneable, Domain
e
and e+1
.
The result of expression comparison is recorded in a Relation
object
and the relation provides check methods that return the relationship encoded
in the object.
Following example shows the usage of range domain when comparing two
expressions.
Suppose the range domain rd
was computed with range analysis
and rd
contains the specified value ranges.
Map<Statement, RangeDomain> range_map = RangeAnalysis.getRanges(proc); RangeDomain rd = range_map.get(stmt); // rd = { i=[1:10], j=[i:20] } Relation rel = rd.compare(i, j); // rel.isLE() will return true since i<=j<=20. // rel.isGT() will return false since i<=j<=20.
Constructor and Description |
---|
RangeDomain()
Constructs an empty range domain.
|
RangeDomain(RangeDomain other)
Constructs a new range domain with the given range domain
other . |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Cleans up the fields of RangeDomain.
|
RangeDomain |
clone()
Returns a clone of the range domain.
|
Relation |
compare(Expression e1,
Expression e2)
Returns the relation between the two expressions under the constraints
implied by the set of value ranges in the RangeDomain object.
|
static Relation |
compare(Expression e1,
RangeDomain rd1,
Expression e2,
RangeDomain rd2)
Compares two expressions symbolically with the given range domain
|
Domain |
diffStrong(Domain other)
Returns the result of strong difference.
|
Domain |
diffWeak(Domain other)
Returns the result of weak difference.
|
boolean |
encloses(Expression e1,
Expression e2) |
boolean |
equals(Domain other)
Pairwise comparison between two RangeDomain objects.
|
boolean |
equals(RangeDomain other) |
int |
evaluateLogic(Expression e)
Evaluates the given logical expression using the constraints.
|
Expression |
expandSymbol(Expression e,
Symbol var)
Eliminates all occurrences of the specified variable from the expression
by replacing them with their value ranges.
|
Expression |
expandSymbols(Expression e,
java.util.Set<Symbol> vars)
Eliminates all occurrences of the specified variables from the expression
by replacing them with their value ranges.
|
Expression |
getRange(Symbol var)
Returns the value range for the specified variable.
|
java.util.Set<Symbol> |
getSymbols()
Returns the set of variables whose value ranges are present.
|
Domain |
intersect(Domain other)
Returns intersection of the two domains.
|
static Expression |
intersectRanges(Expression e1,
RangeDomain rd1,
Expression e2,
RangeDomain rd2)
Computes the intersection of the two expressions with the given range
domains.
|
void |
intersectRanges(RangeDomain other)
Intersects two sets of value ranges using current range domain.
|
boolean |
isEmptyRange(Expression e) |
boolean |
isEQ(Expression e1,
Expression e2) |
boolean |
isGE(Expression e1,
Expression e2) |
boolean |
isGT(Expression e1,
Expression e2) |
boolean |
isLE(Expression e1,
Expression e2) |
boolean |
isLT(Expression e1,
Expression e2) |
void |
kill(java.util.Set<Symbol> vars)
Kills the data containing the specified set of symbols.
|
void |
killGlobal()
Kills any ranges containing global variables.
|
void |
killGlobalAnd(java.util.Set<Symbol> and)
Kills any ranges containing global variables and the specified set of
variables.
|
void |
killLocal()
Kill any var:range mappings containing local variables.
|
void |
killLocalExcept(java.util.Set<Symbol> except)
Kills any ranges containing local variables except for the specified set
of variables.
|
void |
killOrphan()
Kills any ranges containing variables from which Program node is not
accessible.
|
Domain |
merge(Domain other)
Returns merge of the two domains (join operation).
|
void |
narrowRanges(RangeDomain other)
Narrows all value ranges of "other" range domain with this range domain.
|
void |
removeRange(Symbol var)
Removes the value range for the specified variable.
|
void |
removeRangeWith(java.util.Set<Symbol> vars)
Removes value ranges containing the specified set of symbols.
|
void |
removeRangeWith(Symbol var)
Removes value ranges containing the specified variable including the range
of the variable.
|
void |
removeSymbols(java.util.Set<Symbol> vars)
Removes the ranges for the speicfied variables in the map by replacing
them with their value ranges.
|
Expression |
replaceSymbol(Expression e,
Symbol var,
Expression with)
Replace all occurrences of the specified variable in the given expression
with the new expression.
|
void |
replaceSymbol(Symbol var,
Expression with)
Replaces all occurrences of the specified variable in the map with the
given expression.
|
void |
setRange(Symbol var,
Expression value)
Updates the value range for the specified variable.
|
int |
size()
Returns the number of value ranges in the map.
|
void |
substituteForward()
Applies
substituteForward(Expression) to the range expressions
kept in the range domain. |
Expression |
substituteForward(Expression e)
Substitute all occurrences of the symbols that appear in the expression.
|
Expression |
substituteForward(Expression e,
java.util.Set<Symbol> vars)
Substitute all occrrences of the given set of symbols in the expression.
|
Expression |
substituteForward(Expression e,
Symbol var)
Substitute all occurrences of the given symbol in the expression with its
symbolic values.
|
void |
substituteForwardRange()
Applies
getForwardRange(Symbol) to the range expressions
kept in the range domain. |
Expression |
substituteForwardRange(Expression e)
Replaces variables within the given expression with their value ranges
from the existing range domain.
|
RangeDomain |
substituteForwardRange(RangeDomain rd)
Performs
substituteForwardRange(Expression) on the value ranges
within the given range domain. |
Expression |
toExpression()
Converts this range domain to an equivalent logical expression.
|
java.lang.String |
toString()
Returns string for this range domain.
|
Domain |
union(Domain other)
Returns union of the two domains if applicable.
|
static Expression |
unionRanges(Expression e1,
RangeDomain rd1,
Expression e2,
RangeDomain rd2)
Computes the union of the two expressions with the given range domains.
|
void |
unionRanges(RangeDomain other)
Merges two sets of value ranges using current range domain (union
operation).
|
void |
widenAffectedRanges(RangeDomain other,
java.util.Set<Symbol> vars)
Widens subset of value ranges in "other" that contains the specified
symbols either in keys or in value ranges.
|
void |
widenRanges(RangeDomain other)
Widens all value ranges of "other" range domain with this range domain.
|
public RangeDomain()
public RangeDomain(RangeDomain other)
other
.
Unlike clone()
, this constructor reuses the expression contained
in other
.other
- the original range domainpublic RangeDomain clone()
public void clear()
public int size()
public void setRange(Symbol var, Expression value)
var
- the variable whose value range is updated.value
- the new value range of the variable.public Expression getRange(Symbol var)
var
- the variable whose value range is asked for.public void removeRange(Symbol var)
var
- the variable whose value range is being removed.public void removeRangeWith(Symbol var)
var
- the variable whose containers are removed.public void removeRangeWith(java.util.Set<Symbol> vars)
vars
- the variables whose containers are removed.public java.util.Set<Symbol> getSymbols()
public java.lang.String toString()
toString
in class java.lang.Object
public Expression toExpression()
a=[-INF,b]
becomes a<=b
.public boolean isGT(Expression e1, Expression e2)
public boolean isGE(Expression e1, Expression e2)
public boolean isLT(Expression e1, Expression e2)
public boolean isLE(Expression e1, Expression e2)
public boolean isEQ(Expression e1, Expression e2)
public Relation compare(Expression e1, Expression e2)
e1
- the first expression being comparede2
- the second expression being comparedRelation
that stores the result of comparisonpublic static Relation compare(Expression e1, RangeDomain rd1, Expression e2, RangeDomain rd2)
e1
- first expressionrd1
- first range domaine2
- second expressionrd2
- second range domainRelation
of the two expressionspublic int evaluateLogic(Expression e)
e
- the logical expression.public Expression substituteForward(Expression e, Symbol var)
e
- the expression to be substituted.var
- the symbol to be replaced.public Expression substituteForward(Expression e, java.util.Set<Symbol> vars)
e
- the expression to be substituted.vars
- the set of symbols to be replaced.public Expression substituteForward(Expression e)
e
- the expression to be substituted.public void substituteForward()
substituteForward(Expression)
to the range expressions
kept in the range domain.public void substituteForwardRange()
getForwardRange(Symbol)
to the range expressions
kept in the range domain.public Expression substituteForwardRange(Expression e)
e
- the expression to be manipulated.public RangeDomain substituteForwardRange(RangeDomain rd)
substituteForwardRange(Expression)
on the value ranges
within the given range domain.rd
- the range domain to be manipulated.public void removeSymbols(java.util.Set<Symbol> vars)
vars
- the set of variables being removedpublic void replaceSymbol(Symbol var, Expression with)
var
- the variable being replacedwith
- the expression being replaced withpublic Expression replaceSymbol(Expression e, Symbol var, Expression with)
e
- the expression being modifiedvar
- the variable being replacedwith
- the new expression being replaced withpublic Expression expandSymbols(Expression e, java.util.Set<Symbol> vars)
e
- the expression to be modified.vars
- the set of symbols to be replaced by their ranges.public Expression expandSymbol(Expression e, Symbol var)
e
- the expression to be modified.var
- the symbol to be replaced by its range.public void intersectRanges(RangeDomain other)
other
- the range domain intersected withpublic void unionRanges(RangeDomain other)
other
- the range domain merged withpublic void widenRanges(RangeDomain other)
other
- value ranges being widenedpublic void widenAffectedRanges(RangeDomain other, java.util.Set<Symbol> vars)
other
- the range domain containing widening operandsvars
- set of symbols that trigger wideningpublic void narrowRanges(RangeDomain other)
other
- value ranges being narrowed.public static Expression intersectRanges(Expression e1, RangeDomain rd1, Expression e2, RangeDomain rd2)
e1
- first expressionrd1
- first range domaine2
- second expressionrd2
- second range domainpublic static Expression unionRanges(Expression e1, RangeDomain rd1, Expression e2, RangeDomain rd2)
e1
- first expressionrd1
- first range domaine2
- second expressionrd2
- second range domainpublic boolean isEmptyRange(Expression e)
public boolean encloses(Expression e1, Expression e2)
public Domain union(Domain other)
Domain
public Domain merge(Domain other)
Domain
public Domain intersect(Domain other)
Domain
public Domain diffStrong(Domain other)
Domain
diffStrong
in interface Domain
other
- the domain to be subtracted.public Domain diffWeak(Domain other)
Domain
public void kill(java.util.Set<Symbol> vars)
Domain
public boolean equals(RangeDomain other)
public boolean equals(Domain other)
public void killLocal()
public void killLocalExcept(java.util.Set<Symbol> except)
except
- the set of variables not considered for kill.public void killGlobal()
public void killGlobalAnd(java.util.Set<Symbol> and)
and
- the additional variables to be considered for kill.public void killOrphan()