use of org.graalvm.compiler.nodes.PhiNode in project graal by oracle.
the class TypeSystemTest method outputNode.
private static void outputNode(Node node) {
TTY.print(" " + node + " (usage count: " + node.getUsageCount() + ") (inputs:");
for (Node input : node.inputs()) {
TTY.print(" " + input.toString(Verbosity.Id));
}
TTY.println(")");
if (node instanceof AbstractMergeNode) {
for (PhiNode phi : ((AbstractMergeNode) node).phis()) {
outputNode(phi);
}
}
}
use of org.graalvm.compiler.nodes.PhiNode in project graal by oracle.
the class LoopTransformations method processPreLoopPhis.
private static void processPreLoopPhis(LoopEx preLoop, LoopFragmentWhole mainLoop, LoopFragmentWhole postLoop) {
// process phis for the post loop
LoopBeginNode preLoopBegin = preLoop.loopBegin();
for (PhiNode prePhiNode : preLoopBegin.phis()) {
PhiNode postPhiNode = postLoop.getDuplicatedNode(prePhiNode);
PhiNode mainPhiNode = mainLoop.getDuplicatedNode(prePhiNode);
postPhiNode.setValueAt(0, mainPhiNode);
// Build a work list to update the pre loop phis to the post loops phis
for (Node usage : prePhiNode.usages().snapshot()) {
if (usage == mainPhiNode) {
continue;
}
if (preLoop.isOutsideLoop(usage)) {
usage.replaceFirstInput(prePhiNode, postPhiNode);
}
}
}
for (Node node : preLoop.inside().nodes()) {
for (Node externalUsage : node.usages().snapshot()) {
if (preLoop.isOutsideLoop(externalUsage)) {
Node postUsage = postLoop.getDuplicatedNode(node);
assert postUsage != null;
externalUsage.replaceFirstInput(node, postUsage);
}
}
}
}
use of org.graalvm.compiler.nodes.PhiNode in project graal by oracle.
the class CFGPrinter method scheduleInputs.
private void scheduleInputs(Node node, Block nodeBlock) {
if (node instanceof ValuePhiNode) {
PhiNode phi = (PhiNode) node;
Block phiBlock = latestScheduling.get(phi.merge());
assert phiBlock != null;
for (Block pred : phiBlock.getPredecessors()) {
schedule(phi.valueAt((AbstractEndNode) pred.getEndNode()), pred);
}
} else {
for (Node input : node.inputs()) {
schedule(input, nodeBlock);
}
}
}
use of org.graalvm.compiler.nodes.PhiNode in project graal by oracle.
the class CanonicalStringGraphPrinter method writeCanonicalGraphExpressionString.
protected static void writeCanonicalGraphExpressionString(ValueNode node, boolean checkConstants, boolean removeIdentities, PrintWriter writer) {
writer.print(node.getClass().getSimpleName());
writer.print("(");
Fields properties = node.getNodeClass().getData();
for (int i = 0; i < properties.getCount(); i++) {
String dataStr = String.valueOf(properties.get(node, i));
if (removeIdentities) {
dataStr = removeIdentities(dataStr);
}
writer.print(dataStr);
if (i + 1 < properties.getCount() || node.inputPositions().iterator().hasNext()) {
writer.print(", ");
}
}
Iterator<Position> iterator = node.inputPositions().iterator();
while (iterator.hasNext()) {
Position position = iterator.next();
Node input = position.get(node);
if (checkConstants && input instanceof ConstantNode) {
ConstantNode constantNode = (ConstantNode) input;
String valueString = constantNode.getValue().toValueString();
if (removeIdentities) {
valueString = removeIdentities(valueString);
}
writer.print(valueString);
} else if (input instanceof ValueNode && !(input instanceof PhiNode) && !(input instanceof FixedNode)) {
writeCanonicalGraphExpressionString((ValueNode) input, checkConstants, removeIdentities, writer);
} else if (input == null) {
writer.print("null");
} else {
writer.print(input.getClass().getSimpleName());
}
if (iterator.hasNext()) {
writer.print(", ");
}
}
writer.print(")");
}
use of org.graalvm.compiler.nodes.PhiNode in project graal by oracle.
the class MultiTypeGuardInlineInfo method duplicateInvokeForInlining.
private static Invoke duplicateInvokeForInlining(StructuredGraph graph, Invoke invoke, AbstractMergeNode exceptionMerge, PhiNode exceptionObjectPhi, boolean useForInlining) {
Invoke result = (Invoke) invoke.asNode().copyWithInputs();
Node callTarget = result.callTarget().copyWithInputs();
result.asNode().replaceFirstInput(result.callTarget(), callTarget);
result.setUseForInlining(useForInlining);
JavaKind kind = invoke.asNode().getStackKind();
if (kind != JavaKind.Void) {
FrameState stateAfter = invoke.stateAfter();
stateAfter = stateAfter.duplicate(stateAfter.bci);
stateAfter.replaceFirstInput(invoke.asNode(), result.asNode());
result.setStateAfter(stateAfter);
}
if (invoke instanceof InvokeWithExceptionNode) {
assert exceptionMerge != null && exceptionObjectPhi != null;
InvokeWithExceptionNode invokeWithException = (InvokeWithExceptionNode) invoke;
ExceptionObjectNode exceptionEdge = (ExceptionObjectNode) invokeWithException.exceptionEdge();
FrameState stateAfterException = exceptionEdge.stateAfter();
ExceptionObjectNode newExceptionEdge = (ExceptionObjectNode) exceptionEdge.copyWithInputs();
// set new state (pop old exception object, push new one)
newExceptionEdge.setStateAfter(stateAfterException.duplicateModified(JavaKind.Object, JavaKind.Object, newExceptionEdge));
EndNode endNode = graph.add(new EndNode());
newExceptionEdge.setNext(endNode);
exceptionMerge.addForwardEnd(endNode);
exceptionObjectPhi.addInput(newExceptionEdge);
((InvokeWithExceptionNode) result).setExceptionEdge(newExceptionEdge);
}
return result;
}
Aggregations