Mercurial > hg > truffle
changeset 4183:9e0c1b4cfef5
Move all isXxx and asXxx out of CiValue and into their own util class.
line wrap: on
line diff
--- a/graal/com.oracle.max.asm/src/com/oracle/max/asm/target/amd64/AMD64Assembler.java Mon Jan 02 14:38:17 2012 -0800 +++ b/graal/com.oracle.max.asm/src/com/oracle/max/asm/target/amd64/AMD64Assembler.java Mon Jan 02 17:39:20 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2012, 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 @@ -22,6 +22,7 @@ */ package com.oracle.max.asm.target.amd64; +import static com.sun.cri.ci.CiValueUtil.*; import static com.oracle.max.asm.NumUtil.*; import static com.oracle.max.asm.target.amd64.AMD64.*; import static com.oracle.max.cri.intrinsics.MemoryBarriers.*; @@ -166,9 +167,9 @@ } private void emitOperandHelper(CiRegister reg, CiAddress addr) { - CiRegister base = addr.base(); - - CiRegister index = addr.index(); + CiRegister base = isLegal(addr.base) ? asRegister(addr.base) : CiRegister.None; + CiRegister index = isLegal(addr.index) ? asRegister(addr.index) : CiRegister.None; + CiAddress.Scale scale = addr.scale; int disp = addr.displacement; @@ -2203,29 +2204,34 @@ } } + private static boolean needsRex(CiValue value) { + return isRegister(value) && asRegister(value).encoding >= MinEncodingNeedsRex; + } + + private void prefix(CiAddress adr) { - if (adr.base().encoding >= MinEncodingNeedsRex) { - if (adr.index().encoding >= MinEncodingNeedsRex) { + if (needsRex(adr.base)) { + if (needsRex(adr.index)) { emitByte(Prefix.REXXB); } else { emitByte(Prefix.REXB); } } else { - if (adr.index().encoding >= MinEncodingNeedsRex) { + if (needsRex(adr.index)) { emitByte(Prefix.REXX); } } } private void prefixq(CiAddress adr) { - if (adr.base().encoding >= MinEncodingNeedsRex) { - if (adr.index().encoding >= MinEncodingNeedsRex) { + if (needsRex(adr.base)) { + if (needsRex(adr.index)) { emitByte(Prefix.REXWXB); } else { emitByte(Prefix.REXWB); } } else { - if (adr.index().encoding >= MinEncodingNeedsRex) { + if (needsRex(adr.index)) { emitByte(Prefix.REXWX); } else { emitByte(Prefix.REXW); @@ -2235,28 +2241,28 @@ private void prefix(CiAddress adr, CiRegister reg) { if (reg.encoding < 8) { - if (adr.base().encoding >= MinEncodingNeedsRex) { - if (adr.index().encoding >= MinEncodingNeedsRex) { + if (needsRex(adr.base)) { + if (needsRex(adr.index)) { emitByte(Prefix.REXXB); } else { emitByte(Prefix.REXB); } } else { - if (adr.index().encoding >= MinEncodingNeedsRex) { + if (needsRex(adr.index)) { emitByte(Prefix.REXX); } else if (reg.encoding >= 4) { emitByte(Prefix.REX); } } } else { - if (adr.base().encoding >= MinEncodingNeedsRex) { - if (adr.index().encoding >= MinEncodingNeedsRex) { + if (needsRex(adr.base)) { + if (needsRex(adr.index)) { emitByte(Prefix.REXRXB); } else { emitByte(Prefix.REXRB); } } else { - if (adr.index().encoding >= MinEncodingNeedsRex) { + if (needsRex(adr.index)) { emitByte(Prefix.REXRX); } else { emitByte(Prefix.REXR); @@ -2267,28 +2273,28 @@ private void prefixq(CiAddress adr, CiRegister src) { if (src.encoding < 8) { - if (adr.base().encoding >= MinEncodingNeedsRex) { - if (adr.index().encoding >= MinEncodingNeedsRex) { + if (needsRex(adr.base)) { + if (needsRex(adr.index)) { emitByte(Prefix.REXWXB); } else { emitByte(Prefix.REXWB); } } else { - if (adr.index().encoding >= MinEncodingNeedsRex) { + if (needsRex(adr.index)) { emitByte(Prefix.REXWX); } else { emitByte(Prefix.REXW); } } } else { - if (adr.base().encoding >= MinEncodingNeedsRex) { - if (adr.index().encoding >= MinEncodingNeedsRex) { + if (needsRex(adr.base)) { + if (needsRex(adr.index)) { emitByte(Prefix.REXWRXB); } else { emitByte(Prefix.REXWRB); } } else { - if (adr.index().encoding >= MinEncodingNeedsRex) { + if (needsRex(adr.index)) { emitByte(Prefix.REXWRX); } else { emitByte(Prefix.REXWR);
--- a/graal/com.oracle.max.cri/src/com/sun/cri/ci/CiAddress.java Mon Jan 02 14:38:17 2012 -0800 +++ b/graal/com.oracle.max.cri/src/com/sun/cri/ci/CiAddress.java Mon Jan 02 17:39:20 2012 -0800 @@ -22,6 +22,8 @@ */ package com.sun.cri.ci; +import static com.sun.cri.ci.CiValueUtil.*; + /** * Represents an address in target machine memory, specified via some combination of a base register, an index register, * a displacement and a scale. Note that the base and index registers may be {@link CiVariable variable}, that is as yet @@ -33,7 +35,7 @@ /** * A sentinel value used as a place holder in an instruction stream for an address that will be patched. */ - public static final CiAddress Placeholder = new CiAddress(CiKind.Illegal, CiRegister.None.asValue()); + public static final CiAddress Placeholder = new CiAddress(CiKind.Illegal, CiValue.IllegalValue); /** * Base register that defines the start of the address computation; always present. @@ -95,7 +97,7 @@ super(kind); this.base = base; - if (index.isConstant()) { + if (isConstant(index)) { long longIndex = ((CiConstant) index).asLong(); long longDisp = displacement + longIndex * scale.value; if ((int) longIndex != longIndex || (int) longDisp != longDisp) { @@ -105,8 +107,8 @@ this.index = IllegalValue; this.scale = Scale.Times1; } else { - assert base.isIllegal() || base.isVariableOrRegister(); - assert index.isIllegal() || index.isVariableOrRegister(); + assert isIllegal(base) || isVariable(base) || isRegister(base); + assert isIllegal(index) || isVariable(index) || isRegister(index); this.index = index; this.scale = scale; @@ -156,26 +158,6 @@ } /** - * If the base register is a {@link CiRegisterValue} returns the associated {@link CiRegister} - * otherwise raises an exception.. - * @return the base {@link CiRegister} - * @exception Error if {@code base} is not a {@link CiRegisterValue} - */ - public CiRegister base() { - return base.asRegister(); - } - - /** - * If the index register is a {@link CiRegisterValue} returns the associated {@link CiRegister} - * otherwise raises an exception.. - * @return the base {@link CiRegister} - * @exception Error if {@code index} is not a {@link CiRegisterValue} - */ - public CiRegister index() { - return index.asRegister(); - } - - /** * Encodes the possible addressing modes as a simple value. */ public enum Format { @@ -194,8 +176,8 @@ if (this == Placeholder) { return Format.PLACEHOLDER; } - assert base.isLegal(); - if (index.isLegal()) { + assert isLegal(base); + if (isLegal(index)) { if (displacement != 0) { return Format.BASE_INDEX_DISP; } else { @@ -211,10 +193,10 @@ } private static String s(CiValue location) { - if (location.isRegister()) { - return location.asRegister().name; + if (isRegister(location)) { + return asRegister(location).name; } - assert location.isVariable(); + assert isVariable(location); return "v" + ((CiVariable) location).index; }
--- a/graal/com.oracle.max.cri/src/com/sun/cri/ci/CiCallingConvention.java Mon Jan 02 14:38:17 2012 -0800 +++ b/graal/com.oracle.max.cri/src/com/sun/cri/ci/CiCallingConvention.java Mon Jan 02 17:39:20 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2012, 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 @@ -22,6 +22,8 @@ */ package com.sun.cri.ci; +import static com.sun.cri.ci.CiValueUtil.*; + import com.sun.cri.ri.*; @@ -98,7 +100,7 @@ private boolean verify() { for (int i = 0; i < locations.length; i++) { CiValue location = locations[i]; - assert location.isStackSlot() || location.isRegister(); + assert isStackSlot(location) || isRegister(location); } return true; }
--- a/graal/com.oracle.max.cri/src/com/sun/cri/ci/CiMonitorValue.java Mon Jan 02 14:38:17 2012 -0800 +++ b/graal/com.oracle.max.cri/src/com/sun/cri/ci/CiMonitorValue.java Mon Jan 02 17:39:20 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2012, 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 @@ -26,12 +26,11 @@ private static final long serialVersionUID = 8241681800464483691L; public CiValue owner; - public CiValue lockData; - public boolean eliminated; + public final CiValue lockData; + public final boolean eliminated; public CiMonitorValue(CiValue owner, CiValue lockData, boolean eliminated) { super(CiKind.Illegal); - this.owner = owner; this.lockData = lockData; this.eliminated = eliminated;
--- a/graal/com.oracle.max.cri/src/com/sun/cri/ci/CiRegisterValue.java Mon Jan 02 14:38:17 2012 -0800 +++ b/graal/com.oracle.max.cri/src/com/sun/cri/ci/CiRegisterValue.java Mon Jan 02 17:39:20 2012 -0800 @@ -52,9 +52,4 @@ public String toString() { return reg.name + kindSuffix(); } - - @Override - public CiRegister asRegister() { - return reg; - } }
--- a/graal/com.oracle.max.cri/src/com/sun/cri/ci/CiValue.java Mon Jan 02 14:38:17 2012 -0800 +++ b/graal/com.oracle.max.cri/src/com/sun/cri/ci/CiValue.java Mon Jan 02 17:39:20 2012 -0800 @@ -36,10 +36,6 @@ public String toString() { return "-"; } - @Override - public CiRegister asRegister() { - return CiRegister.None; - } }; /** @@ -55,55 +51,10 @@ this.kind = kind; } - public final boolean isVariableOrRegister() { - return this instanceof CiVariable || this instanceof CiRegisterValue; - } - - public CiRegister asRegister() { - throw new InternalError("Not a register: " + this); - } - - public final boolean isIllegal() { - return this == IllegalValue; - } - - public final boolean isLegal() { - return this != IllegalValue; - } - /** - * Determines if this value represents a slot on a stack. These values are created - * by the register allocator for spill slots. They are also used to model method - * parameters passed on the stack according to a specific calling convention. + * String representation of the kind, which should be the end of all {@link #toString()} implementation of subclasses. */ - public final boolean isStackSlot() { - return this instanceof CiStackSlot; - } - - public final boolean isRegister() { - return this instanceof CiRegisterValue; - } - - public final boolean isVariable() { - return this instanceof CiVariable; - } - - public final boolean isAddress() { - return this instanceof CiAddress; - } - - public final boolean isConstant() { - return this instanceof CiConstant; - } - - @Override - public abstract String toString(); - protected final String kindSuffix() { return "|" + kind.typeChar; } - - public final boolean isConstant0() { - return isConstant() && ((CiConstant) this).asInt() == 0; - } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.cri/src/com/sun/cri/ci/CiValueUtil.java Mon Jan 02 17:39:20 2012 -0800 @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2012, 2012, 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.sun.cri.ci; + +public class CiValueUtil { + public static boolean isIllegal(CiValue value) { + assert value != null; + return value == CiValue.IllegalValue; + } + + public static boolean isLegal(CiValue value) { + return !isIllegal(value); + } + + public static boolean isVirtualObject(CiValue value) { + assert value != null; + return value instanceof CiVirtualObject; + } + + + public static boolean isVariable(CiValue value) { + assert value != null; + return value instanceof CiVariable; + } + + public static CiVariable asVariable(CiValue value) { + assert value != null; + return (CiVariable) value; + } + + + public static boolean isConstant(CiValue value) { + assert value != null; + return value instanceof CiConstant; + } + + + public static boolean isStackSlot(CiValue value) { + assert value != null; + return value instanceof CiStackSlot; + } + + public static CiStackSlot asStackSlot(CiValue value) { + assert value != null; + return (CiStackSlot) value; + } + + + public static boolean isRegister(CiValue value) { + assert value != null; + return value instanceof CiRegisterValue; + } + + public static CiRegister asRegister(CiValue value) { + assert value != null; + return ((CiRegisterValue) value).reg; + } + + public static CiRegister asIntReg(CiValue value) { + assert value.kind == CiKind.Int || value.kind == CiKind.Jsr; + return asRegister(value); + } + + public static CiRegister asLongReg(CiValue value) { + assert value.kind == CiKind.Long : value.kind; + return asRegister(value); + } + + public static CiRegister asObjectReg(CiValue value) { + assert value.kind == CiKind.Object; + return asRegister(value); + } + + public static CiRegister asFloatReg(CiValue value) { + assert value.kind == CiKind.Float; + return asRegister(value); + } + + public static CiRegister asDoubleReg(CiValue value) { + assert value.kind == CiKind.Double; + return asRegister(value); + } +}
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/util/ValueUtil.java Mon Jan 02 14:38:17 2012 -0800 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/util/ValueUtil.java Mon Jan 02 17:39:20 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,19 +24,7 @@ import com.sun.cri.ci.*; - -public class ValueUtil { - - public static boolean isIllegal(CiValue value) { - assert value != null; - assert (value == CiValue.IllegalValue) == (value.kind == CiKind.Illegal); - return value == CiValue.IllegalValue; - } - - public static boolean isVirtualObject(CiValue value) { - assert value != null; - return value instanceof CiVirtualObject; - } +public class ValueUtil extends CiValueUtil { public static boolean isLocation(CiValue value) { assert value != null; @@ -47,68 +35,4 @@ assert value != null; return (Location) value; } - - - public static boolean isVariable(CiValue value) { - assert value != null; - return value instanceof CiVariable; - } - - public static CiVariable asVariable(CiValue value) { - assert value != null; - return (CiVariable) value; - } - - public static boolean isConstant(CiValue value) { - assert value != null; - return value instanceof CiConstant; - } - - public static boolean isStackSlot(CiValue value) { - assert value != null; - return value instanceof CiStackSlot; - } - - public static CiStackSlot asStackSlot(CiValue value) { - assert value != null; - return (CiStackSlot) value; - } - - - - public static boolean isRegister(CiValue value) { - assert value != null; - return value instanceof CiRegisterValue; - } - - public static CiRegister asRegister(CiValue value) { - assert value != null; - return ((CiRegisterValue) value).reg; - } - - - public static CiRegister asIntReg(CiValue value) { - assert value.kind == CiKind.Int || value.kind == CiKind.Jsr; - return asRegister(value); - } - - public static CiRegister asLongReg(CiValue value) { - assert value.kind == CiKind.Long : value.kind; - return asRegister(value); - } - - public static CiRegister asObjectReg(CiValue value) { - assert value.kind == CiKind.Object; - return asRegister(value); - } - - public static CiRegister asFloatReg(CiValue value) { - assert value.kind == CiKind.Float; - return asRegister(value); - } - - public static CiRegister asDoubleReg(CiValue value) { - assert value.kind == CiKind.Double; - return asRegister(value); - } }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalCompilation.java Mon Jan 02 14:38:17 2012 -0800 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalCompilation.java Mon Jan 02 17:39:20 2012 -0800 @@ -23,6 +23,8 @@ package com.oracle.max.graal.compiler; +import static com.sun.cri.ci.CiValueUtil.*; + import java.util.*; import com.oracle.max.asm.*; @@ -112,7 +114,7 @@ public void setOperand(ValueNode valueNode, CiValue operand) { assert operand(valueNode) == null : "operand cannot be set twice"; - assert operand != null && operand.isLegal() : "operand must be legal"; + assert operand != null && isLegal(operand) : "operand must be legal"; assert operand.kind.stackKind() == valueNode.kind(); assert !(valueNode instanceof VirtualObjectNode); nodeOperands.set(valueNode, operand);
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/Interval.java Mon Jan 02 14:38:17 2012 -0800 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/Interval.java Mon Jan 02 17:39:20 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2012, 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 @@ -22,6 +22,8 @@ */ package com.oracle.max.graal.compiler.alloc; +import static com.sun.cri.ci.CiValueUtil.*; + import java.util.*; import com.oracle.max.criutils.*; @@ -417,7 +419,7 @@ /** * The kind of this interval. - * Only valid if this is a {@linkplain #isVariable() variable}. + * Only valid if this is a {@linkplain #xxisVariable() variable}. */ private CiKind kind; @@ -484,15 +486,15 @@ private Interval locationHint; void assignLocation(CiValue newLocation) { - if (newLocation.isRegister()) { + if (isRegister(newLocation)) { assert this.location == null : "cannot re-assign location for " + this; if (newLocation.kind == CiKind.Illegal && kind != CiKind.Illegal) { - this.location = newLocation.asRegister().asValue(kind); + this.location = asRegister(newLocation).asValue(kind); return; } } else { - assert this.location == null || this.location.isRegister() : "cannot re-assign location for " + this; - assert newLocation.isStackSlot(); + assert this.location == null || isRegister(this.location) : "cannot re-assign location for " + this; + assert isStackSlot(newLocation); assert newLocation.kind != CiKind.Illegal; assert newLocation.kind == this.kind; } @@ -507,12 +509,12 @@ } public CiKind kind() { - assert !operand.isRegister() : "cannot access type for fixed interval"; + assert !isRegister(operand) : "cannot access type for fixed interval"; return kind; } void setKind(CiKind kind) { - assert operand.isRegister() || this.kind() == CiKind.Illegal || this.kind() == kind : "overwriting existing type"; + assert isRegister(operand) || this.kind() == CiKind.Illegal || this.kind() == kind : "overwriting existing type"; assert kind == kind.stackKind() || kind == CiKind.Short : "these kinds should have int type registers"; this.kind = kind; } @@ -664,10 +666,10 @@ assert operand != null; this.operand = operand; this.operandNumber = operandNumber; - if (operand.isRegister()) { + if (isRegister(operand)) { location = operand; } else { - assert operand.isIllegal() || operand.isVariable(); + assert isIllegal(operand) || isVariable(operand); } this.kind = CiKind.Illegal; this.first = Range.EndMarker; @@ -729,14 +731,14 @@ if (locationHint != null) { assert locationHint.isSplitParent() : "ony split parents are valid hint registers"; - if (locationHint.location != null && locationHint.location.isRegister()) { + if (locationHint.location != null && isRegister(locationHint.location)) { return locationHint; } else if (!locationHint.splitChildren.isEmpty()) { // search the first split child that has a register assigned int len = locationHint.splitChildren.size(); for (int i = 0; i < len; i++) { Interval interval = locationHint.splitChildren.get(i); - if (interval.location != null && interval.location.isRegister()) { + if (interval.location != null && isRegister(interval.location)) { return interval; } } @@ -853,7 +855,7 @@ // Note: use positions are sorted descending . first use has highest index int firstUsage(RegisterPriority minRegisterPriority) { - assert operand.isVariable() : "cannot access use positions for fixed intervals"; + assert isVariable(operand) : "cannot access use positions for fixed intervals"; for (int i = usePosList.size() - 1; i >= 0; --i) { RegisterPriority registerPriority = usePosList.registerPriority(i); @@ -865,7 +867,7 @@ } int nextUsage(RegisterPriority minRegisterPriority, int from) { - assert operand.isVariable() : "cannot access use positions for fixed intervals"; + assert isVariable(operand) : "cannot access use positions for fixed intervals"; for (int i = usePosList.size() - 1; i >= 0; --i) { int usePos = usePosList.usePos(i); @@ -877,7 +879,7 @@ } int nextUsageExact(RegisterPriority exactRegisterPriority, int from) { - assert operand.isVariable() : "cannot access use positions for fixed intervals"; + assert isVariable(operand) : "cannot access use positions for fixed intervals"; for (int i = usePosList.size() - 1; i >= 0; --i) { int usePos = usePosList.usePos(i); @@ -889,7 +891,7 @@ } int previousUsage(RegisterPriority minRegisterPriority, int from) { - assert operand.isVariable() : "cannot access use positions for fixed intervals"; + assert isVariable(operand) : "cannot access use positions for fixed intervals"; int prev = 0; for (int i = usePosList.size() - 1; i >= 0; --i) { @@ -908,7 +910,7 @@ assert covers(pos, LIRInstruction.OperandMode.Input) : "use position not covered by live range"; // do not add use positions for precolored intervals because they are never used - if (registerPriority != RegisterPriority.None && operand.isVariable()) { + if (registerPriority != RegisterPriority.None && isVariable(operand)) { if (GraalOptions.DetailedAsserts) { for (int i = 0; i < usePosList.size(); i++) { assert pos <= usePosList.usePos(i) : "already added a use-position with lower position"; @@ -983,7 +985,7 @@ * @return the child interval split off from this interval */ Interval split(int splitPos, LinearScan allocator) { - assert operand.isVariable() : "cannot split fixed intervals"; + assert isVariable(operand) : "cannot split fixed intervals"; // allocate new interval Interval result = newSplitChild(allocator); @@ -1031,7 +1033,7 @@ * Currently, only the first range can be split, and the new interval must not have split positions */ Interval splitFromStart(int splitPos, LinearScan allocator) { - assert operand.isVariable() : "cannot split fixed intervals"; + assert isVariable(operand) : "cannot split fixed intervals"; assert splitPos > from() && splitPos < to() : "can only split inside interval"; assert splitPos > first.from && splitPos <= first.to : "can only split inside first range"; assert firstUsage(RegisterPriority.None) > splitPos : "can not split when use positions are present"; @@ -1114,7 +1116,7 @@ to = String.valueOf(to()); } String locationString = this.location == null ? "" : "@" + this.location; - return operandNumber + ":" + operand + (operand.isRegister() ? "" : locationString) + "[" + from + "," + to + "]"; + return operandNumber + ":" + operand + (isRegister(operand) ? "" : locationString) + "[" + from + "," + to + "]"; } /** @@ -1132,7 +1134,7 @@ public String logString(LinearScan allocator) { StringBuilder buf = new StringBuilder(100); buf.append(operandNumber).append(':').append(operand).append(' '); - if (!operand.isRegister()) { + if (!isRegister(operand)) { if (location != null) { buf.append("location{").append(location).append("} "); }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/LinearScan.java Mon Jan 02 14:38:17 2012 -0800 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/LinearScan.java Mon Jan 02 17:39:20 2012 -0800 @@ -23,6 +23,7 @@ package com.oracle.max.graal.compiler.alloc; import static com.sun.cri.ci.CiUtil.*; +import static com.sun.cri.ci.CiValueUtil.*; import java.util.*; @@ -120,6 +121,11 @@ this.operands = gen.operands; } + public static boolean isVariableOrRegister(CiValue value) { + return isVariable(value) || isRegister(value); + } + + /** * Converts an operand (variable or register) to an index in a flat address space covering all the * {@linkplain CiVariable variables} and {@linkplain CiRegisterValue registers} being processed by this @@ -132,21 +138,21 @@ static final IntervalPredicate IS_PRECOLORED_INTERVAL = new IntervalPredicate() { @Override public boolean apply(Interval i) { - return i.operand.isRegister(); + return isRegister(i.operand); } }; static final IntervalPredicate IS_VARIABLE_INTERVAL = new IntervalPredicate() { @Override public boolean apply(Interval i) { - return i.operand.isVariable(); + return isVariable(i.operand); } }; static final IntervalPredicate IS_OOP_INTERVAL = new IntervalPredicate() { @Override public boolean apply(Interval i) { - return !i.operand.isRegister() && i.kind() == CiKind.Object; + return !isRegister(i.operand) && i.kind() == CiKind.Object; } }; @@ -177,7 +183,7 @@ */ Interval createInterval(CiValue operand) { assert isProcessed(operand); - assert operand.isLegal(); + assert isLegal(operand); int operandNumber = operandNumber(operand); Interval interval = new Interval(context, operand, operandNumber); assert operandNumber < intervalsSize; @@ -423,11 +429,11 @@ // remove move from register to stack if the stack slot is guaranteed to be correct. // only moves that have been inserted by LinearScan can be removed. assert op.code == StandardOpcode.MOVE : "only moves can have a opId of -1"; - assert resultOperand.isVariable() : "LinearScan inserts only moves to variables"; + assert isVariable(resultOperand) : "LinearScan inserts only moves to variables"; Interval curInterval = intervalFor(resultOperand); - if (!curInterval.location().isRegister() && curInterval.alwaysInMemory()) { + if (!isRegister(curInterval.location()) && curInterval.alwaysInMemory()) { // move target is a stack slot that is always correct, so eliminate instruction if (GraalOptions.TraceLinearScanLevel >= 4) { TTY.println("eliminating move from interval %d to %d", operandNumber(op.input(0)), operandNumber(op.result())); @@ -449,8 +455,8 @@ CiValue fromLocation = interval.location(); CiValue toLocation = canonicalSpillOpr(interval); - assert fromLocation.isRegister() : "from operand must be a register but is: " + fromLocation + " toLocation=" + toLocation + " spillState=" + interval.spillState(); - assert toLocation.isStackSlot() : "to operand must be a stack slot"; + assert isRegister(fromLocation) : "from operand must be a register but is: " + fromLocation + " toLocation=" + toLocation + " spillState=" + interval.spillState(); + assert isStackSlot(toLocation) : "to operand must be a stack slot"; insertionBuffer.append(j + 1, StandardOpcode.MOVE.create(toLocation, fromLocation)); @@ -565,7 +571,7 @@ for (int k = 0; k < n; k++) { CiValue operand = op.operandAt(LIRInstruction.OperandMode.Input, k); - if (operand.isVariable()) { + if (isVariable(operand)) { int operandNum = operandNumber(operand); if (!liveKill.get(operandNum)) { liveGen.set(operandNum); @@ -587,7 +593,7 @@ for (int k = 0; k < n; k++) { CiValue operand = op.operandAt(LIRInstruction.OperandMode.Alive, k); - if (operand.isVariable()) { + if (isVariable(operand)) { int operandNum = operandNumber(operand); if (!liveKill.get(operandNum)) { liveGen.set(operandNum); @@ -628,7 +634,7 @@ for (int k = 0; k < n; k++) { CiValue operand = op.operandAt(LIRInstruction.OperandMode.Temp, k); - if (operand.isVariable()) { + if (isVariable(operand)) { int varNum = operandNumber(operand); liveKill.set(varNum); if (block.loopIndex() >= 0) { @@ -646,7 +652,7 @@ for (int k = 0; k < n; k++) { CiValue operand = op.operandAt(LIRInstruction.OperandMode.Output, k); - if (operand.isVariable()) { + if (isVariable(operand)) { int varNum = operandNumber(operand); liveKill.set(varNum); if (block.loopIndex() >= 0) { @@ -681,7 +687,7 @@ // fixed intervals are never live at block boundaries, so // they need not be processed in live sets // process them only in debug mode so that this can be checked - if (operand.isRegister()) { + if (isRegister(operand)) { if (isProcessed(operand)) { liveKill.set(operandNumber(operand)); } @@ -694,7 +700,7 @@ // this is checked by these assertions to be sure about it. // the entry block may have incoming // values in registers, which is ok. - if (operand.isRegister() && block != ir.startBlock()) { + if (isRegister(operand) && block != ir.startBlock()) { if (isProcessed(operand)) { assert liveKill.get(operandNumber(operand)) : "using fixed register that is not defined in this block"; } @@ -797,7 +803,7 @@ for (int operandNum = 0; operandNum < ir.startBlock().liveIn.size(); operandNum++) { if (ir.startBlock().liveIn.get(operandNum)) { CiValue operand = operands.operandFor(operandNum); - ValueNode instr = operand.isVariable() ? gen.operands.instructionForResult(((CiVariable) operand)) : null; + ValueNode instr = isVariable(operand) ? gen.operands.instructionForResult(((CiVariable) operand)) : null; TTY.println(" var %d (HIR instruction %s); operand=%s", operandNum, instr == null ? " " : instr.toString(), operand.toString()); if (instr instanceof PhiNode) { @@ -877,7 +883,7 @@ interval.setKind(kind); } - if (operand.isVariable() && gen.operands.mustStayInMemory((CiVariable) operand)) { + if (isVariable(operand) && gen.operands.mustStayInMemory((CiVariable) operand)) { interval.addRange(from, maxOpId()); } else { interval.addRange(from, to); @@ -905,7 +911,7 @@ } boolean isProcessed(CiValue operand) { - return !operand.isRegister() || attributes(operand.asRegister()).isAllocatable; + return !isRegister(operand) || attributes(asRegister(operand)).isAllocatable; } void addDef(CiValue operand, int defPos, RegisterPriority registerPriority, CiKind kind) { @@ -968,21 +974,21 @@ RegisterPriority registerPriorityOfOutputOperand(LIRInstruction op, CiValue operand) { if (op.code == StandardOpcode.MOVE) { CiValue res = op.result(); - boolean resultInMemory = res.isVariable() && operands.mustStartInMemory((CiVariable) res); + boolean resultInMemory = isVariable(res) && operands.mustStartInMemory((CiVariable) res); if (resultInMemory) { // Begin of an interval with mustStartInMemory set. // This interval will always get a stack slot first, so return noUse. return RegisterPriority.None; - } else if (op.input(0).isStackSlot()) { + } else if (isStackSlot(op.input(0))) { // method argument (condition must be equal to handleMethodArguments) return RegisterPriority.None; } } - if (operand.isVariable() && operands.mustStartInMemory((CiVariable) operand)) { + if (isVariable(operand) && operands.mustStartInMemory((CiVariable) operand)) { // result is a stack-slot, so prevent immediate reloading return RegisterPriority.None; } @@ -997,14 +1003,14 @@ RegisterPriority registerPriorityOfInputOperand(LIRInstruction op, int operandIndex) { if (op.code == StandardOpcode.MOVE) { CiValue res = op.result(); - boolean resultInMemory = res.isVariable() && operands.mustStartInMemory((CiVariable) res); + boolean resultInMemory = isVariable(res) && operands.mustStartInMemory((CiVariable) res); if (resultInMemory) { // Move to an interval with mustStartInMemory set. // To avoid moves from stack to stack (not allowed) force the input operand to a register return RegisterPriority.MustHaveRegister; - } else if (op.input(0).isVariableOrRegister() && op.result().isVariableOrRegister()) { + } else if (isVariableOrRegister(op.input(0)) && isVariableOrRegister(op.result())) { // The input operand is not forced to a register (moves from stack to register are allowed), // but it is faster if the input operand is in a register return RegisterPriority.ShouldHaveRegister; @@ -1026,12 +1032,12 @@ */ void handleMethodArguments(LIRInstruction op) { if (op.code == StandardOpcode.MOVE) { - if (op.input(0).isStackSlot()) { + if (isStackSlot(op.input(0))) { CiStackSlot slot = (CiStackSlot) op.input(0); if (GraalOptions.DetailedAsserts) { assert op.id() > 0 : "invalid id"; assert blockForId(op.id()).numberOfPreds() == 0 : "move from stack must be in first block"; - assert op.result().isVariable() : "result of move must be a variable"; + assert isVariable(op.result()) : "result of move must be a variable"; if (GraalOptions.TraceLinearScanLevel >= 4) { TTY.println("found move from stack slot %s to %s", slot, op.result()); @@ -1054,7 +1060,7 @@ if (moveFrom != null) { CiValue moveTo = op.result(); - if (moveTo.isVariableOrRegister() && moveFrom.isVariableOrRegister()) { + if (isVariableOrRegister(moveTo) && isVariableOrRegister(moveFrom)) { Interval from = intervalFor(moveFrom); Interval to = intervalFor(moveTo); if (from != null && to != null) { @@ -1131,7 +1137,7 @@ n = op.operandCount(LIRInstruction.OperandMode.Output); for (k = 0; k < n; k++) { CiValue operand = op.operandAt(LIRInstruction.OperandMode.Output, k); - if (operand.isVariableOrRegister()) { + if (isVariableOrRegister(operand)) { addDef(operand, opId, registerPriorityOfOutputOperand(op, operand), operand.kind.stackKind()); } } @@ -1139,7 +1145,7 @@ n = op.operandCount(LIRInstruction.OperandMode.Temp); for (k = 0; k < n; k++) { CiValue operand = op.operandAt(LIRInstruction.OperandMode.Temp, k); - if (operand.isVariableOrRegister()) { + if (isVariableOrRegister(operand)) { if (GraalOptions.TraceLinearScanLevel >= 2) { TTY.println(" temp %s tempPos %d (%s)", operand, opId, RegisterPriority.MustHaveRegister.name()); } @@ -1150,7 +1156,7 @@ n = op.operandCount(LIRInstruction.OperandMode.Alive); for (k = 0; k < n; k++) { CiValue operand = op.operandAt(LIRInstruction.OperandMode.Alive, k); - if (operand.isVariableOrRegister()) { + if (isVariableOrRegister(operand)) { addUse(operand, blockFrom, opId + 1, RegisterPriority.MustHaveRegister, operand.kind.stackKind()); } } @@ -1159,7 +1165,7 @@ n = op.operandCount(LIRInstruction.OperandMode.Input); for (k = 0; k < n; k++) { CiValue operand = op.operandAt(LIRInstruction.OperandMode.Input, k); - if (operand.isVariableOrRegister()) { + if (isVariableOrRegister(operand)) { RegisterPriority p = registerPriorityOfInputOperand(op, k); addUse(operand, blockFrom, opId, p, operand.kind.stackKind()); } @@ -1189,7 +1195,7 @@ // add the range [0, 1] to all fixed intervals. // the register allocator need not handle unhandled fixed intervals for (Interval interval : intervals) { - if (interval != null && interval.operand.isRegister()) { + if (interval != null && isRegister(interval.operand)) { interval.addRange(0, 1); } } @@ -1376,21 +1382,21 @@ } Interval intervalAtBlockBegin(LIRBlock block, CiValue operand) { - assert operand.isVariable() : "register number out of bounds"; + assert isVariable(operand) : "register number out of bounds"; assert intervalFor(operand) != null : "no interval found"; return splitChildAtOpId(intervalFor(operand), block.firstLirInstructionId(), LIRInstruction.OperandMode.Output); } Interval intervalAtBlockEnd(LIRBlock block, CiValue operand) { - assert operand.isVariable() : "register number out of bounds"; + assert isVariable(operand) : "register number out of bounds"; assert intervalFor(operand) != null : "no interval found"; return splitChildAtOpId(intervalFor(operand), block.lastLirInstructionId() + 1, LIRInstruction.OperandMode.Output); } Interval intervalAtOpId(CiValue operand, int opId) { - assert operand.isVariable() : "register number out of bounds"; + assert isVariable(operand) : "register number out of bounds"; assert intervalFor(operand) != null : "no interval found"; return splitChildAtOpId(intervalFor(operand), opId, LIRInstruction.OperandMode.Input); @@ -1532,10 +1538,10 @@ boolean verifyAssignedLocation(Interval interval, CiValue location) { CiKind kind = interval.kind(); - assert location.isRegister() || location.isStackSlot(); + assert isRegister(location) || isStackSlot(location); - if (location.isRegister()) { - CiRegister reg = location.asRegister(); + if (isRegister(location)) { + CiRegister reg = asRegister(location); // register switch (kind) { @@ -1646,7 +1652,7 @@ CiValue operand = interval.operand; assert interval.currentFrom() <= op.id() && op.id() <= interval.currentTo() : "interval should not be active otherwise"; - assert interval.operand.isVariable() : "fixed interval found"; + assert isVariable(interval.operand) : "fixed interval found"; // Check if this range covers the instruction. Intervals that // start or end at the current operation are not included in the @@ -1656,7 +1662,7 @@ // before we've consumed the inputs. if (op.id() < interval.currentTo()) { // caller-save registers must not be included into oop-maps at calls - assert !op.hasCall() || !operand.isRegister() || !isCallerSave(operand) : "interval is in a caller-save register at a call . register will be overwritten"; + assert !op.hasCall() || !isRegister(operand) || !isCallerSave(operand) : "interval is in a caller-save register at a call . register will be overwritten"; frameMap.setReference(interval.location(), registerRefMap, frameRefMap); @@ -1665,7 +1671,7 @@ if (interval.alwaysInMemory() && op.id() > interval.spillDefinitionPos() && !interval.location().equals(interval.spillSlot())) { assert interval.spillDefinitionPos() > 0 : "position not set correctly"; assert interval.spillSlot() != null : "no spill slot assigned"; - assert !interval.operand.isRegister() : "interval is on stack : so stack slot is registered twice"; + assert !isRegister(interval.operand) : "interval is on stack : so stack slot is registered twice"; frameMap.setReference(interval.spillSlot(), registerRefMap, frameRefMap); } } @@ -1673,7 +1679,7 @@ } private boolean isCallerSave(CiValue operand) { - return attributes(operand.asRegister()).isCallerSave; + return attributes(asRegister(operand)).isCallerSave; } @@ -1720,7 +1726,7 @@ // The operand must be live because debug information is considered when building the intervals // if the interval is not live, colorLirOperand will cause an assert on failure CiValue result = colorLirOperand((CiVariable) operand, tempOpId, mode); - assert !hasCall(tempOpId) || result.isStackSlot() || !isCallerSave(result) : "cannot have caller-save register operands at calls"; + assert !hasCall(tempOpId) || isStackSlot(result) || !isCallerSave(result) : "cannot have caller-save register operands at calls"; return result; } }); @@ -1744,7 +1750,7 @@ int n = op.operandCount(mode); for (int k = 0; k < n; k++) { CiValue operand = op.operandAt(mode, k); - if (operand.isVariable()) { + if (isVariable(operand)) { op.setOperandAt(mode, k, colorLirOperand((CiVariable) operand, op.id(), mode)); } } @@ -1948,7 +1954,7 @@ throw new CiBailout(""); } - if (i1.operand.isVariable() && i1.kind() == CiKind.Illegal) { + if (isVariable(i1.operand) && i1.kind() == CiKind.Illegal) { TTY.println("Interval %d has no type assigned", i1.operandNumber); TTY.println(i1.logString(this)); throw new CiBailout(""); @@ -2043,7 +2049,7 @@ int n = op.operandCount(mode); for (int k = 0; k < n; k++) { CiValue operand = op.operandAt(mode, k); - if (operand.isRegister()) { + if (isRegister(operand)) { if (intervalFor(operand) == interval) { ok = true; break; @@ -2073,7 +2079,7 @@ TTY.println("checking interval %d of block B%d", operandNum, block.blockID()); } CiValue operand = operands.operandFor(operandNum); - assert operand.isVariable() : "value must have variable operand"; + assert isVariable(operand) : "value must have variable operand"; ValueNode value = gen.operands.instructionForResult(((CiVariable) operand)); assert value != null : "all intervals live across block boundaries must have Value"; // TKR assert value.asConstant() == null || value.isPinned() :
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/LinearScanWalker.java Mon Jan 02 14:38:17 2012 -0800 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/LinearScanWalker.java Mon Jan 02 17:39:20 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2012, 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,6 +23,7 @@ package com.oracle.max.graal.compiler.alloc; import static com.sun.cri.ci.CiUtil.*; +import static com.sun.cri.ci.CiValueUtil.*; import java.util.*; @@ -88,7 +89,7 @@ void excludeFromUse(Interval i) { CiValue location = i.location(); - int i1 = location.asRegister().number; + int i1 = asRegister(location).number; if (i1 >= availableRegs[0].number && i1 <= availableRegs[availableRegs.length - 1].number) { usePos[i1] = 0; } @@ -97,7 +98,7 @@ void setUsePos(Interval interval, int usePos, boolean onlyProcessUsePos) { if (usePos != -1) { assert usePos != 0 : "must use excludeFromUse to set usePos to 0"; - int i = interval.location().asRegister().number; + int i = asRegister(interval.location()).number; if (i >= availableRegs[0].number && i <= availableRegs[availableRegs.length - 1].number) { if (this.usePos[i] > usePos) { this.usePos[i] = usePos; @@ -111,7 +112,7 @@ void setBlockPos(Interval i, int blockPos) { if (blockPos != -1) { - int reg = i.location().asRegister().number; + int reg = asRegister(i.location()).number; if (reg >= availableRegs[0].number && reg <= availableRegs[availableRegs.length - 1].number) { if (this.blockPos[reg] > blockPos) { this.blockPos[reg] = blockPos; @@ -126,7 +127,7 @@ void freeExcludeActiveFixed() { Interval interval = activeLists.get(RegisterBinding.Fixed); while (interval != Interval.EndMarker) { - assert interval.location().isRegister() : "active interval must have a register assigned"; + assert isRegister(interval.location()) : "active interval must have a register assigned"; excludeFromUse(interval); interval = interval.next; } @@ -135,7 +136,7 @@ void freeExcludeActiveAny() { Interval interval = activeLists.get(RegisterBinding.Any); while (interval != Interval.EndMarker) { - assert interval.location().isRegister() : "active interval must have a register assigned"; + assert isRegister(interval.location()) : "active interval must have a register assigned"; excludeFromUse(interval); interval = interval.next; } @@ -486,7 +487,7 @@ while (parent != null && parent.isSplitChild()) { parent = parent.getSplitChildBeforeOpId(parent.from()); - if (parent.location().isRegister()) { + if (isRegister(parent.location())) { if (parent.firstUsage(RegisterPriority.ShouldHaveRegister) == Integer.MAX_VALUE) { // parent is never used, so kick it out of its assigned register if (GraalOptions.TraceLinearScanLevel >= 4) { @@ -608,8 +609,8 @@ CiRegister hint = null; Interval locationHint = interval.locationHint(true); - if (locationHint != null && locationHint.location() != null && locationHint.location().isRegister()) { - hint = locationHint.location().asRegister(); + if (locationHint != null && locationHint.location() != null && isRegister(locationHint.location())) { + hint = asRegister(locationHint.location()); if (GraalOptions.TraceLinearScanLevel >= 4) { TTY.println(" hint register %d from interval %s", hint.number, locationHint.logString(allocator)); } @@ -670,7 +671,7 @@ CiRegister findLockedRegister(int regNeededUntil, int intervalTo, CiValue ignoreReg, boolean[] needSplit) { int maxReg = -1; - CiRegister ignore = ignoreReg.isRegister() ? ignoreReg.asRegister() : null; + CiRegister ignore = isRegister(ignoreReg) ? asRegister(ignoreReg) : null; for (CiRegister reg : availableRegs) { int i = reg.number; @@ -738,7 +739,7 @@ assert regNeededUntil > 0 && regNeededUntil < Integer.MAX_VALUE : "interval has no use"; CiRegister reg = null; - CiRegister ignore = interval.location() != null && interval.location().isRegister() ? interval.location().asRegister() : null; + CiRegister ignore = interval.location() != null && isRegister(interval.location()) ? asRegister(interval.location()) : null; for (CiRegister availableReg : availableRegs) { int number = availableReg.number; if (availableReg == ignore) { @@ -833,7 +834,7 @@ CiValue input = op.input(0); CiValue result = op.result(); - return input.isVariable() && result.isVariable() && input == from.operand && result == to.operand; + return isVariable(input) && isVariable(result) && input == from.operand && result == to.operand; } // optimization (especially for phi functions of nested loops): @@ -881,7 +882,7 @@ assert interval.firstUsage(RegisterPriority.MustHaveRegister) == beginPos : "must have use position at begin of interval because of move"; assert endHint.firstUsage(RegisterPriority.MustHaveRegister) == endPos : "must have use position at begin of interval because of move"; - if (beginHint.location().isRegister()) { + if (isRegister(beginHint.location())) { // registerHint is not spilled at beginPos : so it would not be benefitial to immediately spill cur return; } @@ -909,7 +910,7 @@ } final CiValue operand = interval.operand; - if (interval.location() != null && interval.location().isStackSlot()) { + if (interval.location() != null && isStackSlot(interval.location())) { // activating an interval that has a stack slot assigned . split it at first use position // used for method parameters if (GraalOptions.TraceLinearScanLevel >= 4) { @@ -919,7 +920,7 @@ result = false; } else { - if (operand.isVariable() && allocator.operands.mustStartInMemory((CiVariable) operand)) { + if (isVariable(operand) && allocator.operands.mustStartInMemory((CiVariable) operand)) { assert interval.location() == null : "register already assigned"; allocator.assignSpillSlot(interval); @@ -951,7 +952,7 @@ } // spilled intervals need not be move to active-list - if (!interval.location().isRegister()) { + if (!isRegister(interval.location())) { result = false; } }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/MoveResolver.java Mon Jan 02 14:38:17 2012 -0800 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/MoveResolver.java Mon Jan 02 17:39:20 2012 -0800 @@ -22,6 +22,8 @@ */ package com.oracle.max.graal.compiler.alloc; +import static com.sun.cri.ci.CiValueUtil.*; + import java.util.*; import com.oracle.max.criutils.*; @@ -126,7 +128,7 @@ usedRegs.clear(); for (i = 0; i < mappingFrom.size(); i++) { Interval interval = mappingFrom.get(i); - if (interval != null && !interval.location().isRegister()) { + if (interval != null && !isRegister(interval.location())) { usedRegs.add(interval.location()); } } @@ -141,8 +143,8 @@ // mark assignedReg and assignedRegHi of the interval as blocked private void blockRegisters(Interval interval) { CiValue location = interval.location(); - if (location.isRegister()) { - int reg = location.asRegister().number; + if (isRegister(location)) { + int reg = asRegister(location).number; assert multipleReadsAllowed || registerBlocked(reg) == 0 : "register already marked as used"; setRegisterBlocked(reg, 1); } @@ -151,8 +153,8 @@ // mark assignedReg and assignedRegHi of the interval as unblocked private void unblockRegisters(Interval interval) { CiValue location = interval.location(); - if (location.isRegister()) { - int reg = location.asRegister().number; + if (isRegister(location)) { + int reg = asRegister(location).number; assert registerBlocked(reg) > 0 : "register already marked as unused"; setRegisterBlocked(reg, -1); } @@ -166,8 +168,8 @@ CiValue fromReg = from != null ? from.location() : null; CiValue reg = to.location(); - if (reg.isRegister()) { - if (registerBlocked(reg.asRegister().number) > 1 || (registerBlocked(reg.asRegister().number) == 1 && reg != fromReg)) { + if (isRegister(reg)) { + if (registerBlocked(asRegister(reg).number) > 1 || (registerBlocked(asRegister(reg).number) == 1 && reg != fromReg)) { return false; } } @@ -251,7 +253,7 @@ mappingTo.remove(i); processedInterval = true; - } else if (fromInterval != null && fromInterval.location().isRegister()) { + } else if (fromInterval != null && isRegister(fromInterval.location())) { // this interval cannot be processed now because target is not free // it starts in a register, so it is a possible candidate for spilling spillCandidate = i; @@ -339,7 +341,7 @@ if (GraalOptions.TraceLinearScanLevel >= 4) { TTY.println("MoveResolver: adding mapping from %s to %d (%s)", fromOpr, toInterval.operandNumber, toInterval.location()); } - assert fromOpr.isConstant() : "only for constants"; + assert isConstant(fromOpr) : "only for constants"; mappingFrom.add(null); mappingFromOpr.add(fromOpr);
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/OperandPool.java Mon Jan 02 14:38:17 2012 -0800 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/OperandPool.java Mon Jan 02 17:39:20 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2012, 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 @@ -22,6 +22,8 @@ */ package com.oracle.max.graal.compiler.alloc; +import static com.sun.cri.ci.CiValueUtil.*; + import java.util.*; import com.oracle.max.graal.compiler.*; @@ -84,7 +86,7 @@ private BitMap mustStayInMemory; /** - * Flags that can be set for {@linkplain CiValue#isVariable() variable} operands. + * Flags that can be set for {@linkplain CiValue#xxisVariable() variable} operands. */ public enum VariableFlag { /** @@ -195,12 +197,12 @@ * @return the unique number for {@code operand} in the range {@code [0 .. size())} */ public int operandNumber(CiValue operand) { - if (operand.isRegister()) { - int number = operand.asRegister().number; + if (isRegister(operand)) { + int number = asRegister(operand).number; assert number < firstVariableNumber; return number; } - assert operand.isVariable() : operand; + assert isVariable(operand) : operand; return firstVariableNumber + ((CiVariable) operand).index; }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/RegisterVerifier.java Mon Jan 02 14:38:17 2012 -0800 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/RegisterVerifier.java Mon Jan 02 17:39:20 2012 -0800 @@ -22,6 +22,8 @@ */ package com.oracle.max.graal.compiler.alloc; +import static com.sun.cri.ci.CiValueUtil.*; + import java.util.*; import com.oracle.max.criutils.*; @@ -80,10 +82,10 @@ CiCallingConvention args = allocator.gen.incomingArguments; for (int n = 0; n < args.locations.length; n++) { CiValue operand = args.locations[n]; - if (operand.isRegister()) { + if (isRegister(operand)) { CiValue reg = operand; Interval interval = intervalAt(reg); - inputState[reg.asRegister().number] = interval; + inputState[asRegister(reg).number] = interval; } } @@ -187,8 +189,8 @@ } static void statePut(Interval[] inputState, CiValue location, Interval interval) { - if (location != null && location.isRegister()) { - CiRegister reg = location.asRegister(); + if (location != null && isRegister(location)) { + CiRegister reg = asRegister(location); int regNum = reg.number; if (interval != null) { if (GraalOptions.TraceLinearScanLevel >= 4) { @@ -205,9 +207,9 @@ } static boolean checkState(Interval[] inputState, CiValue reg, Interval interval) { - if (reg != null && reg.isRegister()) { - if (inputState[reg.asRegister().number] != interval) { - throw new CiBailout("!! Error in register allocation: register " + reg + " does not contain interval " + interval.operand + " but interval " + inputState[reg.asRegister().number]); + if (reg != null && isRegister(reg)) { + if (inputState[asRegister(reg).number] != interval) { + throw new CiBailout("!! Error in register allocation: register " + reg + " does not contain interval " + interval.operand + " but interval " + inputState[asRegister(reg).number]); } } return true; @@ -226,7 +228,7 @@ int n = op.operandCount(LIRInstruction.OperandMode.Input); for (int j = 0; j < n; j++) { CiValue operand = op.operandAt(LIRInstruction.OperandMode.Input, j); - if (operand.isVariableOrRegister() && allocator.isProcessed(operand)) { + if (LinearScan.isVariableOrRegister(operand) && allocator.isProcessed(operand)) { Interval interval = intervalAt(operand); if (op.id() != -1) { interval = interval.getSplitChildAtOpId(op.id(), LIRInstruction.OperandMode.Input, allocator); @@ -238,7 +240,7 @@ n = op.operandCount(LIRInstruction.OperandMode.Alive); for (int j = 0; j < n; j++) { CiValue operand = op.operandAt(LIRInstruction.OperandMode.Alive, j); - if (operand.isVariableOrRegister() && allocator.isProcessed(operand)) { + if (LinearScan.isVariableOrRegister(operand) && allocator.isProcessed(operand)) { Interval interval = intervalAt(operand); if (op.id() != -1) { interval = interval.getSplitChildAtOpId(op.id(), LIRInstruction.OperandMode.Input, allocator); @@ -259,7 +261,7 @@ n = op.operandCount(LIRInstruction.OperandMode.Temp); for (int j = 0; j < n; j++) { CiValue operand = op.operandAt(LIRInstruction.OperandMode.Temp, j); - if (operand.isVariableOrRegister() && allocator.isProcessed(operand)) { + if (LinearScan.isVariableOrRegister(operand) && allocator.isProcessed(operand)) { Interval interval = intervalAt(operand); assert interval != null : "Could not find interval for operand " + operand; if (op.id() != -1) { @@ -274,7 +276,7 @@ n = op.operandCount(LIRInstruction.OperandMode.Output); for (int j = 0; j < n; j++) { CiValue operand = op.operandAt(LIRInstruction.OperandMode.Output, j); - if (operand.isVariableOrRegister() && allocator.isProcessed(operand)) { + if (LinearScan.isVariableOrRegister(operand) && allocator.isProcessed(operand)) { Interval interval = intervalAt(operand); if (op.id() != -1) { interval = interval.getSplitChildAtOpId(op.id(), LIRInstruction.OperandMode.Output, allocator);
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/asm/TargetMethodAssembler.java Mon Jan 02 14:38:17 2012 -0800 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/asm/TargetMethodAssembler.java Mon Jan 02 17:39:20 2012 -0800 @@ -22,6 +22,8 @@ */ package com.oracle.max.graal.compiler.asm; +import static com.sun.cri.ci.CiValueUtil.*; + import java.util.*; import com.oracle.max.asm.*; @@ -186,42 +188,12 @@ } - public CiRegister asIntReg(CiValue value) { - assert value.kind == CiKind.Int || value.kind == CiKind.Jsr; - return asRegister(value); - } - - public CiRegister asLongReg(CiValue value) { - assert value.kind == CiKind.Long : value.kind; - return asRegister(value); - } - - public CiRegister asObjectReg(CiValue value) { - assert value.kind == CiKind.Object; - return asRegister(value); - } - - public CiRegister asFloatReg(CiValue value) { - assert value.kind == CiKind.Float; - return asRegister(value); - } - - public CiRegister asDoubleReg(CiValue value) { - assert value.kind == CiKind.Double; - return asRegister(value); - } - - public CiRegister asRegister(CiValue value) { - assert value.isRegister(); - return value.asRegister(); - } - /** * Returns the integer value of any constants that can be represented by a 32-bit integer value, * including long constants that fit into the 32-bit range. */ public int asIntConst(CiValue value) { - assert (value.kind.stackKind() == CiKind.Int || value.kind == CiKind.Jsr || value.kind == CiKind.Long) && value.isConstant(); + assert (value.kind.stackKind() == CiKind.Int || value.kind == CiKind.Jsr || value.kind == CiKind.Long) && isConstant(value); long c = ((CiConstant) value).asLong(); if (!(NumUtil.isInt(c))) { throw Util.shouldNotReachHere(); @@ -237,7 +209,7 @@ } public CiAddress asFloatConstRef(CiValue value, int alignment) { - assert value.kind == CiKind.Float && value.isConstant(); + assert value.kind == CiKind.Float && isConstant(value); return recordDataReferenceInCode((CiConstant) value, alignment); } @@ -249,12 +221,12 @@ } public CiAddress asDoubleConstRef(CiValue value, int alignment) { - assert value.kind == CiKind.Double && value.isConstant(); + assert value.kind == CiKind.Double && isConstant(value); return recordDataReferenceInCode((CiConstant) value, alignment); } public CiAddress asAddress(CiValue value) { - if (value.isStackSlot()) { + if (isStackSlot(value)) { CiStackSlot slot = (CiStackSlot) value; return new CiAddress(slot.kind, compilation.registerConfig.getFrameRegister().asValue(), compilation.frameMap().offsetForStackSlot(slot)); }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/CFGPrinter.java Mon Jan 02 14:38:17 2012 -0800 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/CFGPrinter.java Mon Jan 02 17:39:20 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2012, 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 @@ -22,6 +22,8 @@ */ package com.oracle.max.graal.compiler.debug; +import static com.sun.cri.ci.CiValueUtil.*; + import java.io.*; import java.util.*; @@ -443,8 +445,8 @@ } private void printInterval(Interval interval) { - out.printf("%s %s ", interval.operand, (interval.operand.isRegister() ? "fixed" : interval.kind().name())); - if (interval.operand.isRegister()) { + out.printf("%s %s ", interval.operand, (isRegister(interval.operand) ? "fixed" : interval.kind().name())); + if (isRegister(interval.operand)) { out.printf("\"[%s|%c]\"", interval.operand, interval.operand.kind.typeChar); } else { if (interval.location() != null) {
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/LIRGenerator.java Mon Jan 02 14:38:17 2012 -0800 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/LIRGenerator.java Mon Jan 02 17:39:20 2012 -0800 @@ -119,11 +119,11 @@ @Override public CiValue setResult(ValueNode x, CiValue operand) { - assert (operand.isVariable() && x.kind() == operand.kind) || (operand.isConstant() && x.kind() == operand.kind.stackKind()) : operand.kind + " for node " + x; + assert (isVariable(operand) && x.kind() == operand.kind) || (isConstant(operand) && x.kind() == operand.kind.stackKind()) : operand.kind + " for node " + x; compilation.setOperand(x, operand); if (GraalOptions.DetailedAsserts) { - if (operand.isVariable()) { + if (isVariable(operand)) { operands.recordResult((CiVariable) operand, x); } } @@ -132,21 +132,21 @@ public CiVariable load(CiValue value) { - if (!value.isVariable()) { + if (!isVariable(value)) { return emitMove(value); } return (CiVariable) value; } public CiValue loadNonConst(CiValue value) { - if (value.isConstant() && !canInlineConstant((CiConstant) value)) { + if (isConstant(value) && !canInlineConstant((CiConstant) value)) { return emitMove(value); } return value; } public CiValue loadForStore(CiValue value, CiKind storeKind) { - if (value.isConstant() && canStoreConstant((CiConstant) value)) { + if (isConstant(value) && canStoreConstant((CiConstant) value)) { return value; } if (storeKind == CiKind.Byte || storeKind == CiKind.Boolean) { @@ -771,7 +771,7 @@ append(StandardOpcode.INDIRECT_CALL.create(target, resultOperand, argList, destinationAddress, callInfo, snippet.marks)); } - if (resultOperand.isLegal()) { + if (isLegal(resultOperand)) { setResult(x.node(), emitMove(resultOperand)); } } @@ -845,7 +845,7 @@ append(StandardOpcode.DIRECT_CALL.create(runtimeCall, physReg, argumentList, null, info, null)); - if (physReg.isLegal()) { + if (isLegal(physReg)) { return emitMove(physReg); } else { return null; @@ -874,7 +874,7 @@ append(StandardOpcode.DIRECT_CALL.create(x.call(), resultOperand, argList, null, info, null)); - if (resultOperand.isLegal()) { + if (isLegal(resultOperand)) { setResult(x, emitMove(resultOperand)); } } @@ -1170,11 +1170,11 @@ } CiValue allocatedResultOperand = operandsArray[resultOperand.index]; - if (!allocatedResultOperand.isVariableOrRegister()) { + if (!isVariable(allocatedResultOperand) && !isRegister(allocatedResultOperand)) { allocatedResultOperand = IllegalValue; } - if (setInstructionResult && allocatedResultOperand.isLegal()) { + if (setInstructionResult && isLegal(allocatedResultOperand)) { CiValue operand = compilation.operand(instruction); if (operand == null) { setResult(instruction, allocatedResultOperand); @@ -1185,7 +1185,7 @@ XirInstruction[] slowPath = snippet.template.slowPath; - if (!operandsArray[resultOperand.index].isConstant() || snippet.template.fastPath.length != 0 || (slowPath != null && slowPath.length > 0)) { + if (!isConstant(operandsArray[resultOperand.index]) || snippet.template.fastPath.length != 0 || (slowPath != null && slowPath.length > 0)) { // XIR instruction is only needed when the operand is not a constant! append(StandardOpcode.XIR.create(snippet, operandsArray, allocatedResultOperand, inputOperandArray, tempOperandArray, inputOperandIndicesArray, tempOperandIndicesArray,
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/PhiResolver.java Mon Jan 02 14:38:17 2012 -0800 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/PhiResolver.java Mon Jan 02 17:39:20 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2012, 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,6 +23,7 @@ package com.oracle.max.graal.compiler.gen; import static com.sun.cri.ci.CiValue.*; +import static com.sun.cri.ci.CiValueUtil.*; import java.util.*; @@ -127,7 +128,7 @@ loop = null; move(null, node); node.startNode = true; - assert temp.isIllegal() : "moveTempTo() call missing"; + assert isIllegal(temp) : "moveTempTo() call missing"; } } @@ -141,10 +142,10 @@ } public void move(CiValue src, CiValue dest) { - assert dest.isVariable() : "destination must be virtual"; + assert isVariable(dest) : "destination must be virtual"; // tty.print("move "); src.print(); tty.print(" to "); dest.print(); tty.cr(); - assert src.isLegal() : "source for phi move is illegal"; - assert dest.isLegal() : "destination for phi move is illegal"; + assert isLegal(src) : "source for phi move is illegal"; + assert isLegal(dest) : "destination for phi move is illegal"; PhiResolverNode srcNode = sourceNode(src); PhiResolverNode destNode = destinationNode(dest); srcNode.destinations.add(destNode); @@ -152,7 +153,7 @@ private PhiResolverNode createNode(CiValue operand, boolean source) { PhiResolverNode node; - if (operand.isVariable()) { + if (isVariable(operand)) { node = operandToNodeMap.get(operand); assert node == null || node.operand.equals(operand); if (node == null) { @@ -179,8 +180,8 @@ } private void emitMove(CiValue src, CiValue dest) { - assert src.isLegal(); - assert dest.isLegal(); + assert isLegal(src); + assert isLegal(dest); gen.emitMove(src, dest); } @@ -217,13 +218,13 @@ } private void moveTempTo(CiValue dest) { - assert temp.isLegal(); + assert isLegal(temp); emitMove(temp, dest); temp = IllegalValue; } private void moveToTemp(CiValue src) { - assert temp.isIllegal(); + assert isIllegal(temp); temp = gen.newVariable(src.kind); emitMove(src, temp); }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/LIRCall.java Mon Jan 02 14:38:17 2012 -0800 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/LIRCall.java Mon Jan 02 17:39:20 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2012, 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 @@ -22,6 +22,8 @@ */ package com.oracle.max.graal.compiler.lir; +import static com.sun.cri.ci.CiValueUtil.*; + import java.util.*; import com.sun.cri.ci.*; @@ -93,7 +95,7 @@ @Override public String operationString() { StringBuilder buf = new StringBuilder(); - if (result.isLegal()) { + if (isLegal(result)) { buf.append(result).append(" = "); } if (targetAddressIndex >= 0) {
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/LIRInstruction.java Mon Jan 02 14:38:17 2012 -0800 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/LIRInstruction.java Mon Jan 02 17:39:20 2012 -0800 @@ -22,6 +22,8 @@ */ package com.oracle.max.graal.compiler.lir; +import static com.sun.cri.ci.CiValueUtil.*; + import com.oracle.max.graal.compiler.asm.*; import com.oracle.max.graal.compiler.util.*; import com.sun.cri.ci.*; @@ -199,7 +201,7 @@ public final int operandCount(OperandMode mode) { switch (mode) { - case Output: return result.isLegal() ? 1 : 0; + case Output: return isLegal(result) ? 1 : 0; case Input: return inputs.length; case Alive: return alives.length; case Temp: return temps.length; @@ -307,7 +309,7 @@ */ public String operationString() { StringBuilder buf = new StringBuilder(); - if (result.isLegal()) { + if (isLegal(result)) { buf.append(result).append(" = "); } if (inputs.length + alives.length > 1) {
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/LIRXirInstruction.java Mon Jan 02 14:38:17 2012 -0800 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/LIRXirInstruction.java Mon Jan 02 17:39:20 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2012, 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 @@ -22,6 +22,8 @@ */ package com.oracle.max.graal.compiler.lir; +import static com.sun.cri.ci.CiValueUtil.*; + import java.util.*; import com.sun.cri.ci.*; @@ -106,7 +108,7 @@ StringBuilder sb = new StringBuilder(); sb.append("XIR: "); - if (result().isLegal()) { + if (isLegal(result())) { sb.append(result() + " = "); }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64ArithmeticOpcode.java Mon Jan 02 14:38:17 2012 -0800 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64ArithmeticOpcode.java Mon Jan 02 17:39:20 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2012, 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 @@ -22,6 +22,8 @@ */ package com.oracle.max.graal.compiler.target.amd64; +import static com.sun.cri.ci.CiValueUtil.*; + import com.oracle.max.asm.target.amd64.*; import com.oracle.max.graal.compiler.asm.*; import com.oracle.max.graal.compiler.lir.*; @@ -46,7 +48,7 @@ return new AMD64LIRInstruction(this, result, null, inputs, alives, LIRInstruction.NO_OPERANDS) { @Override public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - assert !(alive(0) instanceof CiRegisterValue) || tasm.asRegister(result()) != tasm.asRegister(alive(0)) : "result and right must be different registers"; + assert !(alive(0) instanceof CiRegisterValue) || asRegister(result()) != asRegister(alive(0)) : "result and right must be different registers"; AMD64MoveOpcode.move(tasm, masm, result(), input(0)); emit(tasm, masm, result(), alive(0)); } @@ -64,9 +66,9 @@ } protected void emit(TargetMethodAssembler tasm, AMD64MacroAssembler masm, CiValue leftAndResult, CiValue right) { - CiRegister dst = tasm.asRegister(leftAndResult); - if (right.isRegister()) { - CiRegister rreg = tasm.asRegister(right); + CiRegister dst = asRegister(leftAndResult); + if (isRegister(right)) { + CiRegister rreg = asRegister(right); switch (this) { case IADD: masm.addl(dst, rreg); break; case ISUB: masm.subl(dst, rreg); break; @@ -88,7 +90,7 @@ case DDIV: masm.divsd(dst, rreg); break; default: throw Util.shouldNotReachHere(); } - } else if (right.isConstant()) { + } else if (isConstant(right)) { switch (this) { case IADD: masm.incrementl(dst, tasm.asIntConst(right)); break; case ISUB: masm.decrementl(dst, tasm.asIntConst(right)); break;
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64CallOpcode.java Mon Jan 02 14:38:17 2012 -0800 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64CallOpcode.java Mon Jan 02 17:39:20 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2012, 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 @@ -22,6 +22,8 @@ */ package com.oracle.max.graal.compiler.target.amd64; +import static com.sun.cri.ci.CiValueUtil.*; + import java.util.*; import com.oracle.max.asm.target.amd64.*; @@ -66,12 +68,12 @@ if (op.marks != null) { op.marks.put(XirMark.CALLSITE, tasm.recordMark(null, new Mark[0])); } - CiRegister reg = tasm.asRegister(op.targetAddress()); + CiRegister reg = asRegister(op.targetAddress()); indirectCall(tasm, masm, reg, op.target, op.info); break; } case NATIVE_CALL: { - CiRegister reg = tasm.asRegister(op.targetAddress()); + CiRegister reg = asRegister(op.targetAddress()); indirectCall(tasm, masm, reg, op.target, op.info); break; } @@ -101,7 +103,7 @@ directCall(tasm, masm, stub.stubObject, info); - if (result.isLegal()) { + if (isLegal(result)) { AMD64MoveOpcode.move(tasm, masm, result, stub.outResult.asOutArg()); }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64CompareOpcode.java Mon Jan 02 14:38:17 2012 -0800 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64CompareOpcode.java Mon Jan 02 17:39:20 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2012, 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 @@ -22,6 +22,8 @@ */ package com.oracle.max.graal.compiler.target.amd64; +import static com.sun.cri.ci.CiValueUtil.*; + import com.oracle.max.asm.target.amd64.*; import com.oracle.max.graal.compiler.asm.*; import com.oracle.max.graal.compiler.lir.*; @@ -54,9 +56,9 @@ } protected void emit(TargetMethodAssembler tasm, AMD64MacroAssembler masm, CiValue left, CiValue right) { - CiRegister lreg = tasm.asRegister(left); - if (right.isRegister()) { - CiRegister rreg = tasm.asRegister(right); + CiRegister lreg = asRegister(left); + if (isRegister(right)) { + CiRegister rreg = asRegister(right); switch (this) { case ICMP: masm.cmpl(lreg, rreg); break; case LCMP: masm.cmpq(lreg, rreg); break; @@ -65,7 +67,7 @@ case DCMP: masm.ucomisd(lreg, rreg); break; default: throw Util.shouldNotReachHere(); } - } else if (right.isConstant()) { + } else if (isConstant(right)) { switch (this) { case ICMP: masm.cmpl(lreg, tasm.asIntConst(right)); break; case LCMP: masm.cmpq(lreg, tasm.asIntConst(right)); break;
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64CompareToIntOpcode.java Mon Jan 02 14:38:17 2012 -0800 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64CompareToIntOpcode.java Mon Jan 02 17:39:20 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2012, 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 @@ -22,6 +22,8 @@ */ package com.oracle.max.graal.compiler.target.amd64; +import static com.sun.cri.ci.CiValueUtil.*; + import com.oracle.max.asm.*; import com.oracle.max.asm.target.amd64.AMD64Assembler.ConditionFlag; import com.oracle.max.asm.target.amd64.*; @@ -42,13 +44,13 @@ return new AMD64LIRInstruction(this, result, null, LIRInstruction.NO_OPERANDS, LIRInstruction.NO_OPERANDS, LIRInstruction.NO_OPERANDS) { @Override public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - emit(tasm, masm, result()); + emit(masm, result()); } }; } - private void emit(TargetMethodAssembler tasm, AMD64MacroAssembler masm, CiValue result) { - CiRegister dest = tasm.asIntReg(result); + private void emit(AMD64MacroAssembler masm, CiValue result) { + CiRegister dest = asIntReg(result); Label high = new Label(); Label low = new Label(); Label done = new Label();
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64CompilerStubEmitter.java Mon Jan 02 14:38:17 2012 -0800 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64CompilerStubEmitter.java Mon Jan 02 17:39:20 2012 -0800 @@ -23,6 +23,7 @@ package com.oracle.max.graal.compiler.target.amd64; import static com.sun.cri.ci.CiCallingConvention.Type.*; +import static com.sun.cri.ci.CiValueUtil.*; import java.util.*; @@ -151,8 +152,8 @@ for (XirTemp t : template.temps) { if (t instanceof XirRegister) { final XirRegister fixed = (XirRegister) t; - if (fixed.register.isRegister()) { - allocatableRegisters.remove(fixed.register.asRegister()); + if (isRegister(fixed.register)) { + allocatableRegisters.remove(asRegister(fixed.register)); } } } @@ -323,7 +324,7 @@ CiCallingConvention cc = comp.registerConfig.getCallingConvention(RuntimeCall, call.arguments, comp.compiler.target, false); for (int i = 0; i < cc.locations.length; ++i) { CiValue location = cc.locations[i]; - asm.movq(location.asRegister(), tasm.asAddress(inArgs[i])); + asm.movq(asRegister(location), tasm.asAddress(inArgs[i])); } if (GraalOptions.AlignCallsForPatching) {
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64ControlFlowOpcode.java Mon Jan 02 14:38:17 2012 -0800 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64ControlFlowOpcode.java Mon Jan 02 17:39:20 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2012, 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 @@ -22,6 +22,8 @@ */ package com.oracle.max.graal.compiler.target.amd64; +import static com.sun.cri.ci.CiValueUtil.*; + import com.oracle.max.asm.*; import com.oracle.max.asm.target.amd64.*; import com.oracle.max.asm.target.amd64.AMD64Assembler.ConditionFlag; @@ -142,7 +144,7 @@ return new AMD64LIRInstruction(this, CiValue.IllegalValue, null, LIRInstruction.NO_OPERANDS, alives, temps) { @Override public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - tableswitch(tasm, masm, lowKey, defaultTarget, targets, tasm.asIntReg(alive(0)), tasm.asLongReg(temp(0))); + tableswitch(tasm, masm, lowKey, defaultTarget, targets, asIntReg(alive(0)), asLongReg(temp(0))); } @Override @@ -295,17 +297,17 @@ } private static void cmove(TargetMethodAssembler tasm, AMD64MacroAssembler masm, CiValue result, ConditionFlag cond, CiValue other) { - if (other.isRegister()) { - assert tasm.asRegister(other) != tasm.asRegister(result) : "other already overwritten by previous move"; + if (isRegister(other)) { + assert asRegister(other) != asRegister(result) : "other already overwritten by previous move"; switch (other.kind) { - case Int: masm.cmovl(cond, tasm.asRegister(result), tasm.asRegister(other)); break; - case Long: masm.cmovq(cond, tasm.asRegister(result), tasm.asRegister(other)); break; + case Int: masm.cmovl(cond, asRegister(result), asRegister(other)); break; + case Long: masm.cmovq(cond, asRegister(result), asRegister(other)); break; default: throw Util.shouldNotReachHere(); } } else { switch (other.kind) { - case Int: masm.cmovl(cond, tasm.asRegister(result), tasm.asAddress(other)); break; - case Long: masm.cmovq(cond, tasm.asRegister(result), tasm.asAddress(other)); break; + case Int: masm.cmovl(cond, asRegister(result), tasm.asAddress(other)); break; + case Long: masm.cmovq(cond, asRegister(result), tasm.asAddress(other)); break; default: throw Util.shouldNotReachHere(); } }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64ConvertFIOpcode.java Mon Jan 02 14:38:17 2012 -0800 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64ConvertFIOpcode.java Mon Jan 02 17:39:20 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2012, 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 @@ -22,6 +22,8 @@ */ package com.oracle.max.graal.compiler.target.amd64; +import static com.sun.cri.ci.CiValueUtil.*; + import com.oracle.max.asm.*; import com.oracle.max.asm.target.amd64.AMD64Assembler.ConditionFlag; import com.oracle.max.asm.target.amd64.*; @@ -47,13 +49,13 @@ private void emit(TargetMethodAssembler tasm, AMD64MacroAssembler masm, CiValue result, CompilerStub stub, CiValue input) { switch (this) { - case F2I: masm.cvttss2sil(tasm.asIntReg(result), tasm.asFloatReg(input)); break; - case D2I: masm.cvttsd2sil(tasm.asIntReg(result), tasm.asDoubleReg(input)); break; + case F2I: masm.cvttss2sil(asIntReg(result), asFloatReg(input)); break; + case D2I: masm.cvttsd2sil(asIntReg(result), asDoubleReg(input)); break; default: throw Util.shouldNotReachHere(); } Label endLabel = new Label(); - masm.cmp32(tasm.asIntReg(result), Integer.MIN_VALUE); + masm.cmp32(asIntReg(result), Integer.MIN_VALUE); masm.jcc(ConditionFlag.notEqual, endLabel); AMD64CallOpcode.callStub(tasm, masm, stub, null, result, input); masm.bind(endLabel);
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64ConvertFLOpcode.java Mon Jan 02 14:38:17 2012 -0800 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64ConvertFLOpcode.java Mon Jan 02 17:39:20 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2012, 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 @@ -22,6 +22,8 @@ */ package com.oracle.max.graal.compiler.target.amd64; +import static com.sun.cri.ci.CiValueUtil.*; + import com.oracle.max.asm.*; import com.oracle.max.asm.target.amd64.AMD64Assembler.ConditionFlag; import com.oracle.max.asm.target.amd64.*; @@ -47,11 +49,11 @@ } private void emit(TargetMethodAssembler tasm, AMD64MacroAssembler masm, CiValue result, CompilerStub stub, CiValue input, CiValue scratch) { - CiRegister dst = tasm.asLongReg(result); - CiRegister tmp = tasm.asLongReg(scratch); + CiRegister dst = asLongReg(result); + CiRegister tmp = asLongReg(scratch); switch (this) { - case F2L: masm.cvttss2siq(dst, tasm.asFloatReg(input)); break; - case D2L: masm.cvttsd2siq(dst, tasm.asDoubleReg(input)); break; + case F2L: masm.cvttss2siq(dst, asFloatReg(input)); break; + case D2L: masm.cvttsd2siq(dst, asDoubleReg(input)); break; default: throw Util.shouldNotReachHere(); }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64ConvertOpcode.java Mon Jan 02 14:38:17 2012 -0800 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64ConvertOpcode.java Mon Jan 02 17:39:20 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2012, 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 @@ -22,6 +22,8 @@ */ package com.oracle.max.graal.compiler.target.amd64; +import static com.sun.cri.ci.CiValueUtil.*; + import com.oracle.max.asm.target.amd64.*; import com.oracle.max.graal.compiler.asm.*; import com.oracle.max.graal.compiler.lir.*; @@ -55,31 +57,31 @@ switch (this) { case L2I: AMD64MoveOpcode.move(tasm, masm, result, input); - masm.andl(tasm.asIntReg(result), 0xFFFFFFFF); + masm.andl(asIntReg(result), 0xFFFFFFFF); break; case I2B: AMD64MoveOpcode.move(tasm, masm, result, input); - masm.signExtendByte(tasm.asIntReg(result)); + masm.signExtendByte(asIntReg(result)); break; case I2C: AMD64MoveOpcode.move(tasm, masm, result, input); - masm.andl(tasm.asIntReg(result), 0xFFFF); + masm.andl(asIntReg(result), 0xFFFF); break; case I2S: AMD64MoveOpcode.move(tasm, masm, result, input); - masm.signExtendShort(tasm.asIntReg(result)); + masm.signExtendShort(asIntReg(result)); break; - case I2L: masm.movslq(tasm.asLongReg(result), tasm.asIntReg(input)); break; - case F2D: masm.cvtss2sd(tasm.asDoubleReg(result), tasm.asFloatReg(input)); break; - case D2F: masm.cvtsd2ss(tasm.asFloatReg(result), tasm.asDoubleReg(input)); break; - case I2F: masm.cvtsi2ssl(tasm.asFloatReg(result), tasm.asIntReg(input)); break; - case I2D: masm.cvtsi2sdl(tasm.asDoubleReg(result), tasm.asIntReg(input)); break; - case L2F: masm.cvtsi2ssq(tasm.asFloatReg(result), tasm.asLongReg(input)); break; - case L2D: masm.cvtsi2sdq(tasm.asDoubleReg(result), tasm.asLongReg(input)); break; - case MOV_I2F: masm.movdl(tasm.asFloatReg(result), tasm.asIntReg(input)); break; - case MOV_L2D: masm.movdq(tasm.asDoubleReg(result), tasm.asLongReg(input)); break; - case MOV_F2I: masm.movdl(tasm.asIntReg(result), tasm.asFloatReg(input)); break; - case MOV_D2L: masm.movdq(tasm.asLongReg(result), tasm.asDoubleReg(input)); break; + case I2L: masm.movslq(asLongReg(result), asIntReg(input)); break; + case F2D: masm.cvtss2sd(asDoubleReg(result), asFloatReg(input)); break; + case D2F: masm.cvtsd2ss(asFloatReg(result), asDoubleReg(input)); break; + case I2F: masm.cvtsi2ssl(asFloatReg(result), asIntReg(input)); break; + case I2D: masm.cvtsi2sdl(asDoubleReg(result), asIntReg(input)); break; + case L2F: masm.cvtsi2ssq(asFloatReg(result), asLongReg(input)); break; + case L2D: masm.cvtsi2sdq(asDoubleReg(result), asLongReg(input)); break; + case MOV_I2F: masm.movdl(asFloatReg(result), asIntReg(input)); break; + case MOV_L2D: masm.movdq(asDoubleReg(result), asLongReg(input)); break; + case MOV_F2I: masm.movdl(asIntReg(result), asFloatReg(input)); break; + case MOV_D2L: masm.movdq(asLongReg(result), asDoubleReg(input)); break; default: throw Util.shouldNotReachHere(); } }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64DivOpcode.java Mon Jan 02 14:38:17 2012 -0800 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64DivOpcode.java Mon Jan 02 17:39:20 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2012, 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 @@ -22,6 +22,8 @@ */ package com.oracle.max.graal.compiler.target.amd64; +import static com.sun.cri.ci.CiValueUtil.*; + import com.oracle.max.asm.*; import com.oracle.max.asm.target.amd64.*; import com.oracle.max.asm.target.amd64.AMD64Assembler.ConditionFlag; @@ -42,7 +44,7 @@ return new AMD64LIRInstruction(this, result, info, inputs, alives, temps) { @Override public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - emit(tasm, masm, tasm.asRegister(result()), info, tasm.asRegister(input(0)), tasm.asRegister(alive(0))); + emit(tasm, masm, asRegister(result()), info, asRegister(input(0)), asRegister(alive(0))); } }; }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64LIRGenerator.java Mon Jan 02 14:38:17 2012 -0800 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64LIRGenerator.java Mon Jan 02 17:39:20 2012 -0800 @@ -35,6 +35,7 @@ import static com.oracle.max.graal.compiler.target.amd64.AMD64Op1Opcode.*; import static com.oracle.max.graal.compiler.target.amd64.AMD64ShiftOpcode.*; import static com.oracle.max.graal.compiler.target.amd64.AMD64StandardOpcode.*; +import static com.sun.cri.ci.CiValueUtil.*; import com.oracle.max.asm.*; import com.oracle.max.asm.target.amd64.*; @@ -400,7 +401,7 @@ } private CiValue loadShiftCount(CiValue value) { - if (value.isConstant()) { + if (isConstant(value)) { return value; } // Non-constant shift count must be in RCX
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64LogicFloatOpcode.java Mon Jan 02 14:38:17 2012 -0800 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64LogicFloatOpcode.java Mon Jan 02 17:39:20 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2012, 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 @@ -22,6 +22,8 @@ */ package com.oracle.max.graal.compiler.target.amd64; +import static com.sun.cri.ci.CiValueUtil.*; + import com.oracle.max.asm.target.amd64.*; import com.oracle.max.graal.compiler.asm.*; import com.oracle.max.graal.compiler.lir.*; @@ -42,7 +44,7 @@ return new AMD64LIRInstruction(this, result, null, inputs, alives, LIRInstruction.NO_OPERANDS) { @Override public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - assert !(alive(0) instanceof CiRegisterValue) || tasm.asRegister(result()) != tasm.asRegister(alive(0)) : "result and right must be different registers"; + assert !(alive(0) instanceof CiRegisterValue) || asRegister(result()) != asRegister(alive(0)) : "result and right must be different registers"; AMD64MoveOpcode.move(tasm, masm, result(), input(0)); emit(tasm, masm, result(), alive(0)); } @@ -60,9 +62,9 @@ } protected void emit(TargetMethodAssembler tasm, AMD64MacroAssembler masm, CiValue leftAndResult, CiValue right) { - CiRegister dst = tasm.asRegister(leftAndResult); - if (right.isRegister()) { - CiRegister rreg = tasm.asRegister(right); + CiRegister dst = asRegister(leftAndResult); + if (isRegister(right)) { + CiRegister rreg = asRegister(right); switch (this) { case FAND: masm.andps(dst, rreg); break; case FOR: masm.orps(dst, rreg); break; @@ -72,7 +74,7 @@ case DXOR: masm.xorpd(dst, rreg); break; default: throw Util.shouldNotReachHere(); } - } else if (right.isConstant()) { + } else if (isConstant(right)) { switch (this) { case FAND: masm.andps(dst, tasm.asFloatConstRef(right, 16)); break; case FOR: masm.orps(dst, tasm.asFloatConstRef(right, 16)); break;
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64MoveOpcode.java Mon Jan 02 14:38:17 2012 -0800 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64MoveOpcode.java Mon Jan 02 17:39:20 2012 -0800 @@ -22,6 +22,7 @@ */ package com.oracle.max.graal.compiler.target.amd64; +import static com.sun.cri.ci.CiValueUtil.*; import static java.lang.Double.*; import static java.lang.Float.*; @@ -38,7 +39,6 @@ @Override public LIRInstruction create(CiValue result, CiValue input) { - assert !result.isAddress() && !input.isAddress(); assert result.kind == result.kind.stackKind() && result.kind != CiKind.Illegal; CiValue[] inputs = new CiValue[] {input}; @@ -98,7 +98,7 @@ return new AMD64LIRInstruction(this, result, null, inputs, LIRInstruction.NO_OPERANDS, LIRInstruction.NO_OPERANDS) { @Override public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - masm.leaq(tasm.asLongReg(result()), new CiAddress(CiKind.Illegal, input(0), input(1), addrScale, addrDisplacement)); + masm.leaq(asLongReg(result()), new CiAddress(CiKind.Illegal, input(0), input(1), addrScale, addrDisplacement)); } }; } @@ -116,7 +116,7 @@ return new AMD64LIRInstruction(this, result, null, LIRInstruction.NO_OPERANDS, LIRInstruction.NO_OPERANDS, LIRInstruction.NO_OPERANDS) { @Override public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - masm.leaq(tasm.asRegister(result()), tasm.asAddress(stackBlock)); + masm.leaq(asRegister(result()), tasm.asAddress(stackBlock)); } }; } @@ -148,7 +148,7 @@ @Override public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { tasm.recordImplicitException(masm.codeBuffer.position(), info); - masm.nullCheck(tasm.asRegister(input(0))); + masm.nullCheck(asRegister(input(0))); } }; } @@ -172,26 +172,26 @@ protected static void move(TargetMethodAssembler tasm, AMD64MacroAssembler masm, CiValue result, CiValue input) { - if (input.isRegister()) { - if (result.isRegister()) { - reg2reg(tasm, masm, result, input); - } else if (result.isStackSlot()) { + if (isRegister(input)) { + if (isRegister(result)) { + reg2reg(masm, result, input); + } else if (isStackSlot(result)) { reg2stack(tasm, masm, result, input); } else { throw Util.shouldNotReachHere(); } - } else if (input.isStackSlot()) { - if (result.isRegister()) { + } else if (isStackSlot(input)) { + if (isRegister(result)) { stack2reg(tasm, masm, result, input); - } else if (result.isStackSlot()) { + } else if (isStackSlot(result)) { stack2stack(tasm, masm, result, input); } else { throw Util.shouldNotReachHere(); } - } else if (input.isConstant()) { - if (result.isRegister()) { + } else if (isConstant(input)) { + if (isRegister(result)) { const2reg(tasm, masm, result, (CiConstant) input); - } else if (result.isStackSlot()) { + } else if (isStackSlot(result)) { const2stack(tasm, masm, result, (CiConstant) input); } else { throw Util.shouldNotReachHere(); @@ -201,17 +201,17 @@ } } - private static void reg2reg(TargetMethodAssembler tasm, AMD64MacroAssembler masm, CiValue result, CiValue input) { + private static void reg2reg(AMD64MacroAssembler masm, CiValue result, CiValue input) { if (input.equals(result)) { return; } switch (result.kind) { case Jsr: - case Int: masm.movl(tasm.asRegister(result), tasm.asRegister(input)); break; - case Long: masm.movq(tasm.asRegister(result), tasm.asRegister(input)); break; - case Float: masm.movflt(tasm.asFloatReg(result), tasm.asFloatReg(input)); break; - case Double: masm.movdbl(tasm.asDoubleReg(result), tasm.asDoubleReg(input)); break; - case Object: masm.movq(tasm.asRegister(result), tasm.asRegister(input)); break; + case Int: masm.movl(asRegister(result), asRegister(input)); break; + case Long: masm.movq(asRegister(result), asRegister(input)); break; + case Float: masm.movflt(asFloatReg(result), asFloatReg(input)); break; + case Double: masm.movdbl(asDoubleReg(result), asDoubleReg(input)); break; + case Object: masm.movq(asRegister(result), asRegister(input)); break; default: throw Util.shouldNotReachHere("kind=" + result.kind); } } @@ -219,11 +219,11 @@ private static void reg2stack(TargetMethodAssembler tasm, AMD64MacroAssembler masm, CiValue result, CiValue input) { switch (result.kind) { case Jsr: - case Int: masm.movl(tasm.asAddress(result), tasm.asRegister(input)); break; - case Long: masm.movq(tasm.asAddress(result), tasm.asRegister(input)); break; - case Float: masm.movflt(tasm.asAddress(result), tasm.asFloatReg(input)); break; - case Double: masm.movsd(tasm.asAddress(result), tasm.asDoubleReg(input)); break; - case Object: masm.movq(tasm.asAddress(result), tasm.asRegister(input)); break; + case Int: masm.movl(tasm.asAddress(result), asRegister(input)); break; + case Long: masm.movq(tasm.asAddress(result), asRegister(input)); break; + case Float: masm.movflt(tasm.asAddress(result), asFloatReg(input)); break; + case Double: masm.movsd(tasm.asAddress(result), asDoubleReg(input)); break; + case Object: masm.movq(tasm.asAddress(result), asRegister(input)); break; default: throw Util.shouldNotReachHere(); } } @@ -231,11 +231,11 @@ private static void stack2reg(TargetMethodAssembler tasm, AMD64MacroAssembler masm, CiValue result, CiValue input) { switch (result.kind) { case Jsr: - case Int: masm.movl(tasm.asRegister(result), tasm.asAddress(input)); break; - case Long: masm.movq(tasm.asRegister(result), tasm.asAddress(input)); break; - case Float: masm.movflt(tasm.asFloatReg(result), tasm.asAddress(input)); break; - case Double: masm.movdbl(tasm.asDoubleReg(result), tasm.asAddress(input)); break; - case Object: masm.movq(tasm.asRegister(result), tasm.asAddress(input)); break; + case Int: masm.movl(asRegister(result), tasm.asAddress(input)); break; + case Long: masm.movq(asRegister(result), tasm.asAddress(input)); break; + case Float: masm.movflt(asFloatReg(result), tasm.asAddress(input)); break; + case Double: masm.movdbl(asDoubleReg(result), tasm.asAddress(input)); break; + case Object: masm.movq(asRegister(result), tasm.asAddress(input)); break; default: throw Util.shouldNotReachHere(); } } @@ -266,28 +266,28 @@ // Do not optimize with an XOR as this instruction may be between // a CMP and a Jcc in which case the XOR will modify the condition // flags and interfere with the Jcc. - masm.movl(tasm.asRegister(result), tasm.asIntConst(c)); + masm.movl(asRegister(result), tasm.asIntConst(c)); break; case Long: // Do not optimize with an XOR as this instruction may be between // a CMP and a Jcc in which case the XOR will modify the condition // flags and interfere with the Jcc. - masm.movq(tasm.asRegister(result), c.asLong()); + masm.movq(asRegister(result), c.asLong()); break; case Float: // This is *not* the same as 'constant == 0.0f' in the case where constant is -0.0f if (Float.floatToRawIntBits(c.asFloat()) == Float.floatToRawIntBits(0.0f)) { - masm.xorps(tasm.asFloatReg(result), tasm.asFloatReg(result)); + masm.xorps(asFloatReg(result), asFloatReg(result)); } else { - masm.movflt(tasm.asFloatReg(result), tasm.asFloatConstRef(c)); + masm.movflt(asFloatReg(result), tasm.asFloatConstRef(c)); } break; case Double: // This is *not* the same as 'constant == 0.0d' in the case where constant is -0.0d if (Double.doubleToRawLongBits(c.asDouble()) == Double.doubleToRawLongBits(0.0d)) { - masm.xorpd(tasm.asDoubleReg(result), tasm.asDoubleReg(result)); + masm.xorpd(asDoubleReg(result), asDoubleReg(result)); } else { - masm.movdbl(tasm.asDoubleReg(result), tasm.asDoubleConstRef(c)); + masm.movdbl(asDoubleReg(result), tasm.asDoubleConstRef(c)); } break; case Object: @@ -295,12 +295,12 @@ // a CMP and a Jcc in which case the XOR will modify the condition // flags and interfere with the Jcc. if (c.isNull()) { - masm.movq(tasm.asRegister(result), 0x0L); + masm.movq(asRegister(result), 0x0L); } else if (tasm.target.inlineObjects) { tasm.recordDataReferenceInCode(c, 0); - masm.movq(tasm.asRegister(result), 0xDEADDEADDEADDEADL); + masm.movq(asRegister(result), 0xDEADDEADDEADDEADL); } else { - masm.movq(tasm.asRegister(result), tasm.recordDataReferenceInCode(c, 0)); + masm.movq(asRegister(result), tasm.recordDataReferenceInCode(c, 0)); } break; default: @@ -334,14 +334,14 @@ } switch (kind) { case Boolean: - case Byte: masm.movsxb(tasm.asRegister(result), loadAddr); break; - case Char: masm.movzxl(tasm.asRegister(result), loadAddr); break; - case Short: masm.movswl(tasm.asRegister(result), loadAddr); break; - case Int: masm.movslq(tasm.asRegister(result), loadAddr); break; - case Long: masm.movq(tasm.asRegister(result), loadAddr); break; - case Float: masm.movflt(tasm.asFloatReg(result), loadAddr); break; - case Double: masm.movdbl(tasm.asDoubleReg(result), loadAddr); break; - case Object: masm.movq(tasm.asRegister(result), loadAddr); break; + case Byte: masm.movsxb(asRegister(result), loadAddr); break; + case Char: masm.movzxl(asRegister(result), loadAddr); break; + case Short: masm.movswl(asRegister(result), loadAddr); break; + case Int: masm.movslq(asRegister(result), loadAddr); break; + case Long: masm.movq(asRegister(result), loadAddr); break; + case Float: masm.movflt(asFloatReg(result), loadAddr); break; + case Double: masm.movdbl(asDoubleReg(result), loadAddr); break; + case Object: masm.movq(asRegister(result), loadAddr); break; default: throw Util.shouldNotReachHere(); } } @@ -351,20 +351,20 @@ tasm.recordImplicitException(masm.codeBuffer.position(), info); } - if (input.isRegister()) { + if (isRegister(input)) { switch (kind) { case Boolean: - case Byte: masm.movb(storeAddr, tasm.asRegister(input)); break; + case Byte: masm.movb(storeAddr, asRegister(input)); break; case Char: - case Short: masm.movw(storeAddr, tasm.asRegister(input)); break; - case Int: masm.movl(storeAddr, tasm.asRegister(input)); break; - case Long: masm.movq(storeAddr, tasm.asRegister(input)); break; - case Float: masm.movflt(storeAddr, tasm.asFloatReg(input)); break; - case Double: masm.movsd(storeAddr, tasm.asDoubleReg(input)); break; - case Object: masm.movq(storeAddr, tasm.asRegister(input)); break; + case Short: masm.movw(storeAddr, asRegister(input)); break; + case Int: masm.movl(storeAddr, asRegister(input)); break; + case Long: masm.movq(storeAddr, asRegister(input)); break; + case Float: masm.movflt(storeAddr, asFloatReg(input)); break; + case Double: masm.movsd(storeAddr, asDoubleReg(input)); break; + case Object: masm.movq(storeAddr, asRegister(input)); break; default: throw Util.shouldNotReachHere("kind=" + kind); } - } else if (input.isConstant()) { + } else if (isConstant(input)) { CiConstant c = (CiConstant) input; switch (kind) { case Boolean: @@ -399,15 +399,15 @@ } protected static void compareAndSwap(TargetMethodAssembler tasm, AMD64MacroAssembler masm, CiValue result, CiAddress address, CiValue cmpValue, CiValue newValue) { - assert tasm.asRegister(cmpValue) == AMD64.rax && tasm.asRegister(result) == AMD64.rax; + assert asRegister(cmpValue) == AMD64.rax && asRegister(result) == AMD64.rax; if (tasm.target.isMP) { masm.lock(); } switch (cmpValue.kind) { - case Int: masm.cmpxchgl(tasm.asRegister(newValue), address); break; + case Int: masm.cmpxchgl(asRegister(newValue), address); break; case Long: - case Object: masm.cmpxchgq(tasm.asRegister(newValue), address); break; + case Object: masm.cmpxchgq(asRegister(newValue), address); break; default: throw Util.shouldNotReachHere(); } }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64MulOpcode.java Mon Jan 02 14:38:17 2012 -0800 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64MulOpcode.java Mon Jan 02 17:39:20 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2012, 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 @@ -22,6 +22,8 @@ */ package com.oracle.max.graal.compiler.target.amd64; +import static com.sun.cri.ci.CiValueUtil.*; + import com.oracle.max.asm.target.amd64.*; import com.oracle.max.graal.compiler.asm.*; import com.oracle.max.graal.compiler.lir.*; @@ -38,7 +40,7 @@ return new AMD64LIRInstruction(this, result, null, inputs, alives, LIRInstruction.NO_OPERANDS) { @Override public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - assert !(alive(0) instanceof CiRegisterValue) || tasm.asRegister(result()) != tasm.asRegister(alive(0)) : "result and right must be different registers"; + assert !(alive(0) instanceof CiRegisterValue) || asRegister(result()) != asRegister(alive(0)) : "result and right must be different registers"; AMD64MoveOpcode.move(tasm, masm, result(), input(0)); emit(tasm, masm, result(), alive(0)); } @@ -56,11 +58,11 @@ } protected void emit(TargetMethodAssembler tasm, AMD64MacroAssembler masm, CiValue leftAndResult, CiValue right) { - CiRegister dst = tasm.asRegister(leftAndResult); - if (right.isRegister()) { + CiRegister dst = asRegister(leftAndResult); + if (isRegister(right)) { switch (this) { - case IMUL: masm.imull(dst, tasm.asRegister(right)); break; - case LMUL: masm.imulq(dst, tasm.asRegister(right)); break; + case IMUL: masm.imull(dst, asRegister(right)); break; + case LMUL: masm.imulq(dst, asRegister(right)); break; default: throw Util.shouldNotReachHere(); } } else {
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64Op1Opcode.java Mon Jan 02 14:38:17 2012 -0800 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64Op1Opcode.java Mon Jan 02 17:39:20 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2012, 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 @@ -22,6 +22,8 @@ */ package com.oracle.max.graal.compiler.target.amd64; +import static com.sun.cri.ci.CiValueUtil.*; + import com.oracle.max.asm.target.amd64.*; import com.oracle.max.graal.compiler.asm.*; import com.oracle.max.graal.compiler.lir.*; @@ -38,7 +40,7 @@ @Override public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { AMD64MoveOpcode.move(tasm, masm, result(), input(0)); - emit(tasm, masm, result()); + emit(masm, result()); } @Override @@ -53,10 +55,10 @@ }; } - private void emit(TargetMethodAssembler tasm, AMD64MacroAssembler masm, CiValue inputAndResult) { + private void emit(AMD64MacroAssembler masm, CiValue inputAndResult) { switch (this) { - case INEG: masm.negl(tasm.asIntReg(inputAndResult)); break; - case LNEG: masm.negq(tasm.asLongReg(inputAndResult)); break; + case INEG: masm.negl(asIntReg(inputAndResult)); break; + case LNEG: masm.negq(asLongReg(inputAndResult)); break; default: throw Util.shouldNotReachHere(); } }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64ShiftOpcode.java Mon Jan 02 14:38:17 2012 -0800 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64ShiftOpcode.java Mon Jan 02 17:39:20 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2012, 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 @@ -22,6 +22,8 @@ */ package com.oracle.max.graal.compiler.target.amd64; +import static com.sun.cri.ci.CiValueUtil.*; + import com.oracle.max.asm.target.amd64.*; import com.oracle.max.graal.compiler.asm.*; import com.oracle.max.graal.compiler.lir.*; @@ -39,7 +41,7 @@ return new AMD64LIRInstruction(this, result, null, inputs, alives, LIRInstruction.NO_OPERANDS) { @Override public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - assert !(alive(0) instanceof CiRegisterValue) || tasm.asRegister(result()) != tasm.asRegister(alive(0)) : "result and right must be different registers"; + assert !(alive(0) instanceof CiRegisterValue) || asRegister(result()) != asRegister(alive(0)) : "result and right must be different registers"; AMD64MoveOpcode.move(tasm, masm, result(), input(0)); emit(tasm, masm, result(), alive(0)); } @@ -57,9 +59,9 @@ } protected void emit(TargetMethodAssembler tasm, AMD64MacroAssembler masm, CiValue leftAndResult, CiValue right) { - CiRegister dst = tasm.asRegister(leftAndResult); - if (right.isRegister()) { - assert tasm.asRegister(right) == AMD64.rcx; + CiRegister dst = asRegister(leftAndResult); + if (isRegister(right)) { + assert asRegister(right) == AMD64.rcx; switch (this) { case ISHL: masm.shll(dst); break; case ISHR: masm.sarl(dst); break;
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64XirOpcode.java Mon Jan 02 14:38:17 2012 -0800 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64XirOpcode.java Mon Jan 02 17:39:20 2012 -0800 @@ -24,6 +24,7 @@ import static com.sun.cri.ci.CiCallingConvention.Type.*; import static com.sun.cri.ci.CiValue.*; +import static com.sun.cri.ci.CiValueUtil.*; import java.util.*; @@ -190,7 +191,7 @@ case PointerStore: { CiValue value = assureNot64BitConstant(tasm, masm, operands[inst.y().index]); CiValue pointer = operands[inst.x().index]; - assert pointer.isVariableOrRegister(); + assert isRegister(pointer); AMD64MoveOpcode.store(tasm, masm, new CiAddress(inst.kind, pointer, 0), value, inst.kind, (Boolean) inst.extra ? info : null); break; @@ -208,10 +209,10 @@ CiValue index = operands[inst.y().index]; pointer = assureInRegister(tasm, masm, pointer); - assert pointer.isVariableOrRegister(); + assert isRegister(pointer); CiAddress src; - if (index.isConstant()) { + if (isConstant(index)) { assert index.kind == CiKind.Int; CiConstant constantIndex = (CiConstant) index; src = new CiAddress(inst.kind, pointer, constantIndex.asInt() * scale.value + displacement); @@ -234,9 +235,9 @@ CiValue index = operands[inst.y().index]; pointer = assureInRegister(tasm, masm, pointer); - assert pointer.isVariableOrRegister(); + assert isRegister(pointer); CiAddress src = new CiAddress(CiKind.Illegal, pointer, index, scale, displacement); - masm.leaq(result.asRegister(), src); + masm.leaq(asRegister(result), src); break; } @@ -252,10 +253,10 @@ CiValue index = operands[inst.y().index]; pointer = assureInRegister(tasm, masm, pointer); - assert pointer.isVariableOrRegister(); + assert isRegister(pointer); CiAddress dst; - if (index.isConstant()) { + if (isConstant(index)) { assert index.kind == CiKind.Int; CiConstant constantIndex = (CiConstant) index; dst = new CiAddress(inst.kind, pointer, IllegalValue, scale, constantIndex.asInt() * scale.value + displacement); @@ -268,21 +269,21 @@ } case RepeatMoveBytes: - assert operands[inst.x().index].asRegister().equals(AMD64.rsi) : "wrong input x: " + operands[inst.x().index]; - assert operands[inst.y().index].asRegister().equals(AMD64.rdi) : "wrong input y: " + operands[inst.y().index]; - assert operands[inst.z().index].asRegister().equals(AMD64.rcx) : "wrong input z: " + operands[inst.z().index]; + assert asRegister(operands[inst.x().index]).equals(AMD64.rsi) : "wrong input x: " + operands[inst.x().index]; + assert asRegister(operands[inst.y().index]).equals(AMD64.rdi) : "wrong input y: " + operands[inst.y().index]; + assert asRegister(operands[inst.z().index]).equals(AMD64.rcx) : "wrong input z: " + operands[inst.z().index]; masm.repeatMoveBytes(); break; case RepeatMoveWords: - assert operands[inst.x().index].asRegister().equals(AMD64.rsi) : "wrong input x: " + operands[inst.x().index]; - assert operands[inst.y().index].asRegister().equals(AMD64.rdi) : "wrong input y: " + operands[inst.y().index]; - assert operands[inst.z().index].asRegister().equals(AMD64.rcx) : "wrong input z: " + operands[inst.z().index]; + assert asRegister(operands[inst.x().index]).equals(AMD64.rsi) : "wrong input x: " + operands[inst.x().index]; + assert asRegister(operands[inst.y().index]).equals(AMD64.rdi) : "wrong input y: " + operands[inst.y().index]; + assert asRegister(operands[inst.z().index]).equals(AMD64.rcx) : "wrong input z: " + operands[inst.z().index]; masm.repeatMoveWords(); break; case PointerCAS: - assert operands[inst.x().index].asRegister().equals(AMD64.rax) : "wrong input x: " + operands[inst.x().index]; + assert asRegister(operands[inst.x().index]).equals(AMD64.rax) : "wrong input x: " + operands[inst.x().index]; CiValue exchangedVal = operands[inst.y().index]; CiValue exchangedAddress = operands[inst.x().index]; @@ -292,7 +293,7 @@ if ((Boolean) inst.extra && info != null) { tasm.recordImplicitException(masm.codeBuffer.position(), info); } - masm.cmpxchgq(exchangedVal.asRegister(), addr); + masm.cmpxchgq(asRegister(exchangedVal), addr); break; @@ -347,10 +348,10 @@ Label label = labels[((XirLabel) inst.extra).index]; CiValue value = operands[inst.x().index]; if (value.kind == CiKind.Long) { - masm.decq(value.asRegister()); + masm.decq(asRegister(value)); } else { assert value.kind == CiKind.Int; - masm.decl(value.asRegister()); + masm.decl(asRegister(value)); } masm.jcc(ConditionFlag.notZero, label); break; @@ -401,7 +402,7 @@ CiValue pointer = operands[inst.x().index]; CiValue offset = operands[inst.y().index]; CiValue bit = operands[inst.z().index]; - assert offset.isConstant() && bit.isConstant(); + assert isConstant(offset) && isConstant(bit); CiConstant constantOffset = (CiConstant) offset; CiConstant constantBit = (CiConstant) bit; CiAddress src = new CiAddress(inst.kind, pointer, constantOffset.asInt()); @@ -424,7 +425,7 @@ case NullCheck: { tasm.recordImplicitException(masm.codeBuffer.position(), info); CiValue pointer = operands[inst.x().index]; - masm.nullCheck(pointer.asRegister()); + masm.nullCheck(asRegister(pointer)); break; } case Align: { @@ -475,13 +476,13 @@ } case Push: { CiRegisterValue value = assureInRegister(tasm, masm, operands[inst.x().index]); - masm.push(value.asRegister()); + masm.push(asRegister(value)); break; } case Pop: { CiValue result = operands[inst.result.index]; - if (result.isRegister()) { - masm.pop(result.asRegister()); + if (isRegister(result)) { + masm.pop(asRegister(result)); } else { CiRegister rscratch = tasm.compilation.registerConfig.getScratchRegister(); masm.pop(rscratch); @@ -537,7 +538,7 @@ } else if (code instanceof AMD64MulOpcode) { ((AMD64MulOpcode) code).emit(tasm, masm, left, right); } else if (code instanceof AMD64DivOpcode) { - ((AMD64DivOpcode) code).emit(tasm, masm, tasm.asRegister(result), null, tasm.asRegister(left), tasm.asRegister(right)); + ((AMD64DivOpcode) code).emit(tasm, masm, asRegister(result), null, asRegister(left), asRegister(right)); } else if (code instanceof AMD64ShiftOpcode) { ((AMD64ShiftOpcode) code).emit(tasm, masm, left, right); } @@ -570,7 +571,7 @@ } private static CiValue assureNot64BitConstant(TargetMethodAssembler tasm, AMD64MacroAssembler masm, CiValue value) { - if (value.isConstant() && (value.kind == CiKind.Long || value.kind == CiKind.Object)) { + if (isConstant(value) && (value.kind == CiKind.Long || value.kind == CiKind.Object)) { CiRegisterValue register = tasm.compilation.registerConfig.getScratchRegister().asValue(value.kind); AMD64MoveOpcode.move(tasm, masm, register, value); return register; @@ -579,13 +580,13 @@ } private static CiRegisterValue assureInRegister(TargetMethodAssembler tasm, AMD64MacroAssembler masm, CiValue pointer) { - if (pointer.isConstant()) { + if (isConstant(pointer)) { CiRegisterValue register = tasm.compilation.registerConfig.getScratchRegister().asValue(pointer.kind); AMD64MoveOpcode.move(tasm, masm, register, pointer); return register; } - assert pointer.isRegister() : "should be register, but is: " + pointer; + assert isRegister(pointer) : "should be register, but is: " + pointer; return (CiRegisterValue) pointer; } }
--- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/HotSpotXirGenerator.java Mon Jan 02 14:38:17 2012 -0800 +++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/HotSpotXirGenerator.java Mon Jan 02 17:39:20 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ import static com.oracle.max.graal.hotspot.TemplateFlag.*; import static com.sun.cri.ci.CiCallingConvention.Type.*; +import static com.sun.cri.ci.CiValueUtil.*; import java.lang.reflect.*; import java.util.*; @@ -119,7 +120,7 @@ XirOperand cache = asm.createRegisterTemp("cache (rax)", target.wordKind, AMD64.rax); CiCallingConvention conventions = registerConfig.getCallingConvention(JavaCallee, new CiKind[] {CiKind.Object}, target, false); - XirOperand receiver = asm.createRegister("receiver", target.wordKind, conventions.locations[0].asRegister()); + XirOperand receiver = asm.createRegister("receiver", target.wordKind, asRegister(conventions.locations[0])); asm.pload(target.wordKind, temp, receiver, asm.i(config.hubOffset), false); asm.jneq(unverifiedStub, cache, temp); @@ -348,7 +349,7 @@ asm.callRuntime(config.fastMonitorEnterStub, null, useInfoAfter, object, lock); } else { asm.reserveOutgoingStack(target.wordSize * 2); - XirOperand rsp = asm.createRegister("rsp", target.wordKind, AMD64.RSP.asRegister()); + XirOperand rsp = asm.createRegister("rsp", target.wordKind, asRegister(AMD64.RSP)); asm.pstore(CiKind.Object, rsp, asm.i(target.wordSize), object, false); asm.pstore(target.wordKind, rsp, asm.i(0), lock, false); asm.callRuntime(config.monitorEnterStub, null, useInfoAfter); @@ -377,7 +378,7 @@ asm.callRuntime(config.fastMonitorExitStub, null, object, lock); } else { asm.reserveOutgoingStack(target.wordSize); - asm.pstore(target.wordKind, asm.createRegister("rsp", target.wordKind, AMD64.RSP.asRegister()), asm.i(0), lock, false); + asm.pstore(target.wordKind, asm.createRegister("rsp", target.wordKind, asRegister(AMD64.RSP)), asm.i(0), lock, false); asm.callRuntime(config.monitorExitStub, null); }
--- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/target/amd64/AMD64TailcallOpcode.java Mon Jan 02 14:38:17 2012 -0800 +++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/target/amd64/AMD64TailcallOpcode.java Mon Jan 02 17:39:20 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2012, 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 @@ -22,6 +22,8 @@ */ package com.oracle.max.graal.hotspot.target.amd64; +import static com.sun.cri.ci.CiValueUtil.*; + import java.util.*; import com.oracle.max.asm.target.amd64.AMD64MacroAssembler; @@ -60,18 +62,18 @@ // TODO: These moves should not be part of the TAILCALL opcode, but emitted as separate MOVE instructions before. for (int i = 0; i < inputs.length - 1; i++) { assert inputs[i].kind == CiKind.Object || inputs[i].kind == CiKind.Int || inputs[i].kind == CiKind.Long : "only Object, int and long supported for now"; - assert temps[i].isRegister() : "too many parameters"; - if (inputs[i].isRegister()) { - masm.movq(temps[i].asRegister(), inputs[i].asRegister()); + assert isRegister(temps[i]) : "too many parameters"; + if (isRegister(inputs[i])) { + masm.movq(asRegister(temps[i]), asRegister(inputs[i])); } else { - masm.movq(temps[i].asRegister(), tasm.asAddress(inputs[i])); + masm.movq(asRegister(temps[i]), tasm.asAddress(inputs[i])); } } // destroy the current frame (now the return address is the top of stack) masm.leave(); // jump to the target method - masm.jmp(inputs[inputs.length - 1].asRegister()); + masm.jmp(asRegister(inputs[inputs.length - 1])); masm.ensureUniquePC(); break; }
--- a/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/extended/IndexedLocationNode.java Mon Jan 02 14:38:17 2012 -0800 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/extended/IndexedLocationNode.java Mon Jan 02 17:39:20 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2012, 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 @@ @Override public CiAddress createAddress(LIRGeneratorTool gen, ValueNode object) { CiValue base = gen.operand(object); - if (base.isConstant() && ((CiConstant) base).isNull()) { + if (CiValueUtil.isConstant(base) && ((CiConstant) base).isNull()) { base = CiValue.IllegalValue; }
--- a/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/extended/LocationNode.java Mon Jan 02 14:38:17 2012 -0800 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/extended/LocationNode.java Mon Jan 02 17:39:20 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2012, 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 @@ public CiAddress createAddress(LIRGeneratorTool gen, ValueNode object) { CiValue base = gen.operand(object); - if (base.isConstant() && ((CiConstant) base).isNull()) { + if (CiValueUtil.isConstant(base) && ((CiConstant) base).isNull()) { base = CiValue.IllegalValue; } return new CiAddress(valueKind, base, CiValue.IllegalValue, Scale.Times1, displacement());
--- a/graal/com.oracle.max.graal.snippets/src/com/oracle/max/graal/snippets/target/amd64/AMD64MathIntrinsicOpcode.java Mon Jan 02 14:38:17 2012 -0800 +++ b/graal/com.oracle.max.graal.snippets/src/com/oracle/max/graal/snippets/target/amd64/AMD64MathIntrinsicOpcode.java Mon Jan 02 17:39:20 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2012, 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 @@ -22,6 +22,8 @@ */ package com.oracle.max.graal.snippets.target.amd64; +import static com.sun.cri.ci.CiValueUtil.*; + import com.oracle.max.asm.target.amd64.*; import com.oracle.max.graal.compiler.asm.*; import com.oracle.max.graal.compiler.lir.*; @@ -40,7 +42,7 @@ return new AMD64LIRInstruction(this, result, null, inputs, LIRInstruction.NO_OPERANDS, LIRInstruction.NO_OPERANDS) { @Override public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - emit(tasm, masm, tasm.asDoubleReg(result()), tasm.asDoubleReg(input(0))); + emit(tasm, masm, asDoubleReg(result()), asDoubleReg(input(0))); } }; }