# HG changeset patch # User Thomas Wuerthinger # Date 1366907861 -7200 # Node ID de9949311e80f95c61d4fb21ed409d1a40015bc8 # Parent b0f9ab5a185bfdb6af7dfc57b378e6576a7b843c# Parent 2a0a6dfe27be447bbec46edf66532d88e8d8ed1d Merge. diff -r b0f9ab5a185b -r de9949311e80 graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/AllocatableValue.java --- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/AllocatableValue.java Thu Apr 25 18:32:33 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2013, 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.api.code; - -import com.oracle.graal.api.meta.*; - -/** - * Common base class for values that can be manipulated by the register allocator. - */ -public abstract class AllocatableValue extends Value { - - private static final long serialVersionUID = 153019506717492133L; - - /** - * Marker to tell the register allocator that no storage location needs to be allocated for this - * value. - */ - @SuppressWarnings("serial") public static final AllocatableValue UNUSED = new AllocatableValue(Kind.Illegal) { - - @Override - public String toString() { - return "-"; - } - }; - - public AllocatableValue(Kind kind) { - super(kind); - } - -} diff -r b0f9ab5a185b -r de9949311e80 graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CallingConvention.java --- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CallingConvention.java Thu Apr 25 18:32:33 2013 +0200 +++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CallingConvention.java Thu Apr 25 18:37:41 2013 +0200 @@ -76,17 +76,17 @@ */ private final int stackSize; - private final Value returnLocation; + private final AllocatableValue returnLocation; /** * The ordered locations in which the arguments are placed. */ - private final Value[] argumentLocations; + private final AllocatableValue[] argumentLocations; /** * The locations used (and killed) by the call in addition to the arguments. */ - private final Value[] temporaryLocations; + private final AllocatableValue[] temporaryLocations; /** * Creates a description of the registers and stack locations used by a call. @@ -97,8 +97,8 @@ * call * @param argumentLocations the ordered locations in which the arguments are placed */ - public CallingConvention(int stackSize, Value returnLocation, Value... argumentLocations) { - this(Value.NONE, stackSize, returnLocation, argumentLocations); + public CallingConvention(int stackSize, AllocatableValue returnLocation, AllocatableValue... argumentLocations) { + this(AllocatableValue.NONE, stackSize, returnLocation, argumentLocations); } /** @@ -112,7 +112,7 @@ * call * @param argumentLocations the ordered locations in which the arguments are placed */ - public CallingConvention(Value[] temporaryLocations, int stackSize, Value returnLocation, Value... argumentLocations) { + public CallingConvention(AllocatableValue[] temporaryLocations, int stackSize, AllocatableValue returnLocation, AllocatableValue... argumentLocations) { assert argumentLocations != null; assert temporaryLocations != null; assert returnLocation != null; @@ -126,14 +126,14 @@ /** * Gets the location for the return value or {@link Value#ILLEGAL} if a void call. */ - public Value getReturn() { + public AllocatableValue getReturn() { return returnLocation; } /** * Gets the location for the {@code index}'th argument. */ - public Value getArgument(int index) { + public AllocatableValue getArgument(int index) { return argumentLocations[index]; } @@ -155,7 +155,7 @@ * Gets the locations used (and killed) by the call apart from the * {@linkplain #getArgument(int) arguments}. */ - public Value[] getTemporaries() { + public AllocatableValue[] getTemporaries() { if (temporaryLocations.length == 0) { return temporaryLocations; } diff -r b0f9ab5a185b -r de9949311e80 graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/AllocatableValue.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/AllocatableValue.java Thu Apr 25 18:37:41 2013 +0200 @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2013, 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.api.meta; + +/** + * Common base class for values that are stored in some location that's managed by the register + * allocator (e.g. register, stack slot). + */ +public abstract class AllocatableValue extends Value { + + private static final long serialVersionUID = 153019506717492133L; + + public static final AllocatableValue[] NONE = {}; + + public AllocatableValue(Kind kind) { + super(kind); + } + +} diff -r b0f9ab5a185b -r de9949311e80 graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Value.java --- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Value.java Thu Apr 25 18:32:33 2013 +0200 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Value.java Thu Apr 25 18:37:41 2013 +0200 @@ -32,9 +32,7 @@ private static final long serialVersionUID = -6909397188697766469L; - public static final Value[] NONE = {}; - - @SuppressWarnings("serial") public static final Value ILLEGAL = new Value(Kind.Illegal) { + @SuppressWarnings("serial") public static final AllocatableValue ILLEGAL = new AllocatableValue(Kind.Illegal) { @Override public String toString() { diff -r b0f9ab5a185b -r de9949311e80 graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java --- a/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java Thu Apr 25 18:32:33 2013 +0200 +++ b/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java Thu Apr 25 18:37:41 2013 +0200 @@ -90,7 +90,7 @@ public static class AMD64SpillMoveFactory implements LIR.SpillMoveFactory { @Override - public LIRInstruction createMove(Value result, Value input) { + public LIRInstruction createMove(AllocatableValue result, Value input) { return AMD64LIRGenerator.createMove(result, input); } } @@ -143,8 +143,10 @@ return result; } - private static AMD64LIRInstruction createMove(Value dst, Value src) { - if (isRegister(src) || isStackSlot(dst)) { + private static AMD64LIRInstruction createMove(AllocatableValue dst, Value src) { + if (src instanceof AMD64AddressValue) { + return new LeaOp(dst, (AMD64AddressValue) src); + } else if (isRegister(src) || isStackSlot(dst)) { return new MoveFromRegOp(dst, src); } else { return new MoveToRegOp(dst, src); @@ -152,24 +154,23 @@ } @Override - public void emitMove(Value dst, Value src) { + public void emitMove(AllocatableValue dst, Value src) { append(createMove(dst, src)); } - private AMD64AddressValue prepareAddress(Kind kind, Value base, long displacement, Value index, int scale) { + @Override + public AMD64AddressValue emitAddress(Value base, long displacement, Value index, int scale) { AllocatableValue baseRegister; long finalDisp = displacement; if (isConstant(base)) { if (asConstant(base).isNull()) { - baseRegister = AllocatableValue.UNUSED; + baseRegister = Value.ILLEGAL; } else if (asConstant(base).getKind() != Kind.Object && !runtime.needsDataPatch(asConstant(base))) { finalDisp += asConstant(base).asLong(); - baseRegister = AllocatableValue.UNUSED; + baseRegister = Value.ILLEGAL; } else { baseRegister = load(base); } - } else if (base == Value.ILLEGAL) { - baseRegister = AllocatableValue.UNUSED; } else { baseRegister = asAllocatable(base); } @@ -180,12 +181,12 @@ scaleEnum = Scale.fromInt(scale); if (isConstant(index)) { finalDisp += asConstant(index).asLong() * scale; - indexRegister = AllocatableValue.UNUSED; + indexRegister = Value.ILLEGAL; } else { indexRegister = asAllocatable(index); } } else { - indexRegister = AllocatableValue.UNUSED; + indexRegister = Value.ILLEGAL; scaleEnum = Scale.Times1; } @@ -195,9 +196,9 @@ } else { displacementInt = 0; AllocatableValue displacementRegister = load(Constant.forLong(finalDisp)); - if (baseRegister == AllocatableValue.UNUSED) { + if (baseRegister == Value.ILLEGAL) { baseRegister = displacementRegister; - } else if (indexRegister == AllocatableValue.UNUSED) { + } else if (indexRegister == Value.ILLEGAL) { indexRegister = displacementRegister; scaleEnum = Scale.Times1; } else { @@ -205,44 +206,44 @@ } } - return new AMD64AddressValue(kind, baseRegister, indexRegister, scaleEnum, displacementInt); + return new AMD64AddressValue(target().wordKind, baseRegister, indexRegister, scaleEnum, displacementInt); + } + + private AMD64AddressValue asAddress(Value address) { + if (address instanceof AMD64AddressValue) { + return (AMD64AddressValue) address; + } else { + return emitAddress(address, 0, Value.ILLEGAL, 0); + } } @Override - public Variable emitLoad(Kind kind, Value base, long displacement, Value index, int scale, DeoptimizingNode deopting) { - AMD64AddressValue loadAddress = prepareAddress(kind, base, displacement, index, scale); - Variable result = newVariable(loadAddress.getKind()); - append(new LoadOp(result, loadAddress, deopting != null ? state(deopting) : null)); + public Variable emitLoad(Kind kind, Value address, DeoptimizingNode deopting) { + AMD64AddressValue loadAddress = asAddress(address); + Variable result = newVariable(kind); + append(new LoadOp(kind, result, loadAddress, deopting != null ? state(deopting) : null)); return result; } @Override - public void emitStore(Kind kind, Value base, long displacement, Value index, int scale, Value inputVal, DeoptimizingNode deopting) { - AMD64AddressValue storeAddress = prepareAddress(kind, base, displacement, index, scale); + public void emitStore(Kind kind, Value address, Value inputVal, DeoptimizingNode deopting) { + AMD64AddressValue storeAddress = asAddress(address); LIRFrameState state = deopting != null ? state(deopting) : null; if (isConstant(inputVal)) { Constant c = asConstant(inputVal); if (canStoreConstant(c)) { - append(new StoreConstantOp(storeAddress, c, state)); + append(new StoreConstantOp(kind, storeAddress, c, state)); return; } } Variable input = load(inputVal); - append(new StoreOp(storeAddress, input, state)); + append(new StoreOp(kind, storeAddress, input, state)); } @Override - public Variable emitLea(Value base, long displacement, Value index, int scale) { - Variable result = newVariable(target().wordKind); - AMD64AddressValue address = prepareAddress(result.getKind(), base, displacement, index, scale); - append(new LeaOp(result, address)); - return result; - } - - @Override - public Variable emitLea(StackSlot address) { + public Variable emitAddress(StackSlot address) { Variable result = newVariable(target().wordKind); append(new StackLeaOp(result, address)); return result; diff -r b0f9ab5a185b -r de9949311e80 graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java --- a/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java Thu Apr 25 18:32:33 2013 +0200 +++ b/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java Thu Apr 25 18:37:41 2013 +0200 @@ -28,17 +28,13 @@ import static com.oracle.graal.lir.ptx.PTXBitManipulationOp.IntrinsicOpcode.*; import static com.oracle.graal.lir.ptx.PTXCompare.*; -import com.oracle.graal.api.code.AllocatableValue; import com.oracle.graal.api.code.CodeCacheProvider; import com.oracle.graal.api.code.DeoptimizationAction; import com.oracle.graal.api.code.RuntimeCallTarget; import com.oracle.graal.api.code.StackSlot; import com.oracle.graal.api.code.TargetDescription; import com.oracle.graal.api.code.RuntimeCallTarget.Descriptor; -import com.oracle.graal.api.meta.Constant; -import com.oracle.graal.api.meta.Kind; -import com.oracle.graal.api.meta.ResolvedJavaMethod; -import com.oracle.graal.api.meta.Value; +import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.NumUtil; import com.oracle.graal.compiler.gen.LIRGenerator; import com.oracle.graal.compiler.target.LIRGenLowerable; @@ -84,7 +80,7 @@ public static class PTXSpillMoveFactory implements LIR.SpillMoveFactory { @Override - public LIRInstruction createMove(Value result, Value input) { + public LIRInstruction createMove(AllocatableValue result, Value input) { throw new InternalError("NYI"); } } @@ -129,7 +125,7 @@ } @Override - public void emitMove(Value dst, Value src) { + public void emitMove(AllocatableValue dst, Value src) { if (isRegister(src) || isStackSlot(dst)) { append(new MoveFromRegOp(dst, src)); } else { @@ -137,20 +133,19 @@ } } - private PTXAddressValue prepareAddress(Kind kind, Value base, long displacement, Value index, int scale) { + @Override + public PTXAddressValue emitAddress(Value base, long displacement, Value index, int scale) { AllocatableValue baseRegister; long finalDisp = displacement; if (isConstant(base)) { if (asConstant(base).isNull()) { - baseRegister = AllocatableValue.UNUSED; + baseRegister = Value.ILLEGAL; } else if (asConstant(base).getKind() != Kind.Object) { finalDisp += asConstant(base).asLong(); - baseRegister = AllocatableValue.UNUSED; + baseRegister = Value.ILLEGAL; } else { baseRegister = load(base); } - } else if (base == Value.ILLEGAL) { - baseRegister = AllocatableValue.UNUSED; } else { baseRegister = asAllocatable(base); } @@ -166,7 +161,7 @@ indexRegister = index; } - if (baseRegister == AllocatableValue.UNUSED) { + if (baseRegister == Value.ILLEGAL) { baseRegister = asAllocatable(indexRegister); } else { Variable newBase = newVariable(Kind.Int); @@ -177,31 +172,34 @@ } } - return new PTXAddressValue(kind, baseRegister, finalDisp); + return new PTXAddressValue(target().wordKind, baseRegister, finalDisp); + } + + private PTXAddressValue asAddress(Value address) { + if (address instanceof PTXAddressValue) { + return (PTXAddressValue) address; + } else { + return emitAddress(address, 0, Value.ILLEGAL, 0); + } } @Override - public Variable emitLoad(Kind kind, Value base, long displacement, Value index, int scale, DeoptimizingNode deopting) { - PTXAddressValue loadAddress = prepareAddress(kind, base, displacement, index, scale); - Variable result = newVariable(loadAddress.getKind()); - append(new LoadOp(result, loadAddress, deopting != null ? state(deopting) : null)); + public Variable emitLoad(Kind kind, Value address, DeoptimizingNode deopting) { + PTXAddressValue loadAddress = asAddress(address); + Variable result = newVariable(kind); + append(new LoadOp(kind, result, loadAddress, deopting != null ? state(deopting) : null)); return result; } @Override - public void emitStore(Kind kind, Value base, long displacement, Value index, int scale, Value inputVal, DeoptimizingNode deopting) { - PTXAddressValue storeAddress = prepareAddress(kind, base, displacement, index, scale); + public void emitStore(Kind kind, Value address, Value inputVal, DeoptimizingNode deopting) { + PTXAddressValue storeAddress = asAddress(address); Variable input = load(inputVal); - append(new StoreOp(storeAddress, input, deopting != null ? state(deopting) : null)); + append(new StoreOp(kind, storeAddress, input, deopting != null ? state(deopting) : null)); } @Override - public Variable emitLea(Value base, long displacement, Value index, int scale) { - throw new InternalError("NYI"); - } - - @Override - public Variable emitLea(StackSlot address) { + public Variable emitAddress(StackSlot address) { throw new InternalError("NYI"); } diff -r b0f9ab5a185b -r de9949311e80 graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java --- a/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java Thu Apr 25 18:32:33 2013 +0200 +++ b/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java Thu Apr 25 18:37:41 2013 +0200 @@ -208,31 +208,31 @@ } @Override - public void emitMove(Value dst, Value src) { + public void emitMove(AllocatableValue dst, Value src) { // SPARC: Auto-generated method stub } @Override - public Value emitLoad(Kind kind, Value base, long displacement, Value index, int scale, DeoptimizingNode canTrap) { + public Value emitAddress(Value base, long displacement, Value index, int scale) { // SPARC: Auto-generated method stub return null; } @Override - public void emitStore(Kind kind, Value base, long displacement, Value index, int scale, Value input, DeoptimizingNode canTrap) { + public Value emitLoad(Kind kind, Value address, DeoptimizingNode canTrap) { + // SPARC: Auto-generated method stub + return null; + } + + @Override + public void emitStore(Kind kind, Value address, Value input, DeoptimizingNode canTrap) { // SPARC: Auto-generated method stub } @Override - public Value emitLea(Value base, long displacement, Value index, int scale) { - // SPARC: Auto-generated method stub - return null; - } - - @Override - public Value emitLea(StackSlot address) { + public Value emitAddress(StackSlot address) { // SPARC: Auto-generated method stub return null; } diff -r b0f9ab5a185b -r de9949311e80 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/Interval.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/Interval.java Thu Apr 25 18:32:33 2013 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/Interval.java Thu Apr 25 18:37:41 2013 +0200 @@ -409,7 +409,7 @@ * The {@linkplain RegisterValue register} or {@linkplain Variable variable} for this interval * prior to register allocation. */ - public final Value operand; + public final AllocatableValue operand; /** * The operand number for this interval's {@linkplain #operand operand}. @@ -420,7 +420,7 @@ * The {@linkplain RegisterValue register} or {@linkplain StackSlot spill slot} assigned to this * interval. */ - private Value location; + private AllocatableValue location; /** * The stack slot to which all splits of this interval are spilled if necessary. @@ -498,7 +498,7 @@ */ private Interval locationHint; - void assignLocation(Value newLocation) { + void assignLocation(AllocatableValue newLocation) { if (isRegister(newLocation)) { assert this.location == null : "cannot re-assign location for " + this; if (newLocation.getKind() == Kind.Illegal && kind != Kind.Illegal) { @@ -518,7 +518,7 @@ * Gets the {@linkplain RegisterValue register} or {@linkplain StackSlot spill slot} assigned to * this interval. */ - public Value location() { + public AllocatableValue location() { return location; } @@ -673,7 +673,7 @@ */ static final Interval EndMarker = new Interval(Value.ILLEGAL, -1); - Interval(Value operand, int operandNumber) { + Interval(AllocatableValue operand, int operandNumber) { assert operand != null; this.operand = operand; this.operandNumber = operandNumber; diff -r b0f9ab5a185b -r de9949311e80 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java Thu Apr 25 18:32:33 2013 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java Thu Apr 25 18:37:41 2013 +0200 @@ -206,7 +206,7 @@ /** * Gets the operand denoted by a given operand number. */ - private Value operandFor(int operandNumber) { + private AllocatableValue operandFor(int operandNumber) { if (operandNumber < firstVariableNumber) { assert operandNumber >= 0; return registers[operandNumber].asValue(); @@ -281,7 +281,7 @@ * @param operand the operand for the interval * @return the created interval */ - Interval createInterval(Value operand) { + Interval createInterval(AllocatableValue operand) { assert isLegal(operand); int operandNumber = operandNumber(operand); Interval interval = new Interval(operand, operandNumber); @@ -346,7 +346,7 @@ return intervals[operandNumber]; } - Interval getOrCreateInterval(Value operand) { + Interval getOrCreateInterval(AllocatableValue operand) { Interval ret = intervalFor(operand); if (ret == null) { return createInterval(operand); @@ -555,8 +555,8 @@ insertionBuffer.init(instructions); } - Value fromLocation = interval.location(); - Value toLocation = canonicalSpillOpr(interval); + AllocatableValue fromLocation = interval.location(); + AllocatableValue toLocation = canonicalSpillOpr(interval); assert isRegister(fromLocation) : "from operand must be a register but is: " + fromLocation + " toLocation=" + toLocation + " spillState=" + interval.spillState(); assert isStackSlot(toLocation) : "to operand must be a stack slot"; @@ -968,7 +968,7 @@ TTY.println(blockData.get(block).liveOut.toString()); } - void addUse(Value operand, int from, int to, RegisterPriority registerPriority, Kind kind) { + void addUse(AllocatableValue operand, int from, int to, RegisterPriority registerPriority, Kind kind) { if (!isProcessed(operand)) { return; } @@ -987,7 +987,7 @@ interval.addUsePos(to & ~1, registerPriority); } - void addTemp(Value operand, int tempPos, RegisterPriority registerPriority, Kind kind) { + void addTemp(AllocatableValue operand, int tempPos, RegisterPriority registerPriority, Kind kind) { if (!isProcessed(operand)) { return; } @@ -1008,7 +1008,7 @@ return !isRegister(operand) || attributes(asRegister(operand)).isAllocatable(); } - void addDef(Value operand, int defPos, RegisterPriority registerPriority, Kind kind) { + void addDef(AllocatableValue operand, int defPos, RegisterPriority registerPriority, Kind kind) { if (!isProcessed(operand)) { return; } @@ -1114,8 +1114,8 @@ @Override protected Value doValue(Value registerHint) { if (isVariableOrRegister(registerHint)) { - Interval from = getOrCreateInterval(registerHint); - Interval to = getOrCreateInterval(targetValue); + Interval from = getOrCreateInterval((AllocatableValue) registerHint); + Interval to = getOrCreateInterval((AllocatableValue) targetValue); // hints always point from def to use if (hintAtDef) { @@ -1156,7 +1156,7 @@ BitSet live = blockData.get(block).liveOut; for (int operandNum = live.nextSetBit(0); operandNum >= 0; operandNum = live.nextSetBit(operandNum + 1)) { assert live.get(operandNum) : "should not stop here otherwise"; - Value operand = operandFor(operandNum); + AllocatableValue operand = operandFor(operandNum); if (GraalOptions.TraceLinearScanLevel >= 2) { TTY.println("live in %s to %d", operand, blockTo + 2); } @@ -1197,7 +1197,7 @@ @Override public Value doValue(Value operand, OperandMode mode, EnumSet flags) { if (isVariableOrRegister(operand)) { - addDef(operand, opId, registerPriorityOfOutputOperand(op), operand.getKind().getStackKind()); + addDef((AllocatableValue) operand, opId, registerPriorityOfOutputOperand(op), operand.getKind().getStackKind()); addRegisterHint(op, operand, mode, flags, true); } return operand; @@ -1208,7 +1208,7 @@ @Override public Value doValue(Value operand, OperandMode mode, EnumSet flags) { if (isVariableOrRegister(operand)) { - addTemp(operand, opId, RegisterPriority.MustHaveRegister, operand.getKind().getStackKind()); + addTemp((AllocatableValue) operand, opId, RegisterPriority.MustHaveRegister, operand.getKind().getStackKind()); addRegisterHint(op, operand, mode, flags, false); } return operand; @@ -1220,7 +1220,7 @@ public Value doValue(Value operand, OperandMode mode, EnumSet flags) { if (isVariableOrRegister(operand)) { RegisterPriority p = registerPriorityOfInputOperand(flags); - addUse(operand, blockFrom, opId + 1, p, operand.getKind().getStackKind()); + addUse((AllocatableValue) operand, blockFrom, opId + 1, p, operand.getKind().getStackKind()); addRegisterHint(op, operand, mode, flags, false); } return operand; @@ -1232,7 +1232,7 @@ public Value doValue(Value operand, OperandMode mode, EnumSet flags) { if (isVariableOrRegister(operand)) { RegisterPriority p = registerPriorityOfInputOperand(flags); - addUse(operand, blockFrom, opId, p, operand.getKind().getStackKind()); + addUse((AllocatableValue) operand, blockFrom, opId, p, operand.getKind().getStackKind()); addRegisterHint(op, operand, mode, flags, false); } return operand; @@ -1247,7 +1247,7 @@ @Override public Value doValue(Value operand) { - addUse(operand, blockFrom, opId + 1, RegisterPriority.None, operand.getKind().getStackKind()); + addUse((AllocatableValue) operand, blockFrom, opId + 1, RegisterPriority.None, operand.getKind().getStackKind()); return operand; } }); diff -r b0f9ab5a185b -r de9949311e80 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/MoveResolver.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/MoveResolver.java Thu Apr 25 18:32:33 2013 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/MoveResolver.java Thu Apr 25 18:37:41 2013 +0200 @@ -196,8 +196,8 @@ assert fromInterval.kind() == toInterval.kind() : "move between different types"; assert insertIdx != -1 : "must setup insert position first"; - Value fromOpr = fromInterval.operand; - Value toOpr = toInterval.operand; + AllocatableValue fromOpr = fromInterval.operand; + AllocatableValue toOpr = toInterval.operand; insertionBuffer.append(insertIdx, allocator.ir.spillMoveFactory.createMove(toOpr, fromOpr)); @@ -210,7 +210,7 @@ assert fromOpr.getKind() == toInterval.kind() : "move between different types"; assert insertIdx != -1 : "must setup insert position first"; - Value toOpr = toInterval.operand; + AllocatableValue toOpr = toInterval.operand; insertionBuffer.append(insertIdx, allocator.ir.spillMoveFactory.createMove(toOpr, fromOpr)); if (GraalOptions.TraceLinearScanLevel >= 4) { diff -r b0f9ab5a185b -r de9949311e80 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java Thu Apr 25 18:32:33 2013 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java Thu Apr 25 18:37:41 2013 +0200 @@ -52,7 +52,7 @@ /** * This class traverses the HIR instructions and generates LIR instructions from them. */ -public abstract class LIRGenerator extends LIRGeneratorTool { +public abstract class LIRGenerator implements LIRGeneratorTool { public final FrameMap frameMap; public final NodeMap nodeOperands; @@ -168,8 +168,8 @@ @Override public Value setResult(ValueNode x, Value operand) { - assert (isVariable(operand) && x.kind() == operand.getKind()) || (isRegister(operand) && !attributes(asRegister(operand)).isAllocatable()) || - (isConstant(operand) && x.kind() == operand.getKind().getStackKind()) : operand.getKind() + " for node " + x; + assert (!isVariable(operand) || x.kind() == operand.getKind()) : operand.getKind() + " for node " + x; + assert (!isRegister(operand) || !attributes(asRegister(operand)).isAllocatable()); assert operand(x) == null : "operand cannot be set twice"; assert operand != null && isLegal(operand) : "operand must be legal"; assert operand.getKind().getStackKind() == x.kind() : operand.getKind().getStackKind() + " must match " + x.kind(); @@ -251,7 +251,7 @@ * @return the operand representing the ABI defined location used return a value of kind * {@code kind} */ - public Value resultOperandFor(Kind kind) { + public AllocatableValue resultOperandFor(Kind kind) { if (kind == Kind.Void) { return ILLEGAL; } @@ -461,7 +461,7 @@ @Override public void visitReturn(ReturnNode x) { - Value operand = Value.ILLEGAL; + AllocatableValue operand = ILLEGAL; if (x.result() != null) { operand = resultOperandFor(x.result().kind()); emitMove(operand, operand(x.result())); @@ -630,7 +630,7 @@ protected abstract void emitCall(RuntimeCallTarget callTarget, Value result, Value[] arguments, Value[] temps, LIRFrameState info); - protected static Value toStackKind(Value value) { + protected static AllocatableValue toStackKind(AllocatableValue value) { if (value.getKind().getStackKind() != value.getKind()) { // We only have stack-kinds in the LIR, so convert the operand kind for values from the // calling convention. @@ -651,7 +651,7 @@ int j = 0; for (ValueNode arg : arguments) { if (arg != null) { - Value operand = toStackKind(cc.getArgument(j)); + AllocatableValue operand = toStackKind(cc.getArgument(j)); emitMove(operand, operand(arg)); result[j] = operand; j++; @@ -672,7 +672,7 @@ Value[] argLocations = new Value[args.length]; for (int i = 0; i < args.length; i++) { Value arg = args[i]; - Value loc = cc.getArgument(i); + AllocatableValue loc = cc.getArgument(i); emitMove(loc, arg); argLocations[i] = loc; } @@ -826,6 +826,10 @@ return frameMap; } + @Override + public void beforeRegisterAllocation() { + } + public abstract void emitBitCount(Variable result, Value operand); public abstract void emitBitScanForward(Variable result, Value operand); diff -r b0f9ab5a185b -r de9949311e80 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/PhiResolver.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/PhiResolver.java Thu Apr 25 18:32:33 2013 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/PhiResolver.java Thu Apr 25 18:37:41 2013 +0200 @@ -22,9 +22,9 @@ */ package com.oracle.graal.compiler.gen; +import static com.oracle.graal.api.code.ValueUtil.*; import static com.oracle.graal.api.meta.Value.*; import static com.oracle.graal.lir.LIRValueUtil.*; -import static com.oracle.graal.api.code.ValueUtil.*; import java.util.*; @@ -187,7 +187,7 @@ private void emitMove(Value dest, Value src) { assert isLegal(src); assert isLegal(dest); - gen.emitMove(dest, src); + gen.emitMove((AllocatableValue) dest, src); } // Traverse assignment graph in depth first order and generate moves in post order diff -r b0f9ab5a185b -r de9949311e80 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java Thu Apr 25 18:32:33 2013 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java Thu Apr 25 18:37:41 2013 +0200 @@ -243,9 +243,9 @@ @Override protected void emitIndirectCall(IndirectCallTargetNode callTarget, Value result, Value[] parameters, Value[] temps, LIRFrameState callState) { - Value metaspaceMethod = AMD64.rbx.asValue(); + AllocatableValue metaspaceMethod = AMD64.rbx.asValue(); emitMove(metaspaceMethod, operand(((HotSpotIndirectCallTargetNode) callTarget).metaspaceMethod())); - Value targetAddress = AMD64.rax.asValue(); + AllocatableValue targetAddress = AMD64.rax.asValue(); emitMove(targetAddress, operand(callTarget.computedAddress())); append(new AMD64IndirectCallOp(callTarget.target(), result, parameters, temps, metaspaceMethod, targetAddress, callState)); } diff -r b0f9ab5a185b -r de9949311e80 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRegisterConfig.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRegisterConfig.java Thu Apr 25 18:32:33 2013 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRegisterConfig.java Thu Apr 25 18:37:41 2013 +0200 @@ -143,7 +143,7 @@ } private CallingConvention callingConvention(Register[] generalParameterRegisters, JavaType returnType, JavaType[] parameterTypes, Type type, TargetDescription target, boolean stackOnly) { - Value[] locations = new Value[parameterTypes.length]; + AllocatableValue[] locations = new AllocatableValue[parameterTypes.length]; int currentGeneral = 0; int currentXMM = 0; @@ -183,7 +183,7 @@ } Kind returnKind = returnType == null ? Kind.Void : returnType.getKind(); - Value returnLocation = returnKind == Kind.Void ? Value.ILLEGAL : getReturnRegister(returnKind).asValue(returnKind); + AllocatableValue returnLocation = returnKind == Kind.Void ? Value.ILLEGAL : getReturnRegister(returnKind).asValue(returnKind); return new CallingConvention(currentStackOffset, returnLocation, locations); } diff -r b0f9ab5a185b -r de9949311e80 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotUnwindOp.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotUnwindOp.java Thu Apr 25 18:32:33 2013 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotUnwindOp.java Thu Apr 25 18:37:41 2013 +0200 @@ -29,6 +29,7 @@ import com.oracle.graal.amd64.*; import com.oracle.graal.api.code.*; import com.oracle.graal.api.code.RuntimeCallTarget.Descriptor; +import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.amd64.*; import com.oracle.graal.lir.LIRInstruction.Opcode; import com.oracle.graal.lir.amd64.*; diff -r b0f9ab5a185b -r de9949311e80 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64SafepointOp.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64SafepointOp.java Thu Apr 25 18:32:33 2013 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64SafepointOp.java Thu Apr 25 18:37:41 2013 +0200 @@ -27,6 +27,7 @@ import sun.misc.*; import com.oracle.graal.api.code.*; +import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.amd64.*; import com.oracle.graal.hotspot.*; import com.oracle.graal.hotspot.bridge.*; diff -r b0f9ab5a185b -r de9949311e80 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotRuntimeCallTarget.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotRuntimeCallTarget.java Thu Apr 25 18:32:33 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotRuntimeCallTarget.java Thu Apr 25 18:37:41 2013 +0200 @@ -91,13 +91,13 @@ assert stub != null : "linkage without an address must be a stub"; InstalledCode code = stub.getCode(backend); - Value[] argumentLocations = new Value[cc.getArgumentCount()]; + AllocatableValue[] argumentLocations = new AllocatableValue[cc.getArgumentCount()]; for (int i = 0; i < argumentLocations.length; i++) { argumentLocations[i] = cc.getArgument(i); } Set definedRegisters = stub.getDefinedRegisters(); - Value[] temporaryLocations = new Value[definedRegisters.size()]; + AllocatableValue[] temporaryLocations = new AllocatableValue[definedRegisters.size()]; int i = 0; for (Register reg : definedRegisters) { temporaryLocations[i++] = reg.asValue(); diff -r b0f9ab5a185b -r de9949311e80 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Thu Apr 25 18:32:33 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Thu Apr 25 18:37:41 2013 +0200 @@ -47,8 +47,8 @@ import com.oracle.graal.api.code.CodeUtil.RefMapFormatter; import com.oracle.graal.api.code.CompilationResult.Call; import com.oracle.graal.api.code.CompilationResult.DataPatch; +import com.oracle.graal.api.code.CompilationResult.Infopoint; import com.oracle.graal.api.code.CompilationResult.Mark; -import com.oracle.graal.api.code.CompilationResult.Infopoint; import com.oracle.graal.api.code.Register.RegisterFlag; import com.oracle.graal.api.code.RuntimeCallTarget.Descriptor; import com.oracle.graal.api.meta.*; @@ -163,23 +163,23 @@ } } - protected Value ret(Kind kind) { + protected AllocatableValue ret(Kind kind) { if (kind == Kind.Void) { return ILLEGAL; } return globalStubRegConfig.getReturnRegister(kind).asValue(kind); } - protected Value[] javaCallingConvention(Kind... arguments) { + protected AllocatableValue[] javaCallingConvention(Kind... arguments) { return callingConvention(arguments, RuntimeCall); } - protected Value[] nativeCallingConvention(Kind... arguments) { + protected AllocatableValue[] nativeCallingConvention(Kind... arguments) { return callingConvention(arguments, NativeCall); } - private Value[] callingConvention(Kind[] arguments, CallingConvention.Type type) { - Value[] result = new Value[arguments.length]; + private AllocatableValue[] callingConvention(Kind[] arguments, CallingConvention.Type type) { + AllocatableValue[] result = new AllocatableValue[arguments.length]; TargetDescription target = graalRuntime.getTarget(); int currentStackOffset = 0; @@ -285,7 +285,7 @@ * @param ret where the call returns its result * @param args where arguments are passed to the call */ - protected RuntimeCallTarget addStubCall(Descriptor descriptor, Value ret, Value... args) { + protected RuntimeCallTarget addStubCall(Descriptor descriptor, AllocatableValue ret, AllocatableValue... args) { return addRuntimeCall(descriptor, 0L, null, ret, args); } @@ -298,8 +298,8 @@ * @param ret where the call returns its result * @param args where arguments are passed to the call */ - protected RuntimeCallTarget addRuntimeCall(Descriptor descriptor, long address, Register[] tempRegs, Value ret, Value... args) { - Value[] temps = tempRegs == null || tempRegs.length == 0 ? Value.NONE : new Value[tempRegs.length]; + protected RuntimeCallTarget addRuntimeCall(Descriptor descriptor, long address, Register[] tempRegs, AllocatableValue ret, AllocatableValue... args) { + AllocatableValue[] temps = tempRegs == null || tempRegs.length == 0 ? AllocatableValue.NONE : new AllocatableValue[tempRegs.length]; for (int i = 0; i < temps.length; i++) { temps[i] = tempRegs[i].asValue(); } diff -r b0f9ab5a185b -r de9949311e80 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/BeginLockScopeNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/BeginLockScopeNode.java Thu Apr 25 18:32:33 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/BeginLockScopeNode.java Thu Apr 25 18:37:41 2013 +0200 @@ -73,7 +73,7 @@ HotSpotLIRGenerator hsGen = (HotSpotLIRGenerator) gen; StackSlot slot = hsGen.getLockSlot(lockDepth); if (!eliminated) { - Value result = gen.emitLea(slot); + Value result = gen.emitAddress(slot); gen.setResult(this, result); } } diff -r b0f9ab5a185b -r de9949311e80 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CurrentLockNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CurrentLockNode.java Thu Apr 25 18:32:33 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CurrentLockNode.java Thu Apr 25 18:37:41 2013 +0200 @@ -57,7 +57,7 @@ HotSpotLIRGenerator hsGen = (HotSpotLIRGenerator) gen; StackSlot slot = hsGen.getLockSlot(lockDepth); // The register allocator cannot handle stack -> register moves so we use an LEA here - Value result = gen.emitMove(gen.emitLea(slot)); + Value result = gen.emitMove(gen.emitAddress(slot)); gen.setResult(this, result); } diff -r b0f9ab5a185b -r de9949311e80 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/DimensionsNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/DimensionsNode.java Thu Apr 25 18:32:33 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/DimensionsNode.java Thu Apr 25 18:37:41 2013 +0200 @@ -47,7 +47,7 @@ public void generate(LIRGenerator gen) { int size = rank * 4; StackSlot array = gen.frameMap().allocateStackBlock(size, false); - Value result = gen.emitLea(array); + Value result = gen.emitAddress(array); gen.setResult(this, result); } diff -r b0f9ab5a185b -r de9949311e80 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/GetObjectAddressNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/GetObjectAddressNode.java Thu Apr 25 18:32:33 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/GetObjectAddressNode.java Thu Apr 25 18:37:41 2013 +0200 @@ -46,7 +46,7 @@ @Override public void generate(LIRGeneratorTool gen) { - Value obj = gen.newVariable(gen.target().wordKind); + AllocatableValue obj = gen.newVariable(gen.target().wordKind); gen.emitMove(obj, gen.operand(object)); gen.setResult(this, obj); } diff -r b0f9ab5a185b -r de9949311e80 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/MonitorCounterNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/MonitorCounterNode.java Thu Apr 25 18:32:33 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/MonitorCounterNode.java Thu Apr 25 18:37:41 2013 +0200 @@ -43,7 +43,7 @@ public void generate(LIRGenerator gen) { assert graph().getNodes().filter(MonitorCounterNode.class).count() == 1 : "monitor counters not canonicalized to single instance"; StackSlot counter = gen.frameMap().allocateStackBlock(gen.target().wordSize, false); - Value result = gen.emitLea(counter); + Value result = gen.emitAddress(counter); gen.setResult(this, result); } diff -r b0f9ab5a185b -r de9949311e80 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/MonitorExitStubCall.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/MonitorExitStubCall.java Thu Apr 25 18:32:33 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/MonitorExitStubCall.java Thu Apr 25 18:37:41 2013 +0200 @@ -60,7 +60,7 @@ HotSpotLIRGenerator hsGen = (HotSpotLIRGenerator) gen; StackSlot slot = hsGen.getLockSlot(lockDepth); RuntimeCallTarget stub = gen.getRuntime().lookupRuntimeCall(MonitorExitStubCall.MONITOREXIT); - gen.emitCall(stub, stub.getCallingConvention(), this, gen.operand(object), gen.emitLea(slot)); + gen.emitCall(stub, stub.getCallingConvention(), this, gen.operand(object), gen.emitAddress(slot)); } @NodeIntrinsic diff -r b0f9ab5a185b -r de9949311e80 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/TailcallNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/TailcallNode.java Thu Apr 25 18:32:33 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/TailcallNode.java Thu Apr 25 18:37:41 2013 +0200 @@ -71,7 +71,8 @@ parameters.add(frameState.localAt(slot)); } Value[] args = gen.visitInvokeArguments(cc, parameters); - Value entry = gen.emitLoad(Kind.Long, gen.operand(target), config.nmethodEntryOffset, Value.ILLEGAL, 0, null); + Value address = gen.emitAddress(gen.operand(target), config.nmethodEntryOffset, Value.ILLEGAL, 0); + Value entry = gen.emitLoad(Kind.Long, address, null); HotSpotLIRGenerator hsgen = (HotSpotLIRGenerator) gen; hsgen.emitTailcall(args, entry); } diff -r b0f9ab5a185b -r de9949311e80 graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64AddressValue.java --- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64AddressValue.java Thu Apr 25 18:32:33 2013 +0200 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64AddressValue.java Thu Apr 25 18:37:41 2013 +0200 @@ -30,18 +30,19 @@ import com.oracle.graal.asm.amd64.*; import com.oracle.graal.asm.amd64.AMD64Address.Scale; import com.oracle.graal.lir.*; +import com.oracle.graal.lir.LIRInstruction.OperandFlag; public class AMD64AddressValue extends CompositeValue { private static final long serialVersionUID = -4444600052487578694L; - @Component({REG, UNUSED}) protected AllocatableValue base; - @Component({REG, UNUSED}) protected AllocatableValue index; + @Component({REG, OperandFlag.ILLEGAL}) protected AllocatableValue base; + @Component({REG, OperandFlag.ILLEGAL}) protected AllocatableValue index; protected final Scale scale; protected final int displacement; public AMD64AddressValue(Kind kind, AllocatableValue base, int displacement) { - this(kind, base, AllocatableValue.UNUSED, Scale.Times1, displacement); + this(kind, base, Value.ILLEGAL, Scale.Times1, displacement); } public AMD64AddressValue(Kind kind, AllocatableValue base, AllocatableValue index, Scale scale, int displacement) { @@ -53,7 +54,7 @@ } private static Register toRegister(AllocatableValue value) { - if (value == AllocatableValue.UNUSED) { + if (value == Value.ILLEGAL) { return Register.None; } else { RegisterValue reg = (RegisterValue) value; @@ -67,8 +68,7 @@ @Override public String toString() { - StringBuilder s = new StringBuilder(); - s.append(getKind().getJavaName()).append("["); + StringBuilder s = new StringBuilder("["); String sep = ""; if (isLegal(base)) { s.append(base); diff -r b0f9ab5a185b -r de9949311e80 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 Thu Apr 25 18:32:33 2013 +0200 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Arithmetic.java Thu Apr 25 18:37:41 2013 +0200 @@ -26,7 +26,6 @@ import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*; import com.oracle.graal.amd64.*; -import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.amd64.*; import com.oracle.graal.graph.*; diff -r b0f9ab5a185b -r de9949311e80 graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64BitManipulationOp.java --- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64BitManipulationOp.java Thu Apr 25 18:32:33 2013 +0200 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64BitManipulationOp.java Thu Apr 25 18:37:41 2013 +0200 @@ -23,6 +23,7 @@ package com.oracle.graal.lir.amd64; import com.oracle.graal.api.code.*; +import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.amd64.*; import com.oracle.graal.lir.asm.*; diff -r b0f9ab5a185b -r de9949311e80 graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Move.java --- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Move.java Thu Apr 25 18:32:33 2013 +0200 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Move.java Thu Apr 25 18:37:41 2013 +0200 @@ -44,10 +44,10 @@ @Opcode("MOVE") public static class MoveToRegOp extends AMD64LIRInstruction implements MoveOp { - @Def({REG, HINT}) protected Value result; + @Def({REG, HINT}) protected AllocatableValue result; @Use({REG, STACK, CONST}) protected Value input; - public MoveToRegOp(Value result, Value input) { + public MoveToRegOp(AllocatableValue result, Value input) { this.result = result; this.input = input; } @@ -63,7 +63,7 @@ } @Override - public Value getResult() { + public AllocatableValue getResult() { return result; } } @@ -71,10 +71,10 @@ @Opcode("MOVE") public static class MoveFromRegOp extends AMD64LIRInstruction implements MoveOp { - @Def({REG, STACK}) protected Value result; + @Def({REG, STACK}) protected AllocatableValue result; @Use({REG, CONST, HINT}) protected Value input; - public MoveFromRegOp(Value result, Value input) { + public MoveFromRegOp(AllocatableValue result, Value input) { this.result = result; this.input = input; } @@ -90,17 +90,19 @@ } @Override - public Value getResult() { + public AllocatableValue getResult() { return result; } } public abstract static class MemOp extends AMD64LIRInstruction { + protected final Kind kind; @Use({COMPOSITE}) protected AMD64AddressValue address; @State protected LIRFrameState state; - public MemOp(AMD64AddressValue address, LIRFrameState state) { + public MemOp(Kind kind, AMD64AddressValue address, LIRFrameState state) { + this.kind = kind; this.address = address; this.state = state; } @@ -120,14 +122,14 @@ @Def({REG}) protected AllocatableValue result; - public LoadOp(AllocatableValue result, AMD64AddressValue address, LIRFrameState state) { - super(address, state); + public LoadOp(Kind kind, AllocatableValue result, AMD64AddressValue address, LIRFrameState state) { + super(kind, address, state); this.result = result; } @Override public void emitMemAccess(AMD64MacroAssembler masm) { - switch (address.getKind()) { + switch (kind) { case Boolean: case Byte: masm.movsxb(asRegister(result), address.toAddress()); @@ -163,15 +165,15 @@ @Use({REG}) protected AllocatableValue input; - public StoreOp(AMD64AddressValue address, AllocatableValue input, LIRFrameState state) { - super(address, state); + public StoreOp(Kind kind, AMD64AddressValue address, AllocatableValue input, LIRFrameState state) { + super(kind, address, state); this.input = input; } @Override public void emitMemAccess(AMD64MacroAssembler masm) { assert isRegister(input); - switch (address.getKind()) { + switch (kind) { case Boolean: case Byte: masm.movb(address.toAddress(), asRegister(input)); @@ -205,14 +207,14 @@ protected final Constant input; - public StoreConstantOp(AMD64AddressValue address, Constant input, LIRFrameState state) { - super(address, state); + public StoreConstantOp(Kind kind, AMD64AddressValue address, Constant input, LIRFrameState state) { + super(kind, address, state); this.input = input; } @Override public void emitMemAccess(AMD64MacroAssembler masm) { - switch (address.getKind()) { + switch (kind) { case Boolean: case Byte: masm.movb(address.toAddress(), input.asInt() & 0xFF); diff -r b0f9ab5a185b -r de9949311e80 graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXAddressValue.java --- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXAddressValue.java Thu Apr 25 18:32:33 2013 +0200 +++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXAddressValue.java Thu Apr 25 18:37:41 2013 +0200 @@ -29,6 +29,7 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.ptx.*; import com.oracle.graal.lir.*; +import com.oracle.graal.lir.LIRInstruction.OperandFlag; /** * Represents an address in target machine memory, specified via some combination of a base register @@ -38,7 +39,7 @@ private static final long serialVersionUID = 1802222435353022623L; - @Component({REG, UNUSED}) private AllocatableValue base; + @Component({REG, OperandFlag.ILLEGAL}) private AllocatableValue base; private final long displacement; /** @@ -68,7 +69,7 @@ } public PTXAddress toAddress() { - Register baseReg = base == AllocatableValue.UNUSED ? Register.None : asRegister(base); + Register baseReg = base == Value.ILLEGAL ? Register.None : asRegister(base); return new PTXAddress(baseReg, displacement); } diff -r b0f9ab5a185b -r de9949311e80 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 Thu Apr 25 18:32:33 2013 +0200 +++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXArithmetic.java Thu Apr 25 18:37:41 2013 +0200 @@ -25,7 +25,6 @@ import static com.oracle.graal.api.code.ValueUtil.*; import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*; -import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.ptx.*; import com.oracle.graal.graph.*; diff -r b0f9ab5a185b -r de9949311e80 graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXControlFlow.java --- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXControlFlow.java Thu Apr 25 18:32:33 2013 +0200 +++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXControlFlow.java Thu Apr 25 18:37:41 2013 +0200 @@ -97,6 +97,7 @@ @SuppressWarnings("unused") public static class CondMoveOp extends PTXLIRInstruction { + @Def({REG, HINT}) protected Value result; @Alive({REG}) protected Value trueValue; @Use({REG, STACK, CONST}) protected Value falseValue; @@ -119,6 +120,7 @@ @SuppressWarnings("unused") public static class FloatCondMoveOp extends PTXLIRInstruction { + @Def({REG}) protected Value result; @Alive({REG}) protected Value trueValue; @Alive({REG}) protected Value falseValue; @@ -142,14 +144,14 @@ } public static class SequentialSwitchOp extends PTXLIRInstruction implements FallThroughOp { + @Use({CONST}) protected Constant[] keyConstants; private final LabelRef[] keyTargets; private LabelRef defaultTarget; @Alive({REG}) protected Value key; @Temp({REG, ILLEGAL}) protected Value scratch; - public SequentialSwitchOp(Constant[] keyConstants, LabelRef[] keyTargets, LabelRef defaultTarget, - Value key, Value scratch) { + public SequentialSwitchOp(Constant[] keyConstants, LabelRef[] keyTargets, LabelRef defaultTarget, Value key, Value scratch) { assert keyConstants.length == keyTargets.length; this.keyConstants = keyConstants; this.keyTargets = keyTargets; @@ -216,14 +218,14 @@ } public static class TableSwitchOp extends PTXLIRInstruction { + private final int lowKey; private final LabelRef defaultTarget; private final LabelRef[] targets; @Alive protected Value index; @Temp protected Value scratch; - public TableSwitchOp(final int lowKey, final LabelRef defaultTarget, final LabelRef[] targets, - Variable index, Variable scratch) { + public TableSwitchOp(final int lowKey, final LabelRef defaultTarget, final LabelRef[] targets, Variable index, Variable scratch) { this.lowKey = lowKey; this.defaultTarget = defaultTarget; this.targets = targets; @@ -238,9 +240,7 @@ } @SuppressWarnings("unused") - private static void tableswitch(TargetMethodAssembler tasm, PTXAssembler masm, int lowKey, - LabelRef defaultTarget, LabelRef[] targets, - Register value, Register scratch) { + private static void tableswitch(TargetMethodAssembler tasm, PTXAssembler masm, int lowKey, LabelRef defaultTarget, LabelRef[] targets, Register value, Register scratch) { Buffer buf = masm.codeBuffer; // Compare index against jump table bounds int highKey = lowKey + targets.length - 1; diff -r b0f9ab5a185b -r de9949311e80 graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXMove.java --- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXMove.java Thu Apr 25 18:32:33 2013 +0200 +++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXMove.java Thu Apr 25 18:37:41 2013 +0200 @@ -39,10 +39,10 @@ @Opcode("MOVE") public static class SpillMoveOp extends PTXLIRInstruction implements MoveOp { - @Def({REG, STACK}) protected Value result; + @Def({REG, STACK}) protected AllocatableValue result; @Use({REG, STACK, CONST}) protected Value input; - public SpillMoveOp(Value result, Value input) { + public SpillMoveOp(AllocatableValue result, Value input) { this.result = result; this.input = input; } @@ -58,7 +58,7 @@ } @Override - public Value getResult() { + public AllocatableValue getResult() { return result; } } @@ -66,10 +66,10 @@ @Opcode("MOVE") public static class MoveToRegOp extends PTXLIRInstruction implements MoveOp { - @Def({REG, HINT}) protected Value result; + @Def({REG, HINT}) protected AllocatableValue result; @Use({REG, STACK, CONST}) protected Value input; - public MoveToRegOp(Value result, Value input) { + public MoveToRegOp(AllocatableValue result, Value input) { this.result = result; this.input = input; } @@ -85,7 +85,7 @@ } @Override - public Value getResult() { + public AllocatableValue getResult() { return result; } } @@ -93,10 +93,10 @@ @Opcode("MOVE") public static class MoveFromRegOp extends PTXLIRInstruction implements MoveOp { - @Def({REG, STACK}) protected Value result; + @Def({REG, STACK}) protected AllocatableValue result; @Use({REG, CONST, HINT}) protected Value input; - public MoveFromRegOp(Value result, Value input) { + public MoveFromRegOp(AllocatableValue result, Value input) { this.result = result; this.input = input; } @@ -112,18 +112,20 @@ } @Override - public Value getResult() { + public AllocatableValue getResult() { return result; } } public static class LoadOp extends PTXLIRInstruction { + private final Kind kind; @Def({REG}) protected AllocatableValue result; @Use({COMPOSITE}) protected PTXAddressValue address; @State protected LIRFrameState state; - public LoadOp(AllocatableValue result, PTXAddressValue address, LIRFrameState state) { + public LoadOp(Kind kind, AllocatableValue result, PTXAddressValue address, LIRFrameState state) { + this.kind = kind; this.result = result; this.address = address; this.state = state; @@ -132,7 +134,7 @@ @Override public void emitCode(TargetMethodAssembler tasm, PTXAssembler masm) { PTXAddress addr = address.toAddress(); - switch (address.getKind()) { + switch (kind) { case Byte: masm.ld_global_s8(asRegister(result), addr.getBase(), addr.getDisplacement()); break; @@ -165,11 +167,13 @@ public static class StoreOp extends PTXLIRInstruction { + private final Kind kind; @Use({COMPOSITE}) protected PTXAddressValue address; @Use({REG}) protected AllocatableValue input; @State protected LIRFrameState state; - public StoreOp(PTXAddressValue address, AllocatableValue input, LIRFrameState state) { + public StoreOp(Kind kind, PTXAddressValue address, AllocatableValue input, LIRFrameState state) { + this.kind = kind; this.address = address; this.input = input; this.state = state; @@ -179,7 +183,7 @@ public void emitCode(TargetMethodAssembler tasm, PTXAssembler masm) { assert isRegister(input); PTXAddress addr = address.toAddress(); - switch (address.getKind()) { + switch (kind) { case Byte: masm.st_global_s8(addr.getBase(), addr.getDisplacement(), asRegister(input)); break; diff -r b0f9ab5a185b -r de9949311e80 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIR.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIR.java Thu Apr 25 18:32:33 2013 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIR.java Thu Apr 25 18:37:41 2013 +0200 @@ -64,7 +64,7 @@ public interface SpillMoveFactory { - LIRInstruction createMove(Value result, Value input); + LIRInstruction createMove(AllocatableValue result, Value input); } private boolean hasArgInCallerFrame; diff -r b0f9ab5a185b -r de9949311e80 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 Thu Apr 25 18:32:33 2013 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRInstruction.java Thu Apr 25 18:37:41 2013 +0200 @@ -181,11 +181,6 @@ ILLEGAL, /** - * The value can be {@link AllocatableValue#UNUSED}. - */ - UNUSED, - - /** * The register allocator should try to assign a certain register to improve code quality. * Use {@link LIRInstruction#forEachRegisterHint} to access the register hints. */ @@ -205,10 +200,10 @@ static { ALLOWED_FLAGS = new EnumMap<>(OperandMode.class); - ALLOWED_FLAGS.put(USE, EnumSet.of(REG, STACK, COMPOSITE, CONST, ILLEGAL, HINT, UNUSED, UNINITIALIZED)); - ALLOWED_FLAGS.put(ALIVE, EnumSet.of(REG, STACK, COMPOSITE, CONST, ILLEGAL, HINT, UNUSED, UNINITIALIZED)); - ALLOWED_FLAGS.put(TEMP, EnumSet.of(REG, COMPOSITE, CONST, ILLEGAL, UNUSED, HINT)); - ALLOWED_FLAGS.put(DEF, EnumSet.of(REG, STACK, COMPOSITE, ILLEGAL, UNUSED, HINT)); + 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)); } /** diff -r b0f9ab5a185b -r de9949311e80 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRVerifier.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRVerifier.java Thu Apr 25 18:32:33 2013 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRVerifier.java Thu Apr 25 18:37:41 2013 +0200 @@ -232,8 +232,7 @@ private static Value allowed(Object op, Value value, OperandMode mode, EnumSet flags) { if ((isVariable(value) && flags.contains(OperandFlag.REG)) || (isRegister(value) && flags.contains(OperandFlag.REG)) || (isStackSlot(value) && flags.contains(OperandFlag.STACK)) || - (isConstant(value) && flags.contains(OperandFlag.CONST) && mode != OperandMode.DEF) || (isIllegal(value) && flags.contains(OperandFlag.ILLEGAL)) || - (value == AllocatableValue.UNUSED && flags.contains(OperandFlag.UNUSED))) { + (isConstant(value) && flags.contains(OperandFlag.CONST) && mode != OperandMode.DEF) || (isIllegal(value) && flags.contains(OperandFlag.ILLEGAL))) { return value; } TTY.println("instruction %s", op); diff -r b0f9ab5a185b -r de9949311e80 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 Thu Apr 25 18:32:33 2013 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/StandardOp.java Thu Apr 25 18:37:41 2013 +0200 @@ -22,14 +22,14 @@ */ package com.oracle.graal.lir; +import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*; + import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.*; import com.oracle.graal.graph.*; import com.oracle.graal.lir.asm.*; import com.oracle.graal.nodes.cfg.*; -import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*; - /** * A collection of machine-independent LIR operations, as well as interfaces to be implemented for * specific kinds or LIR operations. @@ -117,7 +117,7 @@ Value getInput(); - Value getResult(); + AllocatableValue getResult(); } /** diff -r b0f9ab5a185b -r de9949311e80 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/AddLocationNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/AddLocationNode.java Thu Apr 25 18:32:33 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/AddLocationNode.java Thu Apr 25 18:37:41 2013 +0200 @@ -91,18 +91,6 @@ return getY().generateAddress(gen, xAddr); } - @Override - public Value generateLoad(LIRGeneratorTool gen, Value base, DeoptimizingNode deopting) { - Value xAddr = getX().generateAddress(gen, base); - return getY().generateLoad(gen, xAddr, deopting); - } - - @Override - public void generateStore(LIRGeneratorTool gen, Value base, Value value, DeoptimizingNode deopting) { - Value xAddr = getX().generateAddress(gen, base); - getY().generateStore(gen, xAddr, value, deopting); - } - @NodeIntrinsic public static native Location addLocation(@ConstantNodeParameter Object identity, @ConstantNodeParameter Kind kind, Location x, Location y); } diff -r b0f9ab5a185b -r de9949311e80 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ConstantLocationNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ConstantLocationNode.java Thu Apr 25 18:32:33 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ConstantLocationNode.java Thu Apr 25 18:37:41 2013 +0200 @@ -24,7 +24,6 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.graph.*; -import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.spi.*; /** @@ -56,16 +55,6 @@ @Override public Value generateAddress(LIRGeneratorTool gen, Value base) { - return gen.emitLea(base, displacement(), Value.ILLEGAL, 0); - } - - @Override - public Value generateLoad(LIRGeneratorTool gen, Value base, DeoptimizingNode deopting) { - return gen.emitLoad(getValueKind(), base, displacement(), Value.ILLEGAL, 0, deopting); - } - - @Override - public void generateStore(LIRGeneratorTool gen, Value base, Value value, DeoptimizingNode deopting) { - gen.emitStore(getValueKind(), base, displacement(), Value.ILLEGAL, 0, value, deopting); + return gen.emitAddress(base, displacement(), Value.ILLEGAL, 0); } } diff -r b0f9ab5a185b -r de9949311e80 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/FloatingReadNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/FloatingReadNode.java Thu Apr 25 18:32:33 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/FloatingReadNode.java Thu Apr 25 18:37:41 2013 +0200 @@ -24,6 +24,7 @@ import java.util.*; +import com.oracle.graal.api.meta.*; import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.spi.*; @@ -53,7 +54,8 @@ @Override public void generate(LIRGeneratorTool gen) { - gen.setResult(this, location().generateLoad(gen, gen.operand(object()), this)); + Value address = location().generateAddress(gen, gen.operand(object())); + gen.setResult(this, gen.emitLoad(location().getValueKind(), address, this)); } @Override diff -r b0f9ab5a185b -r de9949311e80 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/IndexedLocationNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/IndexedLocationNode.java Thu Apr 25 18:32:33 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/IndexedLocationNode.java Thu Apr 25 18:37:41 2013 +0200 @@ -91,17 +91,7 @@ @Override public Value generateAddress(LIRGeneratorTool gen, Value base) { - return gen.emitLea(base, displacement, gen.operand(index()), indexScaling()); - } - - @Override - public Value generateLoad(LIRGeneratorTool gen, Value base, DeoptimizingNode deopting) { - return gen.emitLoad(getValueKind(), base, displacement, gen.operand(index()), indexScaling(), deopting); - } - - @Override - public void generateStore(LIRGeneratorTool gen, Value base, Value value, DeoptimizingNode deopting) { - gen.emitStore(getValueKind(), base, displacement, gen.operand(index()), indexScaling(), value, deopting); + return gen.emitAddress(base, displacement, gen.operand(index()), indexScaling()); } @NodeIntrinsic diff -r b0f9ab5a185b -r de9949311e80 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/LocationNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/LocationNode.java Thu Apr 25 18:32:33 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/LocationNode.java Thu Apr 25 18:37:41 2013 +0200 @@ -24,7 +24,6 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.graph.Node.ValueNumberable; -import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.nodes.type.*; @@ -100,8 +99,4 @@ } public abstract Value generateAddress(LIRGeneratorTool gen, Value base); - - public abstract Value generateLoad(LIRGeneratorTool gen, Value base, DeoptimizingNode deopting); - - public abstract void generateStore(LIRGeneratorTool gen, Value base, Value value, DeoptimizingNode deopting); } diff -r b0f9ab5a185b -r de9949311e80 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ReadNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ReadNode.java Thu Apr 25 18:32:33 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ReadNode.java Thu Apr 25 18:37:41 2013 +0200 @@ -57,7 +57,8 @@ @Override public void generate(LIRGeneratorTool gen) { - gen.setResult(this, location().generateLoad(gen, gen.operand(object()), this)); + Value address = location().generateAddress(gen, gen.operand(object())); + gen.setResult(this, gen.emitLoad(location().getValueKind(), address, this)); } @Override diff -r b0f9ab5a185b -r de9949311e80 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeCastNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeCastNode.java Thu Apr 25 18:32:33 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeCastNode.java Thu Apr 25 18:37:41 2013 +0200 @@ -91,7 +91,7 @@ public void generate(LIRGeneratorTool generator) { if (kind() != object().kind()) { assert generator.target().sizeInBytes(kind()) == generator.target().sizeInBytes(object().kind()) : "unsafe cast cannot be used to change the size of a value"; - Value result = generator.newVariable(kind()); + AllocatableValue result = generator.newVariable(kind()); generator.emitMove(result, generator.operand(object())); generator.setResult(this, result); } else { diff -r b0f9ab5a185b -r de9949311e80 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/WriteNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/WriteNode.java Thu Apr 25 18:32:33 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/WriteNode.java Thu Apr 25 18:37:41 2013 +0200 @@ -22,10 +22,11 @@ */ package com.oracle.graal.nodes.extended; +import com.oracle.graal.api.meta.*; +import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.nodes.type.*; -import com.oracle.graal.graph.*; /** * Writes a given {@linkplain #value() value} a {@linkplain AccessNode memory location}. @@ -84,7 +85,8 @@ @Override public void generate(LIRGeneratorTool gen) { - location().generateStore(gen, gen.operand(object()), gen.operand(value()), this); + Value address = location().generateAddress(gen, gen.operand(object())); + gen.emitStore(location().getValueKind(), address, gen.operand(value()), this); } @NodeIntrinsic diff -r b0f9ab5a185b -r de9949311e80 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LIRGeneratorTool.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LIRGeneratorTool.java Thu Apr 25 18:32:33 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LIRGeneratorTool.java Thu Apr 25 18:37:41 2013 +0200 @@ -29,11 +29,11 @@ import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.java.*; -public abstract class LIRGeneratorTool { +public interface LIRGeneratorTool { - public abstract TargetDescription target(); + TargetDescription target(); - public abstract CodeCacheProvider getRuntime(); + CodeCacheProvider getRuntime(); /** * Checks whether the supplied constant can be used without loading it into a register for most @@ -43,100 +43,99 @@ * @return True if the constant can be used directly, false if the constant needs to be in a * register. */ - public abstract boolean canInlineConstant(Constant c); + boolean canInlineConstant(Constant c); - public abstract RegisterAttributes attributes(Register register); + RegisterAttributes attributes(Register register); - public abstract Value operand(ValueNode object); + Value operand(ValueNode object); - public abstract AllocatableValue newVariable(Kind kind); + AllocatableValue newVariable(Kind kind); - public abstract Value setResult(ValueNode x, Value operand); + Value setResult(ValueNode x, Value operand); - public abstract Value emitMove(Value input); + AllocatableValue emitMove(Value input); - public abstract void emitMove(Value dst, Value src); + void emitMove(AllocatableValue dst, Value src); - public abstract Value emitLoad(Kind kind, Value base, long displacement, Value index, int scale, DeoptimizingNode deopting); + Value emitAddress(Value base, long displacement, Value index, int scale); - public abstract void emitStore(Kind kind, Value base, long displacement, Value index, int scale, Value input, DeoptimizingNode deopting); + Value emitAddress(StackSlot slot); - public abstract Value emitLea(Value base, long displacement, Value index, int scale); + Value emitLoad(Kind kind, Value address, DeoptimizingNode deopting); - public abstract Value emitLea(StackSlot slot); + void emitStore(Kind kind, Value address, Value input, DeoptimizingNode deopting); - public abstract Value emitNegate(Value input); + Value emitNegate(Value input); - public abstract Value emitAdd(Value a, Value b); + Value emitAdd(Value a, Value b); - public abstract Value emitSub(Value a, Value b); + Value emitSub(Value a, Value b); - public abstract Value emitMul(Value a, Value b); + Value emitMul(Value a, Value b); - public abstract Value emitDiv(Value a, Value b, DeoptimizingNode deopting); + Value emitDiv(Value a, Value b, DeoptimizingNode deopting); - public abstract Value emitRem(Value a, Value b, DeoptimizingNode deopting); + Value emitRem(Value a, Value b, DeoptimizingNode deopting); - public abstract Value emitUDiv(Value a, Value b, DeoptimizingNode deopting); + Value emitUDiv(Value a, Value b, DeoptimizingNode deopting); - public abstract Value emitURem(Value a, Value b, DeoptimizingNode deopting); + Value emitURem(Value a, Value b, DeoptimizingNode deopting); - public abstract Value emitAnd(Value a, Value b); + Value emitAnd(Value a, Value b); - public abstract Value emitOr(Value a, Value b); + Value emitOr(Value a, Value b); - public abstract Value emitXor(Value a, Value b); + Value emitXor(Value a, Value b); - public abstract Value emitShl(Value a, Value b); + Value emitShl(Value a, Value b); - public abstract Value emitShr(Value a, Value b); + Value emitShr(Value a, Value b); - public abstract Value emitUShr(Value a, Value b); + Value emitUShr(Value a, Value b); - public abstract Value emitConvert(ConvertNode.Op opcode, Value inputVal); + Value emitConvert(ConvertNode.Op opcode, Value inputVal); - public abstract void emitMembar(int barriers); + void emitMembar(int barriers); - public abstract void emitDeoptimize(DeoptimizationAction action, DeoptimizingNode deopting); + void emitDeoptimize(DeoptimizationAction action, DeoptimizingNode deopting); - public abstract void emitNullCheck(ValueNode v, DeoptimizingNode deopting); + void emitNullCheck(ValueNode v, DeoptimizingNode deopting); - public abstract Value emitCall(RuntimeCallTarget callTarget, CallingConvention cc, DeoptimizingNode info, Value... args); + Value emitCall(RuntimeCallTarget callTarget, CallingConvention cc, DeoptimizingNode info, Value... args); - public abstract void emitIf(IfNode i); + void emitIf(IfNode i); - public abstract void emitConditional(ConditionalNode i); + void emitConditional(ConditionalNode i); - public abstract void emitSwitch(SwitchNode i); + void emitSwitch(SwitchNode i); - public abstract void emitInvoke(Invoke i); + void emitInvoke(Invoke i); - public abstract void visitRuntimeCall(RuntimeCallNode i); + void visitRuntimeCall(RuntimeCallNode i); // Handling of block-end nodes still needs to be unified in the LIRGenerator. - public abstract void visitMerge(MergeNode i); + void visitMerge(MergeNode i); - public abstract void visitEndNode(EndNode i); + void visitEndNode(EndNode i); - public abstract void visitLoopEnd(LoopEndNode i); + void visitLoopEnd(LoopEndNode i); - public abstract void visitCompareAndSwap(CompareAndSwapNode i); + void visitCompareAndSwap(CompareAndSwapNode i); // These methods define the contract a runtime specific backend must provide. - public abstract void visitReturn(ReturnNode i); + void visitReturn(ReturnNode i); - public abstract void visitSafepointNode(SafepointNode i); + void visitSafepointNode(SafepointNode i); - public abstract void visitBreakpointNode(BreakpointNode i); + void visitBreakpointNode(BreakpointNode i); - public abstract void emitUnwind(Value operand); + void emitUnwind(Value operand); /** * Called just before register allocation is performed on the LIR owned by this generator. */ - public void beforeRegisterAllocation() { - } + void beforeRegisterAllocation(); - public abstract void visitInfopointNode(InfopointNode i); + void visitInfopointNode(InfopointNode i); } diff -r b0f9ab5a185b -r de9949311e80 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/DirectReadNode.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/DirectReadNode.java Thu Apr 25 18:32:33 2013 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/DirectReadNode.java Thu Apr 25 18:37:41 2013 +0200 @@ -47,7 +47,7 @@ @Override public void generate(LIRGeneratorTool gen) { - gen.setResult(this, gen.emitLoad(readKind, gen.operand(address), 0, Value.ILLEGAL, 0, null)); + gen.setResult(this, gen.emitLoad(readKind, gen.operand(address), null)); } @SuppressWarnings("unchecked") diff -r b0f9ab5a185b -r de9949311e80 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/DirectStoreNode.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/DirectStoreNode.java Thu Apr 25 18:32:33 2013 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/DirectStoreNode.java Thu Apr 25 18:37:41 2013 +0200 @@ -50,7 +50,7 @@ @Override public void generate(LIRGeneratorTool gen) { Value v = gen.operand(value); - gen.emitStore(kind, gen.operand(address), 0, Value.ILLEGAL, 0, v, null); + gen.emitStore(kind, gen.operand(address), v, null); } /* diff -r b0f9ab5a185b -r de9949311e80 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/WriteRegisterNode.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/WriteRegisterNode.java Thu Apr 25 18:32:33 2013 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/WriteRegisterNode.java Thu Apr 25 18:37:41 2013 +0200 @@ -54,7 +54,7 @@ @Override public void generate(LIRGeneratorTool generator) { Value val = generator.operand(value); - generator.emitMove(val, register.asValue(val.getKind())); + generator.emitMove(register.asValue(val.getKind()), val); } @Override diff -r b0f9ab5a185b -r de9949311e80 src/share/vm/graal/graalJavaAccess.hpp --- a/src/share/vm/graal/graalJavaAccess.hpp Thu Apr 25 18:32:33 2013 +0200 +++ b/src/share/vm/graal/graalJavaAccess.hpp Thu Apr 25 18:37:41 2013 +0200 @@ -197,7 +197,7 @@ end_class \ start_class(Value) \ oop_field(Value, kind, "Lcom/oracle/graal/api/meta/Kind;") \ - static_oop_field(Value, ILLEGAL, "Lcom/oracle/graal/api/meta/Value;"); \ + static_oop_field(Value, ILLEGAL, "Lcom/oracle/graal/api/meta/AllocatableValue;"); \ end_class \ start_class(RegisterValue) \ oop_field(RegisterValue, reg, "Lcom/oracle/graal/api/code/Register;") \