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.phases;
024
025import jdk.internal.jvmci.code.*;
026
027import com.oracle.graal.lir.*;
028import com.oracle.graal.lir.gen.*;
029import com.oracle.graal.lir.phases.AllocationPhase.AllocationContext;
030import com.oracle.graal.lir.phases.PostAllocationOptimizationPhase.PostAllocationOptimizationContext;
031import com.oracle.graal.lir.phases.PreAllocationOptimizationPhase.PreAllocationOptimizationContext;
032
033public class LIRSuites {
034
035    private final LIRPhaseSuite<PreAllocationOptimizationContext> preAllocOptStage;
036    private final LIRPhaseSuite<AllocationContext> allocStage;
037    private final LIRPhaseSuite<PostAllocationOptimizationContext> postAllocStage;
038
039    public LIRSuites(LIRPhaseSuite<PreAllocationOptimizationContext> preAllocOptStage, LIRPhaseSuite<AllocationContext> allocStage, LIRPhaseSuite<PostAllocationOptimizationContext> postAllocStage) {
040        this.preAllocOptStage = preAllocOptStage;
041        this.allocStage = allocStage;
042        this.postAllocStage = postAllocStage;
043    }
044
045    public LIRSuites(LIRSuites other) {
046        this(other.getPreAllocationOptimizationStage().copy(), other.getAllocationStage().copy(), other.getPostAllocationOptimizationStage().copy());
047    }
048
049    /**
050     * {@link PreAllocationOptimizationPhase}s are executed between {@link LIR} generation and
051     * register allocation.
052     * <p>
053     * {@link PreAllocationOptimizationPhase Implementers} can create new
054     * {@link LIRGeneratorTool#newVariable variables}, {@link LIRGenerationResult#getFrameMap stack
055     * slots} and {@link LIRGenerationResult#getFrameMapBuilder virtual stack slots}.
056     */
057    public LIRPhaseSuite<PreAllocationOptimizationContext> getPreAllocationOptimizationStage() {
058        return preAllocOptStage;
059    }
060
061    /**
062     * {@link AllocationPhase}s are responsible for register allocation and translating
063     * {@link VirtualStackSlot}s into {@link StackSlot}s.
064     * <p>
065     * After the {@link AllocationStage} there should be no more {@link Variable}s and
066     * {@link VirtualStackSlot}s.
067     */
068    public LIRPhaseSuite<AllocationContext> getAllocationStage() {
069        return allocStage;
070    }
071
072    /**
073     * {@link PostAllocationOptimizationPhase}s are executed after register allocation and before
074     * machine code generation.
075     * <p>
076     * A {@link PostAllocationOptimizationPhase} must not introduce new {@link Variable}s,
077     * {@link VirtualStackSlot}s or {@link StackSlot}s.
078     */
079    public LIRPhaseSuite<PostAllocationOptimizationContext> getPostAllocationOptimizationStage() {
080        return postAllocStage;
081    }
082
083}