001/*
002 * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation.
008 *
009 * This code is distributed in the hope that it will be useful, but WITHOUT
010 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
011 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
012 * version 2 for more details (a copy is included in the LICENSE file that
013 * accompanied this code).
014 *
015 * You should have received a copy of the GNU General Public License version
016 * 2 along with this work; if not, write to the Free Software Foundation,
017 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
018 *
019 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
020 * or visit www.oracle.com if you need additional information or have any
021 * questions.
022 */
023package com.oracle.graal.lir.alloc.lsra;
024
025import static com.oracle.graal.compiler.common.BackendOptions.*;
026
027import java.util.*;
028
029import jdk.internal.jvmci.code.*;
030import jdk.internal.jvmci.common.*;
031
032import com.oracle.graal.compiler.common.alloc.*;
033import com.oracle.graal.compiler.common.cfg.*;
034import com.oracle.graal.lir.alloc.lsra.ssa.*;
035import com.oracle.graal.lir.alloc.lsra.ssi.*;
036import com.oracle.graal.lir.gen.*;
037import com.oracle.graal.lir.gen.LIRGeneratorTool.SpillMoveFactory;
038import com.oracle.graal.lir.phases.*;
039
040public final class LinearScanPhase extends AllocationPhase {
041
042    @Override
043    protected <B extends AbstractBlockBase<B>> void run(TargetDescription target, LIRGenerationResult lirGenRes, List<B> codeEmittingOrder, List<B> linearScanOrder, SpillMoveFactory spillMoveFactory,
044                    RegisterAllocationConfig registerAllocationConfig) {
045        final LinearScan allocator;
046        switch (LinearScanVariant.getValue()) {
047            case SSI_LSRA:
048                allocator = new SSILinearScan(target, lirGenRes, spillMoveFactory, registerAllocationConfig, linearScanOrder);
049                break;
050            case SSA_LSRA:
051                allocator = new SSALinearScan(target, lirGenRes, spillMoveFactory, registerAllocationConfig, linearScanOrder);
052                break;
053            case NONSSA_LSAR:
054                allocator = new LinearScan(target, lirGenRes, spillMoveFactory, registerAllocationConfig, linearScanOrder);
055                break;
056            default:
057                throw JVMCIError.shouldNotReachHere();
058        }
059        allocator.allocate(target, lirGenRes, codeEmittingOrder, linearScanOrder, spillMoveFactory, registerAllocationConfig);
060    }
061
062}