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 */
013package org.jikesrvm.compilers.opt.controlflow;
014
015import org.jikesrvm.compilers.opt.driver.CompilerPhase;
016import 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 */
026public class BuildLST extends CompilerPhase {
027  @Override
028  public String getName() {
029    return "Build LST";
030  }
031
032  /**
033   * This phase contains no per-compilation instance fields.
034   */
035  @Override
036  public final CompilerPhase newExecution(IR ir) {
037    return this;
038  }
039
040  /**
041   * Build the Loop Structure Tree (LST) for the given IR.
042   * NOTE: CFG must be reducible.
043   * TODO: Detect irreducible CFG, apply node splitting and then construct LST.
044   *
045   * @param ir the IR on which to apply the phase
046   */
047  @Override
048  public void perform(IR ir) {
049    ir.cfg.compactNodeNumbering();
050    LTDominators.approximate(ir, true);
051    DominatorTree.perform(ir, true);
052    LSTGraph.perform(ir);
053  }
054}