# HG changeset patch # User Josef Eisl # Date 1403720842 -7200 # Node ID d59e68286d602dc3c0d5c2d2c064994ebca46e6e # Parent aabd00bc60283b721263a03af5cd8ad1cc330f28 Move ValuePosition into a dedicated file. diff -r aabd00bc6028 -r d59e68286d60 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/CompositeValue.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/CompositeValue.java Wed Jun 25 20:15:35 2014 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/CompositeValue.java Wed Jun 25 20:27:22 2014 +0200 @@ -30,7 +30,6 @@ import com.oracle.graal.lir.LIRInstruction.OperandFlag; import com.oracle.graal.lir.LIRInstruction.OperandMode; import com.oracle.graal.lir.LIRInstruction.ValuePositionProcedure; -import com.oracle.graal.lir.LIRIntrospection.ValuePosition; /** * Base class to represent values that need to be stored in more than one register. diff -r aabd00bc6028 -r d59e68286d60 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRInstruction.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRInstruction.java Wed Jun 25 20:15:35 2014 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRInstruction.java Wed Jun 25 20:27:22 2014 +0200 @@ -32,7 +32,6 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.common.*; import com.oracle.graal.debug.*; -import com.oracle.graal.lir.LIRIntrospection.ValuePosition; import com.oracle.graal.lir.asm.*; /** diff -r aabd00bc6028 -r d59e68286d60 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRIntrospection.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRIntrospection.java Wed Jun 25 20:15:35 2014 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRIntrospection.java Wed Jun 25 20:27:22 2014 +0200 @@ -175,144 +175,6 @@ } } - /** - * Describes an operand slot for a {@link LIRInstructionClass}. - */ - public static final class ValuePosition { - - private final OperandMode mode; - private final int index; - private final int subIndex; - private final ValuePosition superPosition; - - public static final int NO_SUBINDEX = -1; - public static final ValuePosition ROOT_VALUE_POSITION = null; - - public ValuePosition(OperandMode mode, int index, int subIndex, ValuePosition superPosition) { - this.mode = mode; - this.index = index; - this.subIndex = subIndex; - this.superPosition = superPosition; - } - - public Value get(LIRInstruction inst) { - return LIRIntrospection.get(inst, this); - } - - public EnumSet getFlags(LIRInstruction inst) { - return LIRIntrospection.getFlags(inst, this); - } - - public void set(LIRInstruction inst, Value value) { - LIRIntrospection.set(inst, this, value); - } - - public int getSubIndex() { - return subIndex; - } - - public int getIndex() { - return index; - } - - public OperandMode getMode() { - return mode; - } - - public ValuePosition getSuperPosition() { - return superPosition; - } - - @Override - public String toString() { - if (superPosition == ROOT_VALUE_POSITION) { - return mode.toString() + index + "/" + subIndex; - } - return superPosition.toString() + "[" + mode.toString() + index + "/" + subIndex + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + index; - result = prime * result + ((mode == null) ? 0 : mode.hashCode()); - result = prime * result + subIndex; - result = prime * result + ((superPosition == null) ? 0 : superPosition.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - ValuePosition other = (ValuePosition) obj; - if (index != other.index) { - return false; - } - if (mode != other.mode) { - return false; - } - if (subIndex != other.subIndex) { - return false; - } - if (superPosition == null) { - if (other.superPosition != null) { - return false; - } - } else if (!superPosition.equals(other.superPosition)) { - return false; - } - return true; - } - - } - - private static CompositeValue getCompositeValue(LIRInstruction inst, ValuePosition pos) { - ValuePosition superPosition = pos.getSuperPosition(); - Value value; - if (superPosition == ValuePosition.ROOT_VALUE_POSITION) { - // At this point we are at the top of the ValuePosition tree - value = inst.getLIRInstructionClass().getValue(inst, pos); - } else { - // Get the containing value - value = getCompositeValue(inst, superPosition); - } - assert value instanceof CompositeValue : "only CompositeValue can contain nested values " + value; - return (CompositeValue) value; - } - - private static Value get(LIRInstruction inst, ValuePosition pos) { - if (pos.getSuperPosition() == ValuePosition.ROOT_VALUE_POSITION) { - return inst.getLIRInstructionClass().getValue(inst, pos); - } - CompositeValue compValue = getCompositeValue(inst, pos); - return compValue.getValueClass().getValue(compValue, pos); - } - - private static void set(LIRInstruction inst, ValuePosition pos, Value value) { - if (pos.getSuperPosition() == ValuePosition.ROOT_VALUE_POSITION) { - inst.getLIRInstructionClass().setValue(inst, pos, value); - } - CompositeValue compValue = getCompositeValue(inst, pos); - compValue.getValueClass().setValue(compValue, pos, value); - } - - private static EnumSet getFlags(LIRInstruction inst, ValuePosition pos) { - if (pos.getSuperPosition() == ValuePosition.ROOT_VALUE_POSITION) { - return inst.getLIRInstructionClass().getFlags(pos); - } - CompositeValue compValue = getCompositeValue(inst, pos); - return compValue.getValueClass().getFlags(pos); - } - protected static Value getValueForPosition(Object obj, long[] offsets, int directCount, ValuePosition pos) { if (pos.getIndex() < directCount) { return getValue(obj, offsets[pos.getIndex()]); diff -r aabd00bc6028 -r d59e68286d60 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/ValuePosition.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/ValuePosition.java Wed Jun 25 20:27:22 2014 +0200 @@ -0,0 +1,154 @@ +/* + * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.lir; + +import java.util.*; + +import com.oracle.graal.api.meta.*; +import com.oracle.graal.lir.LIRInstruction.*; + +/** + * Describes an operand slot for a {@link LIRInstructionClass}. + */ +public final class ValuePosition { + + private final OperandMode mode; + private final int index; + private final int subIndex; + private final ValuePosition superPosition; + + public static final int NO_SUBINDEX = -1; + public static final ValuePosition ROOT_VALUE_POSITION = null; + + public ValuePosition(OperandMode mode, int index, int subIndex, ValuePosition superPosition) { + this.mode = mode; + this.index = index; + this.subIndex = subIndex; + this.superPosition = superPosition; + } + + private static CompositeValue getCompositeValue(LIRInstruction inst, ValuePosition pos) { + ValuePosition superPosition = pos.getSuperPosition(); + Value value; + if (superPosition == ROOT_VALUE_POSITION) { + // At this point we are at the top of the ValuePosition tree + value = inst.getLIRInstructionClass().getValue(inst, pos); + } else { + // Get the containing value + value = getCompositeValue(inst, superPosition); + } + assert value instanceof CompositeValue : "only CompositeValue can contain nested values " + value; + return (CompositeValue) value; + } + + public Value get(LIRInstruction inst) { + if (this.getSuperPosition() == ROOT_VALUE_POSITION) { + return inst.getLIRInstructionClass().getValue(inst, this); + } + CompositeValue compValue = getCompositeValue(inst, this); + return compValue.getValueClass().getValue(compValue, this); + } + + public EnumSet getFlags(LIRInstruction inst) { + if (this.getSuperPosition() == ROOT_VALUE_POSITION) { + return inst.getLIRInstructionClass().getFlags(this); + } + CompositeValue compValue = getCompositeValue(inst, this); + return compValue.getValueClass().getFlags(this); + } + + public void set(LIRInstruction inst, Value value) { + if (this.getSuperPosition() == ROOT_VALUE_POSITION) { + inst.getLIRInstructionClass().setValue(inst, this, value); + } + CompositeValue compValue = getCompositeValue(inst, this); + compValue.getValueClass().setValue(compValue, this, value); + } + + public int getSubIndex() { + return subIndex; + } + + public int getIndex() { + return index; + } + + public OperandMode getMode() { + return mode; + } + + public ValuePosition getSuperPosition() { + return superPosition; + } + + @Override + public String toString() { + if (superPosition == ROOT_VALUE_POSITION) { + return mode.toString() + index + "/" + subIndex; + } + return superPosition.toString() + "[" + mode.toString() + index + "/" + subIndex + "]"; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + index; + result = prime * result + ((mode == null) ? 0 : mode.hashCode()); + result = prime * result + subIndex; + result = prime * result + ((superPosition == null) ? 0 : superPosition.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + ValuePosition other = (ValuePosition) obj; + if (index != other.index) { + return false; + } + if (mode != other.mode) { + return false; + } + if (subIndex != other.subIndex) { + return false; + } + if (superPosition == null) { + if (other.superPosition != null) { + return false; + } + } else if (!superPosition.equals(other.superPosition)) { + return false; + } + return true; + } + +}