Search in sources :

Example 26 with Value

use of jdk.vm.ci.meta.Value in project graal by oracle.

the class WriteRegisterNode method generate.

@Override
public void generate(NodeLIRBuilderTool generator) {
    Value val = generator.operand(value);
    generator.getLIRGeneratorTool().emitMove(register.asValue(val.getValueKind()), val);
}
Also used : Value(jdk.vm.ci.meta.Value)

Example 27 with Value

use of jdk.vm.ci.meta.Value in project graal by oracle.

the class AMD64NodeLIRBuilder method emitIndirectCall.

@Override
protected void emitIndirectCall(IndirectCallTargetNode callTarget, Value result, Value[] parameters, Value[] temps, LIRFrameState callState) {
    Value targetAddressSrc = operand(callTarget.computedAddress());
    AllocatableValue targetAddress = AMD64.rax.asValue(targetAddressSrc.getValueKind());
    gen.emitMove(targetAddress, targetAddressSrc);
    append(new AMD64Call.IndirectCallOp(callTarget.targetMethod(), result, parameters, temps, targetAddress, callState));
}
Also used : AMD64Call(org.graalvm.compiler.lir.amd64.AMD64Call) Value(jdk.vm.ci.meta.Value) AllocatableValue(jdk.vm.ci.meta.AllocatableValue) AllocatableValue(jdk.vm.ci.meta.AllocatableValue)

Example 28 with Value

use of jdk.vm.ci.meta.Value in project graal by oracle.

the class AMD64NodeMatchRules method emitIntegerTestBranchMemory.

