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.driver.CompilerPhase;
016    import org.jikesrvm.compilers.opt.ir.IR;
017    
018    /**
019     * A compiler phase to construct the loop structure tree (LST).
020     * The steps are (1) construct approximate dominators (ie blocks are
021     * not unfactored) and (2) build the LST.
022     *
023     * @see LTDominators
024     * @see LSTGraph
025     */
026    public class BuildLST extends CompilerPhase {
027      @Override
028      public String getName() { return "Build LST"; }
029    
030      /**
031       * This phase contains no per-compilation instance fields.
032       */
033      @Override
034      public final CompilerPhase newExecution(IR ir) {
035        return this;
036      }
037    
038      /**
039       * Build the Loop Structure Tree (LST) for the given IR.
040       * NOTE: CFG must be reducible.
041       * TODO: Detect irreducible CFG, apply node splitting and then construct LST.
042       *
043       * @param ir the IR on which to apply the phase
044       */
045      @Override
046      public void perform(IR ir) {
047        ir.cfg.compactNodeNumbering();
048        LTDominators.approximate(ir, true);
049        DominatorTree.perform(ir, true);
050        LSTGraph.perform(ir);
051      }
052    }