Search in sources :

Example 1 with AArch64SignExtendOp

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

Aggregations

JavaConstant (jdk.vm.ci.meta.JavaConstant)1 LIRKind (org.graalvm.compiler.core.common.LIRKind)1 ConstantValue (org.graalvm.compiler.lir.ConstantValue)1 LIRValueUtil.asJavaConstant (org.graalvm.compiler.lir.LIRValueUtil.asJavaConstant)1 LIRValueUtil.isJavaConstant (org.graalvm.compiler.lir.LIRValueUtil.isJavaConstant)1 Variable (org.graalvm.compiler.lir.Variable)1 AArch64SignExtendOp (org.graalvm.compiler.lir.aarch64.AArch64SignExtendOp)1