E
- An enum that describes the flags that can be associated with a block.C
- An arbitrary cost type that is associated with a block. It is intended to carry
information needed to calculate the solution. Note that C
should not contain
boolean flags. Use an enum entry in E
instead.public abstract class DominatorOptimizationProblem<E extends Enum<E>,C> extends Object
Modifier and Type | Field and Description |
---|---|
private List<? extends AbstractBlockBase<?>> |
blocks |
private BlockMap<C> |
costs |
private EnumMap<E,BitSet> |
flags |
Modifier | Constructor and Description |
---|---|
protected |
DominatorOptimizationProblem(Class<E> flagType,
AbstractControlFlowGraph<?> cfg) |
Modifier and Type | Method and Description |
---|---|
boolean |
get(E flag,
AbstractBlockBase<?> block)
Checks whether a flag is set for a block.
|
AbstractBlockBase<?> |
getBlockForId(int id) |
List<? extends AbstractBlockBase<?>> |
getBlocks() |
C |
getCost(AbstractBlockBase<?> block)
Returns the cost object associated with
block . |
Set<E> |
getFlags()
|
Stream<E> |
getFlagsForBlock(AbstractBlockBase<?> block)
Returns a
Stream of flags associated with block . |
String |
getName(E flag)
Returns the name of a flag.
|
void |
set(E flag,
AbstractBlockBase<?> block)
Sets a flag for a block.
|
void |
setCost(AbstractBlockBase<?> block,
C cost)
Sets the cost for a
block . |
void |
setDominatorPath(E flag,
AbstractBlockBase<?> block)
Sets
flag for all blocks along the dominator path from block to the root
until a block it finds a block where flag is already set. |
Stream<? extends AbstractBlockBase<?>> |
stream(E flag)
Returns a Stream of blocks for which
flag is set. |
private static boolean |
verify(List<? extends AbstractBlockBase<?>> blocks) |
private List<? extends AbstractBlockBase<?>> blocks
protected DominatorOptimizationProblem(Class<E> flagType, AbstractControlFlowGraph<?> cfg)
private static boolean verify(List<? extends AbstractBlockBase<?>> blocks)
public final List<? extends AbstractBlockBase<?>> getBlocks()
public final AbstractBlockBase<?> getBlockForId(int id)
public final void set(E flag, AbstractBlockBase<?> block)
public final boolean get(E flag, AbstractBlockBase<?> block)
public final Stream<? extends AbstractBlockBase<?>> stream(E flag)
flag
is set.public final C getCost(AbstractBlockBase<?> block)
block
. Might return null
if not set.public final void setCost(AbstractBlockBase<?> block, C cost)
block
.public final void setDominatorPath(E flag, AbstractBlockBase<?> block)
flag
for all blocks along the dominator path from block
to the root
until a block it finds a block where flag
is already set.public final Stream<E> getFlagsForBlock(AbstractBlockBase<?> block)
Stream
of flags associated with block
.