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