Mercurial > hg > graal-compiler
changeset 22358:b93161ba3364
Rename SSIUtils->SSIUtil.
author | Josef Eisl <josef.eisl@jku.at> |
---|---|
date | Fri, 24 Jul 2015 13:50:38 +0200 |
parents | dcf959fb2223 |
children | 610c1d8cec4d |
files | graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/ssi/SSILinearScanLifetimeAnalysisPhase.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/ssi/SSILinearScanResolveDataFlowPhase.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/trace/TraceLinearScanLifetimeAnalysisPhase.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/trace/TraceLinearScanResolveDataFlowPhase.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/trace/TraceRegisterAllocationPhase.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/ssi/SSIUtil.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/ssi/SSIUtils.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/ssi/SSIVerifier.java |
diffstat | 8 files changed, 127 insertions(+), 127 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/ssi/SSILinearScanLifetimeAnalysisPhase.java Fri Jul 24 13:49:56 2015 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/ssi/SSILinearScanLifetimeAnalysisPhase.java Fri Jul 24 13:50:38 2015 +0200 @@ -53,7 +53,7 @@ Interval to = allocator.getOrCreateInterval((AllocatableValue) targetValue); - SSIUtils.forEachRegisterHint(allocator.getLIR(), allocator.blockForId(label.id()), label, targetValue, mode, (ValueConsumer) (registerHint, valueMode, valueFlags) -> { + SSIUtil.forEachRegisterHint(allocator.getLIR(), allocator.blockForId(label.id()), label, targetValue, mode, (ValueConsumer) (registerHint, valueMode, valueFlags) -> { if (LinearScan.isVariableOrRegister(registerHint)) { Interval from = allocator.getOrCreateInterval((AllocatableValue) registerHint);
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/ssi/SSILinearScanResolveDataFlowPhase.java Fri Jul 24 13:49:56 2015 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/ssi/SSILinearScanResolveDataFlowPhase.java Fri Jul 24 13:50:38 2015 +0200 @@ -54,11 +54,11 @@ */ for (AbstractBlockBase<?> toBlock : allocator.sortedBlocks()) { if (toBlock.getPredecessorCount() != 0) { - SSIUtils.removeIncoming(allocator.getLIR(), toBlock); + SSIUtil.removeIncoming(allocator.getLIR(), toBlock); } else { assert allocator.getLIR().getControlFlowGraph().getStartBlock().equals(toBlock); } - SSIUtils.removeOutgoing(allocator.getLIR(), toBlock); + SSIUtil.removeOutgoing(allocator.getLIR(), toBlock); } } @@ -68,17 +68,17 @@ if (midBlock != null) { HashMap<Value, Value> map = CollectionsFactory.newMap(); - SSIUtils.forEachValuePair(allocator.getLIR(), midBlock, fromBlock, (to, from) -> map.put(to, from)); + SSIUtil.forEachValuePair(allocator.getLIR(), midBlock, fromBlock, (to, from) -> map.put(to, from)); MyPhiValueVisitor visitor = new MyPhiValueVisitor(moveResolver, toBlock, fromBlock); - SSIUtils.forEachValuePair(allocator.getLIR(), toBlock, midBlock, (to, from) -> { + SSIUtil.forEachValuePair(allocator.getLIR(), toBlock, midBlock, (to, from) -> { Value phiOut = isConstant(from) ? from : map.get(from); assert phiOut != null : "No entry for " + from; visitor.visit(to, phiOut); }); } else { // default case - SSIUtils.forEachValuePair(allocator.getLIR(), toBlock, fromBlock, new MyPhiValueVisitor(moveResolver, toBlock, fromBlock)); + SSIUtil.forEachValuePair(allocator.getLIR(), toBlock, fromBlock, new MyPhiValueVisitor(moveResolver, toBlock, fromBlock)); } }
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/trace/TraceLinearScanLifetimeAnalysisPhase.java Fri Jul 24 13:49:56 2015 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/trace/TraceLinearScanLifetimeAnalysisPhase.java Fri Jul 24 13:50:38 2015 +0200 @@ -130,10 +130,10 @@ // set hints for phi/sigma intervals LIR lir = allocator.getLIR(); for (AbstractBlockBase<?> block : allocator.sortedBlocks()) { - LabelOp label = SSIUtils.incoming(lir, block); + LabelOp label = SSIUtil.incoming(lir, block); for (AbstractBlockBase<?> pred : block.getPredecessors()) { if (isAllocatedOrCurrent(block, pred)) { - BlockEndOp outgoing = SSIUtils.outgoing(lir, pred); + BlockEndOp outgoing = SSIUtil.outgoing(lir, pred); for (int i = 0; i < outgoing.getOutgoingSize(); i++) { Value toValue = label.getIncomingValue(i); if (!isIllegal(toValue)) {
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/trace/TraceLinearScanResolveDataFlowPhase.java Fri Jul 24 13:49:56 2015 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/trace/TraceLinearScanResolveDataFlowPhase.java Fri Jul 24 13:50:38 2015 +0200 @@ -54,7 +54,7 @@ assert midBlock == null; if (containedInTrace(fromBlock) && containedInTrace(toBlock)) { super.resolveCollectMappings(fromBlock, toBlock, midBlock, moveResolver); - SSIUtils.forEachValuePair(allocator.getLIR(), toBlock, fromBlock, new MyPhiValueVisitor(moveResolver, toBlock, fromBlock)); + SSIUtil.forEachValuePair(allocator.getLIR(), toBlock, fromBlock, new MyPhiValueVisitor(moveResolver, toBlock, fromBlock)); } }
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/trace/TraceRegisterAllocationPhase.java Fri Jul 24 13:49:56 2015 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/trace/TraceRegisterAllocationPhase.java Fri Jul 24 13:50:38 2015 +0200 @@ -90,11 +90,11 @@ */ for (AbstractBlockBase<?> toBlock : lir.getControlFlowGraph().getBlocks()) { if (toBlock.getPredecessorCount() != 0) { - SSIUtils.removeIncoming(lir, toBlock); + SSIUtil.removeIncoming(lir, toBlock); } else { assert lir.getControlFlowGraph().getStartBlock().equals(toBlock); } - SSIUtils.removeOutgoing(lir, toBlock); + SSIUtil.removeOutgoing(lir, toBlock); } } @@ -152,7 +152,7 @@ } moveResolver.setInsertPosition(instructions, insertIdx); - SSIUtils.forEachValuePair(lir, toBlock, fromBlock, visitor); + SSIUtil.forEachValuePair(lir, toBlock, fromBlock, visitor); moveResolver.resolveAndAppendMoves(); } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/ssi/SSIUtil.java Fri Jul 24 13:50:38 2015 +0200 @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.lir.ssi; + +import java.util.*; + +import jdk.internal.jvmci.meta.*; + +import com.oracle.graal.compiler.common.cfg.*; +import com.oracle.graal.lir.*; +import com.oracle.graal.lir.StandardOp.BlockEndOp; +import com.oracle.graal.lir.LIRInstruction.*; +import com.oracle.graal.lir.StandardOp.*; +import com.oracle.graal.lir.ssa.SSAUtil.*; + +public final class SSIUtil { + + public static BlockEndOp outgoing(LIR lir, AbstractBlockBase<?> block) { + return (BlockEndOp) outgoingInst(lir, block); + } + + public static LIRInstruction outgoingInst(LIR lir, AbstractBlockBase<?> block) { + List<LIRInstruction> instructions = lir.getLIRforBlock(block); + int index = instructions.size() - 1; + LIRInstruction op = instructions.get(index); + return op; + } + + public static LabelOp incoming(LIR lir, AbstractBlockBase<?> block) { + return (LabelOp) incomingInst(lir, block); + } + + private static LIRInstruction incomingInst(LIR lir, AbstractBlockBase<?> block) { + return lir.getLIRforBlock(block).get(0); + } + + public static void removeIncoming(LIR lir, AbstractBlockBase<?> block) { + incoming(lir, block).clearIncomingValues(); + } + + public static void removeOutgoing(LIR lir, AbstractBlockBase<?> block) { + outgoing(lir, block).clearOutgoingValues(); + } + + /** + * Visits each SIGMA/PHI value pair of an edge, i.e. the outgoing value from the predecessor and + * the incoming value to the merge block. + */ + public static void forEachValuePair(LIR lir, AbstractBlockBase<?> toBlock, AbstractBlockBase<?> fromBlock, PhiValueVisitor visitor) { + assert toBlock.getPredecessors().contains(fromBlock) : String.format("%s not in predecessor list: %s", fromBlock, toBlock.getPredecessors()); + assert fromBlock.getSuccessorCount() == 1 || toBlock.getPredecessorCount() == 1 : String.format("Critical Edge? %s has %d successors and %s has %d predecessors", fromBlock, + fromBlock.getSuccessors(), toBlock, toBlock.getPredecessorCount()); + assert fromBlock.getSuccessors().contains(toBlock) : String.format("Predecessor block %s has wrong successor: %s, should contain: %s", fromBlock, fromBlock.getSuccessors(), toBlock); + + BlockEndOp blockEnd = outgoing(lir, fromBlock); + LabelOp label = incoming(lir, toBlock); + + assert label.getIncomingSize() == blockEnd.getOutgoingSize() : String.format("In/Out size mismatch: in=%d vs. out=%d, blocks %s vs. %s", label.getIncomingSize(), blockEnd.getOutgoingSize(), + toBlock, fromBlock); + + for (int i = 0; i < label.getIncomingSize(); i++) { + visitor.visit(label.getIncomingValue(i), blockEnd.getOutgoingValue(i)); + } + } + + public static void forEachRegisterHint(LIR lir, AbstractBlockBase<?> block, LabelOp label, Value targetValue, OperandMode mode, ValueConsumer valueConsumer) { + assert mode == OperandMode.DEF : "Wrong operand mode: " + mode; + assert lir.getLIRforBlock(block).get(0).equals(label) : String.format("Block %s and Label %s do not match!", block, label); + + if (!label.isPhiIn()) { + return; + } + int idx = indexOfValue(label, targetValue); + assert idx >= 0 : String.format("Value %s not in label %s", targetValue, label); + + for (AbstractBlockBase<?> pred : block.getPredecessors()) { + BlockEndOp blockEnd = outgoing(lir, pred); + Value sourceValue = blockEnd.getOutgoingValue(idx); + valueConsumer.visitValue((LIRInstruction) blockEnd, sourceValue, null, null); + } + + } + + private static int indexOfValue(LabelOp label, Value value) { + for (int i = 0; i < label.getIncomingSize(); i++) { + if (label.getIncomingValue(i).equals(value)) { + return i; + } + } + return -1; + } + +}
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/ssi/SSIUtils.java Fri Jul 24 13:49:56 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,113 +0,0 @@ -/* - * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.graal.lir.ssi; - -import java.util.*; - -import jdk.internal.jvmci.meta.*; - -import com.oracle.graal.compiler.common.cfg.*; -import com.oracle.graal.lir.*; -import com.oracle.graal.lir.StandardOp.BlockEndOp; -import com.oracle.graal.lir.LIRInstruction.*; -import com.oracle.graal.lir.StandardOp.*; -import com.oracle.graal.lir.ssa.SSAUtil.*; - -public final class SSIUtils { - - public static BlockEndOp outgoing(LIR lir, AbstractBlockBase<?> block) { - return (BlockEndOp) outgoingInst(lir, block); - } - - public static LIRInstruction outgoingInst(LIR lir, AbstractBlockBase<?> block) { - List<LIRInstruction> instructions = lir.getLIRforBlock(block); - int index = instructions.size() - 1; - LIRInstruction op = instructions.get(index); - return op; - } - - public static LabelOp incoming(LIR lir, AbstractBlockBase<?> block) { - return (LabelOp) incomingInst(lir, block); - } - - private static LIRInstruction incomingInst(LIR lir, AbstractBlockBase<?> block) { - return lir.getLIRforBlock(block).get(0); - } - - public static void removeIncoming(LIR lir, AbstractBlockBase<?> block) { - incoming(lir, block).clearIncomingValues(); - } - - public static void removeOutgoing(LIR lir, AbstractBlockBase<?> block) { - outgoing(lir, block).clearOutgoingValues(); - } - - /** - * Visits each SIGMA/PHI value pair of an edge, i.e. the outgoing value from the predecessor and - * the incoming value to the merge block. - */ - public static void forEachValuePair(LIR lir, AbstractBlockBase<?> toBlock, AbstractBlockBase<?> fromBlock, PhiValueVisitor visitor) { - assert toBlock.getPredecessors().contains(fromBlock) : String.format("%s not in predecessor list: %s", fromBlock, toBlock.getPredecessors()); - assert fromBlock.getSuccessorCount() == 1 || toBlock.getPredecessorCount() == 1 : String.format("Critical Edge? %s has %d successors and %s has %d predecessors", fromBlock, - fromBlock.getSuccessors(), toBlock, toBlock.getPredecessorCount()); - assert fromBlock.getSuccessors().contains(toBlock) : String.format("Predecessor block %s has wrong successor: %s, should contain: %s", fromBlock, fromBlock.getSuccessors(), toBlock); - - BlockEndOp blockEnd = outgoing(lir, fromBlock); - LabelOp label = incoming(lir, toBlock); - - assert label.getIncomingSize() == blockEnd.getOutgoingSize() : String.format("In/Out size mismatch: in=%d vs. out=%d, blocks %s vs. %s", label.getIncomingSize(), blockEnd.getOutgoingSize(), - toBlock, fromBlock); - - for (int i = 0; i < label.getIncomingSize(); i++) { - visitor.visit(label.getIncomingValue(i), blockEnd.getOutgoingValue(i)); - } - } - - public static void forEachRegisterHint(LIR lir, AbstractBlockBase<?> block, LabelOp label, Value targetValue, OperandMode mode, ValueConsumer valueConsumer) { - assert mode == OperandMode.DEF : "Wrong operand mode: " + mode; - assert lir.getLIRforBlock(block).get(0).equals(label) : String.format("Block %s and Label %s do not match!", block, label); - - if (!label.isPhiIn()) { - return; - } - int idx = indexOfValue(label, targetValue); - assert idx >= 0 : String.format("Value %s not in label %s", targetValue, label); - - for (AbstractBlockBase<?> pred : block.getPredecessors()) { - BlockEndOp blockEnd = outgoing(lir, pred); - Value sourceValue = blockEnd.getOutgoingValue(idx); - valueConsumer.visitValue((LIRInstruction) blockEnd, sourceValue, null, null); - } - - } - - private static int indexOfValue(LabelOp label, Value value) { - for (int i = 0; i < label.getIncomingSize(); i++) { - if (label.getIncomingValue(i).equals(value)) { - return i; - } - } - return -1; - } - -}
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/ssi/SSIVerifier.java Fri Jul 24 13:49:56 2015 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/ssi/SSIVerifier.java Fri Jul 24 13:50:38 2015 +0200 @@ -68,8 +68,8 @@ } private void verifyEdge(AbstractBlockBase<?> from, AbstractBlockBase<?> to) { - BlockEndOp out = SSIUtils.outgoing(lir, from); - LabelOp in = SSIUtils.incoming(lir, to); + BlockEndOp out = SSIUtil.outgoing(lir, from); + LabelOp in = SSIUtil.incoming(lir, to); int outgoingSize = out.getOutgoingSize(); int incomingSize = in.getIncomingSize(); assert outgoingSize == incomingSize : String.format("Outgoing size %d and incoming size %d do not match", outgoingSize, incomingSize);