1 /* 2 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 package org.graalvm.compiler.lir.phases; 24 25 import static org.graalvm.compiler.lir.phases.LIRPhase.Options.LIROptimization; 26 27 import org.graalvm.compiler.lir.ControlFlowOptimizer; 28 import org.graalvm.compiler.lir.EdgeMoveOptimizer; 29 import org.graalvm.compiler.lir.NullCheckOptimizer; 30 import org.graalvm.compiler.lir.RedundantMoveElimination; 31 import org.graalvm.compiler.lir.phases.PostAllocationOptimizationPhase.PostAllocationOptimizationContext; 32 import org.graalvm.compiler.lir.profiling.MethodProfilingPhase; 33 import org.graalvm.compiler.lir.profiling.MoveProfilingPhase; 34 import org.graalvm.compiler.options.NestedBooleanOptionValue; 35 import org.graalvm.compiler.options.Option; 36 import org.graalvm.compiler.options.OptionType; 37 import org.graalvm.compiler.options.OptionValue; 38 39 public class PostAllocationOptimizationStage extends LIRPhaseSuite<PostAllocationOptimizationContext> { 40 public static class Options { 41 // @formatter:off 42 @Option(help = "", type = OptionType.Debug) 43 public static final NestedBooleanOptionValue LIROptEdgeMoveOptimizer = new NestedBooleanOptionValue(LIROptimization, true); 44 @Option(help = "", type = OptionType.Debug) 45 public static final NestedBooleanOptionValue LIROptControlFlowOptimizer = new NestedBooleanOptionValue(LIROptimization, true); 46 @Option(help = "", type = OptionType.Debug) 47 public static final NestedBooleanOptionValue LIROptRedundantMoveElimination = new NestedBooleanOptionValue(LIROptimization, true); 48 @Option(help = "", type = OptionType.Debug) 49 public static final NestedBooleanOptionValue LIROptNullCheckOptimizer = new NestedBooleanOptionValue(LIROptimization, true); 50 @Option(help = "Enables profiling of move types on LIR level. " + 51 "Move types are for example stores (register to stack), " + 52 "constant loads (constant to register) or copies (register to register).", type = OptionType.Debug) 53 public static final OptionValue<Boolean> LIRProfileMoves = new OptionValue<>(false); 54 @Option(help = "Enables profiling of methods.", type = OptionType.Debug) 55 public static final OptionValue<Boolean> LIRProfileMethods = new OptionValue<>(false); 56 // @formatter:on 57 } 58 59 public PostAllocationOptimizationStage() { 60 if (Options.LIROptEdgeMoveOptimizer.getValue()) { 61 appendPhase(new EdgeMoveOptimizer()); 62 } 63 if (Options.LIROptControlFlowOptimizer.getValue()) { 64 appendPhase(new ControlFlowOptimizer()); 65 } 66 if (Options.LIROptRedundantMoveElimination.getValue()) { 67 appendPhase(new RedundantMoveElimination()); 68 } 69 if (Options.LIROptNullCheckOptimizer.getValue()) { 70 appendPhase(new NullCheckOptimizer()); 71 } 72 if (Options.LIRProfileMoves.getValue()) { 73 appendPhase(new MoveProfilingPhase()); 74 } 75 if (Options.LIRProfileMethods.getValue()) { 76 appendPhase(new MethodProfilingPhase()); 77 } 78 } 79 }