Search in sources :

Example 1 with PrimitiveStamp

use of org.graalvm.compiler.core.common.type.PrimitiveStamp in project graal by oracle.

the class RawLoadNode method virtualize.

@Override
public void virtualize(VirtualizerTool tool) {
    ValueNode alias = tool.getAlias(object());
    if (alias instanceof VirtualObjectNode) {
        VirtualObjectNode virtual = (VirtualObjectNode) alias;
        ValueNode offsetValue = tool.getAlias(offset());
        if (offsetValue.isConstant()) {
            long off = offsetValue.asJavaConstant().asLong();
            int entryIndex = virtual.entryIndexForOffset(tool.getArrayOffsetProvider(), off, accessKind());
            if (entryIndex != -1) {
                ValueNode entry = tool.getEntry(virtual, entryIndex);
                JavaKind entryKind = virtual.entryKind(entryIndex);
                if (entry.getStackKind() == getStackKind() || entryKind == accessKind()) {
                    if (!(entry.stamp(NodeView.DEFAULT).isCompatible(stamp(NodeView.DEFAULT)))) {
                        if (entry.stamp(NodeView.DEFAULT) instanceof PrimitiveStamp && stamp instanceof PrimitiveStamp) {
                            PrimitiveStamp p1 = (PrimitiveStamp) stamp;
                            PrimitiveStamp p2 = (PrimitiveStamp) entry.stamp(NodeView.DEFAULT);
                            int width1 = p1.getBits();
                            int width2 = p2.getBits();
                            if (width1 == width2) {
                                Node replacement = ReinterpretNode.create(p2, entry, NodeView.DEFAULT);
                                tool.replaceWith((ValueNode) replacement);
                                return;
                            } else {
                                // different bit width
                                return;
                            }
                        } else {
                            // cannot reinterpret for arbitrary objects
                            return;
                        }
                    }
                    tool.replaceWith(entry);
                }
            }
        }
    }
}
Also used : VirtualObjectNode(org.graalvm.compiler.nodes.virtual.VirtualObjectNode) LoadFieldNode(org.graalvm.compiler.nodes.java.LoadFieldNode) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) ReinterpretNode(org.graalvm.compiler.nodes.calc.ReinterpretNode) VirtualObjectNode(org.graalvm.compiler.nodes.virtual.VirtualObjectNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) Node(org.graalvm.compiler.graph.Node) ValueNode(org.graalvm.compiler.nodes.ValueNode) PrimitiveStamp(org.graalvm.compiler.core.common.type.PrimitiveStamp) JavaKind(jdk.vm.ci.meta.JavaKind)

Example 2 with PrimitiveStamp

use of org.graalvm.compiler.core.common.type.PrimitiveStamp in project graal by oracle.

the class PrimitiveStampBoundaryTest method testShiftBoundaryValues.

private static void testShiftBoundaryValues(ShiftOp<?> shiftOp, HashSet<PrimitiveStamp> stamps, HashSet<IntegerStamp> shifts) {
    for (PrimitiveStamp testStamp : stamps) {
        if (testStamp instanceof IntegerStamp) {
            IntegerStamp stamp = (IntegerStamp) testStamp;
            for (IntegerStamp shiftStamp : shifts) {
                IntegerStamp foldedStamp = (IntegerStamp) shiftOp.foldStamp(stamp, shiftStamp);
                if (foldedStamp.isEmpty()) {
                    assertTrue(stamp.isEmpty() || shiftStamp.isEmpty());
                    continue;
                }
                checkShiftOperation(stamp.getBits(), shiftOp, foldedStamp, stamp.lowerBound(), shiftStamp.lowerBound());
                checkShiftOperation(stamp.getBits(), shiftOp, foldedStamp, stamp.lowerBound(), shiftStamp.upperBound());
                checkShiftOperation(stamp.getBits(), shiftOp, foldedStamp, stamp.upperBound(), shiftStamp.lowerBound());
                checkShiftOperation(stamp.getBits(), shiftOp, foldedStamp, stamp.upperBound(), shiftStamp.upperBound());
            }
        }
    }
}
Also used : IntegerStamp(org.graalvm.compiler.core.common.type.IntegerStamp) PrimitiveStamp(org.graalvm.compiler.core.common.type.PrimitiveStamp)

Example 3 with PrimitiveStamp

