Search in sources :

Example 1 with ConstantValue

use of org.graalvm.compiler.lir.ConstantValue 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)

Example 2 with ConstantValue

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

the class AArch64ArithmeticLIRGenerator method emitSignExtend.

@Override
public Value emitSignExtend(Value inputVal, int fromBits, int toBits) {
    LIRKind resultKind = getResultLirKind(toBits, inputVal);
    assert fromBits <= toBits && toBits <= 64;
    if (fromBits == toBits) {
        return inputVal;
    } else if (isJavaConstant(inputVal)) {
        JavaConstant javaConstant = asJavaConstant(inputVal);
        long constant;
        if (javaConstant.isNull()) {
            constant = 0;
        } else {
            constant = javaConstant.asLong();
        }
        int shiftCount = QWORD.getSizeInBytes() * 8 - fromBits;
        return new ConstantValue(resultKind, JavaConstant.forLong((constant << shiftCount) >> shiftCount));
    }
    Variable result = getLIRGen().newVariable(resultKind);
    getLIRGen().append(new AArch64SignExtendOp(result, getLIRGen().asAllocatable(inputVal), fromBits, toBits));
    return result;
}
Also used : AArch64SignExtendOp(org.graalvm.compiler.lir.aarch64.AArch64SignExtendOp) Variable(org.graalvm.compiler.lir.Variable) LIRValueUtil.asJavaConstant(org.graalvm.compiler.lir.LIRValueUtil.asJavaConstant) LIRValueUtil.isJavaConstant(org.graalvm.compiler.lir.LIRValueUtil.isJavaConstant) JavaConstant(jdk.vm.ci.meta.JavaConstant) LIRKind(org.graalvm.compiler.core.common.LIRKind) ConstantValue(org.graalvm.compiler.lir.ConstantValue)

Example 3 with ConstantValue

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

the class SPARCArithmeticLIRGenerator method emitSignExtend.

@Override
public Value emitSignExtend(Value inputVal, int fromBits, int toBits) {
    assert fromBits <= toBits && toBits <= XWORD.getSizeInBits();
    LIRKind shiftKind = LIRKind.value(WORD);
    LIRKind resultKind = LIRKind.combine(inputVal).changeType(toBits > 32 ? XWORD : WORD);
    int shiftCount = XWORD.getSizeInBits() - fromBits;
    if (fromBits == toBits) {
        return inputVal;
    } else if (isJavaConstant(inputVal)) {
        JavaConstant javaConstant = asJavaConstant(inputVal);
        long constant;
        if (javaConstant.isNull()) {
            constant = 0;
        } else {
            constant = javaConstant.asLong();
        }
        return new ConstantValue(resultKind, JavaConstant.forLong((constant << shiftCount) >> shiftCount));
    } else {
        AllocatableValue inputAllocatable = getLIRGen().asAllocatable(inputVal);
        Variable result = getLIRGen().newVariable(resultKind);
        if (fromBits == WORD.getSizeInBits() && toBits == XWORD.getSizeInBits()) {
            getLIRGen().append(new SPARCOP3Op(Sra, inputAllocatable, g0.asValue(LIRKind.value(WORD)), result));
        } else {
            Variable tmp = getLIRGen().newVariable(resultKind.changeType(XWORD));
            getLIRGen().append(new SPARCOP3Op(Sllx, inputAllocatable, new ConstantValue(shiftKind, JavaConstant.forInt(shiftCount)), tmp));
            getLIRGen().append(new SPARCOP3Op(Srax, tmp, new ConstantValue(shiftKind, JavaConstant.forInt(shiftCount)), result));
        }
        return result;
    }
}
Also used : Variable(org.graalvm.compiler.lir.Variable) JavaConstant(jdk.vm.ci.meta.JavaConstant) LIRValueUtil.asJavaConstant(org.graalvm.compiler.lir.LIRValueUtil.asJavaConstant) LIRValueUtil.isJavaConstant(org.graalvm.compiler.lir.LIRValueUtil.isJavaConstant) LIRKind(org.graalvm.compiler.core.common.LIRKind) ConstantValue(org.graalvm.compiler.lir.ConstantValue) AllocatableValue(jdk.vm.ci.meta.AllocatableValue) SPARCOP3Op(org.graalvm.compiler.lir.sparc.SPARCOP3Op)

