public interface Canonicalizable
Canonicalizable
or one of the two sub-interfaces Canonicalizable.Unary
and
Canonicalizable.Binary
to provide local optimizations like constant folding and strength reduction.
Implementations should return a replacement that is always semantically correct for the given
inputs, or "this" if they do not see an opportunity for improvement.canonical(CanonicalizerTool)
or the equivalent
methods of the two sub-interfaces must not have any side effects.Modifier and Type | Interface and Description |
---|---|
static interface |
Canonicalizable.Binary<T extends Node>
This sub-interface of
Canonicalizable is intended for nodes that have exactly two
inputs. |
static interface |
Canonicalizable.BinaryCommutative<T extends Node>
This sub-interface of
Canonicalizable.Binary is for nodes with two inputs where the
operation is commutative. |
static interface |
Canonicalizable.Unary<T extends Node>
This sub-interface of
Canonicalizable is intended for nodes that have exactly one
input. |
Modifier and Type | Method and Description |
---|---|
Node |
canonical(CanonicalizerTool tool)
Implementations of this method can provide local optimizations like constant folding and
strength reduction.
|
Node canonical(CanonicalizerTool tool)
null
will delete the current node and replace it with null
at
all usages. Note that it is not necessary to delete floating nodes that have no more usages
this way - they will be deleted automatically.tool
- provides access to runtime interfaces like MetaAccessProvider