Mercurial > hg > graal-compiler
changeset 22510:d3d19b31e9a4
Split MoveOp into ValueMoveOp and LoadConstantOp.
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java Wed Aug 26 11:11:27 2015 +0200 +++ b/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java Wed Aug 26 13:27:03 2015 +0200 @@ -70,6 +70,7 @@ import com.oracle.graal.lir.amd64.AMD64Move.LeaDataOp; import com.oracle.graal.lir.amd64.AMD64Move.LeaOp; import com.oracle.graal.lir.amd64.AMD64Move.MembarOp; +import com.oracle.graal.lir.amd64.AMD64Move.MoveFromConstOp; import com.oracle.graal.lir.amd64.AMD64Move.MoveFromRegOp; import com.oracle.graal.lir.amd64.AMD64Move.MoveToRegOp; import com.oracle.graal.lir.amd64.AMD64Move.StackLeaOp; @@ -104,7 +105,7 @@ } @Override - protected LIRInstruction createStackMoveIntern(AllocatableValue result, Value input) { + protected LIRInstruction createStackMoveIntern(AllocatableValue result, AllocatableValue input) { return AMD64LIRGenerator.this.createStackMove(result, input); } @@ -158,14 +159,16 @@ protected AMD64LIRInstruction createMove(AllocatableValue dst, Value src) { if (src instanceof AMD64AddressValue) { return new LeaOp(dst, (AMD64AddressValue) src); + } else if (isConstant(src)) { + return new MoveFromConstOp(dst, asConstant(src)); } else if (isRegister(src) || isStackSlotValue(dst)) { - return new MoveFromRegOp(dst.getKind(), dst, src); + return new MoveFromRegOp(dst.getKind(), dst, (AllocatableValue) src); } else { - return new MoveToRegOp(dst.getKind(), dst, src); + return new MoveToRegOp(dst.getKind(), dst, (AllocatableValue) src); } } - protected LIRInstruction createStackMove(AllocatableValue result, Value input) { + protected LIRInstruction createStackMove(AllocatableValue result, AllocatableValue input) { Kind kind = result.getKind(); OperandSize size; switch (kind) { @@ -185,7 +188,7 @@ return new AMD64PushPopStackMove(size, result, input); } - protected LIRInstruction createStackMove(AllocatableValue result, Value input, Register scratchRegister, StackSlotValue backupSlot) { + protected LIRInstruction createStackMove(AllocatableValue result, AllocatableValue input, Register scratchRegister, StackSlotValue backupSlot) { return new AMD64StackMove(result, input, scratchRegister, backupSlot); }
--- a/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java Wed Aug 26 11:11:27 2015 +0200 +++ b/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java Wed Aug 26 13:27:03 2015 +0200 @@ -83,7 +83,7 @@ } @Override - protected LIRInstruction createStackMoveIntern(AllocatableValue result, Value input) { + protected LIRInstruction createStackMoveIntern(AllocatableValue result, AllocatableValue input) { return SPARCLIRGenerator.this.createStackMove(result, input); } } @@ -129,16 +129,17 @@ } else { return new SPARCMove.LoadConstantFromTable(javaConstant, getConstantTableBase(), dst); } - } else if (!srcIsSlot && !dstIsSlot) { - return new Move(dst, src); - } else if (srcIsSlot != dstIsSlot) { - return new Move(dst, src); } else { - throw JVMCIError.shouldNotReachHere(src.getClass() + " " + dst.getClass()); + assert src instanceof AllocatableValue; + if (srcIsSlot && dstIsSlot) { + throw JVMCIError.shouldNotReachHere(src.getClass() + " " + dst.getClass()); + } else { + return new Move(dst, (AllocatableValue) src); + } } } - protected LIRInstruction createStackMove(AllocatableValue result, Value input) { + protected LIRInstruction createStackMove(AllocatableValue result, AllocatableValue input) { return new SPARCMove.Move(result, input); }
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/backend/AllocatorTest.java Wed Aug 26 11:11:27 2015 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/backend/AllocatorTest.java Wed Aug 26 13:27:03 2015 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2015, 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 @@ -25,15 +25,15 @@ import java.util.*; import jdk.internal.jvmci.code.*; -import com.oracle.graal.debug.*; -import com.oracle.graal.debug.Debug.*; import jdk.internal.jvmci.meta.*; import org.junit.*; import com.oracle.graal.compiler.common.cfg.*; +import com.oracle.graal.debug.*; +import com.oracle.graal.debug.Debug.Scope; import com.oracle.graal.lir.*; -import com.oracle.graal.lir.StandardOp.MoveOp; +import com.oracle.graal.lir.StandardOp.ValueMoveOp; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions; @@ -83,8 +83,8 @@ private void collectStats(final LIRInstruction instr) { instr.forEachOutput(collectStatsProc); - if (instr instanceof MoveOp) { - MoveOp move = (MoveOp) instr; + if (instr instanceof ValueMoveOp) { + ValueMoveOp move = (ValueMoveOp) instr; Value def = move.getResult(); Value use = move.getInput(); if (ValueUtil.isRegister(def)) {
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotMove.java Wed Aug 26 11:11:27 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotMove.java Wed Aug 26 13:27:03 2015 +0200 @@ -27,23 +27,23 @@ import jdk.internal.jvmci.code.*; import jdk.internal.jvmci.common.*; import jdk.internal.jvmci.hotspot.*; -import jdk.internal.jvmci.hotspot.HotSpotVMConfig.*; +import jdk.internal.jvmci.hotspot.HotSpotVMConfig.CompressEncoding; import jdk.internal.jvmci.meta.*; import com.oracle.graal.asm.*; import com.oracle.graal.asm.amd64.*; -import com.oracle.graal.asm.amd64.AMD64Assembler.*; +import com.oracle.graal.asm.amd64.AMD64Assembler.ConditionFlag; import com.oracle.graal.compiler.common.*; import com.oracle.graal.hotspot.*; import com.oracle.graal.lir.*; -import com.oracle.graal.lir.StandardOp.MoveOp; +import com.oracle.graal.lir.StandardOp.LoadConstantOp; import com.oracle.graal.lir.StandardOp.StackStoreOp; import com.oracle.graal.lir.amd64.*; import com.oracle.graal.lir.asm.*; public class AMD64HotSpotMove { - public static final class HotSpotLoadObjectConstantOp extends AMD64LIRInstruction implements MoveOp { + public static final class HotSpotLoadObjectConstantOp extends AMD64LIRInstruction implements LoadConstantOp { public static final LIRInstructionClass<HotSpotLoadObjectConstantOp> TYPE = LIRInstructionClass.create(HotSpotLoadObjectConstantOp.class); @Def({REG, STACK}) private AllocatableValue result; @@ -88,7 +88,7 @@ } } - public Value getInput() { + public Constant getConstant() { return input; } @@ -97,7 +97,7 @@ } } - public static final class HotSpotLoadMetaspaceConstantOp extends AMD64LIRInstruction implements MoveOp { + public static final class HotSpotLoadMetaspaceConstantOp extends AMD64LIRInstruction implements LoadConstantOp { public static final LIRInstructionClass<HotSpotLoadMetaspaceConstantOp> TYPE = LIRInstructionClass.create(HotSpotLoadMetaspaceConstantOp.class); @Def({REG, STACK}) private AllocatableValue result; @@ -151,8 +151,8 @@ } } - public Value getInput() { - return (Value) input; + public Constant getConstant() { + return input; } public AllocatableValue getResult() {
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Move.java Wed Aug 26 11:11:27 2015 +0200 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Move.java Wed Aug 26 13:27:03 2015 +0200 @@ -22,26 +22,29 @@ */ package com.oracle.graal.lir.amd64; -import jdk.internal.jvmci.amd64.*; -import jdk.internal.jvmci.code.*; -import jdk.internal.jvmci.common.*; -import jdk.internal.jvmci.meta.*; import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*; import static java.lang.Double.*; import static java.lang.Float.*; import static jdk.internal.jvmci.code.ValueUtil.*; +import jdk.internal.jvmci.amd64.*; +import jdk.internal.jvmci.code.*; +import jdk.internal.jvmci.common.*; +import jdk.internal.jvmci.meta.*; import com.oracle.graal.asm.*; import com.oracle.graal.asm.amd64.*; -import com.oracle.graal.asm.amd64.AMD64Assembler.*; +import com.oracle.graal.asm.amd64.AMD64Assembler.AMD64MIOp; +import com.oracle.graal.asm.amd64.AMD64Assembler.AMD64MOp; +import com.oracle.graal.asm.amd64.AMD64Assembler.OperandSize; import com.oracle.graal.lir.*; -import com.oracle.graal.lir.StandardOp.MoveOp; +import com.oracle.graal.lir.StandardOp.LoadConstantOp; import com.oracle.graal.lir.StandardOp.NullCheck; +import com.oracle.graal.lir.StandardOp.ValueMoveOp; import com.oracle.graal.lir.asm.*; public class AMD64Move { - private abstract static class AbstractMoveOp extends AMD64LIRInstruction implements MoveOp { + private abstract static class AbstractMoveOp extends AMD64LIRInstruction implements ValueMoveOp { public static final LIRInstructionClass<AbstractMoveOp> TYPE = LIRInstructionClass.create(AbstractMoveOp.class); private Kind moveKind; @@ -67,16 +70,16 @@ public static final LIRInstructionClass<MoveToRegOp> TYPE = LIRInstructionClass.create(MoveToRegOp.class); @Def({REG, HINT}) protected AllocatableValue result; - @Use({REG, STACK, CONST}) protected Value input; + @Use({REG, STACK}) protected AllocatableValue input; - public MoveToRegOp(Kind moveKind, AllocatableValue result, Value input) { + public MoveToRegOp(Kind moveKind, AllocatableValue result, AllocatableValue input) { super(TYPE, moveKind); this.result = result; this.input = input; } @Override - public Value getInput() { + public AllocatableValue getInput() { return input; } @@ -91,16 +94,16 @@ public static final LIRInstructionClass<MoveFromRegOp> TYPE = LIRInstructionClass.create(MoveFromRegOp.class); @Def({REG, STACK}) protected AllocatableValue result; - @Use({REG, CONST, HINT}) protected Value input; + @Use({REG, HINT}) protected AllocatableValue input; - public MoveFromRegOp(Kind moveKind, AllocatableValue result, Value input) { + public MoveFromRegOp(Kind moveKind, AllocatableValue result, AllocatableValue input) { super(TYPE, moveKind); this.result = result; this.input = input; } @Override - public Value getInput() { + public AllocatableValue getInput() { return input; } @@ -110,17 +113,49 @@ } } + @Opcode("MOVE") + public static class MoveFromConstOp extends AMD64LIRInstruction implements LoadConstantOp { + public static final LIRInstructionClass<MoveFromConstOp> TYPE = LIRInstructionClass.create(MoveFromConstOp.class); + + @Def({REG, STACK}) protected AllocatableValue result; + private final JavaConstant input; + + public MoveFromConstOp(AllocatableValue result, JavaConstant input) { + super(TYPE); + this.result = result; + this.input = input; + } + + @Override + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + if (isRegister(result)) { + const2reg(crb, masm, result, input); + } else { + assert isStackSlot(result); + const2stack(crb, masm, result, input); + } + } + + public Constant getConstant() { + return input; + } + + public AllocatableValue getResult() { + return result; + } + } + @Opcode("STACKMOVE") - public static final class AMD64StackMove extends AMD64LIRInstruction implements MoveOp { + public static final class AMD64StackMove extends AMD64LIRInstruction implements ValueMoveOp { public static final LIRInstructionClass<AMD64StackMove> TYPE = LIRInstructionClass.create(AMD64StackMove.class); @Def({STACK}) protected AllocatableValue result; - @Use({STACK, HINT}) protected Value input; + @Use({STACK, HINT}) protected AllocatableValue input; @Alive({OperandFlag.STACK, OperandFlag.UNINITIALIZED}) private StackSlotValue backupSlot; private Register scratch; - public AMD64StackMove(AllocatableValue result, Value input, Register scratch, StackSlotValue backupSlot) { + public AMD64StackMove(AllocatableValue result, AllocatableValue input, Register scratch, StackSlotValue backupSlot) { super(TYPE); this.result = result; this.input = input; @@ -129,7 +164,7 @@ } @Override - public Value getInput() { + public AllocatableValue getInput() { return input; } @@ -195,14 +230,14 @@ } @Opcode("STACKMOVE") - public static final class AMD64PushPopStackMove extends AMD64LIRInstruction implements MoveOp { + public static final class AMD64PushPopStackMove extends AMD64LIRInstruction implements ValueMoveOp { public static final LIRInstructionClass<AMD64PushPopStackMove> TYPE = LIRInstructionClass.create(AMD64PushPopStackMove.class); @Def({STACK}) protected AllocatableValue result; - @Use({STACK, HINT}) protected Value input; + @Use({STACK, HINT}) protected AllocatableValue input; private final OperandSize size; - public AMD64PushPopStackMove(OperandSize size, AllocatableValue result, Value input) { + public AMD64PushPopStackMove(OperandSize size, AllocatableValue result, AllocatableValue input) { super(TYPE); this.result = result; this.input = input; @@ -210,7 +245,7 @@ } @Override - public Value getInput() { + public AllocatableValue getInput() { return input; }
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCMove.java Wed Aug 26 11:11:27 2015 +0200 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCMove.java Wed Aug 26 13:27:03 2015 +0200 @@ -43,13 +43,14 @@ import com.oracle.graal.asm.sparc.SPARCMacroAssembler.Setx; import com.oracle.graal.lir.*; import com.oracle.graal.lir.StandardOp.ImplicitNullCheck; -import com.oracle.graal.lir.StandardOp.MoveOp; +import com.oracle.graal.lir.StandardOp.LoadConstantOp; import com.oracle.graal.lir.StandardOp.NullCheck; +import com.oracle.graal.lir.StandardOp.ValueMoveOp; import com.oracle.graal.lir.asm.*; public class SPARCMove { - public static class LoadInlineConstant extends SPARCLIRInstruction implements SPARCTailDelayedLIRInstruction, MoveOp { + public static class LoadInlineConstant extends SPARCLIRInstruction implements SPARCTailDelayedLIRInstruction, LoadConstantOp { public static final LIRInstructionClass<LoadInlineConstant> TYPE = LIRInstructionClass.create(LoadInlineConstant.class); public static final SizeEstimate SIZE = SizeEstimate.create(1); private JavaConstant constant; @@ -71,7 +72,7 @@ } } - public Value getInput() { + public Constant getConstant() { return constant; } @@ -117,14 +118,14 @@ } @Opcode("MOVE") - public static class Move extends SPARCLIRInstruction implements MoveOp, SPARCTailDelayedLIRInstruction { + public static class Move extends SPARCLIRInstruction implements ValueMoveOp, SPARCTailDelayedLIRInstruction { public static final LIRInstructionClass<Move> TYPE = LIRInstructionClass.create(Move.class); public static final SizeEstimate SIZE = SizeEstimate.create(8); @Def({REG, STACK, HINT}) protected AllocatableValue result; - @Use({REG, STACK}) protected Value input; + @Use({REG, STACK}) protected AllocatableValue input; - public Move(AllocatableValue result, Value input) { + public Move(AllocatableValue result, AllocatableValue input) { super(TYPE, SIZE); this.result = result; this.input = input; @@ -136,7 +137,7 @@ } @Override - public Value getInput() { + public AllocatableValue getInput() { return input; } @@ -150,7 +151,7 @@ * Move between floating-point and general purpose register domain. */ @Opcode("MOVE_FPGP") - public static final class MoveFpGp extends SPARCLIRInstruction implements MoveOp, SPARCTailDelayedLIRInstruction { + public static final class MoveFpGp extends SPARCLIRInstruction implements ValueMoveOp, SPARCTailDelayedLIRInstruction { public static final LIRInstructionClass<MoveFpGp> TYPE = LIRInstructionClass.create(MoveFpGp.class); public static final SizeEstimate SIZE = SizeEstimate.create(2); @@ -165,7 +166,7 @@ this.temp = temp; } - public Value getInput() { + public AllocatableValue getInput() { return input; }
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/EdgeMoveOptimizer.java Wed Aug 26 11:11:27 2015 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/EdgeMoveOptimizer.java Wed Aug 26 13:27:03 2015 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2015, 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 @@ -27,7 +27,9 @@ import jdk.internal.jvmci.code.*; import com.oracle.graal.compiler.common.cfg.*; +import com.oracle.graal.lir.StandardOp.LoadConstantOp; import com.oracle.graal.lir.StandardOp.MoveOp; +import com.oracle.graal.lir.StandardOp.ValueMoveOp; import com.oracle.graal.lir.gen.*; import com.oracle.graal.lir.phases.*; @@ -81,9 +83,8 @@ } /** - * Determines if two operations are both {@linkplain MoveOp moves} that have the same - * {@linkplain MoveOp#getInput() source} and {@linkplain MoveOp#getResult() destination} - * operands. + * Determines if two operations are both {@linkplain MoveOp moves} that have the same source + * and {@linkplain MoveOp#getResult() destination} operands. * * @param op1 the first instruction to compare * @param op2 the second instruction to compare @@ -93,13 +94,20 @@ assert op1 != null; assert op2 != null; - if (op1 instanceof MoveOp && op2 instanceof MoveOp) { - MoveOp move1 = (MoveOp) op1; - MoveOp move2 = (MoveOp) op2; + if (op1 instanceof ValueMoveOp && op2 instanceof ValueMoveOp) { + ValueMoveOp move1 = (ValueMoveOp) op1; + ValueMoveOp move2 = (ValueMoveOp) op2; if (move1.getInput().equals(move2.getInput()) && move1.getResult().equals(move2.getResult())) { // these moves are exactly equal and can be optimized return true; } + } else if (op1 instanceof LoadConstantOp && op2 instanceof LoadConstantOp) { + LoadConstantOp move1 = (LoadConstantOp) op1; + LoadConstantOp move2 = (LoadConstantOp) op2; + if (move1.getConstant().equals(move2.getConstant()) && move1.getResult().equals(move2.getResult())) { + // these moves are exactly equal and can be optimized + return true; + } } return false; }
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/RedundantMoveElimination.java Wed Aug 26 11:11:27 2015 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/RedundantMoveElimination.java Wed Aug 26 13:27:03 2015 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2015, 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 @@ -27,14 +27,15 @@ import java.util.*; import jdk.internal.jvmci.code.*; -import com.oracle.graal.debug.*; import jdk.internal.jvmci.meta.*; import com.oracle.graal.compiler.common.*; import com.oracle.graal.compiler.common.cfg.*; +import com.oracle.graal.debug.*; import com.oracle.graal.lir.LIRInstruction.OperandFlag; import com.oracle.graal.lir.LIRInstruction.OperandMode; import com.oracle.graal.lir.StandardOp.MoveOp; +import com.oracle.graal.lir.StandardOp.ValueMoveOp; import com.oracle.graal.lir.framemap.*; import com.oracle.graal.lir.gen.*; import com.oracle.graal.lir.phases.*; @@ -329,7 +330,7 @@ for (int idx = 0; idx < numInsts; idx++) { LIRInstruction op = instructions.get(idx); if (isEligibleMove(op)) { - MoveOp moveOp = (MoveOp) op; + ValueMoveOp moveOp = (ValueMoveOp) op; int sourceIdx = getStateIdx(moveOp.getInput()); int destIdx = getStateIdx(moveOp.getResult()); if (sourceIdx >= 0 && destIdx >= 0 && iterState[sourceIdx] == iterState[destIdx]) { @@ -360,7 +361,7 @@ /* * Handle the special case of a move instruction */ - MoveOp moveOp = (MoveOp) op; + ValueMoveOp moveOp = (ValueMoveOp) op; int sourceIdx = getStateIdx(moveOp.getInput()); int destIdx = getStateIdx(moveOp.getResult()); if (sourceIdx >= 0 && destIdx >= 0) { @@ -526,8 +527,8 @@ * Returns true for a move instruction which is a candidate for elimination. */ private static boolean isEligibleMove(LIRInstruction op) { - if (op instanceof MoveOp) { - MoveOp moveOp = (MoveOp) op; + if (op instanceof ValueMoveOp) { + ValueMoveOp moveOp = (ValueMoveOp) op; Value source = moveOp.getInput(); Value dest = moveOp.getResult(); /*
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/StandardOp.java Wed Aug 26 11:11:27 2015 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/StandardOp.java Wed Aug 26 13:27:03 2015 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2015, 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 @@ -247,14 +247,27 @@ } /** - * Marker interface for a LIR operation that moves a value from {@link #getInput()} to - * {@link #getResult()}. + * Marker interface for a LIR operation that moves a value to {@link #getResult()}. */ public interface MoveOp { - Value getInput(); + AllocatableValue getResult(); + } + + /** + * Marker interface for a LIR operation that moves some non-constant value to another location. + */ + public interface ValueMoveOp extends MoveOp { - AllocatableValue getResult(); + AllocatableValue getInput(); + } + + /** + * Marker interface for a LIR operation that loads a {@link #getConstant()}. + */ + public interface LoadConstantOp extends MoveOp { + + Constant getConstant(); } /** @@ -363,13 +376,13 @@ } } - public static final class StackMove extends LIRInstruction implements MoveOp { + public static final class StackMove extends LIRInstruction implements ValueMoveOp { public static final LIRInstructionClass<StackMove> TYPE = LIRInstructionClass.create(StackMove.class); @Def({STACK, HINT}) protected AllocatableValue result; - @Use({STACK}) protected Value input; + @Use({STACK}) protected AllocatableValue input; - public StackMove(AllocatableValue result, Value input) { + public StackMove(AllocatableValue result, AllocatableValue input) { super(TYPE); this.result = result; this.input = input; @@ -381,7 +394,7 @@ } @Override - public Value getInput() { + public AllocatableValue getInput() { return input; }
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScanAssignLocationsPhase.java Wed Aug 26 11:11:27 2015 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScanAssignLocationsPhase.java Wed Aug 26 13:27:03 2015 +0200 @@ -38,6 +38,7 @@ import com.oracle.graal.lir.LIRInstruction.OperandFlag; import com.oracle.graal.lir.LIRInstruction.OperandMode; import com.oracle.graal.lir.StandardOp.MoveOp; +import com.oracle.graal.lir.StandardOp.ValueMoveOp; import com.oracle.graal.lir.gen.*; import com.oracle.graal.lir.gen.LIRGeneratorTool.SpillMoveFactory; import com.oracle.graal.lir.phases.*; @@ -186,10 +187,8 @@ InstructionValueProcedure assignProc = (inst, operand, mode, flags) -> isVariable(operand) ? colorLirOperand(inst, (Variable) operand, mode) : operand; // remove useless moves - MoveOp move = null; if (op instanceof MoveOp) { - move = (MoveOp) op; - AllocatableValue result = move.getResult(); + AllocatableValue result = ((MoveOp) op).getResult(); if (isVariable(result) && allocator.isMaterialized(result, op.id(), OperandMode.DEF)) { /* * This happens if a materializable interval is originally not spilled but then @@ -209,7 +208,8 @@ op.forEachState((inst, state) -> computeDebugInfo(inst, state)); // remove useless moves - if (move != null) { + if (op instanceof ValueMoveOp) { + ValueMoveOp move = (ValueMoveOp) op; if (move.getInput().equals(move.getResult())) { return true; }
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScanEliminateSpillMovePhase.java Wed Aug 26 11:11:27 2015 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScanEliminateSpillMovePhase.java Wed Aug 26 13:27:03 2015 +0200 @@ -29,13 +29,15 @@ import java.util.*; import jdk.internal.jvmci.code.*; -import com.oracle.graal.debug.*; import jdk.internal.jvmci.meta.*; import com.oracle.graal.compiler.common.alloc.*; import com.oracle.graal.compiler.common.cfg.*; +import com.oracle.graal.debug.*; import com.oracle.graal.lir.*; +import com.oracle.graal.lir.StandardOp.LoadConstantOp; import com.oracle.graal.lir.StandardOp.MoveOp; +import com.oracle.graal.lir.StandardOp.ValueMoveOp; import com.oracle.graal.lir.alloc.lsra.Interval.SpillState; import com.oracle.graal.lir.alloc.lsra.LinearScan.IntervalPredicate; import com.oracle.graal.lir.gen.*; @@ -111,8 +113,14 @@ * instruction. */ if (Debug.isLogEnabled()) { - Debug.log("eliminating move from interval %d (%s) to %d (%s) in block %s", allocator.operandNumber(move.getInput()), move.getInput(), - allocator.operandNumber(move.getResult()), move.getResult(), block); + if (move instanceof ValueMoveOp) { + ValueMoveOp vmove = (ValueMoveOp) move; + Debug.log("eliminating move from interval %d (%s) to %d (%s) in block %s", allocator.operandNumber(vmove.getInput()), vmove.getInput(), + allocator.operandNumber(vmove.getResult()), vmove.getResult(), block); + } else { + LoadConstantOp load = (LoadConstantOp) move; + Debug.log("eliminating constant load from %s to %d (%s) in block %s", load.getConstant(), allocator.operandNumber(load.getResult()), load.getResult(), block); + } } // null-instructions are deleted by assignRegNum
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScanLifetimeAnalysisPhase.java Wed Aug 26 11:11:27 2015 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScanLifetimeAnalysisPhase.java Wed Aug 26 13:27:03 2015 +0200 @@ -31,18 +31,19 @@ import jdk.internal.jvmci.code.*; import jdk.internal.jvmci.common.*; -import com.oracle.graal.debug.*; -import com.oracle.graal.debug.Debug.*; import jdk.internal.jvmci.meta.*; import com.oracle.graal.compiler.common.alloc.*; import com.oracle.graal.compiler.common.cfg.*; import com.oracle.graal.compiler.common.util.*; +import com.oracle.graal.debug.*; +import com.oracle.graal.debug.Debug.Scope; import com.oracle.graal.lir.*; import com.oracle.graal.lir.LIRInstruction.OperandFlag; import com.oracle.graal.lir.LIRInstruction.OperandMode; -import com.oracle.graal.lir.StandardOp.MoveOp; +import com.oracle.graal.lir.StandardOp.LoadConstantOp; import com.oracle.graal.lir.StandardOp.StackStoreOp; +import com.oracle.graal.lir.StandardOp.ValueMoveOp; import com.oracle.graal.lir.alloc.lsra.Interval.RegisterPriority; import com.oracle.graal.lir.alloc.lsra.Interval.SpillState; import com.oracle.graal.lir.alloc.lsra.LinearScan.BlockData; @@ -537,8 +538,8 @@ * of such moves is assigned the stack slot (which is in the caller's frame) as its spill slot. */ protected void handleMethodArguments(LIRInstruction op) { - if (op instanceof MoveOp) { - MoveOp move = (MoveOp) op; + if (op instanceof ValueMoveOp) { + ValueMoveOp move = (ValueMoveOp) op; if (optimizeMethodArgument(move.getInput())) { StackSlot slot = asStackSlot(move.getInput()); if (DetailedAsserts.getValue()) { @@ -637,8 +638,8 @@ * Determines the register priority for an instruction's output/result operand. */ protected RegisterPriority registerPriorityOfOutputOperand(LIRInstruction op) { - if (op instanceof MoveOp) { - MoveOp move = (MoveOp) op; + if (op instanceof ValueMoveOp) { + ValueMoveOp move = (ValueMoveOp) op; if (optimizeMethodArgument(move.getInput())) { return RegisterPriority.None; } @@ -812,9 +813,9 @@ * can only be a {@link JavaConstant}. */ protected static JavaConstant getMaterializedValue(LIRInstruction op, Value operand, Interval interval) { - if (op instanceof MoveOp) { - MoveOp move = (MoveOp) op; - if (move.getInput() instanceof JavaConstant) { + if (op instanceof LoadConstantOp) { + LoadConstantOp move = (LoadConstantOp) op; + if (move.getConstant() instanceof JavaConstant) { /* * Check if the interval has any uses which would accept an stack location (priority * == ShouldHaveRegister). Rematerialization of such intervals can result in a @@ -829,7 +830,7 @@ return null; } } - return (JavaConstant) move.getInput(); + return (JavaConstant) move.getConstant(); } } return null;
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScanWalker.java Wed Aug 26 11:11:27 2015 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScanWalker.java Wed Aug 26 13:27:03 2015 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2015, 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 @@ -29,14 +29,14 @@ import java.util.*; import jdk.internal.jvmci.code.*; -import com.oracle.graal.debug.*; import jdk.internal.jvmci.meta.*; import com.oracle.graal.compiler.common.alloc.RegisterAllocationConfig.AllocatableRegisters; import com.oracle.graal.compiler.common.cfg.*; import com.oracle.graal.compiler.common.util.*; +import com.oracle.graal.debug.*; import com.oracle.graal.lir.*; -import com.oracle.graal.lir.StandardOp.MoveOp; +import com.oracle.graal.lir.StandardOp.ValueMoveOp; import com.oracle.graal.lir.alloc.lsra.Interval.RegisterBinding; import com.oracle.graal.lir.alloc.lsra.Interval.RegisterPriority; import com.oracle.graal.lir.alloc.lsra.Interval.SpillState; @@ -925,8 +925,8 @@ } static boolean isMove(LIRInstruction op, Interval from, Interval to) { - if (op instanceof MoveOp) { - MoveOp move = (MoveOp) op; + if (op instanceof ValueMoveOp) { + ValueMoveOp move = (ValueMoveOp) op; if (isVariable(move.getInput()) && isVariable(move.getResult())) { return move.getInput() != null && move.getInput().equals(from.operand) && move.getResult() != null && move.getResult().equals(to.operand); }
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/trace/TraceGlobalMoveResolver.java Wed Aug 26 11:11:27 2015 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/trace/TraceGlobalMoveResolver.java Wed Aug 26 13:27:03 2015 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2015, 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 @@ -281,7 +281,7 @@ */ private LIRInstruction createMove(Value fromOpr, AllocatableValue toOpr) { if (isStackSlotValue(toOpr) && isStackSlotValue(fromOpr)) { - return getSpillMoveFactory().createStackMove(toOpr, fromOpr); + return getSpillMoveFactory().createStackMove(toOpr, asStackSlotValue(fromOpr)); } return getSpillMoveFactory().createMove(toOpr, fromOpr); }
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/trace/TraceRegisterAllocationPhase.java Wed Aug 26 11:11:27 2015 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/trace/TraceRegisterAllocationPhase.java Wed Aug 26 13:27:03 2015 +0200 @@ -36,7 +36,7 @@ import com.oracle.graal.debug.*; import com.oracle.graal.debug.Debug.Scope; import com.oracle.graal.lir.*; -import com.oracle.graal.lir.StandardOp.MoveOp; +import com.oracle.graal.lir.StandardOp.ValueMoveOp; import com.oracle.graal.lir.gen.*; import com.oracle.graal.lir.gen.LIRGeneratorTool.SpillMoveFactory; import com.oracle.graal.lir.phases.*; @@ -131,8 +131,8 @@ for (int i = 0; i < instructions.size(); i++) { LIRInstruction inst = instructions.get(i); - if (inst instanceof MoveOp) { - MoveOp move = (MoveOp) inst; + if (inst instanceof ValueMoveOp) { + ValueMoveOp move = (ValueMoveOp) inst; if (isStackSlotValue(move.getInput()) && isStackSlotValue(move.getResult())) { instructions.set(i, spillMoveFactory.createStackMove(move.getResult(), move.getInput())); changed = true;
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/constopt/ConstantLoadOptimization.java Wed Aug 26 11:11:27 2015 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/constopt/ConstantLoadOptimization.java Wed Aug 26 13:27:03 2015 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2015, 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 @@ -24,21 +24,20 @@ import static com.oracle.graal.lir.LIRValueUtil.*; import static com.oracle.graal.lir.phases.LIRPhase.Options.*; -import static jdk.internal.jvmci.code.ValueUtil.*; import java.util.*; import jdk.internal.jvmci.code.*; -import com.oracle.graal.debug.*; -import com.oracle.graal.debug.Debug.*; import jdk.internal.jvmci.meta.*; import jdk.internal.jvmci.options.*; import com.oracle.graal.compiler.common.cfg.*; +import com.oracle.graal.debug.*; +import com.oracle.graal.debug.Debug.Scope; import com.oracle.graal.lir.*; import com.oracle.graal.lir.LIRInstruction.OperandFlag; import com.oracle.graal.lir.LIRInstruction.OperandMode; -import com.oracle.graal.lir.StandardOp.MoveOp; +import com.oracle.graal.lir.StandardOp.LoadConstantOp; import com.oracle.graal.lir.constopt.ConstantTree.Flags; import com.oracle.graal.lir.constopt.ConstantTree.NodeCost; import com.oracle.graal.lir.gen.*; @@ -146,11 +145,11 @@ } private static boolean isConstantLoad(LIRInstruction inst) { - if (!(inst instanceof MoveOp)) { + if (!(inst instanceof LoadConstantOp)) { return false; } - MoveOp move = (MoveOp) inst; - return isConstant(move.getInput()) && isVariable(move.getResult()); + LoadConstantOp load = (LoadConstantOp) inst; + return isVariable(load.getResult()); } private void addUsageToBlockMap(UseEntry entry) {
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/constopt/DefUseTree.java Wed Aug 26 11:11:27 2015 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/constopt/DefUseTree.java Wed Aug 26 13:27:03 2015 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2015, 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 @@ -29,33 +29,33 @@ import com.oracle.graal.compiler.common.cfg.*; import com.oracle.graal.lir.*; -import com.oracle.graal.lir.StandardOp.MoveOp; +import com.oracle.graal.lir.StandardOp.LoadConstantOp; /** * Represents def-use tree of a constant. */ class DefUseTree { - private final LIRInstruction instruction; + private final LoadConstantOp instruction; private final AbstractBlockBase<?> block; private final List<UseEntry> uses; public DefUseTree(LIRInstruction instruction, AbstractBlockBase<?> block) { - assert instruction instanceof MoveOp : "Not a MoveOp: " + instruction; - this.instruction = instruction; + assert instruction instanceof LoadConstantOp : "Not a LoadConstantOp: " + instruction; + this.instruction = (LoadConstantOp) instruction; this.block = block; this.uses = new ArrayList<>(); } public Variable getVariable() { - return (Variable) ((MoveOp) instruction).getResult(); + return (Variable) instruction.getResult(); } public JavaConstant getConstant() { - return (JavaConstant) ((MoveOp) instruction).getInput(); + return (JavaConstant) instruction.getConstant(); } public LIRInstruction getInstruction() { - return instruction; + return (LIRInstruction) instruction; } public AbstractBlockBase<?> getBlock() {
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGeneratorTool.java Wed Aug 26 11:11:27 2015 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGeneratorTool.java Wed Aug 26 13:27:03 2015 +0200 @@ -43,7 +43,7 @@ LIRInstruction createMove(AllocatableValue result, Value input); - LIRInstruction createStackMove(AllocatableValue result, Value input); + LIRInstruction createStackMove(AllocatableValue result, AllocatableValue input); } public abstract class BlockScope implements AutoCloseable {
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/SpillMoveFactoryBase.java Wed Aug 26 11:11:27 2015 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/SpillMoveFactoryBase.java Wed Aug 26 13:27:03 2015 +0200 @@ -47,7 +47,7 @@ return inst; } - public final LIRInstruction createStackMove(AllocatableValue result, Value input) { + public final LIRInstruction createStackMove(AllocatableValue result, AllocatableValue input) { LIRInstruction inst = createStackMoveIntern(result, input); assert checkResult(inst, result, input); return inst; @@ -55,7 +55,7 @@ protected abstract LIRInstruction createMoveIntern(AllocatableValue result, Value input); - protected LIRInstruction createStackMoveIntern(AllocatableValue result, Value input) { + protected LIRInstruction createStackMoveIntern(AllocatableValue result, AllocatableValue input) { return new StackMove(result, input); }
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/profiling/MoveProfiling.java Wed Aug 26 11:11:27 2015 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/profiling/MoveProfiling.java Wed Aug 26 13:27:03 2015 +0200 @@ -34,7 +34,9 @@ import com.oracle.graal.lir.*; import com.oracle.graal.lir.StandardOp.BlockEndOp; import com.oracle.graal.lir.StandardOp.LabelOp; +import com.oracle.graal.lir.StandardOp.LoadConstantOp; import com.oracle.graal.lir.StandardOp.MoveOp; +import com.oracle.graal.lir.StandardOp.ValueMoveOp; import com.oracle.graal.lir.gen.*; import com.oracle.graal.lir.phases.*; @@ -67,26 +69,27 @@ public static MoveType get(MoveOp move) { AllocatableValue dst = move.getResult(); - Value src = move.getInput(); - if (isRegister(dst)) { - if (isRegister(src)) { - return REG2REG; - } - if (isStackSlot(src)) { - return STACK2REG; - } - if (isConstant(src)) { + Value src = null; + if (move instanceof LoadConstantOp) { + if (isRegister(dst)) { return CONST2REG; - } - } else if (isStackSlot(dst)) { - if (isRegister(src)) { - return REG2STACK; - } - if (isConstant(src)) { + } else if (isStackSlot(dst)) { return CONST2STACK; } - if (isStackSlot(src)) { - return STACK2STACK; + } else if (move instanceof ValueMoveOp) { + src = ((ValueMoveOp) move).getInput(); + if (isRegister(dst)) { + if (isRegister(src)) { + return REG2REG; + } else if (isStackSlot(src)) { + return STACK2REG; + } + } else if (isStackSlot(dst)) { + if (isRegister(src)) { + return REG2STACK; + } else if (isStackSlot(src)) { + return STACK2STACK; + } } } throw JVMCIError.shouldNotReachHere(String.format("Unrecognized Move: %s dst=%s, src=%s", move, dst, src));