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.VM;
016    import org.jikesrvm.compilers.opt.ir.IR;
017    
018    /**
019     * Extends the functionality of a {@link LSTGraph} so that it comprises
020     * {@link AnnotatedLSTNode}s which have extra information in them.
021     *
022     * @see LSTGraph
023     * @see AnnotatedLSTNode
024     */
025    public class AnnotatedLSTGraph extends LSTGraph {
026      /**
027       * Debug messages?
028       */
029      private static final boolean DEBUG = false;
030    
031      /**
032       * Debug helper
033       * @param message debug message
034       */
035      private static void report(String message) {
036        if (DEBUG) {
037          VM.sysWrite(message);
038        }
039      }
040    
041      /**
042       * The main entry point
043       * @param ir the IR to process
044       */
045      public static void perform(IR ir) {
046        if (DEBUG) {
047          report("Creating an AnnotatedLSTGraph for " + ir.method);
048        }
049        ir.HIRInfo.loopStructureTree = new AnnotatedLSTGraph(ir, ir.HIRInfo.loopStructureTree);
050        if (DEBUG) {
051          report(ir.HIRInfo.loopStructureTree.toString());
052        }
053      }
054    
055      /**
056       * Constructor
057       *
058       * @param ir    The containing IR
059       * @param graph The {@link LSTGraph} to convert into an annotated graph
060       */
061      public AnnotatedLSTGraph(IR ir, LSTGraph graph) {
062        super(graph);
063        rootNode = new AnnotatedLSTNode(ir, rootNode);
064      }
065    }