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; 014 015import java.util.Enumeration; 016 017import org.jikesrvm.compilers.opt.driver.CompilerPhase; 018import org.jikesrvm.compilers.opt.ir.Move; 019import org.jikesrvm.compilers.opt.ir.IR; 020import org.jikesrvm.compilers.opt.ir.IRTools; 021import org.jikesrvm.compilers.opt.ir.Instruction; 022import org.jikesrvm.compilers.opt.ir.Operator; 023import static org.jikesrvm.compilers.opt.ir.Operators.SPLIT; 024import org.jikesrvm.compilers.opt.ir.Unary; 025import org.jikesrvm.compilers.opt.ir.operand.Operand; 026import org.jikesrvm.compilers.opt.ir.operand.RegisterOperand; 027 028/** 029 * Change SPLIT operations inserting for live range splitting into Moves. 030 */ 031public final class MutateSplits extends CompilerPhase { 032 033 /** 034 * Return this instance of this phase. This phase contains no 035 * per-compilation instance fields. 036 * @param ir not used 037 * @return this 038 */ 039 @Override 040 public CompilerPhase newExecution(IR ir) { 041 return this; 042 } 043 044 @Override 045 public boolean shouldPerform(OptOptions options) { 046 return options.SSA_LIVE_RANGE_SPLITTING; 047 } 048 049 @Override 050 public String getName() { 051 return "Mutate Splits"; 052 } 053 054 /** 055 * The main entrypoint for this pass. 056 */ 057 @Override 058 public void perform(IR ir) { 059 for (Enumeration<Instruction> e = ir.forwardInstrEnumerator(); e.hasMoreElements();) { 060 Instruction s = e.nextElement(); 061 if (s.operator() == SPLIT) { 062 RegisterOperand lhs = Unary.getResult(s); 063 Operator mv = IRTools.getMoveOp(lhs.getType()); 064 Operand rhs = Unary.getVal(s); 065 Move.mutate(s, mv, lhs, rhs); 066 } 067 } 068 } 069}