Example 4 with ConstantValue

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

the class WordCastNode method generate.

@Override
public void generate(NodeLIRBuilderTool generator) {
    Value value = generator.operand(input);
    ValueKind<?> kind = generator.getLIRGeneratorTool().getLIRKind(stamp(NodeView.DEFAULT));
    assert kind.getPlatformKind().getSizeInBytes() == value.getPlatformKind().getSizeInBytes();
    if (trackedPointer && LIRKind.isValue(kind) && !LIRKind.isValue(value)) {
        // just change the PlatformKind, but don't drop reference information
        kind = value.getValueKind().changeType(kind.getPlatformKind());
    }
    if (kind.equals(value.getValueKind()) && !(value instanceof ConstantValue)) {
        generator.setResult(this, value);
    } else {
        AllocatableValue result = generator.getLIRGeneratorTool().newVariable(kind);
        generator.getLIRGeneratorTool().emitMove(result, value);
        generator.setResult(this, result);
    }
}
Also used : ConstantValue(org.graalvm.compiler.lir.ConstantValue) Value(jdk.vm.ci.meta.Value) AllocatableValue(jdk.vm.ci.meta.AllocatableValue) ConstantValue(org.graalvm.compiler.lir.ConstantValue) AllocatableValue(jdk.vm.ci.meta.AllocatableValue)

Example 5 with ConstantValue

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

the class AArch64ArithmeticLIRGenerator method emitZeroExtend.

@Override
public Value emitZeroExtend(Value inputVal, int fromBits, int toBits) {
    assert fromBits <= toBits && toBits <= 64;
    if (fromBits == toBits) {
        return inputVal;
    }
    LIRKind resultKind = getResultLirKind(toBits, inputVal);
    long mask = NumUtil.getNbitNumberLong(fromBits);
    Value maskValue = new ConstantValue(resultKind, JavaConstant.forLong(mask));
    return emitBinary(resultKind, AArch64ArithmeticOp.AND, true, inputVal, maskValue);
}
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

ConstantValue (org.graalvm.compiler.lir.ConstantValue)8 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)4 Value (jdk.vm.ci.meta.Value)4 LIRKind (org.graalvm.compiler.core.common.LIRKind)4 Variable (org.graalvm.compiler.lir.Variable)3 RegisterValue (jdk.vm.ci.code.RegisterValue)2 JavaConstant (jdk.vm.ci.meta.JavaConstant)2 LIRValueUtil.asJavaConstant (org.graalvm.compiler.lir.LIRValueUtil.asJavaConstant)2 LIRValueUtil.isJavaConstant (org.graalvm.compiler.lir.LIRValueUtil.isJavaConstant)2 AArch64AddressValue (org.graalvm.compiler.lir.aarch64.AArch64AddressValue)2 BitSet (java.util.BitSet)1 VirtualObject (jdk.vm.ci.code.VirtualObject)1 JavaValue (jdk.vm.ci.meta.JavaValue)1 GraalError (org.graalvm.compiler.debug.GraalError)1 LIRInstruction (org.graalvm.compiler.lir.LIRInstruction)1 VirtualStackSlot (org.graalvm.compiler.lir.VirtualStackSlot)1 AArch64SignExtendOp (org.graalvm.compiler.lir.aarch64.AArch64SignExtendOp)1 SPARCOP3Op (org.graalvm.compiler.lir.sparc.SPARCOP3Op)1 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)1 ValueNode (org.graalvm.compiler.nodes.ValueNode)1