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;
}
Aggregations