private ComplexMatchResult emitIntegerTestBranchMemory(IfNode x, ValueNode value, LIRLowerableAccess access) {
    LabelRef trueLabel = getLIRBlock(x.trueSuccessor());
    LabelRef falseLabel = getLIRBlock(x.falseSuccessor());
    double trueLabelProbability = x.probability(x.trueSuccessor());
    AMD64Kind kind = getMemoryKind(access);
    OperandSize size = kind == AMD64Kind.QWORD ? QWORD : DWORD;
    if (value.isConstant()) {
        JavaConstant constant = value.asJavaConstant();
        if (constant != null && kind == AMD64Kind.QWORD && !NumUtil.isInt(constant.asLong())) {
            // Only imm32 as long
            return null;
        }
        return builder -> {
            AMD64AddressValue address = (AMD64AddressValue) operand(access.getAddress());
            gen.append(new AMD64BinaryConsumer.MemoryConstOp(AMD64MIOp.TEST, size, address, (int) constant.asLong(), getState(access)));
            gen.append(new BranchOp(Condition.EQ, trueLabel, falseLabel, trueLabelProbability));
            return null;
        };
    } else {
        return builder -> {
            AMD64AddressValue address = (AMD64AddressValue) operand(access.getAddress());
            gen.append(new AMD64BinaryConsumer.MemoryRMOp(AMD64RMOp.TEST, size, gen.asAllocatable(operand(value)), address, getState(access)));
            gen.append(new BranchOp(Condition.EQ, trueLabel, falseLabel, trueLabelProbability));
            return null;
        };
    }
}
Also used : OperandSize(org.graalvm.compiler.asm.amd64.AMD64Assembler.OperandSize) AMD64RMOp(org.graalvm.compiler.asm.amd64.AMD64Assembler.AMD64RMOp) AVXOp(org.graalvm.compiler.asm.amd64.AMD64Assembler.AVXOp) AMD64BinaryConsumer(org.graalvm.compiler.lir.amd64.AMD64BinaryConsumer) NarrowNode(org.graalvm.compiler.nodes.calc.NarrowNode) LabelRef(org.graalvm.compiler.lir.LabelRef) UnsignedRightShiftNode(org.graalvm.compiler.nodes.calc.UnsignedRightShiftNode) SUB(org.graalvm.compiler.asm.amd64.AMD64Assembler.AMD64BinaryArithmetic.SUB) SignExtendNode(org.graalvm.compiler.nodes.calc.SignExtendNode) FloatConvertNode(org.graalvm.compiler.nodes.calc.FloatConvertNode) ZeroExtendNode(org.graalvm.compiler.nodes.calc.ZeroExtendNode) AMD64Kind(jdk.vm.ci.amd64.AMD64Kind) NumUtil(org.graalvm.compiler.core.common.NumUtil) IfNode(org.graalvm.compiler.nodes.IfNode) GraphUtil(org.graalvm.compiler.nodes.util.GraphUtil) NodeView(org.graalvm.compiler.nodes.NodeView) LIRLowerableAccess(org.graalvm.compiler.nodes.memory.LIRLowerableAccess) BranchOp(org.graalvm.compiler.lir.amd64.AMD64ControlFlow.BranchOp) MOVSX(org.graalvm.compiler.asm.amd64.AMD64Assembler.AMD64RMOp.MOVSX) NodeLIRBuilder(org.graalvm.compiler.core.gen.NodeLIRBuilder) DeoptimizingNode(org.graalvm.compiler.nodes.DeoptimizingNode) TargetDescription(jdk.vm.ci.code.TargetDescription) JavaConstant(jdk.vm.ci.meta.JavaConstant) PlatformKind(jdk.vm.ci.meta.PlatformKind) ValueNode(org.graalvm.compiler.nodes.ValueNode) Value(jdk.vm.ci.meta.Value) ComplexMatchResult(org.graalvm.compiler.core.match.ComplexMatchResult) Access(org.graalvm.compiler.nodes.memory.Access) ADD(org.graalvm.compiler.asm.amd64.AMD64Assembler.AMD64BinaryArithmetic.ADD) SS(org.graalvm.compiler.asm.amd64.AMD64Assembler.OperandSize.SS) DWORD(org.graalvm.compiler.asm.amd64.AMD64Assembler.OperandSize.DWORD) GraalError(org.graalvm.compiler.debug.GraalError) ValueKind(jdk.vm.ci.meta.ValueKind) MatchRule(org.graalvm.compiler.core.match.MatchRule) LogicCompareAndSwapNode(org.graalvm.compiler.nodes.java.LogicCompareAndSwapNode) AllocatableValue(jdk.vm.ci.meta.AllocatableValue) CompareNode(org.graalvm.compiler.nodes.calc.CompareNode) LeftShiftNode(org.graalvm.compiler.nodes.calc.LeftShiftNode) MOVSXB(org.graalvm.compiler.asm.amd64.AMD64Assembler.AMD64RMOp.MOVSXB) WriteNode(org.graalvm.compiler.nodes.memory.WriteNode) LIRFrameState(org.graalvm.compiler.lir.LIRFrameState) SD(org.graalvm.compiler.asm.amd64.AMD64Assembler.OperandSize.SD) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) ReinterpretNode(org.graalvm.compiler.nodes.calc.ReinterpretNode) AMD64RRMOp(org.graalvm.compiler.asm.amd64.AMD64Assembler.AMD64RRMOp) AMD64(jdk.vm.ci.amd64.AMD64) AMD64MIOp(org.graalvm.compiler.asm.amd64.AMD64Assembler.AMD64MIOp) ValueCompareAndSwapNode(org.graalvm.compiler.nodes.java.ValueCompareAndSwapNode) MOVSXD(org.graalvm.compiler.asm.amd64.AMD64Assembler.AMD64RMOp.MOVSXD) Condition(org.graalvm.compiler.core.common.calc.Condition) CPUFeature(jdk.vm.ci.amd64.AMD64.CPUFeature) LIRKind(org.graalvm.compiler.core.common.LIRKind) CanonicalCondition(org.graalvm.compiler.core.common.calc.CanonicalCondition) SSEOp(org.graalvm.compiler.asm.amd64.AMD64Assembler.SSEOp) OR(org.graalvm.compiler.asm.amd64.AMD64Assembler.AMD64BinaryArithmetic.OR) LIRValueUtil(org.graalvm.compiler.lir.LIRValueUtil) NodeMatchRules(org.graalvm.compiler.core.gen.NodeMatchRules) XOR(org.graalvm.compiler.asm.amd64.AMD64Assembler.AMD64BinaryArithmetic.XOR) LIRGeneratorTool(org.graalvm.compiler.lir.gen.LIRGeneratorTool) AND(org.graalvm.compiler.asm.amd64.AMD64Assembler.AMD64BinaryArithmetic.AND) AMD64AddressValue(org.graalvm.compiler.lir.amd64.AMD64AddressValue) QWORD(org.graalvm.compiler.asm.amd64.AMD64Assembler.OperandSize.QWORD) AMD64AddressValue(org.graalvm.compiler.lir.amd64.AMD64AddressValue) AMD64Kind(jdk.vm.ci.amd64.AMD64Kind) BranchOp(org.graalvm.compiler.lir.amd64.AMD64ControlFlow.BranchOp) JavaConstant(jdk.vm.ci.meta.JavaConstant) LabelRef(org.graalvm.compiler.lir.LabelRef) OperandSize(org.graalvm.compiler.asm.amd64.AMD64Assembler.OperandSize)

