Commit 7dab1955 authored by Erik Brangs's avatar Erik Brangs

Move functionality for adding an empty CFG to an IR from SplitBasicBlockTest to TestingTools.

parent 92e06b9c
......@@ -14,8 +14,6 @@ package org.jikesrvm.compilers.opt.lir2mir;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.Matchers.lessThanOrEqualTo;
import static org.jikesrvm.compilers.opt.driver.OptConstants.EPILOGUE_BLOCK_BCI;
import static org.jikesrvm.compilers.opt.driver.OptConstants.PROLOGUE_BLOCK_BCI;
import static org.jikesrvm.compilers.opt.ir.Operators.FENCE;
import static org.jikesrvm.compilers.opt.ir.Operators.INT_IFCMP;
import static org.junit.Assert.assertThat;
......@@ -27,12 +25,12 @@ import org.jikesrvm.VM;
import org.jikesrvm.compilers.opt.OptOptions;
import org.jikesrvm.compilers.opt.OptimizingCompilerException;
import org.jikesrvm.compilers.opt.ir.BasicBlock;
import org.jikesrvm.compilers.opt.ir.ControlFlowGraph;
import org.jikesrvm.compilers.opt.ir.Empty;
import org.jikesrvm.compilers.opt.ir.IR;
import org.jikesrvm.compilers.opt.ir.IfCmp;
import org.jikesrvm.compilers.opt.ir.Instruction;
import org.jikesrvm.junit.runners.VMRequirements;
import org.jikesrvm.tests.util.TestingTools;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
......@@ -94,13 +92,7 @@ public class SplitBasicBlockTest {
OptOptions opts = new OptOptions();
IR ir = new IR(null, null, opts);
opts.L2M_MAX_BLOCK_SIZE = maxInstPerBlock;
ir.cfg = new ControlFlowGraph(0);
BasicBlock prologue = new BasicBlock(PROLOGUE_BLOCK_BCI, null, ir.cfg);
BasicBlock epilogue = new BasicBlock(EPILOGUE_BLOCK_BCI, null, ir.cfg);
ir.cfg.addLastInCodeOrder(prologue);
ir.cfg.addLastInCodeOrder(epilogue);
BasicBlock exit = ir.cfg.exit();
epilogue.insertOut(exit);
TestingTools.addEmptyCFGToIR(ir);
return ir;
}
......
......@@ -12,6 +12,9 @@
*/
package org.jikesrvm.tests.util;
import static org.jikesrvm.compilers.opt.driver.OptConstants.EPILOGUE_BLOCK_BCI;
import static org.jikesrvm.compilers.opt.driver.OptConstants.PROLOGUE_BLOCK_BCI;
import java.lang.reflect.Field;
import java.lang.reflect.JikesRVMSupport;
import java.lang.reflect.Method;
......@@ -25,7 +28,10 @@ import org.jikesrvm.classloader.NormalMethod;
import org.jikesrvm.classloader.RVMField;
import org.jikesrvm.classloader.RVMMethod;
import org.jikesrvm.compilers.opt.inlining.InlineSequence;
import org.jikesrvm.compilers.opt.ir.BasicBlock;
import org.jikesrvm.compilers.opt.ir.Call;
import org.jikesrvm.compilers.opt.ir.ControlFlowGraph;
import org.jikesrvm.compilers.opt.ir.IR;
import org.jikesrvm.compilers.opt.ir.Instruction;
public class TestingTools {
......@@ -82,6 +88,16 @@ public class TestingTools {
return new InlineSequence(getNormalMethod(declaringClass, methodName), node, setByteCodeIndex(ByteCodeIndex));
}
public static void addEmptyCFGToIR(IR ir) {
ir.cfg = new ControlFlowGraph(0);
BasicBlock prologue = new BasicBlock(PROLOGUE_BLOCK_BCI, null, ir.cfg);
BasicBlock epilogue = new BasicBlock(EPILOGUE_BLOCK_BCI, null, ir.cfg);
ir.cfg.addLastInCodeOrder(prologue);
ir.cfg.addLastInCodeOrder(epilogue);
BasicBlock exit = ir.cfg.exit();
epilogue.insertOut(exit);
}
public static RVMField getRVMFieldForField(Field field) {
return JikesRVMSupport.getFieldOf(field);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment