Search in sources :

Example 11 with AMD64AddressValue

use of org.graalvm.compiler.lir.amd64.AMD64AddressValue in project graal by oracle.

the class AMD64NodeMatchRules method emitReinterpretMemory.

private Value emitReinterpretMemory(LIRKind to, Access access) {
    AMD64AddressValue address = (AMD64AddressValue) operand(access.getAddress());
    LIRFrameState state = getState(access);
    return getArithmeticLIRGenerator().emitLoad(to, address, state);
}
Also used : AMD64AddressValue(org.graalvm.compiler.lir.amd64.AMD64AddressValue) LIRFrameState(org.graalvm.compiler.lir.LIRFrameState)

Example 12 with AMD64AddressValue

use of org.graalvm.compiler.lir.amd64.AMD64AddressValue in project graal by oracle.

the class AMD64NodeMatchRules method emitCompareBranchMemory.

protected ComplexMatchResult emitCompareBranchMemory(IfNode ifNode, CompareNode compare, ValueNode value, LIRLowerableAccess access) {
    Condition cond = compare.condition().asCondition();
    AMD64Kind kind = getMemoryKind(access);
    // For assertion checking
    boolean matchedAsConstant = false;
    if (value.isConstant()) {
        JavaConstant constant = value.asJavaConstant();
        if (constant != null) {
            if (kind == AMD64Kind.QWORD && !constant.getJavaKind().isObject() && !NumUtil.isInt(constant.asLong())) {
                // Only imm32 as long
                return null;
            }
            // A QWORD that can be encoded as int can be embedded as a constant
            matchedAsConstant = kind == AMD64Kind.QWORD && !constant.getJavaKind().isObject() && NumUtil.isInt(constant.asLong());
        }
        if (kind == AMD64Kind.DWORD) {
            // Any DWORD value should be embeddable as a constant
            matchedAsConstant = true;
        }
        if (kind.isXMM()) {
            ifNode.getDebug().log("Skipping constant compares for float kinds");
            return null;
        }
    }
    boolean matchedAsConstantFinal = matchedAsConstant;
    /*
         * emitCompareBranchMemory expects the memory on the right, so mirror the condition if
         * that's not true. It might be mirrored again the actual compare is emitted but that's ok.
         */
    Condition finalCondition = GraphUtil.unproxify(compare.getX()) == access ? cond.mirror() : cond;
    return new ComplexMatchResult() {

        @Override
        public Value evaluate(NodeLIRBuilder builder) {
            LabelRef trueLabel = getLIRBlock(ifNode.trueSuccessor());
            LabelRef falseLabel = getLIRBlock(ifNode.falseSuccessor());
            boolean unorderedIsTrue = compare.unorderedIsTrue();
            double trueLabelProbability = ifNode.probability(ifNode.trueSuccessor());
            Value other = operand(value);
            /*
                 * Check that patterns which were matched as a constant actually end up seeing a
                 * constant in the LIR.
                 */
            assert !matchedAsConstantFinal || !LIRValueUtil.isVariable(other) : "expected constant value " + value;
            AMD64AddressValue address = (AMD64AddressValue) operand(access.getAddress());
            getLIRGeneratorTool().emitCompareBranchMemory(kind, other, address, getState(access), finalCondition, unorderedIsTrue, trueLabel, falseLabel, trueLabelProbability);
            return null;
        }
    };
}
Also used : Condition(org.graalvm.compiler.core.common.calc.Condition) CanonicalCondition(org.graalvm.compiler.core.common.calc.CanonicalCondition) AMD64AddressValue(org.graalvm.compiler.lir.amd64.AMD64AddressValue) AMD64Kind(jdk.vm.ci.amd64.AMD64Kind) ComplexMatchResult(org.graalvm.compiler.core.match.ComplexMatchResult) NodeLIRBuilder(org.graalvm.compiler.core.gen.NodeLIRBuilder) Value(jdk.vm.ci.meta.Value) AllocatableValue(jdk.vm.ci.meta.AllocatableValue) AMD64AddressValue(org.graalvm.compiler.lir.amd64.AMD64AddressValue) JavaConstant(jdk.vm.ci.meta.JavaConstant) LabelRef(org.graalvm.compiler.lir.LabelRef)

Example 13 with AMD64AddressValue

use of org.graalvm.compiler.lir.amd64.AMD64AddressValue in project graal by oracle.

the class AMD64AddressNode method generate.

