Mercurial > hg > graal-compiler
changeset 16094:c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/ReferenceMap.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/ReferenceMap.java Fri Jun 13 11:47:44 2014 +0200 @@ -27,9 +27,9 @@ public interface ReferenceMap { - void setRegister(int idx, PlatformKind kind); + void setRegister(int idx, LIRKind kind); - void setStackSlot(int offset, PlatformKind kind); + void setStackSlot(int offset, LIRKind kind); boolean hasRegisterRefMap();
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/Register.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/Register.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -147,7 +147,7 @@ * @param kind the specified kind * @return the {@link RegisterValue} */ - public RegisterValue asValue(PlatformKind kind) { + public RegisterValue asValue(LIRKind kind) { return new RegisterValue(kind, this); } @@ -157,7 +157,7 @@ * @return a {@link RegisterValue} with {@link Kind#Illegal} kind. */ public RegisterValue asValue() { - return asValue(Kind.Illegal); + return asValue(LIRKind.Illegal); } /**
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/RegisterValue.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/RegisterValue.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,8 +27,8 @@ /** * Denotes a register that stores a value of a fixed kind. There is exactly one (canonical) instance * of {@link RegisterValue} for each ({@link Register}, {@link Kind}) pair. Use - * {@link Register#asValue(PlatformKind)} to retrieve the canonical {@link RegisterValue} instance - * for a given (register,kind) pair. + * {@link Register#asValue(LIRKind)} to retrieve the canonical {@link RegisterValue} instance for a + * given (register,kind) pair. */ public final class RegisterValue extends AllocatableValue { @@ -39,7 +39,7 @@ /** * Should only be called from {@link Register#Register} to ensure canonicalization. */ - protected RegisterValue(PlatformKind kind, Register register) { + protected RegisterValue(LIRKind kind, Register register) { super(kind); this.reg = register; }
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/StackSlot.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/StackSlot.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,22 +38,22 @@ /** * Gets a {@link StackSlot} instance representing a stack slot at a given index holding a value * of a given kind. - * + * * @param kind The kind of the value stored in the stack slot. * @param offset The offset of the stack slot (in bytes) * @param addFrameSize Specifies if the offset is relative to the stack pointer, or the * beginning of the frame (stack pointer + total frame size). */ - public static StackSlot get(PlatformKind kind, int offset, boolean addFrameSize) { + public static StackSlot get(LIRKind kind, int offset, boolean addFrameSize) { assert addFrameSize || offset >= 0; return new StackSlot(kind, offset, addFrameSize); } /** - * Private constructor to enforce use of {@link #get(PlatformKind, int, boolean)} so that a - * cache can be used. + * Private constructor to enforce use of {@link #get(LIRKind, int, boolean)} so that a cache can + * be used. */ - private StackSlot(PlatformKind kind, int offset, boolean addFrameSize) { + private StackSlot(LIRKind kind, int offset, boolean addFrameSize) { super(kind); this.offset = offset; this.addFrameSize = addFrameSize; @@ -61,7 +61,7 @@ /** * Gets the offset of this stack slot, relative to the stack pointer. - * + * * @return The offset of this slot (in bytes). */ public int getOffset(int totalFrameSize) { @@ -100,7 +100,7 @@ public StackSlot asOutArg() { assert offset >= 0; if (addFrameSize) { - return get(getPlatformKind(), offset, false); + return get(getLIRKind(), offset, false); } return this; } @@ -111,7 +111,7 @@ public StackSlot asInArg() { assert offset >= 0; if (!addFrameSize) { - return get(getPlatformKind(), offset, true); + return get(getLIRKind(), offset, true); } return this; }
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/TargetDescription.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/TargetDescription.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -56,7 +56,7 @@ * The stack alignment requirement of the platform. For example, from Appendix D of <a * href="http://www.intel.com/Assets/PDF/manual/248966.pdf">Intel 64 and IA-32 Architectures * Optimization Reference Manual</a>: - * + * * <pre> * "It is important to ensure that the stack frame is aligned to a * 16-byte boundary upon function entry to keep local __m128 data, @@ -86,5 +86,23 @@ return arch.getSizeInBytes(kind); } + public LIRKind getLIRKind(Kind javaKind) { + switch (javaKind) { + case Boolean: + case Byte: + case Short: + case Char: + case Int: + case Long: + case Float: + case Double: + return LIRKind.value(javaKind); + case Object: + return LIRKind.reference(javaKind); + default: + return LIRKind.Illegal; + } + } + public abstract ReferenceMap createReferenceMap(boolean hasRegisters, int stackSlotCount); }
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/VirtualObject.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/VirtualObject.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,7 +47,7 @@ * returned by {@link ResolvedJavaType#getInstanceFields(boolean) getInstanceFields(true)}. If * {@code type} is an array then the length of the values array determines the reallocated array * length. - * + * * @param type the type of the object whose allocation was removed during compilation. This can * be either an instance of an array type. * @param values an array containing all the values to be stored into the object when it is @@ -61,7 +61,7 @@ } private VirtualObject(ResolvedJavaType type, Value[] values, int id) { - super(Kind.Object); + super(LIRKind.reference(Kind.Object)); this.type = type; this.values = values; this.id = id; @@ -164,7 +164,7 @@ /** * Overwrites the current set of values with a new one. - * + * * @param values an array containing all the values to be stored into the object when it is * recreated. */ @@ -175,7 +175,7 @@ @Override public int hashCode() { - return getPlatformKind().hashCode() + type.hashCode(); + return getLIRKind().hashCode() + type.hashCode(); } @Override
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/AllocatableValue.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/AllocatableValue.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ public static final AllocatableValue[] NONE = {}; - public AllocatableValue(PlatformKind platformKind) { - super(platformKind); + public AllocatableValue(LIRKind lirKind) { + super(lirKind); } }
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Constant.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Constant.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,7 +50,7 @@ public static final Constant TRUE = new PrimitiveConstant(Kind.Boolean, 1L); public static final Constant FALSE = new PrimitiveConstant(Kind.Boolean, 0L); - protected Constant(PlatformKind kind) { + protected Constant(LIRKind kind) { super(kind); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/LIRKind.java Fri Jun 13 11:47:44 2014 +0200 @@ -0,0 +1,204 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.api.meta; + +/** + * Represents the type of values in the LIR. It is composed of a {@link PlatformKind} that gives the + * low level representation of the value, and a {@link #referenceMask} that describes the location + * of object references in the value. + */ +public final class LIRKind { + + /** + * The non-type. This uses {@link #derivedReference}, so it can never be part of an oop map. + */ + public static final LIRKind Illegal = derivedReference(Kind.Illegal); + + private final PlatformKind platformKind; + private final int referenceMask; + + private static final int DERIVED_REFERENCE = -1; + + private LIRKind(PlatformKind platformKind, int referenceMask) { + this.platformKind = platformKind; + this.referenceMask = referenceMask; + } + + /** + * Create a {@link LIRKind} of type {@code platformKind} that contains a primitive value. + */ + public static LIRKind value(PlatformKind platformKind) { + assert platformKind != Kind.Object : "Object should always be used as reference type"; + return new LIRKind(platformKind, 0); + } + + /** + * Create a {@link LIRKind} of type {@code platformKind} that contains a single tracked oop + * reference. + */ + public static LIRKind reference(PlatformKind platformKind) { + int length = platformKind.getVectorLength(); + assert 0 < length && length < 32 : "vector of " + length + " references not supported"; + return new LIRKind(platformKind, (1 << length) - 1); + } + + /** + * Create a {@link LIRKind} of type {@code platformKind} that contains a value that is derived + * from a reference. Values of this {@link LIRKind} can not be live at safepoints. + */ + public static LIRKind derivedReference(PlatformKind platformKind) { + return new LIRKind(platformKind, DERIVED_REFERENCE); + } + + /** + * Create a new {@link LIRKind} with the same reference information and a new + * {@linkplain #getPlatformKind platform kind}. If the new kind is a longer vector than this, + * the new elements are marked as untracked values. + */ + public LIRKind changeType(PlatformKind newPlatformKind) { + if (isDerivedReference()) { + return derivedReference(newPlatformKind); + } else if (referenceMask == 0) { + // value type + return new LIRKind(newPlatformKind, 0); + } else { + // reference type + int newLength = Math.min(32, newPlatformKind.getVectorLength()); + int newReferenceMask = referenceMask & (0xFFFFFFFF >>> (32 - newLength)); + assert newReferenceMask != DERIVED_REFERENCE; + return new LIRKind(newPlatformKind, newReferenceMask); + } + } + + /** + * Create a new {@link LIRKind} with a new {@linkplain #getPlatformKind platform kind}. If the + * new kind is longer than this, the reference positions are repeated to fill the vector. + */ + public LIRKind repeat(PlatformKind newPlatformKind) { + if (isDerivedReference()) { + return derivedReference(newPlatformKind); + } else if (referenceMask == 0) { + // value type + return new LIRKind(newPlatformKind, 0); + } else { + // reference type + int oldLength = platformKind.getVectorLength(); + int newLength = newPlatformKind.getVectorLength(); + assert oldLength <= newLength && newLength < 32 && (newLength % oldLength) == 0; + + // repeat reference mask to fill new kind + int newReferenceMask = 0; + for (int i = 0; i < newLength; i += platformKind.getVectorLength()) { + newReferenceMask |= referenceMask << i; + } + + assert newReferenceMask != DERIVED_REFERENCE; + return new LIRKind(newPlatformKind, newReferenceMask); + } + } + + /** + * Create a new {@link LIRKind} with the same type, but marked as containing a derivedReference. + */ + public LIRKind makeDerivedReference() { + return new LIRKind(platformKind, DERIVED_REFERENCE); + } + + /** + * Get the low level type that is used in code generation. + */ + public PlatformKind getPlatformKind() { + return platformKind; + } + + /** + * Check whether this value is derived from a reference. If this returns {@code true}, this + * value must not be live at safepoints. + */ + public boolean isDerivedReference() { + return referenceMask == DERIVED_REFERENCE; + } + + /** + * Check whether the {@code idx}th part of this value is a reference that must be tracked at + * safepoints. + * + * @param idx The index into the vector if this is a vector kind. Must be 0 if this is a scalar + * kind. + */ + public boolean isReference(int idx) { + assert 0 <= idx && idx < platformKind.getVectorLength() : "invalid index " + idx + " in " + this; + return !isDerivedReference() && (referenceMask & 1 << idx) != 0; + } + + /** + * Check whether this kind is a value type that doesn't need to be tracked at safepoints. + */ + public boolean isValue() { + return referenceMask == 0; + } + + @Override + public String toString() { + if (isValue()) { + return platformKind.name(); + } else if (isDerivedReference()) { + return platformKind.name() + "[*]"; + } else { + StringBuilder ret = new StringBuilder(); + ret.append(platformKind.name()); + ret.append('['); + for (int i = 0; i < platformKind.getVectorLength(); i++) { + if (isReference(i)) { + ret.append('.'); + } else { + ret.append(' '); + } + } + ret.append(']'); + return ret.toString(); + } + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((platformKind == null) ? 0 : platformKind.hashCode()); + result = prime * result + referenceMask; + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof LIRKind)) { + return false; + } + + LIRKind other = (LIRKind) obj; + return platformKind == other.platformKind && referenceMask == other.referenceMask; + } +} \ No newline at end of file
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/NullConstant.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/NullConstant.java Fri Jun 13 11:47:44 2014 +0200 @@ -30,7 +30,7 @@ private static final long serialVersionUID = 8906209595800783961L; protected NullConstant() { - super(Kind.Object); + super(LIRKind.reference(Kind.Object)); } @Override
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/PlatformKind.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/PlatformKind.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,4 +30,8 @@ String name(); Constant getDefaultValue(); + + default int getVectorLength() { + return 1; + } }
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/PrimitiveConstant.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/PrimitiveConstant.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,7 @@ private final long primitive; protected PrimitiveConstant(Kind kind, long primitive) { - super(kind); + super(LIRKind.value(kind)); this.primitive = primitive; assert kind.isPrimitive() || kind == Kind.Illegal;
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Value.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Value.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ private static final long serialVersionUID = -6909397188697766469L; - @SuppressWarnings("serial") public static final AllocatableValue ILLEGAL = new AllocatableValue(Kind.Illegal) { + @SuppressWarnings("serial") public static final AllocatableValue ILLEGAL = new AllocatableValue(LIRKind.Illegal) { @Override public String toString() { @@ -41,17 +41,17 @@ }; private final Kind kind; - private final PlatformKind platformKind; + private final LIRKind lirKind; /** * Initializes a new value of the specified kind. * - * @param platformKind the kind + * @param lirKind the kind */ - protected Value(PlatformKind platformKind) { - this.platformKind = platformKind; - if (platformKind instanceof Kind) { - this.kind = (Kind) platformKind; + protected Value(LIRKind lirKind) { + this.lirKind = lirKind; + if (getPlatformKind() instanceof Kind) { + this.kind = (Kind) getPlatformKind(); } else { this.kind = Kind.Illegal; } @@ -72,23 +72,27 @@ return kind; } + public final LIRKind getLIRKind() { + return lirKind; + } + /** * Returns the platform specific kind used to store this value. */ public final PlatformKind getPlatformKind() { - return platformKind; + return lirKind.getPlatformKind(); } @Override public int hashCode() { - return 41 + platformKind.hashCode(); + return 41 + lirKind.hashCode(); } @Override public boolean equals(Object obj) { if (obj instanceof Value) { Value that = (Value) obj; - return kind.equals(that.kind) && platformKind.equals(that.platformKind); + return kind.equals(that.kind) && lirKind.equals(that.lirKind); } return false; }
--- a/graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineBytecodeParser.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineBytecodeParser.java Fri Jun 13 11:47:44 2014 +0200 @@ -35,7 +35,6 @@ import com.oracle.graal.compiler.common.*; import com.oracle.graal.compiler.common.calc.*; import com.oracle.graal.compiler.common.cfg.*; -import com.oracle.graal.compiler.common.type.*; import com.oracle.graal.compiler.gen.*; import com.oracle.graal.compiler.target.*; import com.oracle.graal.debug.*; @@ -482,7 +481,7 @@ Value classRef = lirBuilder.getClassConstant(field.getDeclaringClass()); long displacement = lirBuilder.getFieldOffset(field); Value address = gen.emitAddress(classRef, displacement, Value.ILLEGAL, 0); - PlatformKind readKind = gen.getPlatformKind(StampFactory.forKind(field.getKind())); + LIRKind readKind = backend.getTarget().getLIRKind(field.getKind()); LIRFrameState state = createFrameState(frameState); return gen.emitLoad(readKind, address, state); } @@ -506,7 +505,7 @@ emitNullCheck(array); long displacement = lirBuilder.getArrayLengthOffset(); Value address = gen.emitAddress(array, displacement, Value.ILLEGAL, 0); - PlatformKind readKind = gen.getPlatformKind(StampFactory.forKind(Kind.Int)); + LIRKind readKind = backend.getTarget().getLIRKind(Kind.Int); LIRFrameState state = createFrameState(frameState); return gen.emitLoad(readKind, address, state); } @@ -682,7 +681,7 @@ for (int i = 0; i < frameState.stackSize(); i++) { Value src = frameState.stackAt(i); if (src instanceof Constant) { - AllocatableValue dst = gen.newVariable(src.getPlatformKind()); + AllocatableValue dst = gen.newVariable(src.getLIRKind()); gen.emitMove(dst, src); frameState.storeStack(i, dst); Debug.log("introduce new variabe %s for stackslot %d (end of block %s", dst, i, currentBlock); @@ -691,7 +690,7 @@ for (int i = 0; i < frameState.localsSize(); i++) { Value src = frameState.localAt(i); if (src instanceof Constant) { - AllocatableValue dst = gen.newVariable(src.getPlatformKind()); + AllocatableValue dst = gen.newVariable(src.getLIRKind()); gen.emitMove(dst, src); frameState.storeLocal(i, dst); Debug.log("introduce new variabe %s for local %d (end of block %s", dst, i, currentBlock);
--- a/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -77,11 +77,11 @@ */ public abstract class AMD64LIRGenerator extends LIRGenerator { - private static final RegisterValue RAX_I = AMD64.rax.asValue(Kind.Int); - private static final RegisterValue RAX_L = AMD64.rax.asValue(Kind.Long); - private static final RegisterValue RDX_I = AMD64.rdx.asValue(Kind.Int); - private static final RegisterValue RDX_L = AMD64.rdx.asValue(Kind.Long); - private static final RegisterValue RCX_I = AMD64.rcx.asValue(Kind.Int); + private static final RegisterValue RAX_I = AMD64.rax.asValue(LIRKind.value(Kind.Int)); + private static final RegisterValue RAX_L = AMD64.rax.asValue(LIRKind.value(Kind.Long)); + private static final RegisterValue RDX_I = AMD64.rdx.asValue(LIRKind.value(Kind.Int)); + private static final RegisterValue RDX_L = AMD64.rdx.asValue(LIRKind.value(Kind.Long)); + private static final RegisterValue RCX_I = AMD64.rcx.asValue(LIRKind.value(Kind.Int)); private class AMD64SpillMoveFactory implements LIR.SpillMoveFactory { @@ -125,7 +125,7 @@ @Override public Variable emitMove(Value input) { - Variable result = newVariable(input.getPlatformKind()); + Variable result = newVariable(input.getLIRKind()); emitMove(result, input); return result; } @@ -208,7 +208,8 @@ } } - return new AMD64AddressValue(target().wordKind, baseRegister, indexRegister, scaleEnum, displacementInt); + LIRKind resultKind = getAddressKind(base, displacement, index); + return new AMD64AddressValue(resultKind, baseRegister, indexRegister, scaleEnum, displacementInt); } public AMD64AddressValue asAddressValue(Value address) { @@ -221,7 +222,7 @@ @Override public Variable emitAddress(StackSlot address) { - Variable result = newVariable(target().wordKind); + Variable result = newVariable(LIRKind.value(target().wordKind)); append(new StackLeaOp(result, address)); return result; } @@ -234,7 +235,7 @@ @Override public void emitCompareBranch(PlatformKind cmpKind, Value left, Value right, Condition cond, boolean unorderedIsTrue, LabelRef trueLabel, LabelRef falseLabel, double trueLabelProbability) { - boolean mirrored = emitCompare(cmpKind, left, right); + boolean mirrored = emitCompare((Kind) cmpKind, left, right); Condition finalCondition = mirrored ? cond.mirror() : cond; if (cmpKind == Kind.Float || cmpKind == Kind.Double) { append(new FloatBranchOp(finalCondition, unorderedIsTrue, trueLabel, falseLabel, trueLabelProbability)); @@ -267,10 +268,10 @@ @Override public Variable emitConditionalMove(PlatformKind cmpKind, Value left, Value right, Condition cond, boolean unorderedIsTrue, Value trueValue, Value falseValue) { - boolean mirrored = emitCompare(cmpKind, left, right); + boolean mirrored = emitCompare((Kind) cmpKind, left, right); Condition finalCondition = mirrored ? cond.mirror() : cond; - Variable result = newVariable(trueValue.getKind()); + Variable result = newVariable(trueValue.getLIRKind()); if (cmpKind == Kind.Float || cmpKind == Kind.Double) { append(new FloatCondMoveOp(result, finalCondition, unorderedIsTrue, load(trueValue), load(falseValue))); } else { @@ -282,7 +283,7 @@ @Override public Variable emitIntegerTestMove(Value left, Value right, Value trueValue, Value falseValue) { emitIntegerTest(left, right); - Variable result = newVariable(trueValue.getKind()); + Variable result = newVariable(trueValue.getLIRKind()); append(new CondMoveOp(result, Condition.EQ, load(trueValue), loadNonConst(falseValue))); return result; } @@ -296,8 +297,8 @@ } } - protected void emitCompareOp(PlatformKind cmpKind, Variable left, Value right) { - switch ((Kind) cmpKind) { + protected void emitCompareOp(Kind cmpKind, Variable left, Value right) { + switch (cmpKind) { case Byte: case Boolean: append(new CompareOp(BCMP, left, right)); @@ -412,7 +413,7 @@ * @param b the right operand of the comparison * @return true if the left and right operands were switched, false otherwise */ - private boolean emitCompare(PlatformKind cmpKind, Value a, Value b) { + private boolean emitCompare(Kind cmpKind, Value a, Value b) { Variable left; Value right; boolean mirrored; @@ -432,7 +433,7 @@ @Override public Variable emitNegate(Value inputVal) { AllocatableValue input = asAllocatable(inputVal); - Variable result = newVariable(input.getKind()); + Variable result = newVariable(input.getLIRKind()); switch (input.getKind()) { case Int: append(new Unary1Op(INEG, result, input)); @@ -455,7 +456,7 @@ @Override public Variable emitNot(Value inputVal) { AllocatableValue input = asAllocatable(inputVal); - Variable result = newVariable(input.getKind()); + Variable result = newVariable(input.getLIRKind()); switch (input.getKind()) { case Int: append(new Unary1Op(INOT, result, input)); @@ -492,7 +493,7 @@ case IXOR: case LXOR: if (NumUtil.isInt(b.asLong())) { - Variable result = newVariable(a.getKind()); + Variable result = newVariable(a.getLIRKind()); append(new BinaryRegConst(op, result, a, b)); return result; } @@ -501,7 +502,7 @@ case IMUL: case LMUL: if (NumUtil.isInt(b.asLong())) { - Variable result = newVariable(a.getKind()); + Variable result = newVariable(a.getLIRKind()); append(new BinaryRegStackConst(op, result, a, b)); return result; } @@ -512,7 +513,7 @@ } private Variable emitBinaryVar(AMD64Arithmetic op, boolean commutative, AllocatableValue a, AllocatableValue b) { - Variable result = newVariable(a.getKind()); + Variable result = newVariable(a.getLIRKind()); if (commutative) { append(new BinaryCommutative(op, result, a, b)); } else { @@ -601,13 +602,13 @@ } public Value emitBinaryMemory(AMD64Arithmetic op, Kind kind, AllocatableValue a, AMD64AddressValue location, LIRFrameState state) { - Variable result = newVariable(a.getKind()); + Variable result = newVariable(a.getLIRKind()); append(new BinaryMemory(op, kind, result, a, location, state)); return result; } protected Value emitConvert2MemoryOp(PlatformKind kind, AMD64Arithmetic op, AMD64AddressValue address, LIRFrameState state) { - Variable result = newVariable(kind); + Variable result = newVariable(LIRKind.value(kind)); append(new Unary2MemoryOp(op, result, (Kind) null, address, state)); return result; } @@ -615,13 +616,13 @@ protected Value emitZeroExtendMemory(Kind memoryKind, int resultBits, AMD64AddressValue address, LIRFrameState state) { // Issue a zero extending load of the proper bit size and set the result to // the proper kind. - Variable result = newVariable(resultBits == 32 ? Kind.Int : Kind.Long); + Variable result = newVariable(LIRKind.value(resultBits == 32 ? Kind.Int : Kind.Long)); append(new ZeroExtendLoadOp(memoryKind, result, address, state)); return result; } private void emitDivRem(AMD64Arithmetic op, Value a, Value b, LIRFrameState state) { - AllocatableValue rax = AMD64.rax.asValue(a.getPlatformKind()); + AllocatableValue rax = AMD64.rax.asValue(a.getLIRKind()); emitMove(rax, a); append(new DivRemOp(op, rax, asAllocatable(b), state)); } @@ -649,12 +650,12 @@ emitDivRem(LDIV, a, b, state); return emitMove(RAX_L); case Float: { - Variable result = newVariable(a.getPlatformKind()); + Variable result = newVariable(a.getLIRKind()); append(new BinaryRegStack(FDIV, result, asAllocatable(a), asAllocatable(b))); return result; } case Double: { - Variable result = newVariable(a.getPlatformKind()); + Variable result = newVariable(a.getLIRKind()); append(new BinaryRegStack(DDIV, result, asAllocatable(a), asAllocatable(b))); return result; } @@ -673,12 +674,12 @@ emitDivRem(LREM, a, b, state); return emitMove(RDX_L); case Float: { - Variable result = newVariable(a.getPlatformKind()); + Variable result = newVariable(a.getLIRKind()); append(new FPDivRemOp(FREM, result, load(a), load(b))); return result; } case Double: { - Variable result = newVariable(a.getPlatformKind()); + Variable result = newVariable(a.getLIRKind()); append(new FPDivRemOp(DREM, result, load(a), load(b))); return result; } @@ -752,7 +753,7 @@ } private Variable emitShift(AMD64Arithmetic op, Value a, Value b) { - Variable result = newVariable(a.getPlatformKind()); + Variable result = newVariable(a.getLIRKind()); AllocatableValue input = asAllocatable(a); if (isConstant(b)) { append(new BinaryRegConst(op, result, input, asConstant(b))); @@ -821,22 +822,22 @@ } } - private AllocatableValue emitConvert2RegOp(PlatformKind kind, AMD64Arithmetic op, AllocatableValue input) { + private AllocatableValue emitConvert2RegOp(LIRKind kind, AMD64Arithmetic op, AllocatableValue input) { Variable result = newVariable(kind); append(new Unary2RegOp(op, result, input)); return result; } - private AllocatableValue emitConvert2Op(PlatformKind kind, AMD64Arithmetic op, AllocatableValue input) { + private AllocatableValue emitConvert2Op(LIRKind kind, AMD64Arithmetic op, AllocatableValue input) { Variable result = newVariable(kind); append(new Unary2Op(op, result, input)); return result; } @Override - public Value emitReinterpret(PlatformKind to, Value inputVal) { - Kind from = inputVal.getKind(); - if (to == from) { + public Value emitReinterpret(LIRKind to, Value inputVal) { + LIRKind from = inputVal.getLIRKind(); + if (to.equals(from)) { return inputVal; } @@ -845,27 +846,28 @@ * Conversions between integer to floating point types require moves between CPU and FPU * registers. */ - switch ((Kind) to) { + Kind fromKind = (Kind) from.getPlatformKind(); + switch ((Kind) to.getPlatformKind()) { case Int: - switch (from) { + switch (fromKind) { case Float: return emitConvert2Op(to, MOV_F2I, input); } break; case Long: - switch (from) { + switch (fromKind) { case Double: return emitConvert2Op(to, MOV_D2L, input); } break; case Float: - switch (from) { + switch (fromKind) { case Int: return emitConvert2Op(to, MOV_I2F, input); } break; case Double: - switch (from) { + switch (fromKind) { case Long: return emitConvert2Op(to, MOV_L2D, input); } @@ -878,25 +880,25 @@ AllocatableValue input = asAllocatable(inputVal); switch (op) { case D2F: - return emitConvert2Op(Kind.Float, D2F, input); + return emitConvert2Op(LIRKind.value(Kind.Float), D2F, input); case D2I: - return emitConvert2Op(Kind.Int, D2I, input); + return emitConvert2Op(LIRKind.value(Kind.Int), D2I, input); case D2L: - return emitConvert2Op(Kind.Long, D2L, input); + return emitConvert2Op(LIRKind.value(Kind.Long), D2L, input); case F2D: - return emitConvert2Op(Kind.Double, F2D, input); + return emitConvert2Op(LIRKind.value(Kind.Double), F2D, input); case F2I: - return emitConvert2Op(Kind.Int, F2I, input); + return emitConvert2Op(LIRKind.value(Kind.Int), F2I, input); case F2L: - return emitConvert2Op(Kind.Long, F2L, input); + return emitConvert2Op(LIRKind.value(Kind.Long), F2L, input); case I2D: - return emitConvert2Op(Kind.Double, I2D, input); + return emitConvert2Op(LIRKind.value(Kind.Double), I2D, input); case I2F: - return emitConvert2Op(Kind.Float, I2F, input); + return emitConvert2Op(LIRKind.value(Kind.Float), I2F, input); case L2D: - return emitConvert2Op(Kind.Double, L2D, input); + return emitConvert2Op(LIRKind.value(Kind.Double), L2D, input); case L2F: - return emitConvert2Op(Kind.Float, L2F, input); + return emitConvert2Op(LIRKind.value(Kind.Float), L2F, input); default: throw GraalInternalError.shouldNotReachHere(); } @@ -906,7 +908,7 @@ public Value emitNarrow(Value inputVal, int bits) { if (inputVal.getKind() == Kind.Long && bits <= 32) { // TODO make it possible to reinterpret Long as Int in LIR without move - return emitConvert2RegOp(Kind.Int, L2I, asAllocatable(inputVal)); + return emitConvert2RegOp(LIRKind.value(Kind.Int), L2I, asAllocatable(inputVal)); } else { return inputVal; } @@ -921,11 +923,11 @@ // sign extend to 64 bits switch (fromBits) { case 8: - return emitConvert2Op(Kind.Long, B2L, asAllocatable(inputVal)); + return emitConvert2Op(LIRKind.value(Kind.Long), B2L, asAllocatable(inputVal)); case 16: - return emitConvert2Op(Kind.Long, S2L, asAllocatable(inputVal)); + return emitConvert2Op(LIRKind.value(Kind.Long), S2L, asAllocatable(inputVal)); case 32: - return emitConvert2Op(Kind.Long, I2L, asAllocatable(inputVal)); + return emitConvert2Op(LIRKind.value(Kind.Long), I2L, asAllocatable(inputVal)); default: throw GraalInternalError.unimplemented("unsupported sign extension (" + fromBits + " bit -> " + toBits + " bit)"); } @@ -933,9 +935,9 @@ // sign extend to 32 bits (smaller values are internally represented as 32 bit values) switch (fromBits) { case 8: - return emitConvert2Op(Kind.Int, B2I, asAllocatable(inputVal)); + return emitConvert2Op(LIRKind.value(Kind.Int), B2I, asAllocatable(inputVal)); case 16: - return emitConvert2Op(Kind.Int, S2I, asAllocatable(inputVal)); + return emitConvert2Op(LIRKind.value(Kind.Int), S2I, asAllocatable(inputVal)); case 32: return inputVal; default: @@ -951,17 +953,17 @@ return inputVal; } else if (fromBits > 32) { assert inputVal.getKind() == Kind.Long; - Variable result = newVariable(Kind.Long); + Variable result = newVariable(LIRKind.value(Kind.Long)); long mask = IntegerStamp.defaultMask(fromBits); append(new BinaryRegConst(AMD64Arithmetic.LAND, result, asAllocatable(inputVal), Constant.forLong(mask))); return result; } else { assert inputVal.getKind().getStackKind() == Kind.Int; - Variable result = newVariable(Kind.Int); + Variable result = newVariable(LIRKind.value(Kind.Int)); int mask = (int) IntegerStamp.defaultMask(fromBits); append(new BinaryRegConst(AMD64Arithmetic.IAND, result, asAllocatable(inputVal), Constant.forInt(mask))); if (toBits > 32) { - Variable longResult = newVariable(Kind.Long); + Variable longResult = newVariable(LIRKind.value(Kind.Long)); emitMove(longResult, result); return longResult; } else { @@ -992,7 +994,7 @@ @Override public Value emitBitCount(Value value) { - Variable result = newVariable(Kind.Int); + Variable result = newVariable(LIRKind.value(Kind.Int)); if (value.getKind().getStackKind() == Kind.Int) { append(new AMD64BitManipulationOp(IPOPCNT, result, asAllocatable(value))); } else { @@ -1003,14 +1005,14 @@ @Override public Value emitBitScanForward(Value value) { - Variable result = newVariable(Kind.Int); + Variable result = newVariable(LIRKind.value(Kind.Int)); append(new AMD64BitManipulationOp(BSF, result, asAllocatable(value))); return result; } @Override public Value emitBitScanReverse(Value value) { - Variable result = newVariable(Kind.Int); + Variable result = newVariable(LIRKind.value(Kind.Int)); if (value.getKind().getStackKind() == Kind.Int) { append(new AMD64BitManipulationOp(IBSR, result, asAllocatable(value))); } else { @@ -1021,56 +1023,56 @@ @Override public Value emitMathAbs(Value input) { - Variable result = newVariable(input.getPlatformKind()); + Variable result = newVariable(input.getLIRKind()); append(new BinaryRegConst(DAND, result, asAllocatable(input), Constant.forDouble(Double.longBitsToDouble(0x7FFFFFFFFFFFFFFFL)))); return result; } @Override public Value emitMathSqrt(Value input) { - Variable result = newVariable(input.getPlatformKind()); + Variable result = newVariable(input.getLIRKind()); append(new Unary2Op(SQRT, result, asAllocatable(input))); return result; } @Override public Value emitMathLog(Value input, boolean base10) { - Variable result = newVariable(input.getPlatformKind()); + Variable result = newVariable(input.getLIRKind()); append(new AMD64MathIntrinsicOp(base10 ? LOG10 : LOG, result, asAllocatable(input))); return result; } @Override public Value emitMathCos(Value input) { - Variable result = newVariable(input.getPlatformKind()); + Variable result = newVariable(input.getLIRKind()); append(new AMD64MathIntrinsicOp(COS, result, asAllocatable(input))); return result; } @Override public Value emitMathSin(Value input) { - Variable result = newVariable(input.getPlatformKind()); + Variable result = newVariable(input.getLIRKind()); append(new AMD64MathIntrinsicOp(SIN, result, asAllocatable(input))); return result; } @Override public Value emitMathTan(Value input) { - Variable result = newVariable(input.getPlatformKind()); + Variable result = newVariable(input.getLIRKind()); append(new AMD64MathIntrinsicOp(TAN, result, asAllocatable(input))); return result; } @Override public Value emitByteSwap(Value input) { - Variable result = newVariable(input.getPlatformKind()); + Variable result = newVariable(input.getLIRKind()); append(new AMD64ByteSwapOp(result, input)); return result; } @Override public Value emitArrayEquals(Kind kind, Value array1, Value array2, Value length) { - Variable result = newVariable(Kind.Int); + Variable result = newVariable(LIRKind.value(Kind.Int)); append(new AMD64ArrayEqualsOp(this, kind, result, array1, array2, asAllocatable(length))); return result; } @@ -1079,7 +1081,7 @@ public void emitReturn(Value input) { AllocatableValue operand = Value.ILLEGAL; if (input != null) { - operand = resultOperandFor(input.getKind()); + operand = resultOperandFor(input.getLIRKind()); emitMove(operand, input); } append(new ReturnOp(operand)); @@ -1089,12 +1091,12 @@ public void emitStrategySwitch(SwitchStrategy strategy, Variable key, LabelRef[] keyTargets, LabelRef defaultTarget) { // a temp is needed for loading object constants boolean needsTemp = key.getKind() == Kind.Object; - append(new StrategySwitchOp(strategy, keyTargets, defaultTarget, key, needsTemp ? newVariable(key.getKind()) : Value.ILLEGAL)); + append(new StrategySwitchOp(strategy, keyTargets, defaultTarget, key, needsTemp ? newVariable(key.getLIRKind()) : Value.ILLEGAL)); } @Override protected void emitTableSwitch(int lowKey, LabelRef defaultTarget, LabelRef[] targets, Value key) { - append(new TableSwitchOp(lowKey, defaultTarget, targets, key, newVariable(target().wordKind), newVariable(key.getPlatformKind()))); + append(new TableSwitchOp(lowKey, defaultTarget, targets, key, newVariable(LIRKind.value(target().wordKind)), newVariable(key.getLIRKind()))); } }
--- a/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64NodeLIRBuilder.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64NodeLIRBuilder.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -90,7 +90,7 @@ } protected Kind getMemoryKind(Access access) { - return (Kind) gen.getPlatformKind(access.asNode().stamp()); + return (Kind) gen.getLIRKind(access.asNode().stamp()).getPlatformKind(); } protected AMD64AddressValue makeAddress(Access access) { @@ -267,7 +267,7 @@ return null; } - private Value emitReinterpretMemory(PlatformKind to, Access access) { + private Value emitReinterpretMemory(LIRKind to, Access access) { AMD64AddressValue address = makeAddress(access); LIRFrameState state = getState(access); return getLIRGeneratorTool().emitLoad(to, address, state); @@ -415,7 +415,7 @@ @MatchRule("(Write Narrow=narrow location value)") public ComplexMatchResult writeNarrow(WriteNode root, NarrowNode narrow) { return builder -> { - PlatformKind writeKind = getLIRGeneratorTool().getPlatformKind(root.value().stamp()); + LIRKind writeKind = getLIRGeneratorTool().getLIRKind(root.value().stamp()); Value address = root.location().generateAddress(builder, getLIRGeneratorTool(), operand(root.object())); Value v = operand(narrow.getInput()); getLIRGeneratorTool().emitStore(writeKind, address, v, state(root)); @@ -455,7 +455,7 @@ @MatchRule("(Reinterpret FloatingRead=access)") public ComplexMatchResult reinterpret(ReinterpretNode root, Access access) { return builder -> { - PlatformKind kind = getLIRGeneratorTool().getPlatformKind(root.stamp()); + LIRKind kind = getLIRGeneratorTool().getLIRKind(root.stamp()); return emitReinterpretMemory(kind, access); };
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/spi/LIRKindTool.java Fri Jun 13 11:47:44 2014 +0200 @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.compiler.common.spi; + +import com.oracle.graal.api.meta.*; + +/** + * This interface can be used to access platform and VM specific kinds. + */ +public interface LIRKindTool { + + LIRKind getIntegerKind(int bits); + + LIRKind getFloatingKind(int bits); + + LIRKind getObjectKind(); +}
--- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/spi/PlatformKindTool.java Fri Jun 13 11:11:44 2014 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.graal.compiler.common.spi; - -import com.oracle.graal.api.meta.*; - -/** - * This interface can be used to access platform and VM specific kinds. - */ -public interface PlatformKindTool { - - PlatformKind getIntegerKind(int bits); - - PlatformKind getFloatingKind(int bits); - - PlatformKind getObjectKind(); -}
--- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/FloatStamp.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/FloatStamp.java Fri Jun 13 11:47:44 2014 +0200 @@ -74,7 +74,7 @@ } @Override - public PlatformKind getPlatformKind(PlatformKindTool tool) { + public LIRKind getLIRKind(LIRKindTool tool) { return tool.getFloatingKind(getBits()); }
--- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/IllegalStamp.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/IllegalStamp.java Fri Jun 13 11:47:44 2014 +0200 @@ -40,7 +40,7 @@ } @Override - public PlatformKind getPlatformKind(PlatformKindTool tool) { + public LIRKind getLIRKind(LIRKindTool tool) { throw GraalInternalError.shouldNotReachHere("illegal stamp should not reach backend"); }
--- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/IntegerStamp.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/IntegerStamp.java Fri Jun 13 11:47:44 2014 +0200 @@ -84,7 +84,7 @@ } @Override - public PlatformKind getPlatformKind(PlatformKindTool tool) { + public LIRKind getLIRKind(LIRKindTool tool) { return tool.getIntegerKind(getBits()); }
--- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/ObjectStamp.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/ObjectStamp.java Fri Jun 13 11:47:44 2014 +0200 @@ -42,7 +42,7 @@ } @Override - public PlatformKind getPlatformKind(PlatformKindTool tool) { + public LIRKind getLIRKind(LIRKindTool tool) { return tool.getObjectKind(); }
--- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/Stamp.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/Stamp.java Fri Jun 13 11:47:44 2014 +0200 @@ -51,10 +51,9 @@ public abstract Kind getStackKind(); /** - * Gets a platform dependent {@link PlatformKind} that can be used to store a value of this - * stamp. + * Gets a platform dependent {@link LIRKind} that can be used to store a value of this stamp. */ - public abstract PlatformKind getPlatformKind(PlatformKindTool tool); + public abstract LIRKind getLIRKind(LIRKindTool tool); /** * Returns the union of this stamp and the given stamp. Typically used to create stamps for phi
--- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/VoidStamp.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/VoidStamp.java Fri Jun 13 11:47:44 2014 +0200 @@ -45,7 +45,7 @@ } @Override - public PlatformKind getPlatformKind(PlatformKindTool tool) { + public LIRKind getLIRKind(LIRKindTool tool) { throw GraalInternalError.shouldNotReachHere("void stamp has no value"); }
--- a/graal/com.oracle.graal.compiler.hsail/src/com/oracle/graal/compiler/hsail/HSAILLIRGenerator.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.compiler.hsail/src/com/oracle/graal/compiler/hsail/HSAILLIRGenerator.java Fri Jun 13 11:47:44 2014 +0200 @@ -81,7 +81,7 @@ @Override public Variable emitMove(Value input) { - Variable result = newVariable(input.getPlatformKind()); + Variable result = newVariable(input.getLIRKind()); emitMove(result, input); return result; } @@ -149,7 +149,9 @@ } } } - return new HSAILAddressValue(target().wordKind, baseRegister, finalDisp); + + LIRKind resultKind = getAddressKind(base, displacement, index); + return new HSAILAddressValue(resultKind, baseRegister, finalDisp); } @Override @@ -184,7 +186,7 @@ double trueDestinationProbability) { // We don't have to worry about mirroring the condition on HSAIL. Condition finalCondition = cond; - Variable result = newVariable(left.getKind()); + Variable result = newVariable(left.getLIRKind()); Kind kind = left.getKind().getStackKind(); switch (kind) { case Int: @@ -209,14 +211,14 @@ @Override public void emitIntegerTestBranch(Value left, Value right, LabelRef trueDestination, LabelRef falseDestination, double trueDestinationProbability) { Variable result = emitAnd(left, right); - Variable dummyResult = newVariable(left.getKind()); + Variable dummyResult = newVariable(left.getLIRKind()); append(new CompareBranchOp(mapKindToCompareOp(left.getKind()), Condition.EQ, result, Constant.forInt(0), dummyResult, dummyResult, trueDestination, falseDestination, false)); } @Override public Variable emitConditionalMove(PlatformKind cmpKind, Value left, Value right, Condition cond, boolean unorderedIsTrue, Value trueValue, Value falseValue) { Condition finalCondition = cond; - Variable result = newVariable(trueValue.getKind()); + Variable result = newVariable(trueValue.getLIRKind()); Kind kind = left.getKind().getStackKind(); switch (kind) { case Int: @@ -247,7 +249,7 @@ */ @Override public Variable emitNegate(Value input) { - Variable result = newVariable(input.getKind()); + Variable result = newVariable(input.getLIRKind()); switch (input.getKind()) { case Int: // Note: The Int case also handles the negation of shorts, bytes, and chars because @@ -278,7 +280,7 @@ */ @Override public Variable emitNot(Value input) { - Variable result = newVariable(input.getKind()); + Variable result = newVariable(input.getLIRKind()); switch (input.getKind()) { case Int: // Note: The Int case also covers other primitive integral types smaller than an int @@ -296,7 +298,7 @@ } public Variable emitTestAddressAdd(Value a, Value b) { - Variable result = newVariable(a.getKind()); + Variable result = newVariable(a.getLIRKind()); switch (a.getKind()) { case Int: append(new Op2Reg(IADD, result, a, loadNonConst(b))); @@ -321,7 +323,7 @@ @Override public Variable emitAdd(Value a, Value b) { - Variable result = newVariable(a.getKind()); + Variable result = newVariable(a.getLIRKind()); switch (a.getKind()) { case Int: append(new Op2Reg(IADD, result, a, loadNonConst(b))); @@ -346,7 +348,7 @@ @Override public Variable emitSub(Value a, Value b) { - Variable result = newVariable(a.getKind()); + Variable result = newVariable(a.getLIRKind()); switch (a.getKind()) { case Int: append(new Op2Reg(ISUB, result, a, loadNonConst(b))); @@ -368,7 +370,7 @@ @Override public Variable emitMul(Value a, Value b) { - Variable result = newVariable(a.getKind()); + Variable result = newVariable(a.getLIRKind()); switch (a.getKind()) { case Int: append(new Op2Reg(IMUL, result, a, loadNonConst(b))); @@ -389,7 +391,7 @@ } public Variable emitUMul(Value a, Value b) { - Variable result = newVariable(a.getKind()); + Variable result = newVariable(a.getLIRKind()); switch (a.getKind()) { case Int: append(new Op2Reg(LUMUL, result, a, loadNonConst(b))); @@ -415,7 +417,7 @@ @Override public Value emitDiv(Value a, Value b, LIRFrameState state) { - Variable result = newVariable(a.getKind()); + Variable result = newVariable(a.getLIRKind()); switch (a.getKind()) { case Int: append(new Op2Reg(IDIV, result, a, loadNonConst(b))); @@ -438,7 +440,7 @@ @Override public Value emitRem(Value a, Value b, LIRFrameState state) { - Variable result = newVariable(a.getKind()); + Variable result = newVariable(a.getLIRKind()); switch (a.getKind()) { case Int: append(new Op2Reg(IREM, result, a, loadNonConst(b))); @@ -470,7 +472,7 @@ @Override public Variable emitAnd(Value a, Value b) { - Variable result = newVariable(a.getKind()); + Variable result = newVariable(a.getLIRKind()); switch (a.getKind()) { case Int: append(new Op2Reg(IAND, result, a, loadNonConst(b))); @@ -486,7 +488,7 @@ @Override public Variable emitOr(Value a, Value b) { - Variable result = newVariable(a.getKind()); + Variable result = newVariable(a.getLIRKind()); switch (a.getKind()) { case Int: append(new Op2Reg(IOR, result, a, loadNonConst(b))); @@ -502,7 +504,7 @@ @Override public Variable emitXor(Value a, Value b) { - Variable result = newVariable(a.getKind()); + Variable result = newVariable(a.getLIRKind()); switch (a.getKind()) { case Int: append(new Op2Reg(IXOR, result, a, loadNonConst(b))); @@ -525,7 +527,7 @@ */ @Override public Variable emitShl(Value a, Value b) { - Variable result = newVariable(a.getKind()); + Variable result = newVariable(a.getLIRKind()); switch (a.getKind()) { case Int: // Note: The Int case also covers the shifting of bytes, shorts and chars because @@ -550,7 +552,7 @@ */ @Override public Variable emitShr(Value a, Value b) { - Variable result = newVariable(a.getKind()); + Variable result = newVariable(a.getLIRKind()); switch (a.getKind()) { case Int: // Note: The Int case also covers the shifting of bytes, shorts and chars because @@ -575,7 +577,7 @@ */ @Override public Variable emitUShr(Value a, Value b) { - Variable result = newVariable(a.getKind()); + Variable result = newVariable(a.getLIRKind()); switch (a.getKind()) { case Int: append(new ShiftOp(IUSHR, result, a, b)); @@ -623,24 +625,24 @@ case D2I: case F2I: to = "s32"; - result = newVariable(Kind.Int); + result = newVariable(LIRKind.value(Kind.Int)); break; case D2L: case F2L: to = "s64"; - result = newVariable(Kind.Long); + result = newVariable(LIRKind.value(Kind.Long)); break; case F2D: case I2D: case L2D: to = "f64"; - result = newVariable(Kind.Double); + result = newVariable(LIRKind.value(Kind.Double)); break; case D2F: case I2F: case L2F: to = "f32"; - result = newVariable(Kind.Float); + result = newVariable(LIRKind.value(Kind.Float)); break; default: throw GraalInternalError.shouldNotReachHere(); @@ -653,7 +655,7 @@ @Override public Value emitNarrow(Value inputVal, int bits) { Variable input = load(inputVal); - Variable result = newVariable(bits > 32 ? Kind.Long : Kind.Int); + Variable result = newVariable(LIRKind.value(bits > 32 ? Kind.Long : Kind.Int)); append(new ConvertOp(result, input, "s" + bits, input.getKind() == Kind.Long ? "s64" : "s32")); return result; } @@ -661,7 +663,7 @@ @Override public Value emitSignExtend(Value inputVal, int fromBits, int toBits) { Variable input = load(inputVal); - Variable result = newVariable(toBits > 32 ? Kind.Long : Kind.Int); + Variable result = newVariable(LIRKind.value(toBits > 32 ? Kind.Long : Kind.Int)); append(new ConvertOp(result, input, "s" + toBits, "s" + fromBits)); return result; } @@ -669,13 +671,13 @@ @Override public Value emitZeroExtend(Value inputVal, int fromBits, int toBits) { Variable input = load(inputVal); - Variable result = newVariable(toBits > 32 ? Kind.Long : Kind.Int); + Variable result = newVariable(LIRKind.value(toBits > 32 ? Kind.Long : Kind.Int)); append(new ConvertOp(result, input, "u" + toBits, "u" + fromBits)); return result; } @Override - public Value emitReinterpret(PlatformKind to, Value inputVal) { + public Value emitReinterpret(LIRKind to, Value inputVal) { Variable result = newVariable(to); emitMove(result, inputVal); return result; @@ -694,7 +696,7 @@ @Override public Value emitBitCount(Value value) { - Variable result = newVariable(Kind.Int); + Variable result = newVariable(LIRKind.value(Kind.Int)); if (value.getKind().getStackKind() == Kind.Int) { append(new HSAILBitManipulationOp(IPOPCNT, result, value)); } else { @@ -721,7 +723,7 @@ */ @Override public Value emitMathAbs(Value input) { - Variable result = newVariable(input.getPlatformKind()); + Variable result = newVariable(input.getLIRKind()); append(new Op1Reg(ABS, result, input)); return result; } @@ -733,7 +735,7 @@ * @return Value representing the result of the operation */ public Value emitMathCeil(Value input) { - Variable result = newVariable(input.getPlatformKind()); + Variable result = newVariable(input.getLIRKind()); append(new Op1Reg(CEIL, result, input)); return result; } @@ -745,7 +747,7 @@ * @return Value representing the result of the operation */ public Value emitMathFloor(Value input) { - Variable result = newVariable(input.getPlatformKind()); + Variable result = newVariable(input.getLIRKind()); append(new Op1Reg(FLOOR, result, input)); return result; } @@ -757,7 +759,7 @@ * @return Value representing the result of the operation */ public Value emitMathRint(Value input) { - Variable result = newVariable(input.getPlatformKind()); + Variable result = newVariable(input.getLIRKind()); append(new Op1Reg(RINT, result, input)); return result; } @@ -770,7 +772,7 @@ */ @Override public Value emitMathSqrt(Value input) { - Variable result = newVariable(input.getPlatformKind()); + Variable result = newVariable(input.getLIRKind()); append(new Op1Reg(SQRT, result, input)); return result; } @@ -810,7 +812,7 @@ public void emitReturn(Value input) { AllocatableValue operand = Value.ILLEGAL; if (input != null) { - operand = resultOperandFor(input.getKind()); + operand = resultOperandFor(input.getLIRKind()); emitMove(operand, input); } append(new ReturnOp(operand));
--- a/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java Fri Jun 13 11:47:44 2014 +0200 @@ -24,7 +24,6 @@ package com.oracle.graal.compiler.ptx; import static com.oracle.graal.api.code.ValueUtil.*; -import static com.oracle.graal.api.meta.Value.*; import static com.oracle.graal.lir.ptx.PTXArithmetic.*; import static com.oracle.graal.lir.ptx.PTXBitManipulationOp.IntrinsicOpcode.*; import static com.oracle.graal.lir.ptx.PTXCompare.*; @@ -112,24 +111,9 @@ } } - protected static AllocatableValue toParamKind(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. - if (isRegister(value)) { - return asRegister(value).asValue(value.getKind().getStackKind()); - } else if (isStackSlot(value)) { - return StackSlot.get(value.getKind().getStackKind(), asStackSlot(value).getRawOffset(), asStackSlot(value).getRawAddFrameSize()); - } else { - throw GraalInternalError.shouldNotReachHere(); - } - } - return value; - } - public Variable emitWarpParam(Kind kind, Warp annotation) { - Variable result = newVariable(kind); - Variable tid = newVariable(Kind.Char); + Variable result = newVariable(target().getLIRKind(kind)); + Variable tid = newVariable(LIRKind.value(Kind.Char)); switch (annotation.dimension()) { case X: @@ -149,7 +133,7 @@ @Override public Variable emitMove(Value input) { - Variable result = newVariable(input.getKind()); + Variable result = newVariable(input.getLIRKind()); emitMove(result, input); return result; } @@ -208,14 +192,15 @@ if (baseRegister.equals(Value.ILLEGAL)) { baseRegister = asAllocatable(indexRegister); } else { - Variable longBaseRegister = newVariable(Kind.Long); + Variable longBaseRegister = newVariable(LIRKind.value(Kind.Long)); emitMove(longBaseRegister, baseRegister); baseRegister = emitAdd(longBaseRegister, indexRegister); } } } - return new PTXAddressValue(target().wordKind, baseRegister, finalDisp); + LIRKind resultKind = getAddressKind(base, displacement, index); + return new PTXAddressValue(resultKind, baseRegister, finalDisp); } private PTXAddressValue asAddress(Value address) { @@ -229,18 +214,18 @@ } @Override - public Variable emitLoad(PlatformKind kind, Value address, LIRFrameState state) { + public Variable emitLoad(LIRKind kind, Value address, LIRFrameState state) { PTXAddressValue loadAddress = asAddress(address); Variable result = newVariable(kind); - append(new LoadOp((Kind) kind, result, loadAddress, state)); + append(new LoadOp((Kind) kind.getPlatformKind(), result, loadAddress, state)); return result; } @Override - public void emitStore(PlatformKind kind, Value address, Value inputVal, LIRFrameState state) { + public void emitStore(LIRKind kind, Value address, Value inputVal, LIRFrameState state) { PTXAddressValue storeAddress = asAddress(address); Variable input = load(inputVal); - append(new StoreOp((Kind) kind, storeAddress, input, state)); + append(new StoreOp((Kind) kind.getPlatformKind(), storeAddress, input, state)); } @Override @@ -301,7 +286,7 @@ emitCompare(finalCondition, left, right); - Variable result = newVariable(trueValue.getKind()); + Variable result = newVariable(trueValue.getLIRKind()); switch (left.getKind().getStackKind()) { case Int: case Long: @@ -366,7 +351,7 @@ @Override public Variable emitIntegerTestMove(Value left, Value right, Value trueValue, Value falseValue) { emitIntegerTest(left, right); - Variable result = newVariable(trueValue.getKind()); + Variable result = newVariable(trueValue.getLIRKind()); append(new CondMoveOp(result, Condition.EQ, load(trueValue), loadNonConst(falseValue), nextPredRegNum)); nextPredRegNum++; @@ -385,7 +370,7 @@ @Override public Variable emitNegate(Value input) { - Variable result = newVariable(input.getKind()); + Variable result = newVariable(input.getLIRKind()); switch (input.getKind()) { case Int: append(new Op1Stack(INEG, result, input)); @@ -404,7 +389,7 @@ @Override public Variable emitNot(Value input) { - Variable result = newVariable(input.getKind()); + Variable result = newVariable(input.getLIRKind()); switch (input.getKind()) { case Int: append(new Op1Stack(INOT, result, input)); @@ -420,7 +405,7 @@ @Override public Variable emitAdd(Value a, Value b) { - Variable result = newVariable(a.getKind()); + Variable result = newVariable(a.getLIRKind()); switch (a.getKind()) { case Int: append(new Op2Stack(IADD, result, a, loadNonConst(b))); @@ -442,7 +427,7 @@ @Override public Variable emitSub(Value a, Value b) { - Variable result = newVariable(a.getKind()); + Variable result = newVariable(a.getLIRKind()); switch (a.getKind()) { case Int: append(new Op2Stack(ISUB, result, a, loadNonConst(b))); @@ -464,7 +449,7 @@ @Override public Variable emitMul(Value a, Value b) { - Variable result = newVariable(a.getKind()); + Variable result = newVariable(a.getLIRKind()); switch (a.getKind()) { case Int: append(new Op2Reg(IMUL, result, a, loadNonConst(b))); @@ -496,7 +481,7 @@ @Override public Value emitDiv(Value a, Value b, LIRFrameState state) { - Variable result = newVariable(a.getKind()); + Variable result = newVariable(a.getLIRKind()); switch (a.getKind()) { case Int: append(new Op2Reg(IDIV, result, a, loadNonConst(b))); @@ -518,7 +503,7 @@ @Override public Value emitRem(Value a, Value b, LIRFrameState state) { - Variable result = newVariable(a.getKind()); + Variable result = newVariable(a.getLIRKind()); switch (a.getKind()) { case Int: append(new Op2Reg(IREM, result, a, loadNonConst(b))); @@ -544,7 +529,7 @@ @Override public Variable emitAnd(Value a, Value b) { - Variable result = newVariable(a.getKind()); + Variable result = newVariable(a.getLIRKind()); switch (a.getKind()) { case Int: append(new Op2Stack(IAND, result, a, loadNonConst(b))); @@ -560,7 +545,7 @@ @Override public Variable emitOr(Value a, Value b) { - Variable result = newVariable(a.getKind()); + Variable result = newVariable(a.getLIRKind()); switch (a.getKind()) { case Int: append(new Op2Stack(IOR, result, a, loadNonConst(b))); @@ -576,7 +561,7 @@ @Override public Variable emitXor(Value a, Value b) { - Variable result = newVariable(a.getKind()); + Variable result = newVariable(a.getLIRKind()); switch (a.getKind()) { case Int: append(new Op2Stack(IXOR, result, a, loadNonConst(b))); @@ -592,7 +577,7 @@ @Override public Variable emitShl(Value a, Value b) { - Variable result = newVariable(a.getKind()); + Variable result = newVariable(a.getLIRKind()); switch (a.getKind()) { case Int: append(new Op2Stack(ISHL, result, a, loadNonConst(b))); @@ -608,7 +593,7 @@ @Override public Variable emitShr(Value a, Value b) { - Variable result = newVariable(a.getKind()); + Variable result = newVariable(a.getLIRKind()); switch (a.getKind()) { case Int: append(new Op2Stack(ISHR, result, a, loadNonConst(b))); @@ -624,7 +609,7 @@ @Override public Variable emitUShr(Value a, Value b) { - Variable result = newVariable(a.getKind()); + Variable result = newVariable(a.getLIRKind()); switch (a.getKind()) { case Int: append(new ShiftOp(IUSHR, result, a, b)); @@ -640,7 +625,7 @@ public Variable emitConvertOp(Kind from, Kind to, Value inputVal) { Variable input = load(inputVal); - Variable result = newVariable(to); + Variable result = newVariable(LIRKind.value(to)); append(new ConvertOp(result, input, to, from)); return result; } @@ -723,17 +708,17 @@ return inputVal; } else if (fromBits > 32) { assert inputVal.getKind() == Kind.Long; - Variable result = newVariable(Kind.Long); + Variable result = newVariable(LIRKind.value(Kind.Long)); long mask = IntegerStamp.defaultMask(fromBits); append(new Op2Stack(LAND, result, inputVal, Constant.forLong(mask))); return result; } else { assert inputVal.getKind() == Kind.Int; - Variable result = newVariable(Kind.Int); + Variable result = newVariable(LIRKind.value(Kind.Int)); int mask = (int) IntegerStamp.defaultMask(fromBits); append(new Op2Stack(IAND, result, inputVal, Constant.forInt(mask))); if (toBits > 32) { - Variable longResult = newVariable(Kind.Long); + Variable longResult = newVariable(LIRKind.value(Kind.Long)); emitMove(longResult, result); return longResult; } else { @@ -743,7 +728,7 @@ } @Override - public Value emitReinterpret(PlatformKind to, Value inputVal) { + public Value emitReinterpret(LIRKind to, Value inputVal) { Variable result = newVariable(to); emitMove(result, inputVal); return result; @@ -766,7 +751,7 @@ @Override public Value emitBitCount(Value value) { - Variable result = newVariable(Kind.Int); + Variable result = newVariable(LIRKind.value(Kind.Int)); if (value.getKind().getStackKind() == Kind.Int) { append(new PTXBitManipulationOp(IPOPCNT, result, value)); } else { @@ -829,7 +814,7 @@ @Override public void emitReturn(Value input) { if (input != null) { - AllocatableValue operand = resultOperandFor(input.getKind()); + AllocatableValue operand = resultOperandFor(input.getLIRKind()); // Load the global memory address from return parameter Variable loadVar = emitLoadReturnAddress(operand.getKind(), operand, null); // Store input in global memory whose location is loadVar @@ -845,7 +830,7 @@ @Override public void emitStrategySwitch(SwitchStrategy strategy, Variable key, LabelRef[] keyTargets, LabelRef defaultTarget) { boolean needsTemp = key.getKind() == Kind.Object; - append(new StrategySwitchOp(strategy, keyTargets, defaultTarget, key, needsTemp ? newVariable(key.getKind()) : Value.ILLEGAL, nextPredRegNum++)); + append(new StrategySwitchOp(strategy, keyTargets, defaultTarget, key, needsTemp ? newVariable(key.getLIRKind()) : Value.ILLEGAL, nextPredRegNum++)); } @Override @@ -853,7 +838,7 @@ // Making a copy of the switch value is necessary because jump table destroys the input // value Variable tmp = emitMove(key); - append(new TableSwitchOp(lowKey, defaultTarget, targets, tmp, newVariable(target().wordKind), nextPredRegNum++)); + append(new TableSwitchOp(lowKey, defaultTarget, targets, tmp, newVariable(LIRKind.value(target().wordKind)), nextPredRegNum++)); } @Override @@ -864,7 +849,7 @@ public Variable emitLoadParam(Kind kind, Value address, LIRFrameState state) { PTXAddressValue loadAddress = asAddress(address); - Variable result = newVariable(kind); + Variable result = newVariable(target().getLIRKind(kind)); append(new LoadParamOp(kind, result, loadAddress, state)); return result; @@ -875,13 +860,13 @@ Variable result; switch (kind) { case Float: - result = newVariable(Kind.Int); + result = newVariable(LIRKind.value(Kind.Int)); break; case Double: - result = newVariable(Kind.Long); + result = newVariable(LIRKind.value(Kind.Long)); break; default: - result = newVariable(kind); + result = newVariable(target().getLIRKind(kind)); } append(new LoadReturnAddrOp(kind, result, loadAddress, state)); @@ -895,10 +880,7 @@ } @Override - public AllocatableValue resultOperandFor(Kind kind) { - if (kind == Kind.Void) { - return ILLEGAL; - } + public AllocatableValue resultOperandFor(LIRKind kind) { return (new Variable(kind, 0)); }
--- a/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java Fri Jun 13 11:47:44 2014 +0200 @@ -90,7 +90,7 @@ @Override public Variable emitMove(Value input) { - Variable result = newVariable(input.getKind()); + Variable result = newVariable(input.getLIRKind()); emitMove(result, input); return result; } @@ -177,14 +177,15 @@ if (finalDisp == 0) { // Nothing to do. Just use the base register. } else { - Variable longBaseRegister = newVariable(Kind.Long); + Variable longBaseRegister = newVariable(LIRKind.derivedReference(Kind.Long)); emitMove(longBaseRegister, baseRegister); baseRegister = emitAdd(longBaseRegister, Constant.forLong(finalDisp)); } } } - return new SPARCAddressValue(target().wordKind, baseRegister, indexRegister, displacementInt); + LIRKind resultKind = getAddressKind(base, displacement, index); + return new SPARCAddressValue(resultKind, baseRegister, indexRegister, displacementInt); } protected SPARCAddressValue asAddressValue(Value address) { @@ -197,7 +198,7 @@ @Override public Value emitAddress(StackSlot address) { - Variable result = newVariable(target().wordKind); + Variable result = newVariable(LIRKind.value(target().wordKind)); append(new StackLoadAddressOp(result, address)); return result; } @@ -206,7 +207,7 @@ public void emitReturn(Value input) { AllocatableValue operand = Value.ILLEGAL; if (input != null) { - operand = resultOperandFor(input.getKind()); + operand = resultOperandFor(input.getLIRKind()); emitMove(operand, input); } append(new ReturnOp(operand)); @@ -268,7 +269,7 @@ boolean mirrored = emitCompare(left, right); Condition finalCondition = mirrored ? cond.mirror() : cond; - Variable result = newVariable(trueValue.getKind()); + Variable result = newVariable(trueValue.getLIRKind()); Kind kind = left.getKind().getStackKind(); switch (kind) { case Int: @@ -332,7 +333,7 @@ @Override public Variable emitIntegerTestMove(Value left, Value right, Value trueValue, Value falseValue) { emitIntegerTest(left, right); - Variable result = newVariable(trueValue.getKind()); + Variable result = newVariable(trueValue.getLIRKind()); Kind kind = left.getKind().getStackKind(); append(new CondMoveOp(kind, result, Condition.EQ, load(trueValue), loadNonConst(falseValue))); return result; @@ -352,7 +353,7 @@ public void emitStrategySwitch(SwitchStrategy strategy, Variable key, LabelRef[] keyTargets, LabelRef defaultTarget) { // a temp is needed for loading long and object constants boolean needsTemp = key.getKind() == Kind.Long || key.getKind() == Kind.Object; - append(new StrategySwitchOp(strategy, keyTargets, defaultTarget, key, needsTemp ? newVariable(key.getKind()) : Value.ILLEGAL)); + append(new StrategySwitchOp(strategy, keyTargets, defaultTarget, key, needsTemp ? newVariable(key.getLIRKind()) : Value.ILLEGAL)); } @Override @@ -360,12 +361,12 @@ // Making a copy of the switch value is necessary because jump table destroys the input // value Variable tmp = emitMove(key); - append(new TableSwitchOp(lowKey, defaultTarget, targets, tmp, newVariable(target().wordKind))); + append(new TableSwitchOp(lowKey, defaultTarget, targets, tmp, newVariable(LIRKind.value(target().wordKind)))); } @Override public Value emitBitCount(Value operand) { - Variable result = newVariable(Kind.Int); + Variable result = newVariable(LIRKind.value(Kind.Int)); if (operand.getKind().getStackKind() == Kind.Int) { append(new SPARCBitManipulationOp(IPOPCNT, result, asAllocatable(operand), this)); } else { @@ -376,14 +377,14 @@ @Override public Value emitBitScanForward(Value operand) { - Variable result = newVariable(Kind.Int); + Variable result = newVariable(LIRKind.value(Kind.Int)); append(new SPARCBitManipulationOp(BSF, result, asAllocatable(operand), this)); return result; } @Override public Value emitBitScanReverse(Value operand) { - Variable result = newVariable(Kind.Int); + Variable result = newVariable(LIRKind.value(Kind.Int)); if (operand.getKind().getStackKind() == Kind.Int) { append(new SPARCBitManipulationOp(IBSR, result, asAllocatable(operand), this)); } else { @@ -394,49 +395,49 @@ @Override public Value emitMathAbs(Value input) { - Variable result = newVariable(input.getPlatformKind()); + Variable result = newVariable(input.getLIRKind()); append(new BinaryRegConst(DAND, result, asAllocatable(input), Constant.forDouble(Double.longBitsToDouble(0x7FFFFFFFFFFFFFFFL)))); return result; } @Override public Value emitMathSqrt(Value input) { - Variable result = newVariable(input.getPlatformKind()); + Variable result = newVariable(input.getLIRKind()); append(new SPARCMathIntrinsicOp(SQRT, result, asAllocatable(input))); return result; } @Override public Value emitMathLog(Value input, boolean base10) { - Variable result = newVariable(input.getPlatformKind()); + Variable result = newVariable(input.getLIRKind()); append(new SPARCMathIntrinsicOp(LOG, result, asAllocatable(input))); return result; } @Override public Value emitMathCos(Value input) { - Variable result = newVariable(input.getPlatformKind()); + Variable result = newVariable(input.getLIRKind()); append(new SPARCMathIntrinsicOp(COS, result, asAllocatable(input))); return result; } @Override public Value emitMathSin(Value input) { - Variable result = newVariable(input.getPlatformKind()); + Variable result = newVariable(input.getLIRKind()); append(new SPARCMathIntrinsicOp(SIN, result, asAllocatable(input))); return result; } @Override public Value emitMathTan(Value input) { - Variable result = newVariable(input.getPlatformKind()); + Variable result = newVariable(input.getLIRKind()); append(new SPARCMathIntrinsicOp(TAN, result, asAllocatable(input))); return result; } @Override public Value emitByteSwap(Value input) { - Variable result = newVariable(input.getPlatformKind()); + Variable result = newVariable(input.getLIRKind()); append(new SPARCByteSwapOp(result, input)); return result; } @@ -449,7 +450,7 @@ @Override public Value emitNegate(Value input) { - Variable result = newVariable(input.getKind()); + Variable result = newVariable(input.getLIRKind()); switch (input.getKind().getStackKind()) { case Int: append(new Op1Stack(INEG, result, input)); @@ -468,7 +469,7 @@ @Override public Value emitNot(Value input) { - Variable result = newVariable(input.getKind()); + Variable result = newVariable(input.getLIRKind()); switch (input.getKind().getStackKind()) { case Int: append(new Op1Stack(INOT, result, input)); @@ -507,7 +508,7 @@ case IMUL: case LMUL: if (NumUtil.isInt(b.asLong())) { - Variable result = newVariable(a.getKind()); + Variable result = newVariable(a.getLIRKind()); append(new BinaryRegConst(op, result, a, b)); return result; } @@ -518,7 +519,7 @@ } private Variable emitBinaryVar(SPARCArithmetic op, boolean commutative, AllocatableValue a, AllocatableValue b) { - Variable result = newVariable(a.getKind()); + Variable result = newVariable(a.getLIRKind()); if (commutative) { append(new BinaryCommutative(op, result, a, b)); } else { @@ -545,7 +546,7 @@ @Override public Variable emitSub(Value a, Value b) { - Variable result = newVariable(a.getKind()); + Variable result = newVariable(a.getLIRKind()); switch (a.getKind().getStackKind()) { case Int: append(new Op2Stack(ISUB, result, a, loadNonConst(b))); @@ -567,7 +568,7 @@ @Override public Variable emitMul(Value a, Value b) { - Variable result = newVariable(a.getKind()); + Variable result = newVariable(a.getLIRKind()); switch (a.getKind().getStackKind()) { case Int: append(new BinaryRegReg(IMUL, result, a, loadNonConst(b))); @@ -599,7 +600,7 @@ @Override public Value emitDiv(Value a, Value b, LIRFrameState state) { - Variable result = newVariable(a.getKind()); + Variable result = newVariable(a.getLIRKind()); switch (a.getKind().getStackKind()) { case Int: append(new BinaryRegReg(IDIV, result, a, loadNonConst(b))); @@ -621,7 +622,7 @@ @Override public Value emitRem(Value a, Value b, LIRFrameState state) { - Variable result = newVariable(a.getKind()); + Variable result = newVariable(a.getLIRKind()); switch (a.getKind().getStackKind()) { case Int: append(new RemOp(IREM, result, a, loadNonConst(b), state, this)); @@ -667,7 +668,7 @@ @Override public Variable emitAnd(Value a, Value b) { - Variable result = newVariable(a.getKind()); + Variable result = newVariable(a.getLIRKind()); switch (a.getKind().getStackKind()) { case Int: append(new Op2Stack(IAND, result, a, loadNonConst(b))); @@ -684,7 +685,7 @@ @Override public Variable emitOr(Value a, Value b) { - Variable result = newVariable(a.getKind()); + Variable result = newVariable(a.getLIRKind()); switch (a.getKind().getStackKind()) { case Int: append(new Op2Stack(IOR, result, a, loadNonConst(b))); @@ -700,7 +701,7 @@ @Override public Variable emitXor(Value a, Value b) { - Variable result = newVariable(a.getKind()); + Variable result = newVariable(a.getLIRKind()); switch (a.getKind().getStackKind()) { case Int: append(new Op2Stack(IXOR, result, a, loadNonConst(b))); @@ -715,7 +716,7 @@ } private Variable emitShift(SPARCArithmetic op, Value a, Value b) { - Variable result = newVariable(a.getPlatformKind()); + Variable result = newVariable(a.getLIRKind()); AllocatableValue input = asAllocatable(a); if (isConstant(b)) { append(new BinaryRegConst(op, result, input, asConstant(b))); @@ -761,13 +762,13 @@ } } - private AllocatableValue emitConvertMove(PlatformKind kind, AllocatableValue input) { + private AllocatableValue emitConvertMove(LIRKind kind, AllocatableValue input) { Variable result = newVariable(kind); emitMove(result, input); return result; } - private AllocatableValue emitConvert2Op(PlatformKind kind, SPARCArithmetic op, AllocatableValue input) { + private AllocatableValue emitConvert2Op(LIRKind kind, SPARCArithmetic op, AllocatableValue input) { Variable result = newVariable(kind); append(new Unary2Op(op, result, input)); return result; @@ -778,25 +779,25 @@ AllocatableValue input = asAllocatable(inputVal); switch (op) { case D2F: - return emitConvert2Op(Kind.Float, D2F, input); + return emitConvert2Op(LIRKind.value(Kind.Float), D2F, input); case D2I: - return emitConvert2Op(Kind.Int, D2I, input); + return emitConvert2Op(LIRKind.value(Kind.Int), D2I, input); case D2L: - return emitConvert2Op(Kind.Long, D2L, input); + return emitConvert2Op(LIRKind.value(Kind.Long), D2L, input); case F2D: - return emitConvert2Op(Kind.Double, F2D, input); + return emitConvert2Op(LIRKind.value(Kind.Double), F2D, input); case F2I: - return emitConvert2Op(Kind.Int, F2I, input); + return emitConvert2Op(LIRKind.value(Kind.Int), F2I, input); case F2L: - return emitConvert2Op(Kind.Long, F2L, input); + return emitConvert2Op(LIRKind.value(Kind.Long), F2L, input); case I2D: - return emitConvert2Op(Kind.Double, I2D, input); + return emitConvert2Op(LIRKind.value(Kind.Double), I2D, input); case I2F: - return emitConvert2Op(Kind.Float, I2F, input); + return emitConvert2Op(LIRKind.value(Kind.Float), I2F, input); case L2D: - return emitConvert2Op(Kind.Double, L2D, input); + return emitConvert2Op(LIRKind.value(Kind.Double), L2D, input); case L2F: - return emitConvert2Op(Kind.Float, L2F, input); + return emitConvert2Op(LIRKind.value(Kind.Float), L2F, input); default: throw GraalInternalError.shouldNotReachHere(); } @@ -805,7 +806,7 @@ @Override public Value emitNarrow(Value inputVal, int bits) { if (inputVal.getKind() == Kind.Long && bits <= 32) { - return emitConvert2Op(Kind.Int, L2I, asAllocatable(inputVal)); + return emitConvert2Op(LIRKind.value(Kind.Int), L2I, asAllocatable(inputVal)); } else { return inputVal; } @@ -820,11 +821,11 @@ // sign extend to 64 bits switch (fromBits) { case 8: - return emitConvert2Op(Kind.Long, B2L, asAllocatable(inputVal)); + return emitConvert2Op(LIRKind.value(Kind.Long), B2L, asAllocatable(inputVal)); case 16: - return emitConvert2Op(Kind.Long, S2L, asAllocatable(inputVal)); + return emitConvert2Op(LIRKind.value(Kind.Long), S2L, asAllocatable(inputVal)); case 32: - return emitConvert2Op(Kind.Long, I2L, asAllocatable(inputVal)); + return emitConvert2Op(LIRKind.value(Kind.Long), I2L, asAllocatable(inputVal)); default: throw GraalInternalError.unimplemented("unsupported sign extension (" + fromBits + " bit -> " + toBits + " bit)"); } @@ -832,9 +833,9 @@ // sign extend to 32 bits (smaller values are internally represented as 32 bit values) switch (fromBits) { case 8: - return emitConvert2Op(Kind.Int, B2I, asAllocatable(inputVal)); + return emitConvert2Op(LIRKind.value(Kind.Int), B2I, asAllocatable(inputVal)); case 16: - return emitConvert2Op(Kind.Int, S2I, asAllocatable(inputVal)); + return emitConvert2Op(LIRKind.value(Kind.Int), S2I, asAllocatable(inputVal)); case 32: return inputVal; default: @@ -850,17 +851,17 @@ return inputVal; } else if (fromBits > 32) { assert inputVal.getKind() == Kind.Long; - Variable result = newVariable(Kind.Long); + Variable result = newVariable(LIRKind.value(Kind.Long)); long mask = IntegerStamp.defaultMask(fromBits); append(new BinaryRegConst(SPARCArithmetic.LAND, result, asAllocatable(inputVal), Constant.forLong(mask))); return result; } else { assert inputVal.getKind() == Kind.Int; - Variable result = newVariable(Kind.Int); + Variable result = newVariable(LIRKind.value(Kind.Int)); int mask = (int) IntegerStamp.defaultMask(fromBits); append(new BinaryRegConst(SPARCArithmetic.IAND, result, asAllocatable(inputVal), Constant.forInt(mask))); if (toBits > 32) { - Variable longResult = newVariable(Kind.Long); + Variable longResult = newVariable(LIRKind.value(Kind.Long)); emitMove(longResult, result); return longResult; } else { @@ -870,12 +871,12 @@ } @Override - public AllocatableValue emitReinterpret(PlatformKind to, Value inputVal) { + public AllocatableValue emitReinterpret(LIRKind to, Value inputVal) { Kind from = inputVal.getKind(); AllocatableValue input = asAllocatable(inputVal); // These cases require a move between CPU and FPU registers: - switch ((Kind) to) { + switch ((Kind) to.getPlatformKind()) { case Int: switch (from) { case Float:
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/Interval.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/Interval.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -451,7 +451,7 @@ /** * The kind of this interval. */ - private PlatformKind kind; + private LIRKind kind; /** * The head of the list of ranges describing this interval. This list is sorted by @@ -533,7 +533,7 @@ void assignLocation(AllocatableValue newLocation) { if (isRegister(newLocation)) { assert this.location == null : "cannot re-assign location for " + this; - if (newLocation.getPlatformKind() == Kind.Illegal && kind != Kind.Illegal) { + if (newLocation.getLIRKind() == LIRKind.Illegal && kind != LIRKind.Illegal) { this.location = asRegister(newLocation).asValue(kind); return; } @@ -542,8 +542,8 @@ } else { assert this.location == null || isRegister(this.location) : "cannot re-assign location for " + this; assert isStackSlot(newLocation); - assert newLocation.getPlatformKind() != Kind.Illegal; - assert newLocation.getPlatformKind() == this.kind; + assert newLocation.getLIRKind() != LIRKind.Illegal; + assert newLocation.getLIRKind().equals(this.kind); } this.location = newLocation; } @@ -556,13 +556,13 @@ return location; } - public PlatformKind kind() { + public LIRKind kind() { assert !isRegister(operand) : "cannot access type for fixed interval"; return kind; } - void setKind(PlatformKind kind) { - assert isRegister(operand) || this.kind() == Kind.Illegal || this.kind() == kind : "overwriting existing type"; + void setKind(LIRKind kind) { + assert isRegister(operand) || this.kind() == LIRKind.Illegal || this.kind() == kind : "overwriting existing type"; this.kind = kind; } @@ -715,7 +715,7 @@ } else { assert isIllegal(operand) || isVariable(operand); } - this.kind = Kind.Illegal; + this.kind = LIRKind.Illegal; this.first = Range.EndMarker; this.usePosList = new UsePosList(4); this.current = Range.EndMarker;
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -959,13 +959,13 @@ } } - void addUse(AllocatableValue operand, int from, int to, RegisterPriority registerPriority, PlatformKind kind) { + void addUse(AllocatableValue operand, int from, int to, RegisterPriority registerPriority, LIRKind kind) { if (!isProcessed(operand)) { return; } Interval interval = getOrCreateInterval(operand); - if (kind != Kind.Illegal) { + if (kind != LIRKind.Illegal) { interval.setKind(kind); } @@ -977,13 +977,13 @@ Debug.log("add use: %s, from %d to %d (%s)", interval, from, to, registerPriority.name()); } - void addTemp(AllocatableValue operand, int tempPos, RegisterPriority registerPriority, PlatformKind kind) { + void addTemp(AllocatableValue operand, int tempPos, RegisterPriority registerPriority, LIRKind kind) { if (!isProcessed(operand)) { return; } Interval interval = getOrCreateInterval(operand); - if (kind != Kind.Illegal) { + if (kind != LIRKind.Illegal) { interval.setKind(kind); } @@ -998,14 +998,14 @@ return !isRegister(operand) || attributes(asRegister(operand)).isAllocatable(); } - void addDef(AllocatableValue operand, LIRInstruction op, RegisterPriority registerPriority, PlatformKind kind) { + void addDef(AllocatableValue operand, LIRInstruction op, RegisterPriority registerPriority, LIRKind kind) { if (!isProcessed(operand)) { return; } int defPos = op.id(); Interval interval = getOrCreateInterval(operand); - if (kind != Kind.Illegal) { + if (kind != LIRKind.Illegal) { interval.setKind(kind); } @@ -1147,7 +1147,7 @@ AllocatableValue operand = intervalFor(operandNum).operand; Debug.log("live in %d: %s", operandNum, operand); - addUse(operand, blockFrom, blockTo + 2, RegisterPriority.None, Kind.Illegal); + addUse(operand, blockFrom, blockTo + 2, RegisterPriority.None, LIRKind.Illegal); // add special use positions for loop-end blocks when the // interval is used anywhere inside this loop. It's possible @@ -1171,7 +1171,7 @@ if (op.destroysCallerSavedRegisters()) { for (Register r : callerSaveRegs) { if (attributes(r).isAllocatable()) { - addTemp(r.asValue(), opId, RegisterPriority.None, Kind.Illegal); + addTemp(r.asValue(), opId, RegisterPriority.None, LIRKind.Illegal); } } Debug.log("operation destroys all caller-save registers"); @@ -1182,7 +1182,7 @@ @Override public Value doValue(Value operand, OperandMode mode, EnumSet<OperandFlag> flags) { if (isVariableOrRegister(operand)) { - addDef((AllocatableValue) operand, op, registerPriorityOfOutputOperand(op), operand.getPlatformKind()); + addDef((AllocatableValue) operand, op, registerPriorityOfOutputOperand(op), operand.getLIRKind()); addRegisterHint(op, operand, mode, flags, true); } return operand; @@ -1193,7 +1193,7 @@ @Override public Value doValue(Value operand, OperandMode mode, EnumSet<OperandFlag> flags) { if (isVariableOrRegister(operand)) { - addTemp((AllocatableValue) operand, opId, RegisterPriority.MustHaveRegister, operand.getPlatformKind()); + addTemp((AllocatableValue) operand, opId, RegisterPriority.MustHaveRegister, operand.getLIRKind()); addRegisterHint(op, operand, mode, flags, false); } return operand; @@ -1205,7 +1205,7 @@ public Value doValue(Value operand, OperandMode mode, EnumSet<OperandFlag> flags) { if (isVariableOrRegister(operand)) { RegisterPriority p = registerPriorityOfInputOperand(flags); - addUse((AllocatableValue) operand, blockFrom, opId + 1, p, operand.getPlatformKind()); + addUse((AllocatableValue) operand, blockFrom, opId + 1, p, operand.getLIRKind()); addRegisterHint(op, operand, mode, flags, false); } return operand; @@ -1217,7 +1217,7 @@ public Value doValue(Value operand, OperandMode mode, EnumSet<OperandFlag> flags) { if (isVariableOrRegister(operand)) { RegisterPriority p = registerPriorityOfInputOperand(flags); - addUse((AllocatableValue) operand, blockFrom, opId, p, operand.getPlatformKind()); + addUse((AllocatableValue) operand, blockFrom, opId, p, operand.getLIRKind()); addRegisterHint(op, operand, mode, flags, false); } return operand; @@ -1233,7 +1233,7 @@ @Override public Value doValue(Value operand) { - addUse((AllocatableValue) operand, blockFrom, opId + 1, RegisterPriority.None, operand.getPlatformKind()); + addUse((AllocatableValue) operand, blockFrom, opId + 1, RegisterPriority.None, operand.getLIRKind()); return operand; } }); @@ -1918,7 +1918,7 @@ throw new GraalInternalError(""); } - if (isVariable(i1.operand) && i1.kind() == Kind.Illegal) { + if (isVariable(i1.operand) && i1.kind() == LIRKind.Illegal) { Debug.log("Interval %d has no type assigned", i1.operandNumber); Debug.log(i1.logString(this)); throw new GraalInternalError("");
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScanWalker.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScanWalker.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -773,7 +773,7 @@ } void initVarsForAlloc(Interval interval) { - availableRegs = allocator.frameMap.registerConfig.getAllocatableRegisters(interval.kind()); + availableRegs = allocator.frameMap.registerConfig.getAllocatableRegisters(interval.kind().getPlatformKind()); } static boolean isMove(LIRInstruction op, Interval from, Interval to) {
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/MoveResolver.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/MoveResolver.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -197,7 +197,7 @@ private void insertMove(Interval fromInterval, Interval toInterval) { assert !fromInterval.operand.equals(toInterval.operand) : "from and to interval equal: " + fromInterval; - assert fromInterval.kind() == toInterval.kind() : "move between different types"; + assert fromInterval.kind().equals(toInterval.kind()) : "move between different types"; assert insertIdx != -1 : "must setup insert position first"; AllocatableValue fromOpr = fromInterval.operand; @@ -209,7 +209,7 @@ } private void insertMove(Value fromOpr, Interval toInterval) { - assert fromOpr.getPlatformKind() == toInterval.kind() : "move between different types"; + assert fromOpr.getLIRKind() == toInterval.kind() : "move between different types"; assert insertIdx != -1 : "must setup insert position first"; AllocatableValue toOpr = toInterval.operand;
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/NodeLIRBuilder.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/NodeLIRBuilder.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -372,8 +372,8 @@ append(new JumpOp(getLIRBlock(merge))); } - protected PlatformKind getPhiKind(PhiNode phi) { - return gen.getPlatformKind(phi.stamp()); + protected LIRKind getPhiKind(PhiNode phi) { + return gen.getLIRKind(phi.stamp()); } private Value operandForPhi(ValuePhiNode phi) { @@ -408,12 +408,12 @@ } private void emitNullCheckBranch(IsNullNode node, LabelRef trueSuccessor, LabelRef falseSuccessor, double trueSuccessorProbability) { - PlatformKind kind = gen.getPlatformKind(node.object().stamp()); + PlatformKind kind = gen.getLIRKind(node.object().stamp()).getPlatformKind(); gen.emitCompareBranch(kind, operand(node.object()), kind.getDefaultValue(), Condition.EQ, false, trueSuccessor, falseSuccessor, trueSuccessorProbability); } public void emitCompareBranch(CompareNode compare, LabelRef trueSuccessor, LabelRef falseSuccessor, double trueSuccessorProbability) { - PlatformKind kind = gen.getPlatformKind(compare.x().stamp()); + PlatformKind kind = gen.getLIRKind(compare.x().stamp()).getPlatformKind(); gen.emitCompareBranch(kind, operand(compare.x()), operand(compare.y()), compare.condition(), compare.unorderedIsTrue(), trueSuccessor, falseSuccessor, trueSuccessorProbability); } @@ -436,11 +436,11 @@ public Variable emitConditional(LogicNode node, Value trueValue, Value falseValue) { if (node instanceof IsNullNode) { IsNullNode isNullNode = (IsNullNode) node; - PlatformKind kind = gen.getPlatformKind(isNullNode.object().stamp()); + PlatformKind kind = gen.getLIRKind(isNullNode.object().stamp()).getPlatformKind(); return gen.emitConditionalMove(kind, operand(isNullNode.object()), kind.getDefaultValue(), Condition.EQ, false, trueValue, falseValue); } else if (node instanceof CompareNode) { CompareNode compare = (CompareNode) node; - PlatformKind kind = gen.getPlatformKind(compare.x().stamp()); + PlatformKind kind = gen.getLIRKind(compare.x().stamp()).getPlatformKind(); return gen.emitConditionalMove(kind, operand(compare.x()), operand(compare.y()), compare.condition(), compare.unorderedIsTrue(), trueValue, falseValue); } else if (node instanceof LogicConstantNode) { return gen.emitMove(((LogicConstantNode) node).getValue() ? trueValue : falseValue); @@ -527,7 +527,7 @@ if (keyCount == 1) { assert defaultTarget != null; double probability = x.probability(x.keySuccessor(0)); - PlatformKind kind = gen.getPlatformKind(x.value().stamp()); + PlatformKind kind = gen.getLIRKind(x.value().stamp()).getPlatformKind(); gen.emitCompareBranch(kind, gen.load(operand(x.value())), x.keyAt(0), Condition.EQ, false, getLIRBlock(x.keySuccessor(0)), defaultTarget, probability); } else { LabelRef[] keyTargets = new LabelRef[keyCount];
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/PhiResolver.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/PhiResolver.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -231,7 +231,7 @@ private void moveToTemp(Value src) { assert isIllegal(temp); - temp = gen.newVariable(src.getPlatformKind()); + temp = gen.newVariable(src.getLIRKind()); emitMove(temp, src); }
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/match/ComplexMatchValue.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/match/ComplexMatchValue.java Fri Jun 13 11:47:44 2014 +0200 @@ -37,7 +37,7 @@ * This is the Value of a node which was matched as part of a complex match. The value isn't * actually useable but this marks it as having been evaluated. */ - @SuppressWarnings("serial") public static Value INTERIOR_MATCH = new Value(Kind.Illegal) { + @SuppressWarnings("serial") public static Value INTERIOR_MATCH = new Value(LIRKind.Illegal) { @Override public String toString() { @@ -54,7 +54,7 @@ final ComplexMatchResult result; public ComplexMatchValue(ComplexMatchResult result) { - super(Kind.Illegal); + super(LIRKind.Illegal); this.result = result; }
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackendFactory.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackendFactory.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -92,7 +92,7 @@ final int stackFrameAlignment = 16; final int implicitNullCheckLimit = 4096; final boolean inlineObjects = true; - return new HotSpotTargetDescription(createArchitecture(config), true, stackFrameAlignment, implicitNullCheckLimit, inlineObjects, Kind.Int); + return new HotSpotTargetDescription(createArchitecture(config), true, stackFrameAlignment, implicitNullCheckLimit, inlineObjects); } @Override
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBytecodeLIRBuilder.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBytecodeLIRBuilder.java Fri Jun 13 11:47:44 2014 +0200 @@ -64,7 +64,7 @@ } } } - params[params.length - 1] = rbp.asValue(Kind.Long); + params[params.length - 1] = rbp.asValue(LIRKind.value(Kind.Long)); gen.emitIncomingValues(params);
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotCompare.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotCompare.java Fri Jun 13 11:47:44 2014 +0200 @@ -30,7 +30,6 @@ import com.oracle.graal.compiler.common.*; import com.oracle.graal.hotspot.data.*; import com.oracle.graal.hotspot.meta.*; -import com.oracle.graal.hotspot.nodes.type.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.amd64.*; import com.oracle.graal.lir.amd64.AMD64Move.MemOp; @@ -38,33 +37,6 @@ public class AMD64HotSpotCompare { - @Opcode("NCMP") - public static class HotSpotCompareNarrowOp extends AMD64LIRInstruction { - - @Use({REG}) protected AllocatableValue x; - @Use({REG, STACK}) protected AllocatableValue y; - - public HotSpotCompareNarrowOp(AllocatableValue x, AllocatableValue y) { - this.x = x; - this.y = y; - } - - @Override - public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { - if (isRegister(y)) { - masm.cmpl(asRegister(x), asRegister(y)); - } else { - assert isStackSlot(y); - masm.cmpl(asRegister(x), (AMD64Address) crb.asAddress(y)); - } - } - - @Override - protected void verify() { - assert x.getPlatformKind() == NarrowOopStamp.NarrowOop && y.getPlatformKind() == NarrowOopStamp.NarrowOop; - } - } - @Opcode("CMP") public static class HotSpotCompareConstantOp extends AMD64LIRInstruction {
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotEpilogueOp.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotEpilogueOp.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,7 +43,7 @@ * initial LIR generation is finished. Until then, we use a placeholder variable so that LIR * verification is successful. */ - private static final Variable PLACEHOLDER = new Variable(Kind.Long, Integer.MAX_VALUE); + private static final Variable PLACEHOLDER = new Variable(LIRKind.value(Kind.Long), Integer.MAX_VALUE); @Use({REG, STACK}) protected AllocatableValue savedRbp = PLACEHOLDER;
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotForeignCallsProvider.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotForeignCallsProvider.java Fri Jun 13 11:47:44 2014 +0200 @@ -56,8 +56,8 @@ // The calling convention for the exception handler stub is (only?) defined in // TemplateInterpreterGenerator::generate_throw_exception() // in templateInterpreter_x86_64.cpp around line 1923 - RegisterValue exception = rax.asValue(Kind.Object); - RegisterValue exceptionPc = rdx.asValue(word); + RegisterValue exception = rax.asValue(LIRKind.reference(Kind.Object)); + RegisterValue exceptionPc = rdx.asValue(LIRKind.value(word)); CallingConvention exceptionCc = new CallingConvention(0, ILLEGAL, exception, exceptionPc); register(new HotSpotForeignCallLinkage(EXCEPTION_HANDLER, 0L, PRESERVES_REGISTERS, LEAF_NOFP, null, exceptionCc, NOT_REEXECUTABLE, ANY_LOCATION)); register(new HotSpotForeignCallLinkage(EXCEPTION_HANDLER_IN_CALLER, JUMP_ADDRESS, PRESERVES_REGISTERS, LEAF_NOFP, exceptionCc, null, NOT_REEXECUTABLE, ANY_LOCATION));
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,6 @@ import com.oracle.graal.hotspot.HotSpotVMConfig.CompressEncoding; import com.oracle.graal.hotspot.amd64.AMD64HotSpotMove.HotSpotStoreConstantOp; import com.oracle.graal.hotspot.meta.*; -import com.oracle.graal.hotspot.nodes.type.*; import com.oracle.graal.hotspot.stubs.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.StandardOp.NoOp; @@ -50,7 +49,6 @@ import com.oracle.graal.lir.amd64.AMD64Move.LeaDataOp; import com.oracle.graal.lir.amd64.AMD64Move.LoadOp; import com.oracle.graal.lir.amd64.AMD64Move.MoveFromRegOp; -import com.oracle.graal.lir.amd64.AMD64Move.MoveToRegOp; import com.oracle.graal.lir.amd64.AMD64Move.StoreOp; import com.oracle.graal.lir.gen.*; @@ -87,7 +85,7 @@ public SaveRbp(NoOp placeholder) { this.placeholder = placeholder; - this.reservedSlot = getResult().getFrameMap().allocateSpillSlot(Kind.Long); + this.reservedSlot = getResult().getFrameMap().allocateSpillSlot(LIRKind.value(Kind.Long)); assert reservedSlot.getRawOffset() == -16 : reservedSlot.getRawOffset(); } @@ -102,10 +100,10 @@ dst = reservedSlot; } else { getResult().getFrameMap().freeSpillSlot(reservedSlot); - dst = newVariable(Kind.Long); + dst = newVariable(LIRKind.value(Kind.Long)); } - placeholder.replace(getResult().getLIR(), new MoveFromRegOp(Kind.Long, dst, rbp.asValue(Kind.Long))); + placeholder.replace(getResult().getLIR(), new MoveFromRegOp(Kind.Long, dst, rbp.asValue(LIRKind.value(Kind.Long)))); return dst; } } @@ -156,7 +154,7 @@ public void emitReturn(Value input) { AllocatableValue operand = Value.ILLEGAL; if (input != null) { - operand = resultOperandFor(input.getKind()); + operand = resultOperandFor(input.getLIRKind()); emitMove(operand, input); } if (pollOnReturnScratchRegister == null) { @@ -230,7 +228,7 @@ for (int i = 0; i < savedRegisters.length; i++) { PlatformKind kind = target().arch.getLargestStorableKind(savedRegisters[i].getRegisterCategory()); assert kind != Kind.Illegal; - StackSlot spillSlot = getResult().getFrameMap().allocateSpillSlot(kind); + StackSlot spillSlot = getResult().getFrameMap().allocateSpillSlot(LIRKind.value(kind)); savedRegisterLocations[i] = spillSlot; } return emitSaveRegisters(savedRegisters, savedRegisterLocations, supportsRemove); @@ -306,7 +304,7 @@ Register thread = getProviders().getRegisters().getThreadRegister(); append(new AMD64HotSpotCRuntimeCallPrologueOp(config.threadLastJavaSpOffset(), thread)); - Variable result = super.emitForeignCall(linkage, null, thread.asValue(Kind.Long), trapRequest); + Variable result = super.emitForeignCall(linkage, null, thread.asValue(LIRKind.value(Kind.Long)), trapRequest); append(new AMD64HotSpotCRuntimeCallEpilogueOp(config.threadLastJavaSpOffset(), config.threadLastJavaFpOffset(), thread)); Map<LIRFrameState, SaveRegistersOp> calleeSaveInfo = ((AMD64HotSpotLIRGenerationResult) getResult()).getCalleeSaveInfo(); @@ -321,7 +319,7 @@ Register thread = getProviders().getRegisters().getThreadRegister(); append(new AMD64HotSpotCRuntimeCallPrologueOp(config.threadLastJavaSpOffset(), thread)); - Variable result = super.emitForeignCall(linkage, null, thread.asValue(Kind.Long)); + Variable result = super.emitForeignCall(linkage, null, thread.asValue(LIRKind.value(Kind.Long))); append(new AMD64HotSpotCRuntimeCallEpilogueOp(config.threadLastJavaSpOffset(), config.threadLastJavaFpOffset(), thread)); Map<LIRFrameState, SaveRegistersOp> calleeSaveInfo = ((AMD64HotSpotLIRGenerationResult) getResult()).getCalleeSaveInfo(); @@ -388,10 +386,10 @@ } private void moveValueToThread(Value v, int offset) { - Kind wordKind = getProviders().getCodeCache().getTarget().wordKind; + LIRKind wordKind = LIRKind.value(getProviders().getCodeCache().getTarget().wordKind); RegisterValue thread = getProviders().getRegisters().getThreadRegister().asValue(wordKind); - AMD64AddressValue address = new AMD64AddressValue(v.getKind(), thread, offset); - emitStore(v.getKind(), address, v, null); + AMD64AddressValue address = new AMD64AddressValue(wordKind, thread, offset); + emitStore(v.getLIRKind(), address, v, null); } @Override @@ -412,7 +410,7 @@ boolean hasDebugInfo = getResult().getLIR().hasDebugInfo(); AllocatableValue savedRbp = saveRbp.finalize(hasDebugInfo); if (hasDebugInfo) { - ((AMD64HotSpotLIRGenerationResult) getResult()).setDeoptimizationRescueSlot(getResult().getFrameMap().allocateSpillSlot(Kind.Long)); + ((AMD64HotSpotLIRGenerationResult) getResult()).setDeoptimizationRescueSlot(getResult().getFrameMap().allocateSpillSlot(LIRKind.value(Kind.Long))); } for (AMD64HotSpotEpilogueOp op : epilogueOps) { @@ -436,17 +434,10 @@ } } - private static Kind getMemoryKind(PlatformKind kind) { - if (kind == NarrowOopStamp.NarrowOop) { - return Kind.Int; - } else { - return (Kind) kind; - } - } - - private static PlatformKind toStackKind(PlatformKind kind) { - if (kind instanceof Kind) { - return ((Kind) kind).getStackKind(); + private static LIRKind toStackKind(LIRKind kind) { + if (kind.getPlatformKind() instanceof Kind) { + Kind stackKind = ((Kind) kind.getPlatformKind()).getStackKind(); + return kind.changeType(stackKind); } else { return kind; } @@ -461,36 +452,39 @@ } @Override - public Variable emitLoad(PlatformKind kind, Value address, LIRFrameState state) { + public Variable emitLoad(LIRKind kind, Value address, LIRFrameState state) { AMD64AddressValue loadAddress = asAddressValue(address); Variable result = newVariable(toStackKind(kind)); - append(new LoadOp(getMemoryKind(kind), result, loadAddress, state)); + append(new LoadOp((Kind) kind.getPlatformKind(), result, loadAddress, state)); return result; } @Override - public void emitStore(PlatformKind kind, Value address, Value inputVal, LIRFrameState state) { + public void emitStore(LIRKind kind, Value address, Value inputVal, LIRFrameState state) { AMD64AddressValue storeAddress = asAddressValue(address); if (isConstant(inputVal)) { Constant c = asConstant(inputVal); if (canStoreConstant(c)) { - append(new HotSpotStoreConstantOp(getMemoryKind(kind), storeAddress, c, state)); + append(new HotSpotStoreConstantOp((Kind) kind.getPlatformKind(), storeAddress, c, state)); return; } } Variable input = load(inputVal); - append(new StoreOp(getMemoryKind(kind), storeAddress, input, state)); + append(new StoreOp((Kind) kind.getPlatformKind(), storeAddress, input, state)); } @Override public Value emitCompress(Value pointer, CompressEncoding encoding, boolean nonNull) { - if (pointer.getPlatformKind() == Kind.Object) { - Variable result = newVariable(NarrowOopStamp.NarrowOop); + LIRKind inputKind = pointer.getLIRKind(); + assert inputKind.getPlatformKind() == Kind.Long || inputKind.getPlatformKind() == Kind.Object; + if (inputKind.isReference(0)) { + // oop + Variable result = newVariable(LIRKind.reference(Kind.Int)); append(new AMD64HotSpotMove.CompressPointer(result, asAllocatable(pointer), getProviders().getRegisters().getHeapBaseRegister().asValue(), encoding, nonNull)); return result; } else { - assert pointer.getPlatformKind() == Kind.Long; - Variable result = newVariable(Kind.Int); + // metaspace pointer + Variable result = newVariable(LIRKind.value(Kind.Int)); AllocatableValue base = Value.ILLEGAL; if (encoding.base != 0) { base = emitMove(Constant.forLong(encoding.base)); @@ -502,13 +496,16 @@ @Override public Value emitUncompress(Value pointer, CompressEncoding encoding, boolean nonNull) { - if (pointer.getPlatformKind() == NarrowOopStamp.NarrowOop) { - Variable result = newVariable(Kind.Object); + LIRKind inputKind = pointer.getLIRKind(); + assert inputKind.getPlatformKind() == Kind.Int; + if (inputKind.isReference(0)) { + // oop + Variable result = newVariable(LIRKind.reference(Kind.Object)); append(new AMD64HotSpotMove.UncompressPointer(result, asAllocatable(pointer), getProviders().getRegisters().getHeapBaseRegister().asValue(), encoding, nonNull)); return result; } else { - assert pointer.getPlatformKind() == Kind.Int; - Variable result = newVariable(Kind.Long); + // metaspace pointer + Variable result = newVariable(LIRKind.value(Kind.Long)); AllocatableValue base = Value.ILLEGAL; if (encoding.base != 0) { base = emitMove(Constant.forLong(encoding.base)); @@ -522,36 +519,30 @@ protected AMD64LIRInstruction createMove(AllocatableValue dst, Value src) { if (src instanceof Constant) { return new AMD64HotSpotMove.HotSpotLoadConstantOp(dst, (Constant) src); - } else if (dst.getPlatformKind() == NarrowOopStamp.NarrowOop) { - if (isRegister(src) || isStackSlot(dst)) { - return new MoveFromRegOp(Kind.Int, dst, src); - } else { - return new MoveToRegOp(Kind.Int, dst, src); - } } else { return super.createMove(dst, src); } } public Value emitCompareAndSwap(Value address, Value expectedValue, Value newValue, Value trueValue, Value falseValue) { - PlatformKind kind = newValue.getPlatformKind(); - assert kind == expectedValue.getPlatformKind(); - Kind memKind = getMemoryKind(kind); + LIRKind kind = newValue.getLIRKind(); + assert kind.equals(expectedValue.getLIRKind()); + Kind memKind = (Kind) kind.getPlatformKind(); AMD64AddressValue addressValue = asAddressValue(address); RegisterValue raxRes = AMD64.rax.asValue(kind); emitMove(raxRes, expectedValue); append(new CompareAndSwapOp(memKind, raxRes, addressValue, raxRes, asAllocatable(newValue))); - assert trueValue.getPlatformKind() == falseValue.getPlatformKind(); - Variable result = newVariable(trueValue.getPlatformKind()); + assert trueValue.getLIRKind().equals(falseValue.getLIRKind()); + Variable result = newVariable(trueValue.getLIRKind()); append(new CondMoveOp(result, Condition.EQ, asAllocatable(trueValue), falseValue)); return result; } public Value emitAtomicReadAndAdd(Value address, Value delta) { - PlatformKind kind = delta.getPlatformKind(); - Kind memKind = getMemoryKind(kind); + LIRKind kind = delta.getLIRKind(); + Kind memKind = (Kind) kind.getPlatformKind(); Variable result = newVariable(kind); AMD64AddressValue addressValue = asAddressValue(address); append(new AMD64Move.AtomicReadAndAddOp(memKind, result, addressValue, asAllocatable(delta))); @@ -559,8 +550,8 @@ } public Value emitAtomicReadAndWrite(Value address, Value newValue) { - PlatformKind kind = newValue.getPlatformKind(); - Kind memKind = getMemoryKind(kind); + LIRKind kind = newValue.getLIRKind(); + Kind memKind = (Kind) kind.getPlatformKind(); Variable result = newVariable(kind); AMD64AddressValue addressValue = asAddressValue(address); append(new AMD64Move.AtomicReadAndWriteOp(memKind, result, addressValue, asAllocatable(newValue))); @@ -573,11 +564,9 @@ } @Override - protected void emitCompareOp(PlatformKind cmpKind, Variable left, Value right) { + protected void emitCompareOp(Kind cmpKind, Variable left, Value right) { if (right instanceof HotSpotConstant) { append(new AMD64HotSpotCompare.HotSpotCompareConstantOp(left, (Constant) right)); - } else if (cmpKind == NarrowOopStamp.NarrowOop) { - append(new AMD64HotSpotCompare.HotSpotCompareNarrowOp(left, asAllocatable(right))); } else { super.emitCompareOp(cmpKind, left, right); }
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotNodeLIRBuilder.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotNodeLIRBuilder.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,6 +32,7 @@ import com.oracle.graal.asm.*; import com.oracle.graal.compiler.amd64.*; import com.oracle.graal.compiler.common.calc.*; +import com.oracle.graal.compiler.common.type.*; import com.oracle.graal.compiler.gen.*; import com.oracle.graal.compiler.match.*; import com.oracle.graal.debug.*; @@ -104,7 +105,7 @@ @Override protected DebugInfoBuilder createDebugInfoBuilder(StructuredGraph graph, NodeMap<Value> nodeOperands) { - HotSpotLockStack lockStack = new HotSpotLockStack(gen.getResult().getFrameMap(), Kind.Long); + HotSpotLockStack lockStack = new HotSpotLockStack(gen.getResult().getFrameMap(), LIRKind.value(Kind.Long)); return new HotSpotDebugInfoBuilder(nodeOperands, lockStack); } @@ -123,7 +124,7 @@ } } } - params[params.length - 1] = rbp.asValue(Kind.Long); + params[params.length - 1] = rbp.asValue(LIRKind.value(Kind.Long)); gen.emitIncomingValues(params); @@ -206,29 +207,28 @@ @Override public void visitDirectCompareAndSwap(DirectCompareAndSwapNode x) { - Kind kind = x.newValue().getKind(); - assert kind == x.expectedValue().getKind(); - Value expected = gen.loadNonConst(operand(x.expectedValue())); Variable newVal = gen.load(operand(x.newValue())); + assert expected.getLIRKind().equals(newVal.getLIRKind()); AMD64AddressValue address = getGen().emitAddress(operand(x.object()), 0, operand(x.offset()), 1); - RegisterValue raxLocal = AMD64.rax.asValue(kind); + RegisterValue raxLocal = AMD64.rax.asValue(expected.getLIRKind()); gen.emitMove(raxLocal, expected); - append(new CompareAndSwapOp(kind, raxLocal, address, raxLocal, newVal)); + append(new CompareAndSwapOp(expected.getKind(), raxLocal, address, raxLocal, newVal)); - Variable result = gen.newVariable(x.getKind()); - gen.emitMove(result, raxLocal); - setResult(x, result); + setResult(x, gen.emitMove(raxLocal)); } boolean canFormCompressedMemory(CompressionNode compress, ConstantLocationNode location) { HotSpotVMConfig config = HotSpotGraalRuntime.runtime().getConfig(); if (config.useCompressedOops && compress.getEncoding().shift <= 3 && NumUtil.isInt(location.getDisplacement())) { - PlatformKind objectKind = compress.getInput().stamp().getPlatformKind(getGen()); - if (objectKind == NarrowOopStamp.NarrowOop || objectKind == Kind.Int && config.narrowKlassBase == config.narrowOopBase) { + Stamp compressedStamp = compress.getInput().stamp(); + if (compressedStamp instanceof NarrowOopStamp) { return true; + } else if (compressedStamp instanceof IntegerStamp) { + IntegerStamp is = (IntegerStamp) compressedStamp; + return is.getBits() == 32 && config.narrowKlassBase == config.narrowOopBase; } } return false; @@ -253,7 +253,7 @@ @MatchRule("(If (FloatLessThan=compare value (Read=access (Compression=compress object) ConstantLocation=location)))") public ComplexMatchResult ifCompareCompressedMemory(IfNode root, CompareNode compare, CompressionNode compress, ValueNode value, ConstantLocationNode location, Access access) { if (canFormCompressedMemory(compress, location)) { - PlatformKind cmpKind = gen.getPlatformKind(compare.x().stamp()); + PlatformKind cmpKind = gen.getLIRKind(compare.x().stamp()).getPlatformKind(); if (cmpKind instanceof Kind) { Kind kind = (Kind) cmpKind; return builder -> { @@ -300,7 +300,7 @@ @MatchRule("(FloatingRead (Pi (Compression=compress object)) ConstantLocation=location)") public ComplexMatchResult readCompressed(Access root, CompressionNode compress, ConstantLocationNode location) { if (canFormCompressedMemory(compress, location)) { - PlatformKind readKind = getGen().getPlatformKind(root.asNode().stamp()); + LIRKind readKind = getGen().getLIRKind(root.asNode().stamp()); return builder -> { return getGen().emitLoad(readKind, makeCompressedAddress(compress, location), getState(root)); }; @@ -312,7 +312,7 @@ @MatchRule("(Write (Pi (Compression=compress object)) ConstantLocation=location value)") public ComplexMatchResult writeCompressed(Access root, CompressionNode compress, ConstantLocationNode location, ValueNode value) { if (canFormCompressedMemory(compress, location)) { - PlatformKind readKind = getGen().getPlatformKind(value.asNode().stamp()); + LIRKind readKind = getGen().getLIRKind(value.asNode().stamp()); return builder -> { getGen().emitStore(readKind, makeCompressedAddress(compress, location), operand(value), getState(root)); return null;
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRegisterConfig.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRegisterConfig.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,6 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.common.*; import com.oracle.graal.hotspot.*; -import com.oracle.graal.hotspot.nodes.type.*; public class AMD64HotSpotRegisterConfig implements RegisterConfig { @@ -70,16 +69,9 @@ return categorized.get(kind); } - PlatformKind primitiveKind; - if (kind == NarrowOopStamp.NarrowOop) { - primitiveKind = Kind.Int; - } else { - primitiveKind = kind; - } - ArrayList<Register> list = new ArrayList<>(); for (Register reg : getAllocatableRegisters()) { - if (architecture.canStoreValue(reg.getRegisterCategory(), primitiveKind)) { + if (architecture.canStoreValue(reg.getRegisterCategory(), kind)) { list.add(reg); } } @@ -222,14 +214,14 @@ case Object: if (!stackOnly && currentGeneral < generalParameterRegisters.length) { Register register = generalParameterRegisters[currentGeneral++]; - locations[i] = register.asValue(kind); + locations[i] = register.asValue(target.getLIRKind(kind)); } break; case Float: case Double: if (!stackOnly && currentXMM < xmmParameterRegisters.length) { Register register = xmmParameterRegisters[currentXMM++]; - locations[i] = register.asValue(kind); + locations[i] = register.asValue(target.getLIRKind(kind)); } break; default: @@ -237,13 +229,13 @@ } if (locations[i] == null) { - locations[i] = StackSlot.get(kind.getStackKind(), currentStackOffset, !type.out); + locations[i] = StackSlot.get(target.getLIRKind(kind.getStackKind()), currentStackOffset, !type.out); currentStackOffset += Math.max(target.getSizeInBytes(kind), target.wordSize); } } Kind returnKind = returnType == null ? Kind.Void : returnType.getKind(); - AllocatableValue returnLocation = returnKind == Kind.Void ? Value.ILLEGAL : getReturnRegister(returnKind).asValue(returnKind.getStackKind()); + AllocatableValue returnLocation = returnKind == Kind.Void ? Value.ILLEGAL : getReturnRegister(returnKind).asValue(target.getLIRKind(returnKind.getStackKind())); return new CallingConvention(currentStackOffset, returnLocation, locations); }
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotSafepointOp.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotSafepointOp.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,7 +51,7 @@ this.state = state; this.config = config; if (isPollingPageFar(config) || ImmutableCode.getValue()) { - temp = tool.getLIRGeneratorTool().newVariable(tool.getLIRGeneratorTool().target().wordKind); + temp = tool.getLIRGeneratorTool().newVariable(LIRKind.value(tool.getLIRGeneratorTool().target().wordKind)); } else { // Don't waste a register if it's unneeded temp = Value.ILLEGAL;
--- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotBackend.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotBackend.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -496,6 +496,7 @@ public void emitCode(CompilationResultBuilder crb, LIR lir, ResolvedJavaMethod method) { assert method != null : lir + " is not associated with a method"; Kind wordKind = getProviders().getCodeCache().getTarget().wordKind; + LIRKind wordLIRKind = LIRKind.value(wordKind); HotSpotVMConfig config = getRuntime().getConfig(); boolean useHSAILDeoptimization = config.useHSAILDeoptimization; @@ -636,14 +637,14 @@ if (useHSAILDeoptimization) { // Aliases for d16 - RegisterValue d16_deoptInfo = HSAIL.d16.asValue(wordKind); + RegisterValue d16_deoptInfo = HSAIL.d16.asValue(wordLIRKind); // Aliases for d17 - RegisterValue d17_donorThreadIndex = HSAIL.d17.asValue(wordKind); + RegisterValue d17_donorThreadIndex = HSAIL.d17.asValue(wordLIRKind); RegisterValue d17_safepointFlagAddrIndex = d17_donorThreadIndex; // Aliases for s34 - RegisterValue s34_deoptOccurred = HSAIL.s34.asValue(Kind.Int); + RegisterValue s34_deoptOccurred = HSAIL.s34.asValue(LIRKind.value(Kind.Int)); RegisterValue s34_donorThreadIndex = s34_deoptOccurred; asm.emitLoadKernelArg(d16_deoptInfo, asm.getDeoptInfoName(), "u64"); @@ -651,20 +652,20 @@ if (useHSAILSafepoints) { // Load address of _notice_safepoints field - asm.emitLoad(wordKind, d17_safepointFlagAddrIndex, new HSAILAddressValue(wordKind, d16_deoptInfo, config.hsailNoticeSafepointsOffset).toAddress()); + asm.emitLoad(wordKind, d17_safepointFlagAddrIndex, new HSAILAddressValue(wordLIRKind, d16_deoptInfo, config.hsailNoticeSafepointsOffset).toAddress()); // Load int value from that field - asm.emitLoadAcquire(s34_deoptOccurred, new HSAILAddressValue(Kind.Int, d17_safepointFlagAddrIndex, 0).toAddress()); + asm.emitLoadAcquire(s34_deoptOccurred, new HSAILAddressValue(wordLIRKind, d17_safepointFlagAddrIndex, 0).toAddress()); asm.emitCompare(Kind.Int, s34_deoptOccurred, Constant.forInt(0), "ne", false, false); asm.cbr(deoptInProgressLabel); } - asm.emitLoadAcquire(s34_deoptOccurred, new HSAILAddressValue(Kind.Int, d16_deoptInfo, config.hsailDeoptOccurredOffset).toAddress()); + asm.emitLoadAcquire(s34_deoptOccurred, new HSAILAddressValue(wordLIRKind, d16_deoptInfo, config.hsailDeoptOccurredOffset).toAddress()); asm.emitCompare(Kind.Int, s34_deoptOccurred, Constant.forInt(0), "ne", false, false); asm.cbr(deoptInProgressLabel); // load thread register if this kernel performs allocation if (usesAllocation) { - RegisterValue threadReg = getProviders().getRegisters().getThreadRegister().asValue(wordKind); + RegisterValue threadReg = getProviders().getRegisters().getThreadRegister().asValue(wordLIRKind); assert HsailDonorThreads.getValue() > 0; - asm.emitLoad(wordKind, threadReg, new HSAILAddressValue(wordKind, d16_deoptInfo, config.hsailCurTlabInfoOffset).toAddress()); + asm.emitLoad(wordKind, threadReg, new HSAILAddressValue(wordLIRKind, d16_deoptInfo, config.hsailCurTlabInfoOffset).toAddress()); if (HsailDonorThreads.getValue() != 1) { asm.emitComment("// map workitem to a donor thread"); asm.emitString(String.format("rem_u32 $%s, %s, %d;", s34_donorThreadIndex.getRegister(), workItemReg, HsailDonorThreads.getValue())); @@ -818,18 +819,18 @@ final int offsetToNumSaves = config.hsailFrameNumSRegOffset; final int offsetToSaveArea = config.hsailFrameHeaderSize; - AllocatableValue scratch64 = HSAIL.d16.asValue(wordKind); - AllocatableValue cuSaveAreaPtr = HSAIL.d17.asValue(wordKind); - AllocatableValue waveMathScratch1 = HSAIL.d18.asValue(wordKind); - AllocatableValue waveMathScratch2 = HSAIL.d19.asValue(wordKind); + AllocatableValue scratch64 = HSAIL.d16.asValue(wordLIRKind); + AllocatableValue cuSaveAreaPtr = HSAIL.d17.asValue(wordLIRKind); + AllocatableValue waveMathScratch1 = HSAIL.d18.asValue(wordLIRKind); + AllocatableValue waveMathScratch2 = HSAIL.d19.asValue(wordLIRKind); - AllocatableValue actionAndReasonReg = HSAIL.actionAndReasonReg.asValue(Kind.Int); - AllocatableValue codeBufferOffsetReg = HSAIL.codeBufferOffsetReg.asValue(Kind.Int); - AllocatableValue scratch32 = HSAIL.s34.asValue(Kind.Int); - AllocatableValue workidreg = HSAIL.s35.asValue(Kind.Int); + AllocatableValue actionAndReasonReg = HSAIL.actionAndReasonReg.asValue(LIRKind.value(Kind.Int)); + AllocatableValue codeBufferOffsetReg = HSAIL.codeBufferOffsetReg.asValue(LIRKind.value(Kind.Int)); + AllocatableValue scratch32 = HSAIL.s34.asValue(LIRKind.value(Kind.Int)); + AllocatableValue workidreg = HSAIL.s35.asValue(LIRKind.value(Kind.Int)); - HSAILAddress deoptNextIndexAddr = new HSAILAddressValue(Kind.Int, scratch64, offsetToDeoptNextIndex).toAddress(); - HSAILAddress neverRanArrayAddr = new HSAILAddressValue(Kind.Int, scratch64, offsetToNeverRanArray).toAddress(); + HSAILAddress deoptNextIndexAddr = new HSAILAddressValue(wordLIRKind, scratch64, offsetToDeoptNextIndex).toAddress(); + HSAILAddress neverRanArrayAddr = new HSAILAddressValue(wordLIRKind, scratch64, offsetToNeverRanArray).toAddress(); // The just-started lanes that see the deopt flag will jump here asm.emitString0(deoptInProgressLabel + ":\n"); @@ -837,7 +838,7 @@ asm.emitWorkItemAbsId(workidreg); asm.emitConvert(waveMathScratch2, workidreg, wordKind, Kind.Int); asm.emit("add", waveMathScratch1, waveMathScratch1, waveMathScratch2); - HSAILAddress neverRanStoreAddr = new HSAILAddressValue(Kind.Byte, waveMathScratch1, 0).toAddress(); + HSAILAddress neverRanStoreAddr = new HSAILAddressValue(wordLIRKind, waveMathScratch1, 0).toAddress(); asm.emitStore(Kind.Byte, Constant.forInt(1), neverRanStoreAddr); asm.emitString("ret;"); @@ -845,7 +846,7 @@ asm.emitString0(asm.getDeoptLabelName() + ":\n"); String labelExit = asm.getDeoptLabelName() + "_Exit"; - HSAILAddress deoptInfoAddr = new HSAILAddressValue(Kind.Int, scratch64, config.hsailDeoptOccurredOffset).toAddress(); + HSAILAddress deoptInfoAddr = new HSAILAddressValue(wordLIRKind, scratch64, config.hsailDeoptOccurredOffset).toAddress(); asm.emitLoadKernelArg(scratch64, asm.getDeoptInfoName(), "u64"); // Set deopt occurred flag @@ -882,14 +883,14 @@ // Add offset to _deopt_save_states[0] asm.emit("add", scratch64, cuSaveAreaPtr, Constant.forInt(offsetToDeoptSaveStates)); - HSAILAddress workItemAddr = new HSAILAddressValue(Kind.Int, scratch64, offsetToDeoptimizationWorkItem).toAddress(); - HSAILAddress actionReasonStoreAddr = new HSAILAddressValue(Kind.Int, scratch64, offsetToDeoptimizationReason).toAddress(); + HSAILAddress workItemAddr = new HSAILAddressValue(wordLIRKind, scratch64, offsetToDeoptimizationWorkItem).toAddress(); + HSAILAddress actionReasonStoreAddr = new HSAILAddressValue(wordLIRKind, scratch64, offsetToDeoptimizationReason).toAddress(); asm.emitComment("// Get _deopt_info._first_frame"); asm.emit("add", waveMathScratch1, scratch64, Constant.forInt(offsetToDeoptimizationFrame)); // Now scratch64 is the _deopt_info._first_frame - HSAILAddress pcStoreAddr = new HSAILAddressValue(Kind.Int, waveMathScratch1, offsetToFramePc).toAddress(); - HSAILAddress regCountsAddr = new HSAILAddressValue(Kind.Int, waveMathScratch1, offsetToNumSaves).toAddress(); + HSAILAddress pcStoreAddr = new HSAILAddressValue(wordLIRKind, waveMathScratch1, offsetToFramePc).toAddress(); + HSAILAddress regCountsAddr = new HSAILAddressValue(wordLIRKind, waveMathScratch1, offsetToNumSaves).toAddress(); asm.emitComment("// store deopting workitem"); asm.emitWorkItemAbsId(scratch32); asm.emitStore(Kind.Int, scratch32, workItemAddr); @@ -911,16 +912,16 @@ // 32 bit registers Kind kind = Kind.Int; int ofst = offsetToSaveArea + reg.encoding * 4; - HSAILAddress addr = new HSAILAddressValue(kind, waveMathScratch1, ofst).toAddress(); - AllocatableValue regValue = reg.asValue(kind); + HSAILAddress addr = new HSAILAddressValue(wordLIRKind, waveMathScratch1, ofst).toAddress(); + AllocatableValue regValue = reg.asValue(LIRKind.value(kind)); asm.emitStore(kind, regValue, addr); } else if (hsailRegConfig.isAllocatableDReg(reg)) { // 64 bit registers Kind kind = Kind.Long; // d reg ofst starts past the 32 sregs int ofst = offsetToSaveArea + (numSRegs * 4) + reg.encoding * 8; - HSAILAddress addr = new HSAILAddressValue(kind, waveMathScratch1, ofst).toAddress(); - AllocatableValue regValue = reg.asValue(kind); + HSAILAddress addr = new HSAILAddressValue(wordLIRKind, waveMathScratch1, ofst).toAddress(); + AllocatableValue regValue = reg.asValue(LIRKind.value(kind)); asm.emitStore(kind, regValue, addr); } else { throw GraalInternalError.unimplemented(); @@ -935,7 +936,7 @@ Kind kind = slot.getKind(); int sizeInBits = (kind.isObject() || kind.getByteCount() == 8 ? 64 : 32); int ofst = offsetToSaveArea + (numSRegs * 4) + (numDRegs * 8) + HSAIL.getStackOffsetStart(slot, sizeInBits); - HSAILAddress addr = new HSAILAddressValue(kind, waveMathScratch1, ofst).toAddress(); + HSAILAddress addr = new HSAILAddressValue(wordLIRKind, waveMathScratch1, ofst).toAddress(); if (sizeInBits == 64) { asm.emitSpillLoad(kind, scratch64, slot); asm.emitStore(kind, scratch64, addr);
--- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotBackendFactory.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotBackendFactory.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -72,7 +72,7 @@ final int stackFrameAlignment = 8; final int implicitNullCheckLimit = 0; final boolean inlineObjects = true; - return new HotSpotTargetDescription(new HSAIL(), true, stackFrameAlignment, implicitNullCheckLimit, inlineObjects, Kind.Int); + return new HotSpotTargetDescription(new HSAIL(), true, stackFrameAlignment, implicitNullCheckLimit, inlineObjects); } public String getArchitecture() {
--- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotLIRGenerator.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotLIRGenerator.java Fri Jun 13 11:47:44 2014 +0200 @@ -33,13 +33,23 @@ import com.oracle.graal.hotspot.*; import com.oracle.graal.hotspot.HotSpotVMConfig.CompressEncoding; import com.oracle.graal.hotspot.meta.*; -import com.oracle.graal.hotspot.nodes.type.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.StandardOp.SaveRegistersOp; import com.oracle.graal.lir.gen.*; import com.oracle.graal.lir.hsail.*; -import com.oracle.graal.lir.hsail.HSAILControlFlow.*; -import com.oracle.graal.lir.hsail.HSAILMove.*; +import com.oracle.graal.lir.hsail.HSAILControlFlow.CondMoveOp; +import com.oracle.graal.lir.hsail.HSAILControlFlow.DeoptimizeOp; +import com.oracle.graal.lir.hsail.HSAILControlFlow.ForeignCall1ArgOp; +import com.oracle.graal.lir.hsail.HSAILControlFlow.ForeignCall2ArgOp; +import com.oracle.graal.lir.hsail.HSAILControlFlow.ForeignCallNoArgOp; +import com.oracle.graal.lir.hsail.HSAILMove.CompareAndSwapOp; +import com.oracle.graal.lir.hsail.HSAILMove.LoadAcquireOp; +import com.oracle.graal.lir.hsail.HSAILMove.LoadOp; +import com.oracle.graal.lir.hsail.HSAILMove.MoveToRegOp; +import com.oracle.graal.lir.hsail.HSAILMove.StoreConstantOp; +import com.oracle.graal.lir.hsail.HSAILMove.StoreOp; +import com.oracle.graal.lir.hsail.HSAILMove.StoreReleaseOp; +import com.oracle.graal.lir.hsail.HSAILMove.WorkItemAbsIdOp; import com.oracle.graal.phases.util.*; /** @@ -97,35 +107,23 @@ } } - private static Kind getMemoryKind(PlatformKind kind) { - if (kind == NarrowOopStamp.NarrowOop) { - return Kind.Int; - } else { - return (Kind) kind; - } - } - @Override - public Variable emitLoad(PlatformKind kind, Value address, LIRFrameState state) { + public Variable emitLoad(LIRKind kind, Value address, LIRFrameState state) { HSAILAddressValue loadAddress = asAddressValue(address); Variable result = newVariable(kind); - if (kind == NarrowOopStamp.NarrowOop) { - append(new LoadOp(Kind.Int, result, loadAddress, state)); - } else { - append(new LoadOp(getMemoryKind(kind), result, loadAddress, state)); - } + append(new LoadOp((Kind) kind.getPlatformKind(), result, loadAddress, state)); return result; } - public Variable emitLoadAcquire(PlatformKind kind, Value address, LIRFrameState state) { + public Variable emitLoadAcquire(LIRKind kind, Value address, LIRFrameState state) { HSAILAddressValue loadAddress = asAddressValue(address); Variable result = newVariable(kind); - append(new LoadAcquireOp(getMemoryKind(kind), result, loadAddress, state)); + append(new LoadAcquireOp((Kind) kind.getPlatformKind(), result, loadAddress, state)); return result; } @Override - public void emitStore(PlatformKind kind, Value address, Value inputVal, LIRFrameState state) { + public void emitStore(LIRKind kind, Value address, Value inputVal, LIRFrameState state) { HSAILAddressValue storeAddress = asAddressValue(address); if (isConstant(inputVal)) { Constant c = asConstant(inputVal); @@ -133,45 +131,41 @@ c = Constant.INT_0; } if (canStoreConstant(c)) { - append(new StoreConstantOp(getMemoryKind(kind), storeAddress, c, state)); + append(new StoreConstantOp((Kind) kind.getPlatformKind(), storeAddress, c, state)); return; } } Variable input = load(inputVal); - if (kind == NarrowOopStamp.NarrowOop) { - append(new StoreOp(Kind.Int, storeAddress, input, state)); - } else { - append(new StoreOp(getMemoryKind(kind), storeAddress, input, state)); - } + append(new StoreOp((Kind) kind.getPlatformKind(), storeAddress, input, state)); } - public void emitStoreRelease(PlatformKind kind, Value address, Value inputVal, LIRFrameState state) { + public void emitStoreRelease(LIRKind kind, Value address, Value inputVal, LIRFrameState state) { HSAILAddressValue storeAddress = asAddressValue(address); // TODO: handle Constants here Variable input = load(inputVal); - append(new StoreReleaseOp(getMemoryKind(kind), storeAddress, input, state)); + append(new StoreReleaseOp((Kind) kind.getPlatformKind(), storeAddress, input, state)); } public Value emitCompareAndSwap(Value address, Value expectedValue, Value newValue, Value trueValue, Value falseValue) { - PlatformKind kind = newValue.getPlatformKind(); - assert kind == expectedValue.getPlatformKind(); - Kind memKind = getMemoryKind(kind); + LIRKind kind = newValue.getLIRKind(); + assert kind == expectedValue.getLIRKind(); + Kind memKind = (Kind) kind.getPlatformKind(); HSAILAddressValue addressValue = asAddressValue(address); Variable expected = emitMove(expectedValue); Variable casResult = newVariable(kind); append(new CompareAndSwapOp(memKind, casResult, addressValue, expected, asAllocatable(newValue))); - assert trueValue.getPlatformKind() == falseValue.getPlatformKind(); - Variable nodeResult = newVariable(trueValue.getPlatformKind()); + assert trueValue.getLIRKind() == falseValue.getLIRKind(); + Variable nodeResult = newVariable(trueValue.getLIRKind()); append(new CondMoveOp(HSAILLIRGenerator.mapKindToCompareOp(memKind), casResult, expected, nodeResult, Condition.EQ, trueValue, falseValue)); return nodeResult; } @Override public Value emitAtomicReadAndAdd(Value address, Value delta) { - PlatformKind kind = delta.getPlatformKind(); - Kind memKind = getMemoryKind(kind); + LIRKind kind = delta.getLIRKind(); + Kind memKind = (Kind) kind.getPlatformKind(); Variable result = newVariable(kind); HSAILAddressValue addressValue = asAddressValue(address); append(new HSAILMove.AtomicReadAndAddOp(memKind, result, addressValue, asAllocatable(delta))); @@ -180,8 +174,8 @@ @Override public Value emitAtomicReadAndWrite(Value address, Value newValue) { - PlatformKind kind = newValue.getPlatformKind(); - Kind memKind = getMemoryKind(kind); + LIRKind kind = newValue.getLIRKind(); + Kind memKind = (Kind) kind.getPlatformKind(); Variable result = newVariable(kind); HSAILAddressValue addressValue = asAddressValue(address); append(new HSAILMove.AtomicReadAndWriteOp(memKind, result, addressValue, asAllocatable(newValue))); @@ -209,13 +203,13 @@ */ @Override public Variable emitForeignCall(ForeignCallLinkage linkage, LIRFrameState state, Value... args) { - Variable result = newVariable(Kind.Object); // linkage.getDescriptor().getResultType()); + Variable result = newVariable(LIRKind.reference(Kind.Object)); // linkage.getDescriptor().getResultType()); // to make the LIRVerifier happy, we move any constants into registers Value[] argLocations = new Value[args.length]; for (int i = 0; i < args.length; i++) { Value arg = args[i]; - AllocatableValue loc = newVariable(arg.getKind()); + AllocatableValue loc = newVariable(arg.getLIRKind()); emitMove(loc, arg); argLocations[i] = loc; } @@ -240,23 +234,13 @@ @Override protected HSAILLIRInstruction createMove(AllocatableValue dst, Value src) { - if (dst.getPlatformKind() == NarrowOopStamp.NarrowOop) { - if (HotSpotCompressedNullConstant.COMPRESSED_NULL.equals(src)) { - return new MoveToRegOp(Kind.Int, dst, Constant.INT_0); - } else if (src instanceof HotSpotObjectConstant) { - if (HotSpotObjectConstant.isCompressed((Constant) src)) { - Variable uncompressed = newVariable(Kind.Object); - append(new MoveToRegOp(Kind.Object, uncompressed, src)); - CompressEncoding oopEncoding = config.getOopEncoding(); - return new HSAILMove.CompressPointer(dst, newVariable(Kind.Object), uncompressed, oopEncoding.base, oopEncoding.shift, oopEncoding.alignment, true); - } else { - return new MoveToRegOp(Kind.Object, dst, src); - } - } else if (isRegister(src) || isStackSlot(dst)) { - return new MoveFromRegOp(Kind.Int, dst, src); - } else { - return new MoveToRegOp(Kind.Int, dst, src); - } + if (HotSpotCompressedNullConstant.COMPRESSED_NULL.equals(src)) { + return new MoveToRegOp(Kind.Int, dst, Constant.INT_0); + } else if (src instanceof HotSpotObjectConstant && HotSpotObjectConstant.isCompressed((Constant) src)) { + Variable uncompressed = newVariable(LIRKind.reference(Kind.Object)); + append(new MoveToRegOp(Kind.Object, uncompressed, src)); + CompressEncoding oopEncoding = config.getOopEncoding(); + return new HSAILMove.CompressPointer(dst, newVariable(LIRKind.reference(Kind.Object)), uncompressed, oopEncoding.base, oopEncoding.shift, oopEncoding.alignment, true); } else { return super.createMove(dst, src); } @@ -297,14 +281,14 @@ @Override public Value emitCompress(Value pointer, CompressEncoding encoding, boolean nonNull) { - Variable result = newVariable(NarrowOopStamp.NarrowOop); - append(new HSAILMove.CompressPointer(result, newVariable(pointer.getPlatformKind()), asAllocatable(pointer), encoding.base, encoding.shift, encoding.alignment, nonNull)); + Variable result = newVariable(LIRKind.reference(Kind.Int)); + append(new HSAILMove.CompressPointer(result, newVariable(pointer.getLIRKind()), asAllocatable(pointer), encoding.base, encoding.shift, encoding.alignment, nonNull)); return result; } @Override public Value emitUncompress(Value pointer, CompressEncoding encoding, boolean nonNull) { - Variable result = newVariable(Kind.Object); + Variable result = newVariable(LIRKind.reference(Kind.Object)); append(new HSAILMove.UncompressPointer(result, asAllocatable(pointer), encoding.base, encoding.shift, encoding.alignment, nonNull)); return result; } @@ -315,13 +299,13 @@ public void emitNullCheck(Value address, LIRFrameState state) { assert address.getKind() == Kind.Object : address + " - " + address.getKind() + " not an object!"; - Variable obj = newVariable(Kind.Object); + Variable obj = newVariable(LIRKind.reference(Kind.Object)); emitMove(obj, address); append(new HSAILMove.NullCheckOp(obj, state)); } public Variable emitWorkItemAbsId() { - Variable result = newVariable(Kind.Int); + Variable result = newVariable(LIRKind.value(Kind.Int)); append(new WorkItemAbsIdOp(result)); return result; }
--- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotNodeLIRBuilder.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotNodeLIRBuilder.java Fri Jun 13 11:47:44 2014 +0200 @@ -78,12 +78,12 @@ } public void visitDirectCompareAndSwap(DirectCompareAndSwapNode x) { - Kind kind = x.newValue().getKind(); - assert kind == x.expectedValue().getKind(); - Variable expected = getGen().load(operand(x.expectedValue())); Variable newVal = getGen().load(operand(x.newValue())); + LIRKind kind = newVal.getLIRKind(); + assert kind.equals(expected.getLIRKind()); + int disp = 0; HSAILAddressValue address; Value index = operand(x.offset()); @@ -96,7 +96,7 @@ } Variable casResult = gen.newVariable(kind); - append(new CompareAndSwapOp(kind, casResult, address, expected, newVal)); + append(new CompareAndSwapOp((Kind) kind.getPlatformKind(), casResult, address, expected, newVal)); setResult(x, casResult); }
--- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotRegisterConfig.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotRegisterConfig.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,6 @@ import com.oracle.graal.api.code.CallingConvention.Type; import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.common.*; -import com.oracle.graal.hotspot.nodes.type.*; import com.oracle.graal.hsail.*; /** @@ -107,7 +106,7 @@ if (!stackOnly && currentRegs32 < generalParameterRegisters.length) { Register register = generalParameterRegisters[currentRegs32++]; - locations[i] = register.asValue(kind); + locations[i] = register.asValue(target.getLIRKind(kind)); } break; case Long: @@ -115,7 +114,7 @@ case Double: if (!stackOnly && currentRegs64 < longParameterRegisters.length) { Register register = longParameterRegisters[currentRegs64++]; - locations[i] = register.asValue(kind); + locations[i] = register.asValue(target.getLIRKind(kind)); } break; default: @@ -123,13 +122,13 @@ } if (locations[i] == null) { - locations[i] = StackSlot.get(kind.getStackKind(), currentStackOffset, !type.out); + locations[i] = StackSlot.get(target.getLIRKind(kind.getStackKind()), currentStackOffset, !type.out); currentStackOffset += Math.max(target.getSizeInBytes(kind), target.wordSize); } } Kind returnKind = returnType == null ? Kind.Void : returnType.getKind(); - AllocatableValue returnLocation = returnKind == Kind.Void ? Value.ILLEGAL : getReturnRegister(returnKind).asValue(returnKind); + AllocatableValue returnLocation = returnKind == Kind.Void ? Value.ILLEGAL : getReturnRegister(returnKind).asValue(target.getLIRKind(returnKind)); return new CallingConvention(currentStackOffset, returnLocation, locations); } @@ -145,14 +144,7 @@ @Override public Register[] getAllocatableRegisters(PlatformKind kind) { - Kind primitiveKind; - if (kind == NarrowOopStamp.NarrowOop) { - primitiveKind = Kind.Int; - } else { - primitiveKind = (Kind) kind; - } - - switch (primitiveKind) { + switch ((Kind) kind) { case Int: case Short: case Byte:
--- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotSafepointOp.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotSafepointOp.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -61,23 +61,23 @@ masm.emitComment(" /* HSAIL safepoint bci=" + frameState.debugInfo().getBytecodePosition().getBCI() + ", frameState=" + frameState + " */"); String afterSafepointLabel = "@LAfterSafepoint_at_pos_" + codeBufferPos; - AllocatableValue scratch64 = HSAIL.d16.asValue(Kind.Object); - AllocatableValue spAddrReg = HSAIL.d17.asValue(Kind.Object); - AllocatableValue scratch32 = HSAIL.s34.asValue(Kind.Int); + AllocatableValue scratch64 = HSAIL.d16.asValue(LIRKind.reference(Kind.Object)); + AllocatableValue spAddrReg = HSAIL.d17.asValue(LIRKind.reference(Kind.Object)); + AllocatableValue scratch32 = HSAIL.s34.asValue(LIRKind.value(Kind.Int)); masm.emitLoadKernelArg(scratch64, masm.getDeoptInfoName(), "u64"); // Build address of noticeSafepoints field - HSAILAddress noticeSafepointsAddr = new HSAILAddressValue(Kind.Object, scratch64, offsetToNoticeSafepoints).toAddress(); + HSAILAddress noticeSafepointsAddr = new HSAILAddressValue(LIRKind.value(Kind.Long), scratch64, offsetToNoticeSafepoints).toAddress(); masm.emitLoad(Kind.Object, spAddrReg, noticeSafepointsAddr); // Load int value from that field - HSAILAddress noticeSafepointsIntAddr = new HSAILAddressValue(Kind.Int, spAddrReg, 0).toAddress(); + HSAILAddress noticeSafepointsIntAddr = new HSAILAddressValue(LIRKind.value(Kind.Long), spAddrReg, 0).toAddress(); masm.emitLoadAcquire(scratch32, noticeSafepointsIntAddr); masm.emitCompare(Kind.Int, scratch32, Constant.forInt(0), "eq", false, false); masm.cbr(afterSafepointLabel); - AllocatableValue actionAndReasonReg = HSAIL.actionAndReasonReg.asValue(Kind.Int); - AllocatableValue codeBufferOffsetReg = HSAIL.codeBufferOffsetReg.asValue(Kind.Int); + AllocatableValue actionAndReasonReg = HSAIL.actionAndReasonReg.asValue(LIRKind.value(Kind.Int)); + AllocatableValue codeBufferOffsetReg = HSAIL.codeBufferOffsetReg.asValue(LIRKind.value(Kind.Int)); masm.emitMov(Kind.Int, actionAndReasonReg, actionAndReason); masm.emitMov(Kind.Int, codeBufferOffsetReg, Constant.forInt(codeBufferPos)); masm.emitJumpToLabelName(masm.getDeoptLabelName());
--- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/replacements/HSAILDirectLoadAcquireNode.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/replacements/HSAILDirectLoadAcquireNode.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,8 @@ @Override public void generate(NodeLIRBuilderTool gen) { HSAILHotSpotLIRGenerator hsailgen = (HSAILHotSpotLIRGenerator) (gen.getLIRGeneratorTool()); - Value result = hsailgen.emitLoadAcquire(getKind(), gen.operand(getAddress()), null); + LIRKind kind = hsailgen.getLIRKind(stamp()); + Value result = hsailgen.emitLoadAcquire(kind, gen.operand(getAddress()), null); gen.setResult(this, result); }
--- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/replacements/HSAILDirectStoreReleaseNode.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/replacements/HSAILDirectStoreReleaseNode.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,8 @@ public void generate(NodeLIRBuilderTool gen) { HSAILHotSpotLIRGenerator hsailgen = (HSAILHotSpotLIRGenerator) (gen.getLIRGeneratorTool()); Value v = gen.operand(getValue()); - hsailgen.emitStoreRelease(getKind(), gen.operand(getAddress()), v, null); + LIRKind kind = hsailgen.getLIRKind(getValue().stamp()); + hsailgen.emitStoreRelease(kind, gen.operand(getAddress()), v, null); } @NodeIntrinsic
--- a/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotBackendFactory.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotBackendFactory.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -93,7 +93,7 @@ final int stackFrameAlignment = 1; final int implicitNullCheckLimit = 0; final boolean inlineObjects = true; - return new HotSpotTargetDescription(createArchitecture(), true, stackFrameAlignment, implicitNullCheckLimit, inlineObjects, Kind.Int); + return new HotSpotTargetDescription(createArchitecture(), true, stackFrameAlignment, implicitNullCheckLimit, inlineObjects); } public String getArchitecture() {
--- a/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotRegisterConfig.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotRegisterConfig.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -110,7 +110,7 @@ if (returnKind == Kind.Void) { returnLocation = Value.ILLEGAL; } else { - returnLocation = new Variable(returnKind, currentGeneral++); + returnLocation = new Variable(target.getLIRKind(returnKind), currentGeneral++); } AllocatableValue[] locations = new AllocatableValue[parameterTypes.length]; @@ -129,7 +129,7 @@ case Double: case Object: if (!stackOnly) { - locations[i] = new Variable(kind, currentGeneral++); + locations[i] = new Variable(target.getLIRKind(kind), currentGeneral++); } break; default: @@ -137,7 +137,7 @@ } if (locations[i] == null) { - locations[i] = StackSlot.get(kind.getStackKind(), currentStackOffset, !type.out); + locations[i] = StackSlot.get(target.getLIRKind(kind.getStackKind()), currentStackOffset, !type.out); currentStackOffset += Math.max(target.getSizeInBytes(kind), target.wordSize); } }
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackendFactory.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackendFactory.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ final int stackFrameAlignment = 16; final int implicitNullCheckLimit = 4096; final boolean inlineObjects = true; - return new HotSpotTargetDescription(createArchitecture(), true, stackFrameAlignment, implicitNullCheckLimit, inlineObjects, Kind.Int); + return new HotSpotTargetDescription(createArchitecture(), true, stackFrameAlignment, implicitNullCheckLimit, inlineObjects); } public HotSpotBackend createBackend(HotSpotGraalRuntime runtime, HotSpotBackend host) {
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotForeignCallsProvider.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotForeignCallsProvider.java Fri Jun 13 11:47:44 2014 +0200 @@ -52,10 +52,10 @@ // The calling convention for the exception handler stub is (only?) defined in // TemplateInterpreterGenerator::generate_throw_exception() // in templateInterpreter_sparc.cpp around line 1925 - RegisterValue outgoingException = o0.asValue(Kind.Object); - RegisterValue outgoingExceptionPc = o1.asValue(word); - RegisterValue incomingException = i0.asValue(Kind.Object); - RegisterValue incomingExceptionPc = i1.asValue(word); + RegisterValue outgoingException = o0.asValue(target.getLIRKind(Kind.Object)); + RegisterValue outgoingExceptionPc = o1.asValue(target.getLIRKind(word)); + RegisterValue incomingException = i0.asValue(target.getLIRKind(Kind.Object)); + RegisterValue incomingExceptionPc = i1.asValue(LIRKind.value(word)); CallingConvention outgoingExceptionCc = new CallingConvention(0, ILLEGAL, outgoingException, outgoingExceptionPc); CallingConvention incomingExceptionCc = new CallingConvention(0, ILLEGAL, incomingException, incomingExceptionPc); register(new HotSpotForeignCallLinkage(EXCEPTION_HANDLER, 0L, PRESERVES_REGISTERS, LEAF_NOFP, outgoingExceptionCc, incomingExceptionCc, NOT_REEXECUTABLE, ANY_LOCATION));
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java Fri Jun 13 11:47:44 2014 +0200 @@ -120,7 +120,7 @@ public void emitReturn(Value input) { AllocatableValue operand = Value.ILLEGAL; if (input != null) { - operand = resultOperandFor(input.getKind()); + operand = resultOperandFor(input.getLIRKind()); emitMove(operand, input); } append(new SPARCHotSpotReturnOp(operand, getStub() != null)); @@ -148,9 +148,9 @@ } private void moveValueToThread(Value v, int offset) { - Kind wordKind = getProviders().getCodeCache().getTarget().wordKind; + LIRKind wordKind = LIRKind.value(getProviders().getCodeCache().getTarget().wordKind); RegisterValue thread = getProviders().getRegisters().getThreadRegister().asValue(wordKind); - SPARCAddressValue pendingDeoptAddress = new SPARCAddressValue(v.getKind(), thread, offset); + SPARCAddressValue pendingDeoptAddress = new SPARCAddressValue(wordKind, thread, offset); append(new StoreOp(v.getKind(), pendingDeoptAddress, emitMove(v), null)); } @@ -167,25 +167,25 @@ } @Override - public Variable emitLoad(PlatformKind kind, Value address, LIRFrameState state) { + public Variable emitLoad(LIRKind kind, Value address, LIRFrameState state) { SPARCAddressValue loadAddress = asAddressValue(address); Variable result = newVariable(kind); - append(new LoadOp((Kind) kind, result, loadAddress, state)); + append(new LoadOp((Kind) kind.getPlatformKind(), result, loadAddress, state)); return result; } @Override - public void emitStore(PlatformKind kind, Value address, Value inputVal, LIRFrameState state) { + public void emitStore(LIRKind kind, Value address, Value inputVal, LIRFrameState state) { SPARCAddressValue storeAddress = asAddressValue(address); if (isConstant(inputVal)) { Constant c = asConstant(inputVal); if (canStoreConstant(c)) { - append(new StoreConstantOp((Kind) kind, storeAddress, c, state)); + append(new StoreConstantOp((Kind) kind.getPlatformKind(), storeAddress, c, state)); return; } } Variable input = load(inputVal); - append(new StoreOp((Kind) kind, storeAddress, input, state)); + append(new StoreOp((Kind) kind.getPlatformKind(), storeAddress, input, state)); } public Value emitCompareAndSwap(Value address, Value expectedValue, Value newValue, Value trueValue, Value falseValue) { @@ -243,7 +243,7 @@ for (int i = 0; i < savedRegisters.length; i++) { PlatformKind kind = target().arch.getLargestStorableKind(savedRegisters[i].getRegisterCategory()); assert kind != Kind.Illegal; - StackSlot spillSlot = getResult().getFrameMap().allocateSpillSlot(kind); + StackSlot spillSlot = getResult().getFrameMap().allocateSpillSlot(LIRKind.value(kind)); savedRegisterLocations[i] = spillSlot; } return emitSaveRegisters(savedRegisters, savedRegisterLocations, false); @@ -261,7 +261,7 @@ Register thread = getProviders().getRegisters().getThreadRegister(); Variable framePcVariable = load(framePc); Variable senderSpVariable = load(senderSp); - Variable scratchVariable = newVariable(getHostWordKind()); + Variable scratchVariable = newVariable(LIRKind.value(getHostWordKind())); append(new SPARCHotSpotEnterUnpackFramesStackFrameOp(thread, config.threadLastJavaSpOffset(), config.threadLastJavaPcOffset(), framePcVariable, senderSpVariable, scratchVariable)); } @@ -284,7 +284,7 @@ Register threadRegister = getProviders().getRegisters().getThreadRegister(); Register stackPointerRegister = getProviders().getRegisters().getStackPointerRegister(); append(new SPARCHotSpotCRuntimeCallPrologueOp(config.threadLastJavaSpOffset(), threadRegister, stackPointerRegister)); - Variable result = super.emitForeignCall(linkage, null, threadRegister.asValue(Kind.Long), trapRequest); + Variable result = super.emitForeignCall(linkage, null, threadRegister.asValue(LIRKind.value(Kind.Long)), trapRequest); append(new SPARCHotSpotCRuntimeCallEpilogueOp(config.threadLastJavaSpOffset(), config.threadLastJavaPcOffset(), config.threadJavaFrameAnchorFlagsOffset(), threadRegister)); return result;
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotNodeLIRBuilder.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotNodeLIRBuilder.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -52,7 +52,7 @@ @Override protected DebugInfoBuilder createDebugInfoBuilder(StructuredGraph graph, NodeMap<Value> nodeOperands) { - HotSpotLockStack lockStack = new HotSpotLockStack(gen.getResult().getFrameMap(), Kind.Long); + HotSpotLockStack lockStack = new HotSpotLockStack(gen.getResult().getFrameMap(), LIRKind.value(Kind.Long)); return new HotSpotDebugInfoBuilder(nodeOperands, lockStack); } @@ -68,17 +68,17 @@ @Override public void visitDirectCompareAndSwap(DirectCompareAndSwapNode x) { - Kind kind = x.newValue().getKind(); - assert kind == x.expectedValue().getKind(); - Variable address = gen.load(operand(x.object())); Value offset = operand(x.offset()); Variable cmpValue = (Variable) gen.loadNonConst(operand(x.expectedValue())); Variable newValue = gen.load(operand(x.newValue())); + LIRKind kind = cmpValue.getLIRKind(); + assert kind.equals(newValue.getLIRKind()); + if (ValueUtil.isConstant(offset)) { assert !gen.getCodeCache().needsDataPatch(asConstant(offset)); - Variable longAddress = gen.newVariable(Kind.Long); + Variable longAddress = gen.newVariable(LIRKind.value(Kind.Long)); gen.emitMove(longAddress, address); address = getGen().emitAdd(longAddress, asConstant(offset)); } else { @@ -88,10 +88,7 @@ } append(new CompareAndSwapOp(address, cmpValue, newValue)); - - Variable result = gen.newVariable(x.getKind()); - gen.emitMove(result, newValue); - setResult(x, result); + setResult(x, gen.emitMove(newValue)); } @Override
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotRegisterConfig.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotRegisterConfig.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -198,14 +198,14 @@ case Object: if (!stackOnly && currentGeneral < generalParameterRegisters.length) { Register register = generalParameterRegisters[currentGeneral++]; - locations[i] = register.asValue(kind); + locations[i] = register.asValue(target.getLIRKind(kind)); } break; case Float: case Double: if (!stackOnly && currentFloating < fpuParameterRegisters.length) { Register register = fpuParameterRegisters[currentFloating++]; - locations[i] = register.asValue(kind); + locations[i] = register.asValue(target.getLIRKind(kind)); } break; default: @@ -213,13 +213,13 @@ } if (locations[i] == null) { - locations[i] = StackSlot.get(kind.getStackKind(), currentStackOffset, !type.out); + locations[i] = StackSlot.get(target.getLIRKind(kind.getStackKind()), currentStackOffset, !type.out); currentStackOffset += Math.max(target.getSizeInBytes(kind), target.wordSize); } } Kind returnKind = returnType == null ? Kind.Void : returnType.getKind(); - AllocatableValue returnLocation = returnKind == Kind.Void ? Value.ILLEGAL : getReturnRegister(returnKind, type).asValue(returnKind.getStackKind()); + AllocatableValue returnLocation = returnKind == Kind.Void ? Value.ILLEGAL : getReturnRegister(returnKind, type).asValue(target.getLIRKind(returnKind.getStackKind())); return new CallingConvention(currentStackOffset, returnLocation, locations); }
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotSafepointOp.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotSafepointOp.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -52,7 +52,7 @@ public SPARCHotSpotSafepointOp(LIRFrameState state, HotSpotVMConfig config, LIRGeneratorTool tool) { this.state = state; this.config = config; - temp = tool.newVariable(tool.target().wordKind); + temp = tool.newVariable(LIRKind.value(tool.target().wordKind)); } @Override
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotLockStack.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotLockStack.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,9 +36,9 @@ private StackSlot[] locks; private final FrameMap frameMap; - private final Kind slotKind; + private final LIRKind slotKind; - public HotSpotLockStack(FrameMap frameMap, Kind slotKind) { + public HotSpotLockStack(FrameMap frameMap, LIRKind slotKind) { this.frameMap = frameMap; this.slotKind = slotKind; }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotReferenceMap.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotReferenceMap.java Fri Jun 13 11:47:44 2014 +0200 @@ -28,7 +28,7 @@ import com.oracle.graal.api.code.CodeUtil.RefMapFormatter; import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; -import com.oracle.graal.hotspot.nodes.type.*; +import com.oracle.graal.compiler.common.*; public class HotSpotReferenceMap implements ReferenceMap, Serializable { @@ -56,40 +56,90 @@ */ private final BitSet frameRefMap; - private final int frameSlotSize; + private final TargetDescription target; - public HotSpotReferenceMap(int registerCount, int frameSlotCount, int frameSlotSize) { + public HotSpotReferenceMap(int registerCount, int frameSlotCount, TargetDescription target) { if (registerCount > 0) { this.registerRefMap = new BitSet(registerCount * 3); } else { this.registerRefMap = null; } this.frameRefMap = new BitSet(frameSlotCount * 3); - this.frameSlotSize = frameSlotSize; + this.target = target; + } + + private static void setOop(BitSet map, int startIdx, LIRKind kind) { + int length = kind.getPlatformKind().getVectorLength(); + map.clear(3 * startIdx, 3 * (startIdx + length) - 1); + for (int i = 0, idx = 3 * startIdx; i < length; i++, idx += 3) { + if (kind.isReference(i)) { + map.set(idx); + } + } } - public void setRegister(int idx, PlatformKind kind) { - if (kind == Kind.Object) { - registerRefMap.set(3 * idx); - } else if (kind == NarrowOopStamp.NarrowOop) { - registerRefMap.set(3 * idx); - registerRefMap.set(3 * idx + 1); + private static void setNarrowOop(BitSet map, int idx, LIRKind kind) { + int length = kind.getPlatformKind().getVectorLength(); + int nextIdx = idx + (length + 1) / 2; + map.clear(3 * idx, 3 * nextIdx - 1); + for (int i = 0, regIdx = 3 * idx; i < length; i += 2, regIdx += 3) { + if (kind.isReference(i)) { + map.set(regIdx); + map.set(regIdx + 1); + } + if ((i + 1) < length && kind.isReference(i + 1)) { + map.set(regIdx); + map.set(regIdx + 2); + } } } - public void setStackSlot(int offset, PlatformKind kind) { - int idx = offset / frameSlotSize; - if (kind == Kind.Object) { - assert offset % frameSlotSize == 0; - frameRefMap.set(3 * idx); - } else if (kind == NarrowOopStamp.NarrowOop) { - frameRefMap.set(3 * idx); - if (offset % frameSlotSize == 0) { - frameRefMap.set(3 * idx + 1); + public void setRegister(int idx, LIRKind kind) { + if (kind.isDerivedReference()) { + throw GraalInternalError.shouldNotReachHere("derived reference cannot be inserted in ReferenceMap"); + } + + PlatformKind platformKind = kind.getPlatformKind(); + int bytesPerElement = target.getSizeInBytes(platformKind) / platformKind.getVectorLength(); + + if (bytesPerElement == target.wordSize) { + setOop(registerRefMap, idx, kind); + } else if (bytesPerElement == target.wordSize / 2) { + setNarrowOop(registerRefMap, idx, kind); + } else { + assert kind.isValue() : "unsupported reference kind " + kind; + } + } + + public void setStackSlot(int offset, LIRKind kind) { + if (kind.isDerivedReference()) { + throw GraalInternalError.shouldNotReachHere("derived reference cannot be inserted in ReferenceMap"); + } + + PlatformKind platformKind = kind.getPlatformKind(); + int bytesPerElement = target.getSizeInBytes(platformKind) / platformKind.getVectorLength(); + assert offset % bytesPerElement == 0 : "unaligned value in ReferenceMap"; + + if (bytesPerElement == target.wordSize) { + setOop(frameRefMap, offset / target.wordSize, kind); + } else if (bytesPerElement == target.wordSize / 2) { + if (platformKind.getVectorLength() > 1) { + setNarrowOop(frameRefMap, offset / target.wordSize, kind); } else { - assert offset % frameSlotSize == frameSlotSize / 2; - frameRefMap.set(3 * idx + 2); + // in this case, offset / target.wordSize may not divide evenly + // so setNarrowOop won't work correctly + int idx = offset / target.wordSize; + if (kind.isReference(0)) { + frameRefMap.set(3 * idx); + if (offset % target.wordSize == 0) { + frameRefMap.set(3 * idx + 1); + } else { + frameRefMap.set(3 * idx + 2); + } + } } + } else { + assert kind.isValue() : "unknown reference kind " + kind; } }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotTargetDescription.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotTargetDescription.java Fri Jun 13 11:47:44 2014 +0200 @@ -23,29 +23,15 @@ package com.oracle.graal.hotspot; import com.oracle.graal.api.code.*; -import com.oracle.graal.api.meta.*; -import com.oracle.graal.hotspot.nodes.type.*; public class HotSpotTargetDescription extends TargetDescription { - private final PlatformKind rawNarrowOopKind; - - public HotSpotTargetDescription(Architecture arch, boolean isMP, int stackAlignment, int implicitNullCheckLimit, boolean inlineObjects, PlatformKind rawNarrowOopKind) { + public HotSpotTargetDescription(Architecture arch, boolean isMP, int stackAlignment, int implicitNullCheckLimit, boolean inlineObjects) { super(arch, isMP, stackAlignment, implicitNullCheckLimit, inlineObjects); - this.rawNarrowOopKind = rawNarrowOopKind; - } - - @Override - public int getSizeInBytes(PlatformKind kind) { - if (kind == NarrowOopStamp.NarrowOop) { - return super.getSizeInBytes(rawNarrowOopKind); - } else { - return super.getSizeInBytes(kind); - } } @Override public ReferenceMap createReferenceMap(boolean hasRegisters, int stackSlotCount) { - return new HotSpotReferenceMap(hasRegisters ? arch.getRegisterReferenceMapBitCount() : 0, stackSlotCount, wordSize); + return new HotSpotReferenceMap(hasRegisters ? arch.getRegisterReferenceMapBitCount() : 0, stackSlotCount, this); } }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotCompressedNullConstant.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotCompressedNullConstant.java Fri Jun 13 11:47:44 2014 +0200 @@ -23,7 +23,6 @@ package com.oracle.graal.hotspot.meta; import com.oracle.graal.api.meta.*; -import com.oracle.graal.hotspot.nodes.type.*; /** * The compressed representation of the {@link Constant#NULL_OBJECT null constant}. @@ -35,7 +34,7 @@ public static final Constant COMPRESSED_NULL = new HotSpotCompressedNullConstant(); private HotSpotCompressedNullConstant() { - super(NarrowOopStamp.NarrowOop); + super(LIRKind.reference(Kind.Int)); } @Override
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMonitorValue.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMonitorValue.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ private final boolean eliminated; public HotSpotMonitorValue(Value owner, StackSlot slot, boolean eliminated) { - super(Kind.Illegal); + super(LIRKind.Illegal); this.owner = owner; this.slot = slot; this.eliminated = eliminated;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotObjectConstant.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotObjectConstant.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,6 @@ package com.oracle.graal.hotspot.meta; import com.oracle.graal.api.meta.*; -import com.oracle.graal.hotspot.nodes.type.*; /** * Represents a constant non-{@code null} object reference, within the compiler and across the @@ -79,7 +78,7 @@ private final boolean compressed; private HotSpotObjectConstant(Object object, boolean compressed) { - super(compressed ? NarrowOopStamp.NarrowOop : Kind.Object); + super(LIRKind.reference(compressed ? Kind.Int : Kind.Object)); this.object = object; this.compressed = compressed; assert object != null;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CStringNode.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CStringNode.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,7 +44,7 @@ } public static AllocatableValue emitCString(NodeLIRBuilderTool gen, String value) { - AllocatableValue dst = gen.getLIRGeneratorTool().newVariable(gen.getLIRGeneratorTool().target().wordKind); + AllocatableValue dst = gen.getLIRGeneratorTool().newVariable(LIRKind.value(gen.getLIRGeneratorTool().target().wordKind)); gen.getLIRGeneratorTool().emitData(dst, toCString(value)); return dst; }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CurrentJavaThreadNode.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CurrentJavaThreadNode.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,14 +38,17 @@ */ public final class CurrentJavaThreadNode extends FloatingNode implements LIRLowerable { + private LIRKind wordKind; + private CurrentJavaThreadNode(Kind kind) { super(StampFactory.forKind(kind)); + this.wordKind = LIRKind.value(kind); } @Override public void generate(NodeLIRBuilderTool gen) { Register rawThread = ((HotSpotLIRGenerator) gen.getLIRGeneratorTool()).getProviders().getRegisters().getThreadRegister(); - gen.setResult(this, rawThread.asValue(this.getKind())); + gen.setResult(this, rawThread.asValue(wordKind)); } private static int eetopOffset() {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/GetObjectAddressNode.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/GetObjectAddressNode.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,7 +46,7 @@ @Override public void generate(NodeLIRBuilderTool gen) { - AllocatableValue obj = gen.getLIRGeneratorTool().newVariable(gen.getLIRGeneratorTool().target().wordKind); + AllocatableValue obj = gen.getLIRGeneratorTool().newVariable(LIRKind.derivedReference(gen.getLIRGeneratorTool().target().wordKind)); gen.getLIRGeneratorTool().emitMove(obj, gen.operand(object)); gen.setResult(this, obj); }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/TailcallNode.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/TailcallNode.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -71,7 +71,7 @@ } Value[] args = gen.visitInvokeArguments(cc, parameters); Value address = lirGen.emitAddress(gen.operand(target), config.nmethodEntryOffset, Value.ILLEGAL, 0); - Value entry = lirGen.emitLoad(Kind.Long, address, null); + Value entry = lirGen.emitLoad(LIRKind.value(Kind.Long), address, null); HotSpotLIRGenerator hsgen = (HotSpotLIRGenerator) gen; hsgen.emitTailcall(args, entry); }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/type/NarrowOopStamp.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/type/NarrowOopStamp.java Fri Jun 13 11:47:44 2014 +0200 @@ -71,8 +71,8 @@ } @Override - public PlatformKind getPlatformKind(PlatformKindTool tool) { - return NarrowOop; + public LIRKind getLIRKind(LIRKindTool tool) { + return LIRKind.reference(Kind.Int); } @Override
--- a/graal/com.oracle.graal.hsail/src/com/oracle/graal/hsail/HSAIL.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.hsail/src/com/oracle/graal/hsail/HSAIL.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64AddressValue.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64AddressValue.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,11 +41,11 @@ protected final Scale scale; protected final int displacement; - public AMD64AddressValue(PlatformKind kind, AllocatableValue base, int displacement) { + public AMD64AddressValue(LIRKind kind, AllocatableValue base, int displacement) { this(kind, base, Value.ILLEGAL, Scale.Times1, displacement); } - public AMD64AddressValue(PlatformKind kind, AllocatableValue base, AllocatableValue index, Scale scale, int displacement) { + public AMD64AddressValue(LIRKind kind, AllocatableValue base, AllocatableValue index, Scale scale, int displacement) { super(kind); this.base = base; this.index = index; @@ -93,13 +93,13 @@ public boolean equals(Object obj) { if (obj instanceof AMD64AddressValue) { AMD64AddressValue addr = (AMD64AddressValue) obj; - return getPlatformKind() == addr.getPlatformKind() && displacement == addr.displacement && base.equals(addr.base) && scale == addr.scale && index.equals(addr.index); + return getLIRKind().equals(addr.getLIRKind()) && displacement == addr.displacement && base.equals(addr.base) && scale == addr.scale && index.equals(addr.index); } return false; } @Override public int hashCode() { - return base.hashCode() ^ index.hashCode() ^ (displacement << 4) ^ (scale.value << 8) ^ getPlatformKind().hashCode(); + return base.hashCode() ^ index.hashCode() ^ (displacement << 4) ^ (scale.value << 8) ^ getLIRKind().hashCode(); } }
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Arithmetic.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Arithmetic.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -351,7 +351,7 @@ @Use({REG, STACK}) public AllocatableValue y; public MulHighOp(AMD64Arithmetic opcode, AllocatableValue y) { - PlatformKind kind = y.getPlatformKind(); + LIRKind kind = y.getLIRKind(); this.opcode = opcode; this.x = AMD64.rax.asValue(kind); @@ -411,8 +411,8 @@ public DivRemOp(AMD64Arithmetic opcode, AllocatableValue x, AllocatableValue y, LIRFrameState state) { this.opcode = opcode; - this.divResult = AMD64.rax.asValue(x.getPlatformKind()); - this.remResult = AMD64.rdx.asValue(x.getPlatformKind()); + this.divResult = AMD64.rax.asValue(x.getLIRKind()); + this.remResult = AMD64.rdx.asValue(x.getLIRKind()); this.x = x; this.y = y; this.state = state; @@ -446,7 +446,7 @@ public FPDivRemOp(AMD64Arithmetic opcode, AllocatableValue result, AllocatableValue x, AllocatableValue y) { this.opcode = opcode; this.result = result; - this.raxTemp = AMD64.rax.asValue(Kind.Int); + this.raxTemp = AMD64.rax.asValue(LIRKind.value(Kind.Int)); this.x = x; this.y = y; }
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64ArrayEqualsOp.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64ArrayEqualsOp.java Fri Jun 13 11:47:44 2014 +0200 @@ -75,15 +75,15 @@ this.lengthValue = length; // Allocate some temporaries. - this.temp1 = tool.newVariable(tool.target().wordKind); - this.temp2 = tool.newVariable(tool.target().wordKind); - this.temp3 = tool.newVariable(tool.target().wordKind); - this.temp4 = tool.newVariable(tool.target().wordKind); + this.temp1 = tool.newVariable(LIRKind.derivedReference(tool.target().wordKind)); + this.temp2 = tool.newVariable(LIRKind.derivedReference(tool.target().wordKind)); + this.temp3 = tool.newVariable(LIRKind.value(tool.target().wordKind)); + this.temp4 = tool.newVariable(LIRKind.value(tool.target().wordKind)); // We only need the vector temporaries if we generate SSE code. if (supportsSSE41(tool.target())) { - this.vectorTemp1 = tool.newVariable(Kind.Double); - this.vectorTemp2 = tool.newVariable(Kind.Double); + this.vectorTemp1 = tool.newVariable(LIRKind.value(Kind.Double)); + this.vectorTemp2 = tool.newVariable(LIRKind.value(Kind.Double)); } else { this.vectorTemp1 = Value.ILLEGAL; this.vectorTemp2 = Value.ILLEGAL;
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Call.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Call.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -141,7 +141,7 @@ * The register allocator does not support virtual registers that are used at the call * site, so use a fixed register. */ - callTemp = AMD64.rax.asValue(Kind.Long); + callTemp = AMD64.rax.asValue(LIRKind.value(Kind.Long)); assert ValueUtil.differentRegisters(parameters, callTemp); }
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64ControlFlow.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64ControlFlow.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -157,9 +157,8 @@ break; case Object: assert condition == Condition.EQ || condition == Condition.NE; - Register temp = asObjectReg(scratch); - AMD64Move.move(crb, masm, temp.asValue(Kind.Object), keyConstants[index]); - masm.cmpptr(keyRegister, temp); + AMD64Move.move(crb, masm, scratch, keyConstants[index]); + masm.cmpptr(keyRegister, asObjectReg(scratch)); break; default: throw new GraalInternalError("switch only supported for int, long and object");
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64FrameMap.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64FrameMap.java Fri Jun 13 11:47:44 2014 +0200 @@ -98,7 +98,7 @@ } @Override - protected StackSlot allocateNewSpillSlot(PlatformKind kind, int additionalOffset) { + protected StackSlot allocateNewSpillSlot(LIRKind kind, int additionalOffset) { return StackSlot.get(kind, -spillSize + additionalOffset, true); } }
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64RestoreRegistersOp.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64RestoreRegistersOp.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -55,7 +55,7 @@ } protected void restoreRegister(CompilationResultBuilder crb, AMD64MacroAssembler masm, Register register, StackSlot input) { - RegisterValue result = register.asValue(input.getKind()); + RegisterValue result = register.asValue(input.getLIRKind()); AMD64Move.move(crb, masm, result, input); }
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64SaveRegistersOp.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64SaveRegistersOp.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -54,7 +54,7 @@ protected final boolean supportsRemove; /** - * + * * @param savedRegisters the registers saved by this operation which may be subject to * {@linkplain #remove(Set) pruning} * @param slots the slots to which the registers are saved @@ -67,7 +67,7 @@ } protected void saveRegister(CompilationResultBuilder crb, AMD64MacroAssembler masm, StackSlot result, Register register) { - RegisterValue input = register.asValue(result.getKind()); + RegisterValue input = register.asValue(result.getLIRKind()); AMD64Move.move(crb, masm, result, input); }
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64ZapRegistersOp.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64ZapRegistersOp.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -59,7 +59,7 @@ public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { for (int i = 0; i < zappedRegisters.length; i++) { if (zappedRegisters[i] != null) { - RegisterValue registerValue = zappedRegisters[i].asValue(zapValues[i].getPlatformKind()); + RegisterValue registerValue = zappedRegisters[i].asValue(zapValues[i].getLIRKind()); AMD64Move.move(crb, masm, registerValue, zapValues[i]); } }
--- a/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILAddressValue.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILAddressValue.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,23 +42,23 @@ /** * Creates an {@link HSAILAddressValue} with given base register and no displacement. - * + * * @param kind the kind of the value being addressed * @param base the base register */ - public HSAILAddressValue(Kind kind, AllocatableValue base) { + public HSAILAddressValue(LIRKind kind, AllocatableValue base) { this(kind, base, 0); } /** * Creates an {@link HSAILAddressValue} with given base register and a displacement. This is the * most general constructor. - * + * * @param kind the kind of the value being addressed * @param base the base register * @param displacement the displacement */ - public HSAILAddressValue(Kind kind, AllocatableValue base, long displacement) { + public HSAILAddressValue(LIRKind kind, AllocatableValue base, long displacement) { super(kind); this.base = base; this.displacement = displacement; @@ -92,7 +92,7 @@ public boolean equals(Object obj) { if (obj instanceof HSAILAddressValue) { HSAILAddressValue addr = (HSAILAddressValue) obj; - return getKind() == addr.getKind() && displacement == addr.displacement && base.equals(addr.base); + return getLIRKind().equals(addr.getLIRKind()) && displacement == addr.displacement && base.equals(addr.base); } return false; }
--- a/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILControlFlow.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILControlFlow.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -177,8 +177,8 @@ masm.emitComment("/* HSAIL Deoptimization pos=" + codeBufferPos + ", bci=" + frameState.debugInfo().getBytecodePosition().getBCI() + ", frameState=" + frameState + " */"); - AllocatableValue actionAndReasonReg = HSAIL.actionAndReasonReg.asValue(Kind.Int); - AllocatableValue codeBufferOffsetReg = HSAIL.codeBufferOffsetReg.asValue(Kind.Int); + AllocatableValue actionAndReasonReg = HSAIL.actionAndReasonReg.asValue(LIRKind.value(Kind.Int)); + AllocatableValue codeBufferOffsetReg = HSAIL.codeBufferOffsetReg.asValue(LIRKind.value(Kind.Int)); masm.emitMov(Kind.Int, actionAndReasonReg, actionAndReason); masm.emitMov(Kind.Int, codeBufferOffsetReg, Constant.forInt(codeBufferPos)); masm.emitJumpToLabelName(masm.getDeoptLabelName());
--- a/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILFrameMap.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILFrameMap.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,9 +28,9 @@ /** * HSAIL specific frame map. - * + * * This is the format of a HSAIL stack frame: - * + * * <pre> * TODO stack frame layout * </pre> @@ -66,7 +66,7 @@ } @Override - protected StackSlot allocateNewSpillSlot(PlatformKind kind, int additionalOffset) { + protected StackSlot allocateNewSpillSlot(LIRKind kind, int additionalOffset) { return StackSlot.get(kind, -spillSize + additionalOffset, true); } }
--- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXAddressValue.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXAddressValue.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,23 +43,23 @@ /** * Creates an {@link PTXAddressValue} with given base register and no displacement. - * + * * @param kind the kind of the value being addressed * @param base the base register */ - public PTXAddressValue(PlatformKind kind, AllocatableValue base) { + public PTXAddressValue(LIRKind kind, AllocatableValue base) { this(kind, base, 0); } /** * Creates an {@link PTXAddressValue} with given base register and a displacement. This is the * most general constructor. - * + * * @param kind the kind of the value being addressed * @param base the base register * @param displacement the displacement */ - public PTXAddressValue(PlatformKind kind, AllocatableValue base, long displacement) { + public PTXAddressValue(LIRKind kind, AllocatableValue base, long displacement) { super(kind); this.base = base; this.displacement = displacement; @@ -94,13 +94,13 @@ public boolean equals(Object obj) { if (obj instanceof PTXAddressValue) { PTXAddressValue addr = (PTXAddressValue) obj; - return getPlatformKind() == addr.getPlatformKind() && displacement == addr.displacement && base.equals(addr.base); + return getLIRKind().equals(addr.getLIRKind()) && displacement == addr.displacement && base.equals(addr.base); } return false; } @Override public int hashCode() { - return base.hashCode() ^ ((int) displacement << 4) ^ getPlatformKind().hashCode(); + return base.hashCode() ^ ((int) displacement << 4) ^ getLIRKind().hashCode(); } }
--- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXFrameMap.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXFrameMap.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,9 +28,9 @@ /** * PTX specific frame map. - * + * * This is the format of a PTX stack frame: - * + * * <pre> * TODO stack frame layout * </pre> @@ -66,7 +66,7 @@ } @Override - protected StackSlot allocateNewSpillSlot(PlatformKind kind, int additionalOffset) { + protected StackSlot allocateNewSpillSlot(LIRKind kind, int additionalOffset) { return StackSlot.get(kind, -spillSize + additionalOffset, true); } }
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCAddressValue.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCAddressValue.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,11 +39,11 @@ @Component({REG, OperandFlag.ILLEGAL}) protected AllocatableValue index; protected final int displacement; - public SPARCAddressValue(PlatformKind kind, AllocatableValue base, int displacement) { + public SPARCAddressValue(LIRKind kind, AllocatableValue base, int displacement) { this(kind, base, Value.ILLEGAL, displacement); } - public SPARCAddressValue(PlatformKind kind, AllocatableValue base, AllocatableValue index, int displacement) { + public SPARCAddressValue(LIRKind kind, AllocatableValue base, AllocatableValue index, int displacement) { super(kind); assert isIllegal(index) || displacement == 0; this.base = base; @@ -94,13 +94,13 @@ public boolean equals(Object obj) { if (obj instanceof SPARCAddressValue) { SPARCAddressValue addr = (SPARCAddressValue) obj; - return getPlatformKind() == addr.getPlatformKind() && displacement == addr.displacement && base.equals(addr.base) && index.equals(addr.index); + return getLIRKind().equals(addr.getLIRKind()) && displacement == addr.displacement && base.equals(addr.base) && index.equals(addr.index); } return false; } @Override public int hashCode() { - return base.hashCode() ^ index.hashCode() ^ (displacement << 4) ^ getPlatformKind().hashCode(); + return base.hashCode() ^ index.hashCode() ^ (displacement << 4) ^ getLIRKind().hashCode(); } }
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCArithmetic.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCArithmetic.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -271,8 +271,8 @@ this.result = result; this.x = x; this.y = y; - this.scratch1 = gen.newVariable(x.getKind()); - this.scratch2 = gen.newVariable(x.getKind()); + this.scratch1 = gen.newVariable(x.getLIRKind()); + this.scratch2 = gen.newVariable(x.getLIRKind()); this.state = state; }
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCBitManipulationOp.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCBitManipulationOp.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -62,7 +62,7 @@ this.result = result; this.input = input; if (opcode == IntrinsicOpcode.IBSR || opcode == IntrinsicOpcode.LBSR) { - scratch = gen.newVariable(input.getKind()); + scratch = gen.newVariable(input.getLIRKind()); } }
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCControlFlow.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCControlFlow.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -190,16 +190,14 @@ emitCompare(masm, target, condition, CC.Icc); break; case Long: { - Register temp = asLongReg(scratch); - SPARCMove.move(crb, masm, temp.asValue(Kind.Long), keyConstants[index]); - new Cmp(keyRegister, temp).emit(masm); + SPARCMove.move(crb, masm, scratch, keyConstants[index]); + new Cmp(keyRegister, asLongReg(scratch)).emit(masm); emitCompare(masm, target, condition, CC.Xcc); break; } case Object: { - Register temp = asObjectReg(scratch); - SPARCMove.move(crb, masm, temp.asValue(Kind.Object), keyConstants[index]); - new Cmp(keyRegister, temp).emit(masm); + SPARCMove.move(crb, masm, scratch, keyConstants[index]); + new Cmp(keyRegister, asObjectReg(scratch)).emit(masm); emitCompare(masm, target, condition, CC.Ptrcc); break; }
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCFrameMap.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCFrameMap.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,7 @@ * * <pre> * Base Contents - * + * * : : ----- * caller | incoming overflow argument n | ^ * frame : ... : | positive @@ -98,7 +98,7 @@ } @Override - protected StackSlot allocateNewSpillSlot(PlatformKind kind, int additionalOffset) { + protected StackSlot allocateNewSpillSlot(LIRKind kind, int additionalOffset) { return StackSlot.get(kind, -spillSize + additionalOffset, true); } }
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCSaveRegistersOp.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCSaveRegistersOp.java Fri Jun 13 11:47:44 2014 +0200 @@ -67,7 +67,7 @@ } private static void saveRegister(CompilationResultBuilder crb, SPARCMacroAssembler masm, StackSlot result, Register register) { - RegisterValue input = register.asValue(result.getKind()); + RegisterValue input = register.asValue(result.getLIRKind()); SPARCMove.move(crb, masm, result, input); }
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/CompositeValue.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/CompositeValue.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -48,7 +48,7 @@ private static final DebugMetric COMPOSITE_VALUE_COUNT = Debug.metric("CompositeValues"); - public CompositeValue(PlatformKind kind) { + public CompositeValue(LIRKind kind) { super(kind); COMPOSITE_VALUE_COUNT.increment(); valueClass = CompositeValueClass.get(getClass());
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/FrameMap.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/FrameMap.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -259,17 +259,17 @@ * @param additionalOffset * @return A spill slot denoting the reserved memory area. */ - protected abstract StackSlot allocateNewSpillSlot(PlatformKind kind, int additionalOffset); + protected abstract StackSlot allocateNewSpillSlot(LIRKind kind, int additionalOffset); /** - * Returns the spill slot size for the given {@link PlatformKind}. The default value is the size - * in bytes for the target architecture. + * Returns the spill slot size for the given {@link LIRKind}. The default value is the size in + * bytes for the target architecture. * - * @param kind the {@link PlatformKind} to be stored in the spill slot. + * @param kind the {@link LIRKind} to be stored in the spill slot. * @return the size in bytes */ - public int spillSlotSize(PlatformKind kind) { - return target.getSizeInBytes(kind); + public int spillSlotSize(LIRKind kind) { + return target.getSizeInBytes(kind.getPlatformKind()); } /** @@ -280,12 +280,12 @@ * @param kind The kind of the spill slot to be reserved. * @return A spill slot denoting the reserved memory area. */ - public StackSlot allocateSpillSlot(PlatformKind kind) { + public StackSlot allocateSpillSlot(LIRKind kind) { assert frameSize == -1 : "frame size must not yet be fixed"; if (freedSlots != null) { for (Iterator<StackSlot> iter = freedSlots.iterator(); iter.hasNext();) { StackSlot s = iter.next(); - if (s.getPlatformKind() == kind) { + if (s.getLIRKind() == kind) { iter.remove(); if (freedSlots.isEmpty()) { freedSlots = null; @@ -302,8 +302,8 @@ private Set<StackSlot> freedSlots; /** - * Frees a spill slot that was obtained via {@link #allocateSpillSlot(PlatformKind)} such that - * it can be reused for the next allocation request for the same kind of slot. + * Frees a spill slot that was obtained via {@link #allocateSpillSlot(LIRKind)} such that it can + * be reused for the next allocation request for the same kind of slot. */ public void freeSpillSlot(StackSlot slot) { if (freedSlots == null) { @@ -338,7 +338,7 @@ for (int slotIndex = 0; slotIndex < slots; slotIndex++) { StackSlot objectSlot = null; if (objects.get(slotIndex)) { - objectSlot = allocateNewSpillSlot(Kind.Object, slotIndex * stackSlotSize()); + objectSlot = allocateNewSpillSlot(LIRKind.reference(Kind.Object), slotIndex * stackSlotSize()); objectStackSlots.add(objectSlot); if (outObjectStackSlots != null) { outObjectStackSlots.add(objectSlot); @@ -348,7 +348,7 @@ if (objectSlot != null) { result = objectSlot; } else { - result = allocateNewSpillSlot(target.wordKind, 0); + result = allocateNewSpillSlot(LIRKind.value(target.wordKind), 0); } } } @@ -356,7 +356,7 @@ return result; } else { - return allocateNewSpillSlot(target.wordKind, 0); + return allocateNewSpillSlot(LIRKind.value(target.wordKind), 0); } } @@ -377,7 +377,7 @@ * @param refMap A reference map, as created by {@link #initReferenceMap(boolean)}. */ public void setReference(Value location, ReferenceMap refMap) { - PlatformKind kind = location.getPlatformKind(); + LIRKind kind = location.getLIRKind(); if (isRegister(location)) { refMap.setRegister(asRegister(location).getReferenceMapIndex(), kind); } else if (isStackSlot(location)) {
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/RedundantMoveElimination.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/RedundantMoveElimination.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -510,7 +510,7 @@ /* * Moves with mismatching kinds are not moves, but memory loads/stores! */ - return source.getKind() == dest.getKind() && source.getPlatformKind() == dest.getPlatformKind() && source.getKind() != Kind.Illegal; + return source.getKind() == dest.getKind() && source.getLIRKind() == dest.getLIRKind() && source.getKind() != Kind.Illegal; } return false; }
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/Variable.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/Variable.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,11 +42,11 @@ /** * Creates a new variable. - * + * * @param kind * @param index */ - public Variable(PlatformKind kind, int index) { + public Variable(LIRKind kind, int index) { super(kind); assert index >= 0; this.index = index;
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/ArithmeticLIRGenerator.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/ArithmeticLIRGenerator.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ */ public interface ArithmeticLIRGenerator { - PlatformKind getPlatformKind(Stamp stamp); + LIRKind getLIRKind(Stamp stamp); Value emitNegate(Value input); @@ -70,7 +70,7 @@ Value emitFloatConvert(FloatConvert op, Value inputVal); - Value emitReinterpret(PlatformKind to, Value inputVal); + Value emitReinterpret(LIRKind to, Value inputVal); Value emitNarrow(Value inputVal, int bits);
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGenerator.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGenerator.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,6 @@ package com.oracle.graal.lir.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 java.util.*; @@ -45,7 +44,7 @@ /** * This class traverses the HIR instructions and generates LIR instructions from them. */ -public abstract class LIRGenerator implements LIRGeneratorTool, PlatformKindTool { +public abstract class LIRGenerator implements LIRGeneratorTool, LIRKindTool { public static class Options { // @formatter:off @@ -104,12 +103,12 @@ /** * Creates a new {@linkplain Variable variable}. * - * @param platformKind The kind of the new variable. + * @param lirKind The kind of the new variable. * @return a new variable */ @Override - public Variable newVariable(PlatformKind platformKind) { - return new Variable(platformKind, res.getLIR().nextVariable()); + public Variable newVariable(LIRKind lirKind) { + return new Variable(lirKind, res.getLIR().nextVariable()); } @Override @@ -156,11 +155,8 @@ * @return the operand representing the ABI defined location used return a value of kind * {@code kind} */ - public AllocatableValue resultOperandFor(Kind kind) { - if (kind == Kind.Void) { - return ILLEGAL; - } - return res.getFrameMap().registerConfig.getReturnRegister(kind).asValue(kind); + public AllocatableValue resultOperandFor(LIRKind kind) { + return res.getFrameMap().registerConfig.getReturnRegister((Kind) kind.getPlatformKind()).asValue(kind); } public void append(LIRInstruction op) { @@ -234,10 +230,11 @@ 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. + LIRKind stackKind = value.getLIRKind().changeType(value.getKind().getStackKind()); if (isRegister(value)) { - return asRegister(value).asValue(value.getKind().getStackKind()); + return asRegister(value).asValue(stackKind); } else if (isStackSlot(value)) { - return StackSlot.get(value.getKind().getStackKind(), asStackSlot(value).getRawOffset(), asStackSlot(value).getRawAddFrameSize()); + return StackSlot.get(stackKind, asStackSlot(value).getRawOffset(), asStackSlot(value).getRawAddFrameSize()); } else { throw GraalInternalError.shouldNotReachHere(); } @@ -349,36 +346,46 @@ /** * Default implementation: Return the Java stack kind for each stamp. */ - public PlatformKind getPlatformKind(Stamp stamp) { - return stamp.getPlatformKind(this); + public LIRKind getLIRKind(Stamp stamp) { + return stamp.getLIRKind(this); } - public PlatformKind getIntegerKind(int bits) { + public LIRKind getIntegerKind(int bits) { if (bits <= 8) { - return Kind.Byte; + return LIRKind.value(Kind.Byte); } else if (bits <= 16) { - return Kind.Short; + return LIRKind.value(Kind.Short); } else if (bits <= 32) { - return Kind.Int; + return LIRKind.value(Kind.Int); } else { assert bits <= 64; - return Kind.Long; + return LIRKind.value(Kind.Long); } } - public PlatformKind getFloatingKind(int bits) { + public LIRKind getFloatingKind(int bits) { switch (bits) { case 32: - return Kind.Float; + return LIRKind.value(Kind.Float); case 64: - return Kind.Double; + return LIRKind.value(Kind.Double); default: throw GraalInternalError.shouldNotReachHere(); } } - public PlatformKind getObjectKind() { - return Kind.Object; + public LIRKind getObjectKind() { + return LIRKind.reference(Kind.Object); + } + + protected LIRKind getAddressKind(Value base, long displacement, Value index) { + if (base.getLIRKind().isValue() && (index.equals(Value.ILLEGAL) || index.getLIRKind().isValue())) { + return LIRKind.value(target().wordKind); + } else if (base.getLIRKind().isReference(0) && displacement == 0L && index.equals(Value.ILLEGAL)) { + return LIRKind.reference(target().wordKind); + } else { + return LIRKind.derivedReference(target().wordKind); + } } public AbstractBlock<?> getCurrentBlock() {
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGeneratorTool.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGeneratorTool.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -52,9 +52,9 @@ void doBlockEnd(AbstractBlock<?> block); - Value emitLoad(PlatformKind kind, Value address, LIRFrameState state); + Value emitLoad(LIRKind kind, Value address, LIRFrameState state); - void emitStore(PlatformKind kind, Value address, Value input, LIRFrameState state); + void emitStore(LIRKind kind, Value address, Value input, LIRFrameState state); void emitNullCheck(Value address, LIRFrameState state); @@ -106,7 +106,7 @@ RegisterAttributes attributes(Register register); - Variable newVariable(PlatformKind kind); + Variable newVariable(LIRKind kind); Variable emitMove(Value input); @@ -166,7 +166,7 @@ * @return the operand representing the ABI defined location used return a value of kind * {@code kind} */ - AllocatableValue resultOperandFor(Kind kind); + AllocatableValue resultOperandFor(LIRKind kind); void append(LIRInstruction op);
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ReinterpretNode.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ReinterpretNode.java Fri Jun 13 11:47:44 2014 +0200 @@ -104,7 +104,7 @@ @Override public void generate(NodeMappableLIRBuilder builder, ArithmeticLIRGenerator gen) { - PlatformKind kind = gen.getPlatformKind(stamp()); + LIRKind kind = gen.getLIRKind(stamp()); builder.setResult(this, gen.emitReinterpret(kind, builder.operand(value()))); }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/FloatingReadNode.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/FloatingReadNode.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -62,7 +62,7 @@ @Override public void generate(NodeLIRBuilderTool gen) { Value address = location().generateAddress(gen, gen.getLIRGeneratorTool(), gen.operand(object())); - PlatformKind readKind = gen.getLIRGeneratorTool().getPlatformKind(stamp()); + LIRKind readKind = gen.getLIRGeneratorTool().getLIRKind(stamp()); gen.setResult(this, gen.getLIRGeneratorTool().emitLoad(readKind, address, null)); }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ReadNode.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ReadNode.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -56,7 +56,7 @@ @Override public void generate(NodeLIRBuilderTool gen) { Value address = location().generateAddress(gen, gen.getLIRGeneratorTool(), gen.operand(object())); - PlatformKind readKind = gen.getLIRGeneratorTool().getPlatformKind(stamp()); + LIRKind readKind = gen.getLIRGeneratorTool().getLIRKind(stamp()); gen.setResult(this, gen.getLIRGeneratorTool().emitLoad(readKind, address, gen.state(this))); }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/WriteNode.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/WriteNode.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -53,7 +53,7 @@ } else { v = gen.operand(value()); } - PlatformKind writeKind = gen.getLIRGeneratorTool().getPlatformKind(value().stamp()); + LIRKind writeKind = gen.getLIRGeneratorTool().getLIRKind(value().stamp()); gen.getLIRGeneratorTool().emitStore(writeKind, address, v, gen.state(this)); }
--- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinter.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinter.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -532,7 +532,7 @@ } private void printInterval(Interval interval) { - out.printf("%s %s ", interval.operand, (isRegister(interval.operand) ? "fixed" : interval.kind().name())); + out.printf("%s %s ", interval.operand, (isRegister(interval.operand) ? "fixed" : interval.kind())); if (isRegister(interval.operand)) { out.printf("\"[%s|%c]\"", interval.operand, interval.operand.getKind().getTypeChar()); } else {
--- a/graal/com.oracle.graal.ptx/src/com/oracle/graal/ptx/PTX.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.ptx/src/com/oracle/graal/ptx/PTX.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -197,12 +197,12 @@ } @Override - public boolean canStoreValue(RegisterCategory category, PlatformKind platformKind) { - if (!(platformKind instanceof Kind)) { + public boolean canStoreValue(RegisterCategory category, PlatformKind lirKind) { + if (!(lirKind instanceof Kind)) { return false; } - Kind kind = (Kind) platformKind; + Kind kind = (Kind) lirKind; if (category == REG) { switch (kind) { case Boolean:
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/DirectReadNode.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/DirectReadNode.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,7 +51,8 @@ @Override public void generate(NodeLIRBuilderTool gen) { - gen.setResult(this, gen.getLIRGeneratorTool().emitLoad(readKind, gen.operand(address), null)); + LIRKind kind = gen.getLIRGeneratorTool().target().getLIRKind(readKind); + gen.setResult(this, gen.getLIRGeneratorTool().emitLoad(kind, gen.operand(address), null)); } @SuppressWarnings("unchecked")
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/DirectStoreNode.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/DirectStoreNode.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,7 +50,8 @@ @Override public void generate(NodeLIRBuilderTool gen) { Value v = gen.operand(value); - gen.getLIRGeneratorTool().emitStore(kind, gen.operand(address), v, null); + LIRKind lirKind = gen.getLIRGeneratorTool().target().getLIRKind(kind); + gen.getLIRGeneratorTool().emitStore(lirKind, gen.operand(address), v, null); } protected ValueNode getAddress() {
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/ReadRegisterNode.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/ReadRegisterNode.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -75,7 +75,8 @@ @Override public void generate(NodeLIRBuilderTool generator) { - Value result = register.asValue(getKind()); + LIRKind kind = generator.getLIRGeneratorTool().getLIRKind(stamp()); + Value result = register.asValue(kind); if (incoming) { generator.getLIRGeneratorTool().emitIncomingValues(new Value[]{result}); }
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/WriteRegisterNode.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/WriteRegisterNode.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -54,7 +54,7 @@ @Override public void generate(NodeLIRBuilderTool generator) { Value val = generator.operand(value); - generator.getLIRGeneratorTool().emitMove(register.asValue(val.getKind()), val); + generator.getLIRGeneratorTool().emitMove(register.asValue(val.getLIRKind()), val); } @Override
--- a/graal/com.oracle.graal.sparc/src/com/oracle/graal/sparc/SPARC.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.sparc/src/com/oracle/graal/sparc/SPARC.java Fri Jun 13 11:47:44 2014 +0200 @@ -195,12 +195,12 @@ } @Override - public boolean canStoreValue(RegisterCategory category, PlatformKind platformKind) { - if (!(platformKind instanceof Kind)) { + public boolean canStoreValue(RegisterCategory category, PlatformKind lirKind) { + if (!(lirKind instanceof Kind)) { return false; } - Kind kind = (Kind) platformKind; + Kind kind = (Kind) lirKind; if (category == CPU) { switch (kind) { case Boolean:
--- a/graal/com.oracle.graal.word/src/com/oracle/graal/word/nodes/WordCastNode.java Fri Jun 13 11:11:44 2014 +0200 +++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/nodes/WordCastNode.java Fri Jun 13 11:47:44 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -71,7 +71,12 @@ assert getKind() != input.getKind(); assert generator.getLIRGeneratorTool().target().getSizeInBytes(getKind()) == generator.getLIRGeneratorTool().target().getSizeInBytes(input.getKind()); - AllocatableValue result = generator.getLIRGeneratorTool().newVariable(getKind()); + LIRKind kind = generator.getLIRGeneratorTool().getLIRKind(stamp()); + if (kind.isValue()) { + kind = kind.makeDerivedReference(); + } + + AllocatableValue result = generator.getLIRGeneratorTool().newVariable(kind); generator.getLIRGeneratorTool().emitMove(result, generator.operand(input)); generator.setResult(this, result); }