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.OperationNotImplementedException; 016 import org.jikesrvm.compilers.opt.OptOptions; 017 import org.jikesrvm.compilers.opt.driver.CompilerPhase; 018 import org.jikesrvm.compilers.opt.driver.OptimizingCompiler; 019 import org.jikesrvm.compilers.opt.ir.IR; 020 021 /** 022 * Driver routine for dominator tree computation 023 */ 024 public final class DominatorTreePhase extends CompilerPhase { 025 026 @Override 027 public boolean shouldPerform(OptOptions options) { 028 // only perform if the dominators were successfully computed and 029 // one of the following options are set. 030 return options.SSA || options.PRINT_DOMINATORS; 031 } 032 033 /** 034 * Returns "Dominator Tree" 035 * @return "Dominator Tree" 036 */ 037 @Override 038 public String getName() { 039 return "Dominator Tree"; 040 } 041 042 /** 043 * Should the IR be printed before and/or after this phase? 044 * @param options controlling compiler options 045 * @param before query control 046 * @return {@code false} 047 */ 048 @Override 049 public boolean printingEnabled(OptOptions options, boolean before) { 050 return false; 051 } 052 053 @Override 054 public void perform(IR ir) { 055 // make sure the dominator computation completed successfully 056 if (!ir.HIRInfo.dominatorsAreComputed) { 057 return; 058 } 059 try { 060 DominatorTree.perform(ir, true); 061 } catch (OperationNotImplementedException e) { 062 if (ir.options.PRINT_DOMINATORS || ir.options.PRINT_SSA) { 063 OptimizingCompiler.report(e.getMessage()); 064 } 065 } 066 } 067 }