Mercurial > hg > graal-jvmci-8
changeset 8167:7f57c30575c8
Make AMD64Address a low-level representation for use by the assembler only.
line wrap: on
line diff
--- a/graal/com.oracle.graal.amd64/src/com/oracle/graal/amd64/AMD64.java Thu Mar 07 15:16:19 2013 +0100 +++ b/graal/com.oracle.graal.amd64/src/com/oracle/graal/amd64/AMD64.java Thu Mar 07 16:20:18 2013 +0100 @@ -24,7 +24,6 @@ import static com.oracle.graal.api.code.MemoryBarriers.*; import static com.oracle.graal.api.code.Register.RegisterFlag.*; -import static com.oracle.graal.api.meta.Kind.*; import java.nio.*; @@ -106,8 +105,6 @@ rip }; - public static final RegisterValue RSP = rsp.asValue(Long); - public AMD64() { super("AMD64", 8,
--- a/graal/com.oracle.graal.amd64/src/com/oracle/graal/amd64/AMD64Address.java Thu Mar 07 15:16:19 2013 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,203 +0,0 @@ -/* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.graal.amd64; - -import static com.oracle.graal.api.code.ValueUtil.*; - -import com.oracle.graal.api.code.*; -import com.oracle.graal.api.meta.*; - -/** - * 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 a variable that will get a register assigned later by the register allocator. - */ -public final class AMD64Address extends Address { - - private static final long serialVersionUID = -4101548147426595051L; - - private final Value[] baseIndex; - private final Scale scale; - private final int displacement; - - /** - * Creates an {@link AMD64Address} with given base register, no scaling and no displacement. - * - * @param kind the kind of the value being addressed - * @param base the base register - */ - public AMD64Address(Kind kind, Value base) { - this(kind, base, ILLEGAL, Scale.Times1, 0); - } - - /** - * Creates an {@link AMD64Address} with given base register, no scaling and a given - * displacement. - * - * @param kind the kind of the value being addressed - * @param base the base register - * @param displacement the displacement - */ - public AMD64Address(Kind kind, Value base, int displacement) { - this(kind, base, ILLEGAL, Scale.Times1, displacement); - } - - /** - * Creates an {@link AMD64Address} with given base and index registers, scaling and - * displacement. This is the most general constructor. - * - * @param kind the kind of the value being addressed - * @param base the base register - * @param index the index register - * @param scale the scaling factor - * @param displacement the displacement - */ - public AMD64Address(Kind kind, Value base, Value index, Scale scale, int displacement) { - super(kind); - this.baseIndex = new Value[2]; - this.setBase(base); - this.setIndex(index); - this.scale = scale; - this.displacement = displacement; - - assert !isConstant(base) && !isStackSlot(base); - assert !isConstant(index) && !isStackSlot(index); - } - - /** - * A scaling factor used in the SIB addressing mode. - */ - public enum Scale { - Times1(1, 0), Times2(2, 1), Times4(4, 2), Times8(8, 3); - - private Scale(int value, int log2) { - this.value = value; - this.log2 = log2; - } - - /** - * The value (or multiplier) of this scale. - */ - public final int value; - - /** - * The {@linkplain #value value} of this scale log 2. - */ - public final int log2; - - public static Scale fromInt(int scale) { - switch (scale) { - case 1: - return Times1; - case 2: - return Times2; - case 4: - return Times4; - case 8: - return Times8; - default: - throw new IllegalArgumentException(String.valueOf(scale)); - } - } - } - - @Override - public Value[] components() { - return baseIndex; - } - - @Override - public String toString() { - StringBuilder s = new StringBuilder(); - s.append(getKind().getJavaName()).append("["); - String sep = ""; - if (isLegal(getBase())) { - s.append(getBase()); - sep = " + "; - } - if (isLegal(getIndex())) { - s.append(sep).append(getIndex()).append(" * ").append(getScale().value); - sep = " + "; - } - if (getDisplacement() < 0) { - s.append(" - ").append(-getDisplacement()); - } else if (getDisplacement() > 0) { - s.append(sep).append(getDisplacement()); - } - s.append("]"); - return s.toString(); - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof AMD64Address) { - AMD64Address addr = (AMD64Address) obj; - return getKind() == addr.getKind() && getDisplacement() == addr.getDisplacement() && getBase().equals(addr.getBase()) && getScale() == addr.getScale() && - getIndex().equals(addr.getIndex()); - } - return false; - } - - @Override - public int hashCode() { - return getBase().hashCode() ^ getIndex().hashCode() ^ (getDisplacement() << 4) ^ (getScale().value << 8) ^ (getKind().ordinal() << 12); - } - - /** - * @return Base register that defines the start of the address computation. If not present, is - * denoted by {@link Value#ILLEGAL}. - */ - public Value getBase() { - return baseIndex[0]; - } - - public void setBase(Value base) { - this.baseIndex[0] = base; - } - - /** - * @return Index register, the value of which (possibly scaled by {@link #scale}) is added to - * {@link #getBase}. If not present, is denoted by {@link Value#ILLEGAL}. - */ - public Value getIndex() { - return baseIndex[1]; - } - - public void setIndex(Value index) { - this.baseIndex[1] = index; - } - - /** - * @return Scaling factor for indexing, dependent on target operand size. - */ - public Scale getScale() { - return scale; - } - - /** - * @return Optional additive displacement. - */ - public int getDisplacement() { - return displacement; - } -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/AbstractAddress.java Thu Mar 07 16:20:18 2013 +0100 @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.api.code; + +/** + * Marker interface that represents a platform specific address. + */ +public interface AbstractAddress { +}
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/Address.java Thu Mar 07 15:16:19 2013 +0100 +++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/Address.java Thu Mar 07 16:20:18 2013 +0100 @@ -28,7 +28,7 @@ * Base class to represent an address in target machine memory. The concrete representation of the * address is platform dependent. */ -public abstract class Address extends Value { +public abstract class Address extends Value implements AbstractAddress { private static final long serialVersionUID = -1003772042519945089L;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.asm.amd64/src/com/oracle/graal/asm/amd64/AMD64Address.java Thu Mar 07 16:20:18 2013 +0100 @@ -0,0 +1,163 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.asm.amd64; + +import com.oracle.graal.api.code.*; + +/** + * 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 a variable that will get a register assigned later by the register allocator. + */ +public final class AMD64Address implements AbstractAddress { + + private final Register base; + private final Register index; + private final Scale scale; + private final int displacement; + + /** + * Creates an {@link AMD64Address} with given base register, no scaling and no displacement. + * + * @param base the base register + */ + public AMD64Address(Register base) { + this(base, Register.None, Scale.Times1, 0); + } + + /** + * Creates an {@link AMD64Address} with given base register, no scaling and a given + * displacement. + * + * @param base the base register + * @param displacement the displacement + */ + public AMD64Address(Register base, int displacement) { + this(base, Register.None, Scale.Times1, displacement); + } + + /** + * Creates an {@link AMD64Address} with given base and index registers, scaling and + * displacement. This is the most general constructor. + * + * @param base the base register + * @param index the index register + * @param scale the scaling factor + * @param displacement the displacement + */ + public AMD64Address(Register base, Register index, Scale scale, int displacement) { + this.base = base; + this.index = index; + this.scale = scale; + this.displacement = displacement; + } + + /** + * A scaling factor used in the SIB addressing mode. + */ + public enum Scale { + Times1(1, 0), Times2(2, 1), Times4(4, 2), Times8(8, 3); + + private Scale(int value, int log2) { + this.value = value; + this.log2 = log2; + } + + /** + * The value (or multiplier) of this scale. + */ + public final int value; + + /** + * The {@linkplain #value value} of this scale log 2. + */ + public final int log2; + + public static Scale fromInt(int scale) { + switch (scale) { + case 1: + return Times1; + case 2: + return Times2; + case 4: + return Times4; + case 8: + return Times8; + default: + throw new IllegalArgumentException(String.valueOf(scale)); + } + } + } + + @Override + public String toString() { + StringBuilder s = new StringBuilder(); + s.append("["); + String sep = ""; + if (getBase() != Register.None) { + s.append(getBase()); + sep = " + "; + } + if (getIndex() != Register.None) { + s.append(sep).append(getIndex()).append(" * ").append(getScale().value); + sep = " + "; + } + if (getDisplacement() < 0) { + s.append(" - ").append(-getDisplacement()); + } else if (getDisplacement() > 0) { + s.append(sep).append(getDisplacement()); + } + s.append("]"); + return s.toString(); + } + + /** + * @return Base register that defines the start of the address computation. If not present, is + * denoted by {@link Register#None}. + */ + public Register getBase() { + return base; + } + + /** + * @return Index register, the value of which (possibly scaled by {@link #getScale}) is added to + * {@link #getBase}. If not present, is denoted by {@link Register#None}. + */ + public Register getIndex() { + return index; + } + + /** + * @return Scaling factor for indexing, dependent on target operand size. + */ + public Scale getScale() { + return scale; + } + + /** + * @return Optional additive displacement. + */ + public int getDisplacement() { + return displacement; + } +}
--- a/graal/com.oracle.graal.asm.amd64/src/com/oracle/graal/asm/amd64/AMD64Assembler.java Thu Mar 07 15:16:19 2013 +0100 +++ b/graal/com.oracle.graal.asm.amd64/src/com/oracle/graal/asm/amd64/AMD64Assembler.java Thu Mar 07 16:20:18 2013 +0100 @@ -38,19 +38,13 @@ */ public class AMD64Assembler extends AbstractAssembler { - /** - * The kind for pointers and raw registers. Since we know we are 64 bit here, we can hardcode - * it. - */ - private static final Kind Word = Kind.Long; - private static final int MinEncodingNeedsRex = 8; /** * A sentinel value used as a place holder in an instruction stream for an address that will be * patched. */ - private static final AMD64Address Placeholder = new AMD64Address(Kind.Illegal, rip.asValue()); + private static final AMD64Address Placeholder = new AMD64Address(rip); /** * The x86 condition codes used for conditional jumps/moves. @@ -232,8 +226,8 @@ assert (reg & 0x07) == reg; int regenc = reg << 3; - Register base = isLegal(addr.getBase()) ? asRegister(addr.getBase()) : Register.None; - Register index = isLegal(addr.getIndex()) ? asRegister(addr.getIndex()) : Register.None; + Register base = addr.getBase(); + Register index = addr.getIndex(); AMD64Address.Scale scale = addr.getScale(); int disp = addr.getDisplacement(); @@ -1781,8 +1775,8 @@ } } - private static boolean needsRex(Value value) { - return isRegister(value) && asRegister(value).encoding >= MinEncodingNeedsRex; + private static boolean needsRex(Register reg) { + return reg.encoding >= MinEncodingNeedsRex; } private void prefix(AMD64Address adr) { @@ -2249,7 +2243,7 @@ // the code where this idiom is used, in particular the // orderAccess code. lock(); - addl(new AMD64Address(Word, RSP, 0), 0); // Assert the lock# signal here + addl(new AMD64Address(rsp, 0), 0); // Assert the lock# signal here } } } @@ -2290,7 +2284,7 @@ } public void nullCheck(Register r) { - testl(AMD64.rax, new AMD64Address(Word, r.asValue(Word), 0)); + testl(AMD64.rax, new AMD64Address(r, 0)); } @Override @@ -2372,7 +2366,8 @@ @Override public AMD64Address makeAddress(Kind kind, Value base, int displacement) { - return new AMD64Address(kind, base, displacement); + assert isRegister(base); + return new AMD64Address(asRegister(base), displacement); } @Override
--- a/graal/com.oracle.graal.asm.amd64/src/com/oracle/graal/asm/amd64/AMD64MacroAssembler.java Thu Mar 07 15:16:19 2013 +0100 +++ b/graal/com.oracle.graal.asm.amd64/src/com/oracle/graal/asm/amd64/AMD64MacroAssembler.java Thu Mar 07 16:20:18 2013 +0100 @@ -26,7 +26,6 @@ import com.oracle.graal.amd64.*; import com.oracle.graal.api.code.*; -import com.oracle.graal.api.meta.*; /** * This class implements commonly used X86 code patterns. @@ -222,7 +221,7 @@ * volatile field! */ public final void movlong(AMD64Address dst, long src) { - AMD64Address high = new AMD64Address(dst.getKind(), dst.getBase(), dst.getIndex(), dst.getScale(), dst.getDisplacement() + 4); + AMD64Address high = new AMD64Address(dst.getBase(), dst.getIndex(), dst.getScale(), dst.getDisplacement() + 4); movl(dst, (int) (src & 0xFFFFFFFF)); movl(high, (int) (src >> 32)); } @@ -230,7 +229,7 @@ public final void flog(Register dest, Register value, boolean base10) { assert dest.isFpu() && value.isFpu(); - AMD64Address tmp = new AMD64Address(Kind.Double, AMD64.RSP); + AMD64Address tmp = new AMD64Address(AMD64.rsp); if (base10) { fldlg2(); } else { @@ -264,7 +263,7 @@ private AMD64Address trigPrologue(Register value) { assert value.isFpu(); - AMD64Address tmp = new AMD64Address(Kind.Double, AMD64.RSP); + AMD64Address tmp = new AMD64Address(AMD64.rsp); subq(AMD64.rsp, 8); movsd(tmp, value); fld(tmp); @@ -286,18 +285,16 @@ * @param frameToCSA offset from the frame pointer to the CSA */ public final void save(CalleeSaveLayout csl, int frameToCSA) { - RegisterValue frame = frameRegister.asValue(); for (Register r : csl.registers) { int offset = csl.offsetOf(r); - movq(new AMD64Address(target.wordKind, frame, frameToCSA + offset), r); + movq(new AMD64Address(frameRegister, frameToCSA + offset), r); } } public final void restore(CalleeSaveLayout csl, int frameToCSA) { - RegisterValue frame = frameRegister.asValue(); for (Register r : csl.registers) { int offset = csl.offsetOf(r); - movq(r, new AMD64Address(target.wordKind, frame, frameToCSA + offset)); + movq(r, new AMD64Address(frameRegister, frameToCSA + offset)); } } }
--- a/graal/com.oracle.graal.asm/src/com/oracle/graal/asm/AbstractAssembler.java Thu Mar 07 15:16:19 2013 +0100 +++ b/graal/com.oracle.graal.asm/src/com/oracle/graal/asm/AbstractAssembler.java Thu Mar 07 16:20:18 2013 +0100 @@ -87,12 +87,12 @@ /** * This is used by the TargetMethodAssembler to convert a {@link StackSlot} to an - * {@link Address}. + * {@link AbstractAddress}. */ - public abstract Address makeAddress(Kind kind, Value base, int displacement); + public abstract AbstractAddress makeAddress(Kind kind, Value base, int displacement); /** * Returns a target specific placeholder address that can be used for code patching. */ - public abstract Address getPlaceholder(); + public abstract AbstractAddress getPlaceholder(); }
--- a/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java Thu Mar 07 15:16:19 2013 +0100 +++ b/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java Thu Mar 07 16:20:18 2013 +0100 @@ -30,11 +30,11 @@ import static com.oracle.graal.lir.amd64.AMD64MathIntrinsicOp.IntrinsicOpcode.*; import com.oracle.graal.amd64.*; -import com.oracle.graal.amd64.AMD64Address.Scale; import com.oracle.graal.api.code.*; import com.oracle.graal.api.code.RuntimeCallTarget.Descriptor; import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.*; +import com.oracle.graal.asm.amd64.AMD64Address.Scale; import com.oracle.graal.asm.amd64.AMD64Assembler.ConditionFlag; import com.oracle.graal.compiler.gen.*; import com.oracle.graal.compiler.target.*;
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java Thu Mar 07 15:16:19 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java Thu Mar 07 16:20:18 2013 +0100 @@ -31,13 +31,13 @@ import sun.misc.*; import com.oracle.graal.amd64.*; -import com.oracle.graal.amd64.AMD64Address.Scale; import com.oracle.graal.api.code.*; import com.oracle.graal.api.code.RuntimeCallTarget.Descriptor; import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.*; +import com.oracle.graal.asm.amd64.*; +import com.oracle.graal.asm.amd64.AMD64Address.Scale; import com.oracle.graal.asm.amd64.AMD64Assembler.ConditionFlag; -import com.oracle.graal.asm.amd64.*; import com.oracle.graal.compiler.amd64.*; import com.oracle.graal.compiler.gen.*; import com.oracle.graal.hotspot.*; @@ -204,7 +204,7 @@ disp -= frameSize; } tasm.blockComment("[stack overflow check]"); - asm.movq(new AMD64Address(asm.target.wordKind, AMD64.RSP, -disp), AMD64.rax); + asm.movq(new AMD64Address(rsp, -disp), AMD64.rax); } } } @@ -224,7 +224,7 @@ if (GraalOptions.ZapStackOnMethodEntry) { final int intSize = 4; for (int i = 0; i < frameSize / intSize; ++i) { - asm.movl(new AMD64Address(Kind.Int, rsp.asValue(), i * intSize), 0xC1C1C1C1); + asm.movl(new AMD64Address(rsp, i * intSize), 0xC1C1C1C1); } } CalleeSaveLayout csl = frameMap.registerConfig.getCalleeSaveLayout(); @@ -288,7 +288,7 @@ Register inlineCacheKlass = rax; // see definition of IC_Klass in // c1_LIRAssembler_x86.cpp Register receiver = asRegister(cc.getArgument(0)); - AMD64Address src = new AMD64Address(target.wordKind, receiver.asValue(), config.hubOffset); + AMD64Address src = new AMD64Address(receiver, config.hubOffset); asm.cmpq(inlineCacheKlass, src); asm.jcc(ConditionFlag.NotEqual, unverifiedStub);
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64SafepointOp.java Thu Mar 07 15:16:19 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64SafepointOp.java Thu Mar 07 16:20:18 2013 +0100 @@ -26,7 +26,6 @@ import static com.oracle.graal.phases.GraalOptions.*; import sun.misc.*; -import com.oracle.graal.amd64.*; import com.oracle.graal.api.code.*; import com.oracle.graal.asm.amd64.*; import com.oracle.graal.hotspot.*; @@ -65,13 +64,13 @@ asm.movq(scratch.getRegister(), config.safepointPollingAddress + offset); tasm.recordMark(Marks.MARK_POLL_FAR); tasm.recordSafepoint(pos, state); - asm.movq(scratch.getRegister(), new AMD64Address(tasm.target.wordKind, scratch)); + asm.movq(scratch.getRegister(), new AMD64Address(scratch.getRegister())); } else { tasm.recordMark(Marks.MARK_POLL_NEAR); tasm.recordSafepoint(pos, state); // The C++ code transforms the polling page offset into an RIP displacement // to the real address at that offset in the polling page. - asm.movq(scratch.getRegister(), new AMD64Address(tasm.target.wordKind, rip.asValue(), offset)); + asm.movq(scratch.getRegister(), new AMD64Address(rip, offset)); } } }
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64AddressValue.java Thu Mar 07 15:16:19 2013 +0100 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64AddressValue.java Thu Mar 07 16:20:18 2013 +0100 @@ -25,10 +25,10 @@ import static com.oracle.graal.api.code.ValueUtil.*; import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*; -import com.oracle.graal.amd64.*; -import com.oracle.graal.amd64.AMD64Address.Scale; import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; +import com.oracle.graal.asm.amd64.*; +import com.oracle.graal.asm.amd64.AMD64Address.Scale; import com.oracle.graal.lir.*; public class AMD64AddressValue extends CompositeValue { @@ -52,10 +52,17 @@ this.displacement = displacement; } + private static Register toRegister(AllocatableValue value) { + if (value == AllocatableValue.UNUSED) { + return Register.None; + } else { + RegisterValue reg = (RegisterValue) value; + return reg.getRegister(); + } + } + public AMD64Address toAddress() { - Value baseVal = base == AllocatableValue.UNUSED ? Value.ILLEGAL : base; - Value indexVal = index == AllocatableValue.UNUSED ? Value.ILLEGAL : index; - return new AMD64Address(getKind(), baseVal, indexVal, scale, displacement); + return new AMD64Address(toRegister(base), toRegister(index), scale, displacement); } @Override
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64BitManipulationOp.java Thu Mar 07 15:16:19 2013 +0100 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64BitManipulationOp.java Thu Mar 07 16:20:18 2013 +0100 @@ -22,7 +22,6 @@ */ package com.oracle.graal.lir.amd64; -import com.oracle.graal.amd64.*; import com.oracle.graal.api.code.*; import com.oracle.graal.asm.amd64.*; import com.oracle.graal.lir.asm.*;
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Compare.java Thu Mar 07 15:16:19 2013 +0100 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Compare.java Thu Mar 07 16:20:18 2013 +0100 @@ -25,7 +25,6 @@ import static com.oracle.graal.api.code.ValueUtil.*; import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*; -import com.oracle.graal.amd64.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.amd64.*; import com.oracle.graal.graph.*;
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64ControlFlow.java Thu Mar 07 15:16:19 2013 +0100 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64ControlFlow.java Thu Mar 07 16:20:18 2013 +0100 @@ -26,13 +26,13 @@ import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*; import com.oracle.graal.amd64.*; -import com.oracle.graal.amd64.AMD64Address.Scale; +import com.oracle.graal.api.code.CompilationResult.JumpTable; import com.oracle.graal.api.code.*; -import com.oracle.graal.api.code.CompilationResult.JumpTable; import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.*; +import com.oracle.graal.asm.amd64.*; +import com.oracle.graal.asm.amd64.AMD64Address.Scale; import com.oracle.graal.asm.amd64.AMD64Assembler.ConditionFlag; -import com.oracle.graal.asm.amd64.*; import com.oracle.graal.graph.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.LIRInstruction.Opcode; @@ -338,11 +338,11 @@ // Set scratch to address of jump table int leaPos = buf.position(); - masm.leaq(scratch, new AMD64Address(tasm.target.wordKind, AMD64.rip.asValue(), 0)); + masm.leaq(scratch, new AMD64Address(AMD64.rip, 0)); int afterLea = buf.position(); // Load jump table entry into scratch and jump to it - masm.movslq(value, new AMD64Address(Kind.Int, scratch.asValue(), value.asValue(), Scale.Times4, 0)); + masm.movslq(value, new AMD64Address(scratch, value, Scale.Times4, 0)); masm.addq(scratch, value); masm.jmp(scratch); @@ -354,7 +354,7 @@ // Patch LEA instruction above now that we know the position of the jump table int jumpTablePos = buf.position(); buf.setPosition(leaPos); - masm.leaq(scratch, new AMD64Address(tasm.target.wordKind, AMD64.rip.asValue(), jumpTablePos - afterLea)); + masm.leaq(scratch, new AMD64Address(AMD64.rip, jumpTablePos - afterLea)); buf.setPosition(jumpTablePos); // Emit jump table entries
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64TestOp.java Thu Mar 07 15:16:19 2013 +0100 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64TestOp.java Thu Mar 07 16:20:18 2013 +0100 @@ -25,7 +25,6 @@ import static com.oracle.graal.api.code.ValueUtil.*; import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*; -import com.oracle.graal.amd64.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.amd64.*; import com.oracle.graal.graph.*;
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/asm/TargetMethodAssembler.java Thu Mar 07 15:16:19 2013 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/asm/TargetMethodAssembler.java Thu Mar 07 16:20:18 2013 +0100 @@ -150,7 +150,7 @@ compilationResult.recordSafepoint(pos, debugInfo); } - public Address recordDataReferenceInCode(Constant data, int alignment, boolean inlined) { + public AbstractAddress recordDataReferenceInCode(Constant data, int alignment, boolean inlined) { assert data != null; int pos = asm.codeBuffer.position(); Debug.log("Data reference in code: pos = %d, data = %s", pos, data.toString()); @@ -176,11 +176,11 @@ /** * Returns the address of a float constant that is embedded as a data references into the code. */ - public Address asFloatConstRef(Value value) { + public AbstractAddress asFloatConstRef(Value value) { return asFloatConstRef(value, 4); } - public Address asFloatConstRef(Value value, int alignment) { + public AbstractAddress asFloatConstRef(Value value, int alignment) { assert value.getKind() == Kind.Float && isConstant(value); return recordDataReferenceInCode((Constant) value, alignment, false); } @@ -188,11 +188,11 @@ /** * Returns the address of a double constant that is embedded as a data references into the code. */ - public Address asDoubleConstRef(Value value) { + public AbstractAddress asDoubleConstRef(Value value) { return asDoubleConstRef(value, 8); } - public Address asDoubleConstRef(Value value, int alignment) { + public AbstractAddress asDoubleConstRef(Value value, int alignment) { assert value.getKind() == Kind.Double && isConstant(value); return recordDataReferenceInCode((Constant) value, alignment, false); } @@ -200,37 +200,37 @@ /** * Returns the address of a long constant that is embedded as a data references into the code. */ - public Address asLongConstRef(Value value) { + public AbstractAddress asLongConstRef(Value value) { assert value.getKind() == Kind.Long && isConstant(value); return recordDataReferenceInCode((Constant) value, 8, false); } - public Address asIntAddr(Value value) { + public AbstractAddress asIntAddr(Value value) { assert value.getKind() == Kind.Int; return asAddress(value); } - public Address asLongAddr(Value value) { + public AbstractAddress asLongAddr(Value value) { assert value.getKind() == Kind.Long; return asAddress(value); } - public Address asObjectAddr(Value value) { + public AbstractAddress asObjectAddr(Value value) { assert value.getKind() == Kind.Object; return asAddress(value); } - public Address asFloatAddr(Value value) { + public AbstractAddress asFloatAddr(Value value) { assert value.getKind() == Kind.Float; return asAddress(value); } - public Address asDoubleAddr(Value value) { + public AbstractAddress asDoubleAddr(Value value) { assert value.getKind() == Kind.Double; return asAddress(value); } - public Address asAddress(Value value) { + public AbstractAddress asAddress(Value value) { if (isStackSlot(value)) { StackSlot slot = (StackSlot) value; return asm.makeAddress(slot.getKind(), frameMap.registerConfig.getFrameRegister().asValue(), frameMap.offsetForStackSlot(slot));