001/* 002 * Copyright (c) 2013, 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.compiler.phases; 024 025import static com.oracle.graal.compiler.common.GraalOptions.*; 026 027import com.oracle.graal.loop.phases.*; 028import com.oracle.graal.nodes.spi.*; 029import com.oracle.graal.phases.*; 030import com.oracle.graal.phases.common.*; 031import com.oracle.graal.phases.tiers.*; 032import com.oracle.graal.virtual.phases.ea.*; 033 034public class MidTier extends PhaseSuite<MidTierContext> { 035 036 public MidTier() { 037 CanonicalizerPhase canonicalizer = new CanonicalizerPhase(); 038 if (ImmutableCode.getValue()) { 039 canonicalizer.disableReadCanonicalization(); 040 } 041 042 if (OptPushThroughPi.getValue()) { 043 appendPhase(new PushThroughPiPhase()); 044 } 045 if (OptCanonicalizer.getValue()) { 046 appendPhase(canonicalizer); 047 } 048 049 appendPhase(new ValueAnchorCleanupPhase()); 050 appendPhase(new LockEliminationPhase()); 051 052 if (OptReadElimination.getValue()) { 053 appendPhase(new EarlyReadEliminationPhase(canonicalizer)); 054 } 055 056 if (OptFloatingReads.getValue()) { 057 appendPhase(new IncrementalCanonicalizerPhase<>(canonicalizer, new FloatingReadPhase())); 058 } 059 appendPhase(new RemoveValueProxyPhase()); 060 061 if (OptCanonicalizer.getValue()) { 062 appendPhase(canonicalizer); 063 } 064 065 if (OptEliminatePartiallyRedundantGuards.getValue()) { 066 appendPhase(new OptimizeGuardAnchorsPhase()); 067 } 068 069 if (ConditionalElimination.getValue() && OptCanonicalizer.getValue()) { 070 appendPhase(new IterativeConditionalEliminationPhase(canonicalizer, true)); 071 } 072 073 if (OptEliminatePartiallyRedundantGuards.getValue()) { 074 appendPhase(new OptimizeGuardAnchorsPhase()); 075 } 076 077 if (OptCanonicalizer.getValue()) { 078 appendPhase(canonicalizer); 079 } 080 081 appendPhase(new IncrementalCanonicalizerPhase<>(canonicalizer, new LoopSafepointEliminationPhase())); 082 083 appendPhase(new LoopSafepointInsertionPhase()); 084 085 appendPhase(new IncrementalCanonicalizerPhase<>(canonicalizer, new GuardLoweringPhase())); 086 087 if (VerifyHeapAtReturn.getValue()) { 088 appendPhase(new VerifyHeapAtReturnPhase()); 089 } 090 091 appendPhase(new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.MID_TIER)); 092 093 appendPhase(new FrameStateAssignmentPhase()); 094 095 if (ReassociateInvariants.getValue()) { 096 appendPhase(new ReassociateInvariantPhase()); 097 } 098 099 if (OptDeoptimizationGrouping.getValue()) { 100 appendPhase(new DeoptimizationGroupingPhase()); 101 } 102 103 if (OptCanonicalizer.getValue()) { 104 appendPhase(canonicalizer); 105 } 106 } 107}