@Override
public void generate(NodeLIRBuilderTool gen) {
    LIRGeneratorTool tool = gen.getLIRGeneratorTool();
    AllocatableValue baseValue = base == null ? Value.ILLEGAL : tool.asAllocatable(gen.operand(base));
    AllocatableValue indexValue = index == null ? Value.ILLEGAL : tool.asAllocatable(gen.operand(index));
    AllocatableValue baseReference = LIRKind.derivedBaseFromValue(baseValue);
    AllocatableValue indexReference;
    if (index == null) {
        indexReference = null;
    } else if (scale.equals(Scale.Times1)) {
        indexReference = LIRKind.derivedBaseFromValue(indexValue);
    } else {
        if (LIRKind.isValue(indexValue)) {
            indexReference = null;
        } else {
            indexReference = Value.ILLEGAL;
        }
    }
    LIRKind kind = LIRKind.combineDerived(tool.getLIRKind(stamp(NodeView.DEFAULT)), baseReference, indexReference);
    gen.setResult(this, new AMD64AddressValue(kind, baseValue, indexValue, scale, displacement));
}
Also used : AMD64AddressValue(org.graalvm.compiler.lir.amd64.AMD64AddressValue) LIRKind(org.graalvm.compiler.core.common.LIRKind) LIRGeneratorTool(org.graalvm.compiler.lir.gen.LIRGeneratorTool) AllocatableValue(jdk.vm.ci.meta.AllocatableValue)

Example 14 with AMD64AddressValue

use of org.graalvm.compiler.lir.amd64.AMD64AddressValue in project graal by oracle.

the class AMD64HotSpotLIRGenerator method moveValueToThread.

private void moveValueToThread(Value v, int offset) {
    LIRKind wordKind = LIRKind.value(target().arch.getWordKind());
    RegisterValue thread = getProviders().getRegisters().getThreadRegister().asValue(wordKind);
    AMD64AddressValue address = new AMD64AddressValue(wordKind, thread, offset);
    arithmeticLIRGen.emitStore(v.getValueKind(), address, v, null);
}
Also used : AMD64AddressValue(org.graalvm.compiler.lir.amd64.AMD64AddressValue) RegisterValue(jdk.vm.ci.code.RegisterValue) LIRKind(org.graalvm.compiler.core.common.LIRKind)

Example 15 with AMD64AddressValue

use of org.graalvm.compiler.lir.amd64.AMD64AddressValue in project graal by oracle.

the class AMD64HotSpotLIRGenerator method emitNullCheck.

@Override
public void emitNullCheck(Value address, LIRFrameState state) {
    if (address.getValueKind().getPlatformKind() == getLIRKindTool().getNarrowOopKind().getPlatformKind()) {
        CompressEncoding encoding = config.getOopEncoding();
        Value uncompressed;
        if (encoding.getShift() <= 3) {
            LIRKind wordKind = LIRKind.unknownReference(target().arch.getWordKind());
            uncompressed = new AMD64AddressValue(wordKind, getProviders().getRegisters().getHeapBaseRegister().asValue(wordKind), asAllocatable(address), Scale.fromInt(1 << encoding.getShift()), 0);
        } else {
            uncompressed = emitUncompress(address, encoding, false);
        }
        append(new AMD64Move.NullCheckOp(asAddressValue(uncompressed), state));
        return;
    }
    super.emitNullCheck(address, state);
}
Also used : AMD64AddressValue(org.graalvm.compiler.lir.amd64.AMD64AddressValue) CompressEncoding(org.graalvm.compiler.core.common.CompressEncoding) Value(jdk.vm.ci.meta.Value) AllocatableValue(jdk.vm.ci.meta.AllocatableValue) RegisterValue(jdk.vm.ci.code.RegisterValue) AMD64AddressValue(org.graalvm.compiler.lir.amd64.AMD64AddressValue) LIRKind(org.graalvm.compiler.core.common.LIRKind) AMD64Move(org.graalvm.compiler.lir.amd64.AMD64Move)

Aggregations

AMD64AddressValue (org.graalvm.compiler.lir.amd64.AMD64AddressValue)15 AMD64Kind (jdk.vm.ci.amd64.AMD64Kind)10 Variable (org.graalvm.compiler.lir.Variable)9 LIRKind (org.graalvm.compiler.core.common.LIRKind)6 RegisterValue (jdk.vm.ci.code.RegisterValue)5 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)5 JavaConstant (jdk.vm.ci.meta.JavaConstant)4 Value (jdk.vm.ci.meta.Value)4 NodeLIRBuilder (org.graalvm.compiler.core.gen.NodeLIRBuilder)4 ComplexMatchResult (org.graalvm.compiler.core.match.ComplexMatchResult)4 AMD64BinaryConsumer (org.graalvm.compiler.lir.amd64.AMD64BinaryConsumer)4 BranchOp (org.graalvm.compiler.lir.amd64.AMD64ControlFlow.BranchOp)4 AMD64MIOp (org.graalvm.compiler.asm.amd64.AMD64Assembler.AMD64MIOp)3 AMD64RMOp (org.graalvm.compiler.asm.amd64.AMD64Assembler.AMD64RMOp)3 OperandSize (org.graalvm.compiler.asm.amd64.AMD64Assembler.OperandSize)3 CanonicalCondition (org.graalvm.compiler.core.common.calc.CanonicalCondition)3 Condition (org.graalvm.compiler.core.common.calc.Condition)3 AMD64Move (org.graalvm.compiler.lir.amd64.AMD64Move)3 AMD64 (jdk.vm.ci.amd64.AMD64)2 CPUFeature (jdk.vm.ci.amd64.AMD64.CPUFeature)2