Example 29 with Value

use of jdk.vm.ci.meta.Value 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 30 with Value

use of jdk.vm.ci.meta.Value in project graal by oracle.

the class AArch64ArithmeticLIRGenerator method emitNarrow.

@Override
public Value emitNarrow(Value inputVal, int bits) {
    if (inputVal.getPlatformKind() == AArch64Kind.QWORD && bits <= 32) {
        LIRKind resultKind = getResultLirKind(bits, inputVal);
        long mask = NumUtil.getNbitNumberLong(bits);
        Value maskValue = new ConstantValue(resultKind, JavaConstant.forLong(mask));
        return emitBinary(resultKind, AArch64ArithmeticOp.AND, true, inputVal, maskValue);
    } else {
        return inputVal;
    }
}
Also used : ConstantValue(org.graalvm.compiler.lir.ConstantValue) AArch64AddressValue(org.graalvm.compiler.lir.aarch64.AArch64AddressValue) RegisterValue(jdk.vm.ci.code.RegisterValue) Value(jdk.vm.ci.meta.Value) AllocatableValue(jdk.vm.ci.meta.AllocatableValue) LIRKind(org.graalvm.compiler.core.common.LIRKind) ConstantValue(org.graalvm.compiler.lir.ConstantValue)

Aggregations

Value (jdk.vm.ci.meta.Value)151 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)76 RegisterValue (jdk.vm.ci.code.RegisterValue)33 LIRKind (org.graalvm.compiler.core.common.LIRKind)18 LIRInstruction (org.graalvm.compiler.lir.LIRInstruction)14 LIRValueUtil.isConstantValue (org.graalvm.compiler.lir.LIRValueUtil.isConstantValue)14 LIRValueUtil.isStackSlotValue (org.graalvm.compiler.lir.LIRValueUtil.isStackSlotValue)14 OperandMode (org.graalvm.compiler.lir.LIRInstruction.OperandMode)12 Variable (org.graalvm.compiler.lir.Variable)12 ComplexMatchValue (org.graalvm.compiler.core.match.ComplexMatchValue)11 Indent (org.graalvm.compiler.debug.Indent)11 EnumSet (java.util.EnumSet)10 DebugContext (org.graalvm.compiler.debug.DebugContext)10 GraalError (org.graalvm.compiler.debug.GraalError)10 LIRFrameState (org.graalvm.compiler.lir.LIRFrameState)10 BitSet (java.util.BitSet)9 Register (jdk.vm.ci.code.Register)9 ConstantValue (org.graalvm.compiler.lir.ConstantValue)9 SPARCAddressValue (org.graalvm.compiler.lir.sparc.SPARCAddressValue)9 ValueNode (org.graalvm.compiler.nodes.ValueNode)9