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.*; 026import static com.oracle.graal.compiler.phases.HighTier.Options.*; 027import static com.oracle.graal.phases.common.DeadCodeEliminationPhase.Optionality.*; 028import jdk.internal.jvmci.options.*; 029 030import com.oracle.graal.loop.phases.*; 031import com.oracle.graal.nodes.spi.*; 032import com.oracle.graal.phases.*; 033import com.oracle.graal.phases.common.*; 034import com.oracle.graal.phases.common.inlining.*; 035import com.oracle.graal.phases.tiers.*; 036import com.oracle.graal.virtual.phases.ea.*; 037 038public class HighTier extends PhaseSuite<HighTierContext> { 039 040 public static class Options { 041 042 // @formatter:off 043 @Option(help = "Enable inlining", type = OptionType.Expert) 044 public static final OptionValue<Boolean> Inline = new OptionValue<>(true); 045 // @formatter:on 046 } 047 048 public HighTier() { 049 CanonicalizerPhase canonicalizer = new CanonicalizerPhase(); 050 if (ImmutableCode.getValue()) { 051 canonicalizer.disableReadCanonicalization(); 052 } 053 054 if (OptCanonicalizer.getValue()) { 055 appendPhase(canonicalizer); 056 } 057 058 if (Inline.getValue()) { 059 appendPhase(new InliningPhase(canonicalizer)); 060 appendPhase(new DeadCodeEliminationPhase(Optional)); 061 062 if (ConditionalElimination.getValue() && OptCanonicalizer.getValue()) { 063 appendPhase(canonicalizer); 064 appendPhase(new IterativeConditionalEliminationPhase(canonicalizer, false)); 065 } 066 } 067 068 if (OptConvertDeoptsToGuards.getValue()) { 069 appendPhase(new ConvertDeoptimizeToGuardPhase()); 070 } 071 072 if (FullUnroll.getValue()) { 073 appendPhase(new LoopFullUnrollPhase(canonicalizer)); 074 } 075 076 if (OptLoopTransform.getValue()) { 077 if (LoopPeeling.getValue()) { 078 appendPhase(new LoopPeelingPhase()); 079 } 080 if (LoopUnswitch.getValue()) { 081 appendPhase(new LoopUnswitchingPhase()); 082 } 083 } 084 085 if (OptCanonicalizer.getValue()) { 086 appendPhase(canonicalizer); 087 } 088 089 if (PartialEscapeAnalysis.getValue()) { 090 appendPhase(new PartialEscapePhase(true, canonicalizer)); 091 } 092 appendPhase(new RemoveValueProxyPhase()); 093 094 appendPhase(new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.HIGH_TIER)); 095 } 096}