# HG changeset patch # User Josef Eisl # Date 1413444374 -7200 # Node ID 35ae3e9165822339e78a829c7fed646d9dcf1ff6 # Parent a2ad508b8723e8e1194eb69a146fe187fb874bed Make LIRInstruction an interface. diff -r a2ad508b8723 -r 35ae3e916582 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64IndirectCallOp.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64IndirectCallOp.java Wed Oct 15 17:31:48 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64IndirectCallOp.java Thu Oct 16 09:26:14 2014 +0200 @@ -65,7 +65,7 @@ } @Override - protected void verify() { + public void verify() { super.verify(); assert asRegister(metaspaceMethod).equals(METHOD); } diff -r a2ad508b8723 -r 35ae3e916582 graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCIndirectCallOp.java --- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCIndirectCallOp.java Wed Oct 15 17:31:48 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCIndirectCallOp.java Thu Oct 16 09:26:14 2014 +0200 @@ -65,7 +65,7 @@ } @Override - protected void verify() { + public void verify() { super.verify(); assert asRegister(metaspaceMethod).equals(METHOD); } diff -r a2ad508b8723 -r 35ae3e916582 graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Arithmetic.java --- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Arithmetic.java Wed Oct 15 17:31:48 2014 +0200 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Arithmetic.java Thu Oct 16 09:26:14 2014 +0200 @@ -306,7 +306,7 @@ } @Override - protected void verify() { + public void verify() { super.verify(); verifyKind(opcode, result, x, y); } @@ -422,7 +422,7 @@ } @Override - protected void verify() { + public void verify() { super.verify(); // left input in rax, right input in any register but rax and rdx, result quotient in // rax, result remainder in rdx @@ -487,7 +487,7 @@ } @Override - protected void verify() { + public void verify() { super.verify(); verifyKind(opcode, result, x, y); } diff -r a2ad508b8723 -r 35ae3e916582 graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Call.java --- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Call.java Wed Oct 15 17:31:48 2014 +0200 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Call.java Thu Oct 16 09:26:14 2014 +0200 @@ -96,7 +96,7 @@ } @Override - protected void verify() { + public void verify() { super.verify(); assert isRegister(targetAddress) : "The current register allocator cannot handle variables to be used at call sites, it must be in a fixed register for now"; } diff -r a2ad508b8723 -r 35ae3e916582 graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Compare.java --- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Compare.java Wed Oct 15 17:31:48 2014 +0200 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Compare.java Thu Oct 16 09:26:14 2014 +0200 @@ -59,7 +59,7 @@ } @Override - protected void verify() { + public void verify() { super.verify(); assert (name().startsWith("B") && x.getKind().getStackKind() == Kind.Int && y.getKind().getStackKind() == Kind.Int) || (name().startsWith("S") && x.getKind().getStackKind() == Kind.Int && y.getKind().getStackKind() == Kind.Int) || @@ -146,7 +146,7 @@ } @Override - protected void verify() { + public void verify() { super.verify(); assert y instanceof Variable || y instanceof Constant; assert kind != Kind.Long || !(y instanceof Constant) || NumUtil.isInt(((Constant) y).asLong()); diff -r a2ad508b8723 -r 35ae3e916582 graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64LIRInstruction.java --- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64LIRInstruction.java Wed Oct 15 17:31:48 2014 +0200 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64LIRInstruction.java Thu Oct 16 09:26:14 2014 +0200 @@ -29,7 +29,7 @@ /** * Convenience class to provide AMD64MacroAssembler for the {@link #emitCode} method. */ -public abstract class AMD64LIRInstruction extends LIRInstruction { +public abstract class AMD64LIRInstruction extends LIRInstructionBase { @Override public final void emitCode(CompilationResultBuilder crb) { diff -r a2ad508b8723 -r 35ae3e916582 graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64TestMemoryOp.java --- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64TestMemoryOp.java Wed Oct 15 17:31:48 2014 +0200 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64TestMemoryOp.java Thu Oct 16 09:26:14 2014 +0200 @@ -72,7 +72,7 @@ } @Override - protected void verify() { + public void verify() { super.verify(); assert (kind == Kind.Int || kind == Kind.Long) && kind == y.getKind() : address + " " + y; } diff -r a2ad508b8723 -r 35ae3e916582 graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64TestOp.java --- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64TestOp.java Wed Oct 15 17:31:48 2014 +0200 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64TestOp.java Thu Oct 16 09:26:14 2014 +0200 @@ -46,7 +46,7 @@ } @Override - protected void verify() { + public void verify() { super.verify(); assert (x.getKind() == Kind.Int && y.getKind().getStackKind() == Kind.Int) || (x.getKind() == Kind.Long && y.getKind() == Kind.Long) : x + " " + y; } diff -r a2ad508b8723 -r 35ae3e916582 graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILArithmetic.java --- a/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILArithmetic.java Wed Oct 15 17:31:48 2014 +0200 +++ b/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILArithmetic.java Thu Oct 16 09:26:14 2014 +0200 @@ -212,7 +212,7 @@ } @Override - protected void verify() { + public void verify() { super.verify(); verifyKind(opcode, result, x, y); } diff -r a2ad508b8723 -r 35ae3e916582 graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILCompare.java --- a/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILCompare.java Wed Oct 15 17:31:48 2014 +0200 +++ b/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILCompare.java Thu Oct 16 09:26:14 2014 +0200 @@ -70,7 +70,7 @@ } @Override - protected void verify() { + public void verify() { super.verify(); assert (x.getKind() == y.getKind() && ((name().startsWith("I") && x.getKind() == Kind.Int) || (name().startsWith("L") && x.getKind() == Kind.Long) || (name().startsWith("A") && x.getKind() == Kind.Object) || (name().startsWith("F") && x.getKind() == Kind.Float) || (name().startsWith("D") && x.getKind() == Kind.Double))); diff -r a2ad508b8723 -r 35ae3e916582 graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILLIRInstruction.java --- a/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILLIRInstruction.java Wed Oct 15 17:31:48 2014 +0200 +++ b/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILLIRInstruction.java Thu Oct 16 09:26:14 2014 +0200 @@ -29,7 +29,7 @@ /** * Convenience class to provide HSAILAssembler for the {@link #emitCode} method. */ -public abstract class HSAILLIRInstruction extends LIRInstruction { +public abstract class HSAILLIRInstruction extends LIRInstructionBase { @Override public final void emitCode(CompilationResultBuilder crb) { diff -r a2ad508b8723 -r 35ae3e916582 graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXArithmetic.java --- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXArithmetic.java Wed Oct 15 17:31:48 2014 +0200 +++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXArithmetic.java Thu Oct 16 09:26:14 2014 +0200 @@ -173,7 +173,7 @@ } @Override - protected void verify() { + public void verify() { super.verify(); verifyKind(opcode, result, x, y); } @@ -226,7 +226,7 @@ } @Override - protected void verify() { + public void verify() { super.verify(); verifyKind(opcode, result, x, y); } diff -r a2ad508b8723 -r 35ae3e916582 graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXCompare.java --- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXCompare.java Wed Oct 15 17:31:48 2014 +0200 +++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXCompare.java Thu Oct 16 09:26:14 2014 +0200 @@ -63,7 +63,7 @@ } @Override - protected void verify() { + public void verify() { super.verify(); assert (name().startsWith("I") && x.getKind() == Kind.Int && y.getKind().getStackKind() == Kind.Int) || (name().startsWith("L") && x.getKind() == Kind.Long && y.getKind() == Kind.Long) || (name().startsWith("A") && x.getKind() == Kind.Object && y.getKind() == Kind.Object) || diff -r a2ad508b8723 -r 35ae3e916582 graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXLIRInstruction.java --- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXLIRInstruction.java Wed Oct 15 17:31:48 2014 +0200 +++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXLIRInstruction.java Thu Oct 16 09:26:14 2014 +0200 @@ -29,7 +29,7 @@ /** * Convenience class to provide PTXAssembler for the {@link #emitCode} method. */ -public abstract class PTXLIRInstruction extends LIRInstruction { +public abstract class PTXLIRInstruction extends LIRInstructionBase { @Override public final void emitCode(CompilationResultBuilder crb) { diff -r a2ad508b8723 -r 35ae3e916582 graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXParameterOp.java --- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXParameterOp.java Wed Oct 15 17:31:48 2014 +0200 +++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXParameterOp.java Thu Oct 16 09:26:14 2014 +0200 @@ -31,7 +31,7 @@ import com.oracle.graal.lir.*; import com.oracle.graal.lir.asm.*; -public class PTXParameterOp extends LIRInstruction { +public class PTXParameterOp extends LIRInstructionBase { @Def({REG}) protected Value[] params; // True if the parameter list has return argument as the last diff -r a2ad508b8723 -r 35ae3e916582 graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXTestOp.java --- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXTestOp.java Wed Oct 15 17:31:48 2014 +0200 +++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXTestOp.java Thu Oct 16 09:26:14 2014 +0200 @@ -49,7 +49,7 @@ } @Override - protected void verify() { + public void verify() { super.verify(); assert (x.getKind() == Kind.Int && y.getKind().getStackKind() == Kind.Int) || (x.getKind() == Kind.Long && y.getKind() == Kind.Long) : x + " " + y; } diff -r a2ad508b8723 -r 35ae3e916582 graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCArithmetic.java --- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCArithmetic.java Wed Oct 15 17:31:48 2014 +0200 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCArithmetic.java Thu Oct 16 09:26:14 2014 +0200 @@ -169,7 +169,7 @@ } @Override - protected void verify() { + public void verify() { super.verify(); verifyKind(opcode, result, x, y); } diff -r a2ad508b8723 -r 35ae3e916582 graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCCall.java --- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCCall.java Wed Oct 15 17:31:48 2014 +0200 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCCall.java Thu Oct 16 09:26:14 2014 +0200 @@ -137,7 +137,7 @@ } @Override - protected void verify() { + public void verify() { super.verify(); assert isRegister(targetAddress) : "The current register allocator cannot handle variables to be used at call sites, it must be in a fixed register for now"; } diff -r a2ad508b8723 -r 35ae3e916582 graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCCompare.java --- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCCompare.java Wed Oct 15 17:31:48 2014 +0200 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCCompare.java Thu Oct 16 09:26:14 2014 +0200 @@ -58,7 +58,7 @@ } @Override - protected void verify() { + public void verify() { super.verify(); // @formatter:off assert (name().startsWith("I") && diff -r a2ad508b8723 -r 35ae3e916582 graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCLIRInstruction.java --- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCLIRInstruction.java Wed Oct 15 17:31:48 2014 +0200 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCLIRInstruction.java Thu Oct 16 09:26:14 2014 +0200 @@ -29,7 +29,7 @@ /** * Convenience class to provide SPARCMacroAssembler for the {@link #emitCode} method. */ -public abstract class SPARCLIRInstruction extends LIRInstruction { +public abstract class SPARCLIRInstruction extends LIRInstructionBase { protected SPARCDelayedControlTransfer delayedControlTransfer = SPARCDelayedControlTransfer.DUMMY; @Override diff -r a2ad508b8723 -r 35ae3e916582 graal/com.oracle.graal.lir.test/src/com/oracle/graal/lir/test/CompositeValueReplacementTest1.java --- a/graal/com.oracle.graal.lir.test/src/com/oracle/graal/lir/test/CompositeValueReplacementTest1.java Wed Oct 15 17:31:48 2014 +0200 +++ b/graal/com.oracle.graal.lir.test/src/com/oracle/graal/lir/test/CompositeValueReplacementTest1.java Thu Oct 16 09:26:14 2014 +0200 @@ -94,7 +94,7 @@ } - private static class TestOp extends LIRInstruction { + private static class TestOp extends LIRInstructionBase { @Use({COMPOSITE}) protected NestedCompositeValue compValue; diff -r a2ad508b8723 -r 35ae3e916582 graal/com.oracle.graal.lir.test/src/com/oracle/graal/lir/test/CompositeValueReplacementTest2.java --- a/graal/com.oracle.graal.lir.test/src/com/oracle/graal/lir/test/CompositeValueReplacementTest2.java Wed Oct 15 17:31:48 2014 +0200 +++ b/graal/com.oracle.graal.lir.test/src/com/oracle/graal/lir/test/CompositeValueReplacementTest2.java Thu Oct 16 09:26:14 2014 +0200 @@ -95,7 +95,7 @@ } - private static class TestOp extends LIRInstruction { + private static class TestOp extends LIRInstructionBase { @Use({COMPOSITE}) protected NestedCompositeValue compValue; diff -r a2ad508b8723 -r 35ae3e916582 graal/com.oracle.graal.lir.test/src/com/oracle/graal/lir/test/CompositeValueReplacementTest3.java --- a/graal/com.oracle.graal.lir.test/src/com/oracle/graal/lir/test/CompositeValueReplacementTest3.java Wed Oct 15 17:31:48 2014 +0200 +++ b/graal/com.oracle.graal.lir.test/src/com/oracle/graal/lir/test/CompositeValueReplacementTest3.java Thu Oct 16 09:26:14 2014 +0200 @@ -95,7 +95,7 @@ } - private static class TestOp extends LIRInstruction { + private static class TestOp extends LIRInstructionBase { @Use({COMPOSITE}) protected NestedCompositeValue compValue; diff -r a2ad508b8723 -r 35ae3e916582 graal/com.oracle.graal.lir.test/src/com/oracle/graal/lir/test/CompositeValueReplacementTest4.java --- a/graal/com.oracle.graal.lir.test/src/com/oracle/graal/lir/test/CompositeValueReplacementTest4.java Wed Oct 15 17:31:48 2014 +0200 +++ b/graal/com.oracle.graal.lir.test/src/com/oracle/graal/lir/test/CompositeValueReplacementTest4.java Thu Oct 16 09:26:14 2014 +0200 @@ -95,7 +95,7 @@ } - private static class TestOp extends LIRInstruction { + private static class TestOp extends LIRInstructionBase { @Use({COMPOSITE}) protected NestedCompositeValue compValue; diff -r a2ad508b8723 -r 35ae3e916582 graal/com.oracle.graal.lir.test/src/com/oracle/graal/lir/test/ValuePositionTest1.java --- a/graal/com.oracle.graal.lir.test/src/com/oracle/graal/lir/test/ValuePositionTest1.java Wed Oct 15 17:31:48 2014 +0200 +++ b/graal/com.oracle.graal.lir.test/src/com/oracle/graal/lir/test/ValuePositionTest1.java Thu Oct 16 09:26:14 2014 +0200 @@ -86,7 +86,7 @@ } } - private static class TestOp extends LIRInstruction { + private static class TestOp extends LIRInstructionBase { @Use({COMPOSITE}) protected NestedCompositeValue compValue; diff -r a2ad508b8723 -r 35ae3e916582 graal/com.oracle.graal.lir.test/src/com/oracle/graal/lir/test/ValuePositionTest2.java --- a/graal/com.oracle.graal.lir.test/src/com/oracle/graal/lir/test/ValuePositionTest2.java Wed Oct 15 17:31:48 2014 +0200 +++ b/graal/com.oracle.graal.lir.test/src/com/oracle/graal/lir/test/ValuePositionTest2.java Thu Oct 16 09:26:14 2014 +0200 @@ -88,7 +88,7 @@ } } - private static class TestOp extends LIRInstruction { + private static class TestOp extends LIRInstructionBase { @Use({COMPOSITE}) protected NestedCompositeValue compValue; diff -r a2ad508b8723 -r 35ae3e916582 graal/com.oracle.graal.lir.test/src/com/oracle/graal/lir/test/ValuePositionTest3.java --- a/graal/com.oracle.graal.lir.test/src/com/oracle/graal/lir/test/ValuePositionTest3.java Wed Oct 15 17:31:48 2014 +0200 +++ b/graal/com.oracle.graal.lir.test/src/com/oracle/graal/lir/test/ValuePositionTest3.java Thu Oct 16 09:26:14 2014 +0200 @@ -99,7 +99,7 @@ } - private static class TestOp extends LIRInstruction { + private static class TestOp extends LIRInstructionBase { @Use({COMPOSITE}) protected Value value; diff -r a2ad508b8723 -r 35ae3e916582 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/FullInfopointOp.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/FullInfopointOp.java Wed Oct 15 17:31:48 2014 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/FullInfopointOp.java Thu Oct 16 09:26:14 2014 +0200 @@ -29,7 +29,7 @@ * Emits an infopoint (only mark the position). */ @Opcode("INFOPOINT") -public class FullInfopointOp extends LIRInstruction { +public class FullInfopointOp extends LIRInstructionBase { @State protected LIRFrameState state; diff -r a2ad508b8723 -r 35ae3e916582 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRInstruction.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRInstruction.java Wed Oct 15 17:31:48 2014 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRInstruction.java Thu Oct 16 09:26:14 2014 +0200 @@ -23,27 +23,23 @@ package com.oracle.graal.lir; import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*; -import static com.oracle.graal.lir.LIRInstruction.OperandMode.*; import java.lang.annotation.*; -import java.util.*; import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; -import com.oracle.graal.debug.*; import com.oracle.graal.lir.asm.*; /** - * The {@code LIRInstruction} class definition. + * The {@code LIRInstruction} interface definition. */ -public abstract class LIRInstruction { - - public static final Value[] NO_OPERANDS = {}; +public interface LIRInstruction { + static final Value[] NO_OPERANDS = {}; /** * Constants denoting how a LIR instruction uses an operand. */ - public enum OperandMode { + enum OperandMode { /** * The value must have been defined before. It is alive before the instruction until the * beginning of the instruction, but not necessarily throughout the instruction. A register @@ -76,41 +72,41 @@ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) - public static @interface Use { + static @interface Use { OperandFlag[] value() default REG; } @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) - public static @interface Alive { + static @interface Alive { OperandFlag[] value() default REG; } @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) - public static @interface Temp { + static @interface Temp { OperandFlag[] value() default REG; } @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) - public static @interface Def { + static @interface Def { OperandFlag[] value() default REG; } @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) - public static @interface State { + static @interface State { } /** * Flags for an operand. */ - public enum OperandFlag { + enum OperandFlag { /** * The value can be a {@link RegisterValue}. */ @@ -149,183 +145,83 @@ UNINITIALIZED, } - /** - * For validity checking of the operand flags defined by instruction subclasses. - */ - protected static final EnumMap> ALLOWED_FLAGS; - - static { - ALLOWED_FLAGS = new EnumMap<>(OperandMode.class); - ALLOWED_FLAGS.put(USE, EnumSet.of(REG, STACK, COMPOSITE, CONST, ILLEGAL, HINT, UNINITIALIZED)); - ALLOWED_FLAGS.put(ALIVE, EnumSet.of(REG, STACK, COMPOSITE, CONST, ILLEGAL, HINT, UNINITIALIZED)); - ALLOWED_FLAGS.put(TEMP, EnumSet.of(REG, COMPOSITE, CONST, ILLEGAL, HINT)); - ALLOWED_FLAGS.put(DEF, EnumSet.of(REG, STACK, COMPOSITE, ILLEGAL, HINT)); - } - - /** - * The flags of the base and index value of an address. - */ - protected static final EnumSet ADDRESS_FLAGS = EnumSet.of(REG, ILLEGAL); - - private final LIRInstructionClass instructionClass; + void emitCode(CompilationResultBuilder crb); - /** - * Instruction id for register allocation. - */ - private int id; - - private static final DebugMetric LIR_NODE_COUNT = Debug.metric("LIRNodes"); + int id(); - /** - * Constructs a new LIR instruction. - */ - public LIRInstruction() { - LIR_NODE_COUNT.increment(); - instructionClass = LIRInstructionClass.get(getClass()); - id = -1; - } - - public abstract void emitCode(CompilationResultBuilder crb); - - public final int id() { - return id; - } - - public final void setId(int id) { - this.id = id; - } + void setId(int id); /** * Gets the instruction name. */ - public final String name() { - return instructionClass.getOpcode(this); - } + String name(); - public final boolean hasOperands() { - return instructionClass.hasOperands() || hasState() || destroysCallerSavedRegisters(); - } + boolean hasOperands(); - public final boolean hasState() { - return instructionClass.hasState(this); - } + boolean hasState(); /** * Determines if this instruction destroys all caller-saved registers.. */ - public boolean destroysCallerSavedRegisters() { - return false; - } + boolean destroysCallerSavedRegisters(); // ValuePositionProcedures - public final void forEachInputPos(ValuePositionProcedure proc) { - instructionClass.forEachUsePos(this, proc); - } + void forEachInputPos(ValuePositionProcedure proc); - public final void forEachAlivePos(ValuePositionProcedure proc) { - instructionClass.forEachAlivePos(this, proc); - } + void forEachAlivePos(ValuePositionProcedure proc); - public final void forEachTempPos(ValuePositionProcedure proc) { - instructionClass.forEachTempPos(this, proc); - } + void forEachTempPos(ValuePositionProcedure proc); - public final void forEachOutputPos(ValuePositionProcedure proc) { - instructionClass.forEachDefPos(this, proc); - } + void forEachOutputPos(ValuePositionProcedure proc); // InstructionValueProcedures - public final void forEachInput(InstructionValueProcedure proc) { - instructionClass.forEachUse(this, proc); - } + void forEachInput(InstructionValueProcedure proc); - public final void forEachAlive(InstructionValueProcedure proc) { - instructionClass.forEachAlive(this, proc); - } + void forEachAlive(InstructionValueProcedure proc); - public final void forEachTemp(InstructionValueProcedure proc) { - instructionClass.forEachTemp(this, proc); - } + void forEachTemp(InstructionValueProcedure proc); - public final void forEachOutput(InstructionValueProcedure proc) { - instructionClass.forEachDef(this, proc); - } + void forEachOutput(InstructionValueProcedure proc); - public final void forEachState(InstructionValueProcedure proc) { - instructionClass.forEachState(this, proc); - } + void forEachState(InstructionValueProcedure proc); // ValueProcedures - public final void forEachInput(ValueProcedure proc) { - instructionClass.forEachUse(this, proc); - } + void forEachInput(ValueProcedure proc); - public final void forEachAlive(ValueProcedure proc) { - instructionClass.forEachAlive(this, proc); - } + void forEachAlive(ValueProcedure proc); - public final void forEachTemp(ValueProcedure proc) { - instructionClass.forEachTemp(this, proc); - } + void forEachTemp(ValueProcedure proc); - public final void forEachOutput(ValueProcedure proc) { - instructionClass.forEachDef(this, proc); - } + void forEachOutput(ValueProcedure proc); - public final void forEachState(ValueProcedure proc) { - instructionClass.forEachState(this, proc); - } + void forEachState(ValueProcedure proc); // States - public final void forEachState(InstructionStateProcedure proc) { - instructionClass.forEachState(this, proc); - } + void forEachState(InstructionStateProcedure proc); - public final void forEachState(StateProcedure proc) { - instructionClass.forEachState(this, proc); - } + void forEachState(StateProcedure proc); // InstructionValueConsumers - public final void visitEachInput(InstructionValueConsumer proc) { - instructionClass.forEachUse(this, proc); - } + void visitEachInput(InstructionValueConsumer proc); - public final void visitEachAlive(InstructionValueConsumer proc) { - instructionClass.forEachAlive(this, proc); - } + void visitEachAlive(InstructionValueConsumer proc); - public final void visitEachTemp(InstructionValueConsumer proc) { - instructionClass.forEachTemp(this, proc); - } + void visitEachTemp(InstructionValueConsumer proc); - public final void visitEachOutput(InstructionValueConsumer proc) { - instructionClass.forEachDef(this, proc); - } + void visitEachOutput(InstructionValueConsumer proc); - public final void visitEachState(InstructionValueConsumer proc) { - instructionClass.forEachState(this, proc); - } + void visitEachState(InstructionValueConsumer proc); // ValueConsumers - public final void visitEachInput(ValueConsumer proc) { - instructionClass.forEachUse(this, proc); - } + void visitEachInput(ValueConsumer proc); - public final void visitEachAlive(ValueConsumer proc) { - instructionClass.forEachAlive(this, proc); - } + void visitEachAlive(ValueConsumer proc); - public final void visitEachTemp(ValueConsumer proc) { - instructionClass.forEachTemp(this, proc); - } + void visitEachTemp(ValueConsumer proc); - public final void visitEachOutput(ValueConsumer proc) { - instructionClass.forEachDef(this, proc); - } + void visitEachOutput(ValueConsumer proc); - public final void visitEachState(ValueConsumer proc) { - instructionClass.forEachState(this, proc); - } + void visitEachState(ValueConsumer proc); /** * Iterates all register hints for the specified value, i.e., all preferred candidates for the @@ -342,9 +238,7 @@ * clients can stop the iteration once a suitable hint has been found. * @return The non-null value returned by the procedure, or null. */ - public Value forEachRegisterHint(Value value, OperandMode mode, InstructionValueProcedure proc) { - return instructionClass.forEachRegisterHint(this, mode, proc); - } + Value forEachRegisterHint(Value value, OperandMode mode, InstructionValueProcedure proc); /** * @see #forEachRegisterHint(Value, OperandMode, InstructionValueProcedure) @@ -355,26 +249,11 @@ * clients can stop the iteration once a suitable hint has been found. * @return The non-null value returned by the procedure, or null. */ - public Value forEachRegisterHint(Value value, OperandMode mode, ValueProcedure proc) { - return instructionClass.forEachRegisterHint(this, mode, proc); - } + Value forEachRegisterHint(Value value, OperandMode mode, ValueProcedure proc); - protected void verify() { - } + String toStringWithIdPrefix(); - public final String toStringWithIdPrefix() { - if (id != -1) { - return String.format("%4d %s", id, toString()); - } - return " " + toString(); - } + void verify(); - @Override - public String toString() { - return instructionClass.toString(this); - } - - public LIRInstructionClass getLIRInstructionClass() { - return instructionClass; - } + LIRInstructionClass getLIRInstructionClass(); } diff -r a2ad508b8723 -r 35ae3e916582 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRInstructionBase.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRInstructionBase.java Thu Oct 16 09:26:14 2014 +0200 @@ -0,0 +1,237 @@ +/* + * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.lir; + +import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*; +import static com.oracle.graal.lir.LIRInstruction.OperandMode.*; + +import java.util.*; + +import com.oracle.graal.api.meta.*; +import com.oracle.graal.debug.*; +import com.oracle.graal.lir.asm.*; + +/** + * The base class for an {@code LIRInstruction}. + */ +public abstract class LIRInstructionBase implements LIRInstruction { + + /** + * For validity checking of the operand flags defined by instruction subclasses. + */ + protected static final EnumMap> ALLOWED_FLAGS; + + static { + ALLOWED_FLAGS = new EnumMap<>(OperandMode.class); + ALLOWED_FLAGS.put(USE, EnumSet.of(REG, STACK, COMPOSITE, CONST, ILLEGAL, HINT, UNINITIALIZED)); + ALLOWED_FLAGS.put(ALIVE, EnumSet.of(REG, STACK, COMPOSITE, CONST, ILLEGAL, HINT, UNINITIALIZED)); + ALLOWED_FLAGS.put(TEMP, EnumSet.of(REG, COMPOSITE, CONST, ILLEGAL, HINT)); + ALLOWED_FLAGS.put(DEF, EnumSet.of(REG, STACK, COMPOSITE, ILLEGAL, HINT)); + } + + /** + * The flags of the base and index value of an address. + */ + protected static final EnumSet ADDRESS_FLAGS = EnumSet.of(REG, ILLEGAL); + + private final LIRInstructionClass instructionClass; + + /** + * Instruction id for register allocation. + */ + private int id; + + private static final DebugMetric LIR_NODE_COUNT = Debug.metric("LIRNodes"); + + /** + * Constructs a new LIR instruction. + */ + public LIRInstructionBase() { + LIR_NODE_COUNT.increment(); + instructionClass = LIRInstructionClass.get(getClass()); + id = -1; + } + + public abstract void emitCode(CompilationResultBuilder crb); + + public final int id() { + return id; + } + + public final void setId(int id) { + this.id = id; + } + + public final String name() { + return instructionClass.getOpcode(this); + } + + public final boolean hasOperands() { + return instructionClass.hasOperands() || hasState() || destroysCallerSavedRegisters(); + } + + public final boolean hasState() { + return instructionClass.hasState(this); + } + + public boolean destroysCallerSavedRegisters() { + return false; + } + + // ValuePositionProcedures + public final void forEachInputPos(ValuePositionProcedure proc) { + instructionClass.forEachUsePos(this, proc); + } + + public final void forEachAlivePos(ValuePositionProcedure proc) { + instructionClass.forEachAlivePos(this, proc); + } + + public final void forEachTempPos(ValuePositionProcedure proc) { + instructionClass.forEachTempPos(this, proc); + } + + public final void forEachOutputPos(ValuePositionProcedure proc) { + instructionClass.forEachDefPos(this, proc); + } + + // InstructionValueProcedures + public final void forEachInput(InstructionValueProcedure proc) { + instructionClass.forEachUse(this, proc); + } + + public final void forEachAlive(InstructionValueProcedure proc) { + instructionClass.forEachAlive(this, proc); + } + + public final void forEachTemp(InstructionValueProcedure proc) { + instructionClass.forEachTemp(this, proc); + } + + public final void forEachOutput(InstructionValueProcedure proc) { + instructionClass.forEachDef(this, proc); + } + + public final void forEachState(InstructionValueProcedure proc) { + instructionClass.forEachState(this, proc); + } + + // ValueProcedures + public final void forEachInput(ValueProcedure proc) { + instructionClass.forEachUse(this, proc); + } + + public final void forEachAlive(ValueProcedure proc) { + instructionClass.forEachAlive(this, proc); + } + + public final void forEachTemp(ValueProcedure proc) { + instructionClass.forEachTemp(this, proc); + } + + public final void forEachOutput(ValueProcedure proc) { + instructionClass.forEachDef(this, proc); + } + + public final void forEachState(ValueProcedure proc) { + instructionClass.forEachState(this, proc); + } + + // States + public final void forEachState(InstructionStateProcedure proc) { + instructionClass.forEachState(this, proc); + } + + public final void forEachState(StateProcedure proc) { + instructionClass.forEachState(this, proc); + } + + // InstructionValueConsumers + public final void visitEachInput(InstructionValueConsumer proc) { + instructionClass.forEachUse(this, proc); + } + + public final void visitEachAlive(InstructionValueConsumer proc) { + instructionClass.forEachAlive(this, proc); + } + + public final void visitEachTemp(InstructionValueConsumer proc) { + instructionClass.forEachTemp(this, proc); + } + + public final void visitEachOutput(InstructionValueConsumer proc) { + instructionClass.forEachDef(this, proc); + } + + public final void visitEachState(InstructionValueConsumer proc) { + instructionClass.forEachState(this, proc); + } + + // ValueConsumers + public final void visitEachInput(ValueConsumer proc) { + instructionClass.forEachUse(this, proc); + } + + public final void visitEachAlive(ValueConsumer proc) { + instructionClass.forEachAlive(this, proc); + } + + public final void visitEachTemp(ValueConsumer proc) { + instructionClass.forEachTemp(this, proc); + } + + public final void visitEachOutput(ValueConsumer proc) { + instructionClass.forEachDef(this, proc); + } + + public final void visitEachState(ValueConsumer proc) { + instructionClass.forEachState(this, proc); + } + + public Value forEachRegisterHint(Value value, OperandMode mode, InstructionValueProcedure proc) { + return instructionClass.forEachRegisterHint(this, mode, proc); + } + + public Value forEachRegisterHint(Value value, OperandMode mode, ValueProcedure proc) { + return instructionClass.forEachRegisterHint(this, mode, proc); + } + + public void verify() { + } + + public final String toStringWithIdPrefix() { + if (id != -1) { + return String.format("%4d %s", id, toString()); + } + return " " + toString(); + } + + @Override + public String toString() { + return instructionClass.toString(this); + } + + public LIRInstructionClass getLIRInstructionClass() { + return instructionClass; + } +} diff -r a2ad508b8723 -r 35ae3e916582 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRIntrospection.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRIntrospection.java Wed Oct 15 17:31:48 2014 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRIntrospection.java Thu Oct 16 09:26:14 2014 +0200 @@ -202,7 +202,7 @@ protected static void forEach(LIRInstruction inst, Values values, OperandMode mode, InstructionValueProcedure proc) { for (int i = 0; i < values.getCount(); i++) { - assert LIRInstruction.ALLOWED_FLAGS.get(mode).containsAll(values.getFlags(i)); + assert LIRInstructionBase.ALLOWED_FLAGS.get(mode).containsAll(values.getFlags(i)); if (i < values.getDirectCount()) { Value value = values.getValue(inst, i); @@ -238,7 +238,7 @@ protected static CompositeValue forEachComponent(LIRInstruction inst, CompositeValue obj, Values values, OperandMode mode, InstructionValueProcedure proc) { CompositeValue newCompValue = null; for (int i = 0; i < values.getCount(); i++) { - assert LIRInstruction.ALLOWED_FLAGS.get(mode).containsAll(values.getFlags(i)); + assert LIRInstructionBase.ALLOWED_FLAGS.get(mode).containsAll(values.getFlags(i)); if (i < values.getDirectCount()) { Value value = values.getValue(obj, i); @@ -286,7 +286,7 @@ protected static void forEach(LIRInstruction inst, Object obj, Values values, OperandMode mode, ValuePositionProcedure proc, ValuePosition outerPosition) { for (int i = 0; i < values.getCount(); i++) { - assert LIRInstruction.ALLOWED_FLAGS.get(mode).containsAll(values.getFlags(i)); + assert LIRInstructionBase.ALLOWED_FLAGS.get(mode).containsAll(values.getFlags(i)); if (i < values.getDirectCount()) { Value value = values.getValue(obj, i); diff -r a2ad508b8723 -r 35ae3e916582 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/SimpleInfopointOp.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/SimpleInfopointOp.java Wed Oct 15 17:31:48 2014 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/SimpleInfopointOp.java Thu Oct 16 09:26:14 2014 +0200 @@ -26,7 +26,7 @@ import com.oracle.graal.lir.asm.*; @Opcode("SIMPLE_INFOPOINT") -public class SimpleInfopointOp extends LIRInstruction { +public class SimpleInfopointOp extends LIRInstructionBase { private final InfopointReason reason; private final BytecodePosition position; diff -r a2ad508b8723 -r 35ae3e916582 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/StandardOp.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/StandardOp.java Wed Oct 15 17:31:48 2014 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/StandardOp.java Thu Oct 16 09:26:14 2014 +0200 @@ -43,23 +43,23 @@ * A block delimiter. Every well formed block must contain exactly one such operation and it * must be the last operation in the block. */ - public interface BlockEndOp { + public interface BlockEndOp extends LIRInstruction { } - public interface NullCheck { + public interface NullCheck extends LIRInstruction { Value getCheckedValue(); LIRFrameState getState(); } - public interface ImplicitNullCheck { + public interface ImplicitNullCheck extends LIRInstruction { boolean makeNullCheckFor(Value value, LIRFrameState nullCheckState, int implicitNullCheckLimit); } /** * LIR operation that defines the position of a label. */ - public static class LabelOp extends LIRInstruction { + public static class LabelOp extends LIRInstructionBase { private static final Value[] NO_VALUES = new Value[0]; @@ -103,7 +103,7 @@ /** * LIR operation that is an unconditional jump to a {@link #destination()}. */ - public static class JumpOp extends LIRInstruction implements BlockEndOp { + public static class JumpOp extends LIRInstructionBase implements BlockEndOp { private final LabelRef destination; @@ -133,7 +133,7 @@ * Marker interface for a LIR operation that moves a value from {@link #getInput()} to * {@link #getResult()}. */ - public interface MoveOp { + public interface MoveOp extends LIRInstruction { Value getInput(); @@ -145,7 +145,7 @@ * {@linkplain #remove(Set) pruned} and a mapping from registers to the frame slots in which * they are saved can be {@linkplain #getMap(FrameMap) retrieved}. */ - public interface SaveRegistersOp { + public interface SaveRegistersOp extends LIRInstruction { /** * Determines if the {@link #remove(Set)} operation is supported for this object. @@ -177,7 +177,7 @@ * A LIR operation that does nothing. If the operation records its position, it can be * subsequently {@linkplain #replace(LIR, LIRInstruction) replaced}. */ - public static class NoOp extends LIRInstruction { + public static class NoOp extends LIRInstructionBase { /** * The block in which this instruction is located.