src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core/src/org/graalvm/compiler/core/gen/NodeLIRBuilder.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File
*** old/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core/src/org/graalvm/compiler/core/gen/NodeLIRBuilder.java	Mon Mar 20 17:37:43 2017
--- new/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core/src/org/graalvm/compiler/core/gen/NodeLIRBuilder.java	Mon Mar 20 17:37:43 2017

*** 20,48 **** --- 20,46 ---- * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.compiler.core.gen; import static org.graalvm.compiler.core.common.GraalOptions.MatchExpressions; import static org.graalvm.compiler.debug.GraalDebugConfig.Options.LogVerbose; import static org.graalvm.compiler.lir.LIR.verifyBlock; import static jdk.vm.ci.code.ValueUtil.asRegister; import static jdk.vm.ci.code.ValueUtil.isLegal; import static jdk.vm.ci.code.ValueUtil.isRegister; + import static org.graalvm.compiler.core.common.GraalOptions.MatchExpressions; + import static org.graalvm.compiler.debug.GraalDebugConfig.Options.LogVerbose; + import static org.graalvm.compiler.lir.LIR.verifyBlock; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Map.Entry; import org.graalvm.compiler.core.common.LIRKind; import org.graalvm.compiler.core.common.calc.Condition; import org.graalvm.compiler.core.common.cfg.AbstractBlockBase; import org.graalvm.compiler.core.common.cfg.BlockMap; import org.graalvm.compiler.core.common.type.Stamp; import org.graalvm.compiler.core.match.ComplexMatchValue; + import org.graalvm.compiler.core.match.MatchPattern; import org.graalvm.compiler.core.match.MatchRuleRegistry; import org.graalvm.compiler.core.match.MatchStatement; import org.graalvm.compiler.debug.Debug; import org.graalvm.compiler.debug.Debug.Scope; import org.graalvm.compiler.debug.GraalError;
*** 97,106 **** --- 95,107 ---- import org.graalvm.compiler.nodes.extended.SwitchNode; import org.graalvm.compiler.nodes.spi.LIRLowerable; import org.graalvm.compiler.nodes.spi.NodeLIRBuilderTool; import org.graalvm.compiler.nodes.spi.NodeValueMap; import org.graalvm.compiler.nodes.virtual.VirtualObjectNode; + import org.graalvm.compiler.options.OptionValues; + import org.graalvm.util.EconomicMap; + import org.graalvm.util.UnmodifiableMapCursor; import jdk.vm.ci.code.CallingConvention; import jdk.vm.ci.code.StackSlot; import jdk.vm.ci.code.ValueUtil; import jdk.vm.ci.meta.AllocatableValue;
*** 115,141 **** --- 116,145 ---- */ public abstract class NodeLIRBuilder implements NodeLIRBuilderTool, LIRGenerationDebugContext { private final NodeMap<Value> nodeOperands; private final DebugInfoBuilder debugInfoBuilder; + private final int traceLIRGeneratorLevel; protected final LIRGenerator gen; private ValueNode currentInstruction; private ValueNode lastInstructionPrinted; // Debugging only private final NodeMatchRules nodeMatchRules; ! private EconomicMap<Class<? extends Node>, List<MatchStatement>> matchRules; public NodeLIRBuilder(StructuredGraph graph, LIRGeneratorTool gen, NodeMatchRules nodeMatchRules) { this.gen = (LIRGenerator) gen; this.nodeMatchRules = nodeMatchRules; this.nodeOperands = graph.createNodeMap(); this.debugInfoBuilder = createDebugInfoBuilder(graph, this); if (MatchExpressions.getValue()) { matchRules = MatchRuleRegistry.lookup(nodeMatchRules.getClass()); + OptionValues options = graph.getOptions(); + if (MatchExpressions.getValue(options)) { + matchRules = MatchRuleRegistry.lookup(nodeMatchRules.getClass(), options); } + traceLIRGeneratorLevel = TTY.isSuppressed() ? 0 : Options.TraceLIRGeneratorLevel.getValue(options); assert nodeMatchRules.lirBuilder == null; nodeMatchRules.lirBuilder = this; }
*** 175,187 **** --- 179,192 ---- } @Override public ValueNode valueForOperand(Value value) { assert nodeOperands != null; for (Entry<Node, Value> entry : nodeOperands.entries()) { ! if (entry.getValue().equals(value)) { return (ValueNode) entry.getKey(); + UnmodifiableMapCursor<Node, Value> cursor = nodeOperands.getEntries(); ! while (cursor.advance()) { + if (cursor.getValue().equals(value)) { + return (ValueNode) cursor.getKey(); } } return null; }
*** 204,214 **** --- 209,219 ---- * Used by the {@link MatchStatement} machinery to override the generation LIR for some * ValueNodes. */ public void setMatchResult(Node x, Value operand) { assert operand.equals(ComplexMatchValue.INTERIOR_MATCH) || operand instanceof ComplexMatchValue; ! assert operand instanceof ComplexMatchValue || x.getUsageCount() == 1 : "interior matches must be single user"; ! assert operand instanceof ComplexMatchValue || MatchPattern.isSingleValueUser(x) : "interior matches must be single user"; assert nodeOperands != null && nodeOperands.get(x) == null : "operand cannot be set twice"; assert !(x instanceof VirtualObjectNode); nodeOperands.set(x, operand); }
*** 225,235 **** --- 230,240 ---- } throw GraalError.shouldNotReachHere("Block not in successor list of current block"); } public final void append(LIRInstruction op) { ! if (Options.PrintIRWithLIR.getValue(nodeOperands.graph().getOptions()) && !TTY.isSuppressed()) { if (currentInstruction != null && lastInstructionPrinted != currentInstruction) { lastInstructionPrinted = currentInstruction; InstructionPrinter ip = new InstructionPrinter(TTY.out()); ip.printInstructionListing(currentInstruction); }
*** 316,325 **** --- 321,332 ---- } @Override @SuppressWarnings("try") public void doBlock(Block block, StructuredGraph graph, BlockMap<List<Node>> blockMap) { + + OptionValues options = graph.getOptions(); try (BlockScope blockScope = gen.getBlockScope(block)) { setSourcePosition(null); if (block == gen.getResult().getLIR().getControlFlowGraph().getStartBlock()) { assert block.getPredecessorCount() == 0;
*** 330,340 **** --- 337,347 ---- AbstractBeginNode begin = block.getBeginNode(); if (begin instanceof AbstractMergeNode) { AbstractMergeNode merge = (AbstractMergeNode) begin; LabelOp label = (LabelOp) gen.getResult().getLIR().getLIRforBlock(block).get(0); label.setPhiValues(createPhiIn(merge)); ! if (Options.PrintIRWithLIR.getValue(options) && !TTY.isSuppressed()) { TTY.println("Created PhiIn: " + label); } } }
*** 343,357 **** --- 350,365 ---- // Allow NodeLIRBuilder subclass to specialize code generation of any interesting groups // of instructions matchComplexExpressions(nodes); + boolean trace = traceLIRGeneratorLevel >= 3; for (int i = 0; i < nodes.size(); i++) { Node node = nodes.get(i); if (node instanceof ValueNode) { ValueNode valueNode = (ValueNode) node; ! if (Options.TraceLIRGeneratorLevel.getValue() >= 3) { ! if (trace) { TTY.println("LIRGen for " + valueNode); } Value operand = getOperand(valueNode); if (operand == null) { if (!peephole(valueNode)) {
*** 399,409 **** --- 407,417 ---- @SuppressWarnings("try") protected void matchComplexExpressions(List<Node> nodes) { if (matchRules != null) { try (Scope s = Debug.scope("MatchComplexExpressions")) { ! if (LogVerbose.getValue(nodeOperands.graph().getOptions())) { int i = 0; for (Node node : nodes) { Debug.log("%d: (%s) %1S", i++, node.getUsageCount(), node); } }
*** 430,440 **** --- 438,448 ---- } protected abstract boolean peephole(ValueNode valueNode); private void doRoot(ValueNode instr) { ! if (Options.TraceLIRGeneratorLevel.getValue() >= 2) { ! if (traceLIRGeneratorLevel >= 2) { TTY.println("Emitting LIR for instruction " + instr); } currentInstruction = instr; Debug.log("Visiting %s", instr);

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core/src/org/graalvm/compiler/core/gen/NodeLIRBuilder.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File