Mercurial > hg > truffle
changeset 19212:95a7954ea155
Add LinearScanPhase.
author | Josef Eisl <josef.eisl@jku.at> |
---|---|
date | Fri, 06 Feb 2015 20:25:14 +0100 |
parents | 6081b30fe164 |
children | d7e743760000 |
files | graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScan.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScanPhase.java |
diffstat | 3 files changed, 48 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- 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<T> c = new LowLevelMidTierPhase.Context<>(codeEmittingOrder, linearScanOrder); try (Scope s = Debug.scope("Allocator")) { if (backend.shouldAllocateRegisters()) { - LinearScan.allocate(target, lirGenRes); + new LinearScanPhase<T>().apply(target, lirGenRes, c); } }
--- 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"</a> 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> blockData; + final BlockMap<BlockData> 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<LIRInstruction> 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.
--- /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<B extends AbstractBlock<B>> extends LowLevelMidTierPhase<B> { + + @Override + protected void run(TargetDescription target, LIRGenerationResult lirGenRes, List<B> codeEmittingOrder, List<B> linearScanOrder) { + new LinearScan(target, lirGenRes).allocate(); + } + +}