1 /* 2 * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 package org.graalvm.compiler.lir.alloc.lsra.ssa; 24 25 import org.graalvm.compiler.core.common.alloc.RegisterAllocationConfig; 26 import org.graalvm.compiler.core.common.cfg.AbstractBlockBase; 27 import org.graalvm.compiler.debug.Debug; 28 import org.graalvm.compiler.debug.Debug.Scope; 29 import org.graalvm.compiler.lir.alloc.lsra.LinearScan; 30 import org.graalvm.compiler.lir.alloc.lsra.LinearScanEliminateSpillMovePhase; 31 import org.graalvm.compiler.lir.alloc.lsra.LinearScanLifetimeAnalysisPhase; 32 import org.graalvm.compiler.lir.alloc.lsra.LinearScanResolveDataFlowPhase; 33 import org.graalvm.compiler.lir.alloc.lsra.MoveResolver; 34 import org.graalvm.compiler.lir.gen.LIRGenerationResult; 35 import org.graalvm.compiler.lir.gen.LIRGeneratorTool.MoveFactory; 36 import org.graalvm.compiler.lir.ssa.SSAUtil; 37 38 import jdk.vm.ci.code.TargetDescription; 39 40 public final class SSALinearScan extends LinearScan { 41 42 public SSALinearScan(TargetDescription target, LIRGenerationResult res, MoveFactory spillMoveFactory, RegisterAllocationConfig regAllocConfig, AbstractBlockBase<?>[] sortedBlocks, 43 boolean neverSpillConstants) { 44 super(target, res, spillMoveFactory, regAllocConfig, sortedBlocks, neverSpillConstants); 45 } 46 47 @Override 48 protected MoveResolver createMoveResolver() { 49 SSAMoveResolver moveResolver = new SSAMoveResolver(this); 50 assert moveResolver.checkEmpty(); 51 return moveResolver; 52 } 53 54 @Override 55 protected LinearScanLifetimeAnalysisPhase createLifetimeAnalysisPhase() { 56 return new SSALinearScanLifetimeAnalysisPhase(this); 57 } 58 59 @Override 60 protected LinearScanResolveDataFlowPhase createResolveDataFlowPhase() { 61 return new SSALinearScanResolveDataFlowPhase(this); 62 } 63 64 @Override 65 protected LinearScanEliminateSpillMovePhase createSpillMoveEliminationPhase() { 66 return new SSALinearScanEliminateSpillMovePhase(this); 67 } 68 69 @Override 70 @SuppressWarnings("try") 71 protected void beforeSpillMoveElimination() { 72 /* 73 * PHI Ins are needed for the RegisterVerifier, otherwise PHIs where the Out and In value 74 * matches (ie. there is no resolution move) are falsely detected as errors. 75 */ 76 try (Scope s1 = Debug.scope("Remove Phi In")) { 77 for (AbstractBlockBase<?> toBlock : sortedBlocks()) { 78 if (toBlock.getPredecessorCount() > 1) { 79 SSAUtil.removePhiIn(getLIR(), toBlock); 80 } 81 } 82 } 83 } 84 85 }