< prev index next >

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/ssa/SSAUtil.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2015, 2018, 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. --- 1,7 ---- /* ! * Copyright (c) 2015, 2019, 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.
*** 29,43 **** import org.graalvm.compiler.core.common.LIRKind; import org.graalvm.compiler.core.common.cfg.AbstractBlockBase; import org.graalvm.compiler.lir.LIR; import org.graalvm.compiler.lir.LIRInstruction; - import org.graalvm.compiler.lir.LIRInstruction.OperandMode; import org.graalvm.compiler.lir.StandardOp.BlockEndOp; import org.graalvm.compiler.lir.StandardOp.JumpOp; import org.graalvm.compiler.lir.StandardOp.LabelOp; - import org.graalvm.compiler.lir.ValueConsumer; import jdk.vm.ci.meta.Value; /** * Utilities for working with Static-Single-Assignment LIR form. --- 29,41 ----
*** 112,128 **** int index = instructions.size() - 1; LIRInstruction op = instructions.get(index); return (JumpOp) op; } - public static JumpOp phiOutOrNull(LIR lir, AbstractBlockBase<?> block) { - if (block.getSuccessorCount() != 1) { - return null; - } - return phiOut(lir, block); - } - public static int phiOutIndex(LIR lir, AbstractBlockBase<?> block) { assert block.getSuccessorCount() == 1; ArrayList<LIRInstruction> instructions = lir.getLIRforBlock(block); int index = instructions.size() - 1; assert instructions.get(index) instanceof JumpOp; --- 110,119 ----
*** 147,208 **** public static boolean verifySSAForm(LIR lir) { return new SSAVerifier(lir).verify(); } - public static boolean isMerge(AbstractBlockBase<?> block) { - return block.getPredecessorCount() > 1; - } - public static void verifyPhi(LIR lir, AbstractBlockBase<?> merge) { assert merge.getPredecessorCount() > 1; for (AbstractBlockBase<?> pred : merge.getPredecessors()) { forEachPhiValuePair(lir, merge, pred, (phiIn, phiOut) -> { assert phiIn.getValueKind().equals(phiOut.getValueKind()) || (phiIn.getPlatformKind().equals(phiOut.getPlatformKind()) && LIRKind.isUnknownReference(phiIn) && LIRKind.isValue(phiOut)); }); } } ! public static void forEachPhiRegisterHint(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()) { ! JumpOp jump = phiOut(lir, pred); ! Value sourceValue = jump.getOutgoingValue(idx); ! valueConsumer.visitValue(jump, 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; } - - public static int numPhiOut(LIR lir, AbstractBlockBase<?> block) { - if (block.getSuccessorCount() != 1) { - // cannot be a phi_out block - return 0; - } - return numPhiIn(lir, block.getSuccessors()[0]); - } - - private static int numPhiIn(LIR lir, AbstractBlockBase<?> block) { - if (!isMerge(block)) { - return 0; - } - return phiIn(lir, block).getPhiSize(); - } - } --- 138,161 ---- public static boolean verifySSAForm(LIR lir) { return new SSAVerifier(lir).verify(); } public static void verifyPhi(LIR lir, AbstractBlockBase<?> merge) { assert merge.getPredecessorCount() > 1; for (AbstractBlockBase<?> pred : merge.getPredecessors()) { forEachPhiValuePair(lir, merge, pred, (phiIn, phiOut) -> { assert phiIn.getValueKind().equals(phiOut.getValueKind()) || (phiIn.getPlatformKind().equals(phiOut.getPlatformKind()) && LIRKind.isUnknownReference(phiIn) && LIRKind.isValue(phiOut)); }); } } ! public 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; } }
< prev index next >