use of org.graalvm.compiler.core.common.type.PrimitiveStamp in project graal by oracle.

the class PrimitiveStampBoundaryTest method testConvertBoundaryValues.

private static void testConvertBoundaryValues(ArithmeticOpTable.FloatConvertOp op, int bits, HashSet<PrimitiveStamp> stamps) {
    for (PrimitiveStamp stamp : stamps) {
        if (bits == stamp.getBits()) {
            Stamp lower = boundaryStamp(stamp, false);
            Stamp upper = boundaryStamp(stamp, true);
            checkConvertOperation(op, op.foldStamp(stamp), lower);
            checkConvertOperation(op, op.foldStamp(stamp), upper);
        }
    }
}
Also used : PrimitiveStamp(org.graalvm.compiler.core.common.type.PrimitiveStamp) Stamp(org.graalvm.compiler.core.common.type.Stamp) IntegerStamp(org.graalvm.compiler.core.common.type.IntegerStamp) FloatStamp(org.graalvm.compiler.core.common.type.FloatStamp) PrimitiveStamp(org.graalvm.compiler.core.common.type.PrimitiveStamp)

Example 4 with PrimitiveStamp

use of org.graalvm.compiler.core.common.type.PrimitiveStamp in project graal by oracle.

the class PrimitiveStampBoundaryTest method testUnaryBoundaryValues.

private static void testUnaryBoundaryValues(ArithmeticOpTable.UnaryOp<?> op, HashSet<PrimitiveStamp> stamps) {
    for (PrimitiveStamp v1 : stamps) {
        Stamp result = op.foldStamp(v1);
        checkUnaryOperation(op, result, boundaryStamp(v1, false));
        checkUnaryOperation(op, result, boundaryStamp(v1, true));
    }
}
Also used : PrimitiveStamp(org.graalvm.compiler.core.common.type.PrimitiveStamp) Stamp(org.graalvm.compiler.core.common.type.Stamp) IntegerStamp(org.graalvm.compiler.core.common.type.IntegerStamp) FloatStamp(org.graalvm.compiler.core.common.type.FloatStamp) PrimitiveStamp(org.graalvm.compiler.core.common.type.PrimitiveStamp)

Example 5 with PrimitiveStamp

use of org.graalvm.compiler.core.common.type.PrimitiveStamp in project graal by oracle.

the class PrimitiveStampBoundaryTest method testConvertBoundaryValues.

private static void testConvertBoundaryValues(IntegerConvertOp<?> op, int inputBits, int resultBits, HashSet<PrimitiveStamp> stamps) {
    for (PrimitiveStamp stamp : stamps) {
        if (inputBits == stamp.getBits()) {
            Stamp lower = boundaryStamp(stamp, false);
            Stamp upper = boundaryStamp(stamp, true);
            checkConvertOperation(op, inputBits, resultBits, op.foldStamp(inputBits, resultBits, stamp), lower);
            checkConvertOperation(op, inputBits, resultBits, op.foldStamp(inputBits, resultBits, stamp), upper);
        }
    }
}
Also used : PrimitiveStamp(org.graalvm.compiler.core.common.type.PrimitiveStamp) Stamp(org.graalvm.compiler.core.common.type.Stamp) IntegerStamp(org.graalvm.compiler.core.common.type.IntegerStamp) FloatStamp(org.graalvm.compiler.core.common.type.FloatStamp) PrimitiveStamp(org.graalvm.compiler.core.common.type.PrimitiveStamp)

Aggregations

PrimitiveStamp (org.graalvm.compiler.core.common.type.PrimitiveStamp)6 IntegerStamp (org.graalvm.compiler.core.common.type.IntegerStamp)5 FloatStamp (org.graalvm.compiler.core.common.type.FloatStamp)4 Stamp (org.graalvm.compiler.core.common.type.Stamp)4 JavaKind (jdk.vm.ci.meta.JavaKind)1 Node (org.graalvm.compiler.graph.Node)1 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)1 ValueNode (org.graalvm.compiler.nodes.ValueNode)1 ReinterpretNode (org.graalvm.compiler.nodes.calc.ReinterpretNode)1 LoadFieldNode (org.graalvm.compiler.nodes.java.LoadFieldNode)1 VirtualObjectNode (org.graalvm.compiler.nodes.virtual.VirtualObjectNode)1