001 /*
002 * This file is part of the Jikes RVM project (http://jikesrvm.org).
003 *
004 * This file is licensed to You under the Eclipse Public License (EPL);
005 * You may not use this file except in compliance with the License. You
006 * may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/eclipse-1.0.php
009 *
010 * See the COPYRIGHT.txt file distributed with this work for information
011 * regarding copyright ownership.
012 */
013 package org.jikesrvm.compilers.opt.controlflow;
014
015 import org.jikesrvm.compilers.opt.DefUse;
016 import org.jikesrvm.compilers.opt.OptOptions;
017 import org.jikesrvm.compilers.opt.driver.CompilerPhase;
018 import org.jikesrvm.compilers.opt.ir.IR;
019
020 /**
021 * The driver that creates an annotated {@link AnnotatedLSTGraph}.
022 *
023 * @see AnnotatedLSTGraph
024 */
025 public class LoopAnalysis extends CompilerPhase {
026 /**
027 * Return a string name for this phase.
028 * @return "Loop Analysis"
029 */
030 public final String getName() {
031 return "Loop Analysis";
032 }
033
034 /**
035 * Should the optimisation be performed
036 */
037 public boolean shouldPerform(OptOptions options) {
038 return options.getOptLevel() >= 3;
039 }
040
041 /**
042 * The main entry point
043 * @param ir the IR to process
044 */
045 public final void perform(IR ir) {
046 if (!ir.hasReachableExceptionHandlers()) {
047 // Build LST tree and dominator info
048 new DominatorsPhase(false).perform(ir);
049 DefUse.computeDU(ir);
050 // Build annotated version
051 ir.HIRInfo.loopStructureTree = new AnnotatedLSTGraph(ir, ir.HIRInfo.loopStructureTree);
052 }
053 }
054 }