# HG changeset patch # User Josef Eisl # Date 1423250714 -3600 # Node ID 95a7954ea155285f90011ac18227b4aee97be8ce # Parent 6081b30fe164b274974be20991854d3886cecc2c Add LinearScanPhase. diff -r 6081b30fe164 -r 95a7954ea155 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java Fri Feb 06 20:06:38 2015 +0100 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java Fri Feb 06 20:25:14 2015 +0100 @@ -364,7 +364,7 @@ LowLevelMidTierPhase.Context c = new LowLevelMidTierPhase.Context<>(codeEmittingOrder, linearScanOrder); try (Scope s = Debug.scope("Allocator")) { if (backend.shouldAllocateRegisters()) { - LinearScan.allocate(target, lirGenRes); + new LinearScanPhase().apply(target, lirGenRes, c); } } diff -r 6081b30fe164 -r 95a7954ea155 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScan.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScan.java Fri Feb 06 20:06:38 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScan.java Fri Feb 06 20:25:14 2015 +0100 @@ -56,7 +56,7 @@ * >"Optimized Interval Splitting in a Linear Scan Register Allocator" by Christian Wimmer and * Hanspeter Moessenboeck. */ -public final class LinearScan { +final class LinearScan { final TargetDescription target; final LIRGenerationResult res; @@ -109,7 +109,7 @@ public BitSet liveKill; } - public final BlockMap blockData; + final BlockMap blockData; /** * List of blocks in linear-scan order. This is only correct as long as the CFG does not change. @@ -161,7 +161,7 @@ */ private final int firstVariableNumber; - public LinearScan(TargetDescription target, LIRGenerationResult res) { + LinearScan(TargetDescription target, LIRGenerationResult res) { this.target = target; this.res = res; this.ir = res.getLIR(); @@ -178,13 +178,13 @@ this.callKillsRegisters = this.frameMapBuilder.getRegisterConfig().areAllAllocatableRegistersCallerSaved(); } - public int getFirstLirInstructionId(AbstractBlock block) { + int getFirstLirInstructionId(AbstractBlock block) { int result = ir.getLIRforBlock(block).get(0).id(); assert result >= 0; return result; } - public int getLastLirInstructionId(AbstractBlock block) { + int getLastLirInstructionId(AbstractBlock block) { List instructions = ir.getLIRforBlock(block); int result = instructions.get(instructions.size() - 1).id(); assert result >= 0; @@ -220,7 +220,7 @@ /** * Gets the highest operand number for a register operand. This value will never change. */ - public int maxRegisterNumber() { + int maxRegisterNumber() { return firstVariableNumber - 1; } @@ -1374,7 +1374,7 @@ sortedIntervals = combinedList; } - public void allocateRegisters() { + void allocateRegisters() { try (Indent indent = Debug.logAndIndent("allocate registers")) { Interval precoloredIntervals; Interval notPrecoloredIntervals; @@ -1731,11 +1731,7 @@ } } - public static void allocate(TargetDescription target, LIRGenerationResult res) { - new LinearScan(target, res).allocate(); - } - - private void allocate() { + void allocate() { /* * This is the point to enable debug logging for the whole register allocation. diff -r 6081b30fe164 -r 95a7954ea155 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScanPhase.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScanPhase.java Fri Feb 06 20:25:14 2015 +0100 @@ -0,0 +1,39 @@ +/* + * 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.alloc.lsra; + +import java.util.*; + +import com.oracle.graal.api.code.*; +import com.oracle.graal.compiler.common.cfg.*; +import com.oracle.graal.lir.gen.*; +import com.oracle.graal.lir.phases.*; + +public final class LinearScanPhase> extends LowLevelMidTierPhase { + + @Override + protected void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder) { + new LinearScan(target, lirGenRes).allocate(); + } + +}