use of jdk.vm.ci.meta.AllocatableValue in project graal by oracle.
the class SPARCHotSpotLIRGenerator method emitCompress.
@Override
public Value emitCompress(Value pointer, CompressEncoding encoding, boolean nonNull) {
LIRKind inputKind = pointer.getValueKind(LIRKind.class);
assert inputKind.getPlatformKind() == XWORD : inputKind;
if (inputKind.isReference(0)) {
// oop
Variable result = newVariable(LIRKind.compressedReference(WORD));
append(new SPARCHotSpotMove.CompressPointer(result, asAllocatable(pointer), getProviders().getRegisters().getHeapBaseRegister().asValue(), encoding, nonNull));
return result;
} else {
// metaspace pointer
Variable result = newVariable(LIRKind.value(WORD));
AllocatableValue base = Value.ILLEGAL;
if (encoding.hasBase()) {
base = emitLoadConstant(LIRKind.value(XWORD), JavaConstant.forLong(encoding.getBase()));
}
append(new SPARCHotSpotMove.CompressPointer(result, asAllocatable(pointer), base, encoding, nonNull));
return result;
}
}
use of jdk.vm.ci.meta.AllocatableValue in project graal by oracle.
the class SPARCHotSpotSafepointOp method emitPrologue.
static void emitPrologue(SPARCHotSpotNodeLIRBuilder lir, SPARCHotSpotLIRGenerator gen) {
if (!gen.config.threadLocalHandshakes) {
AllocatableValue var = gen.getSafepointAddressValue();
lir.append(new SPARCHotSpotSafepointOp.SPARCLoadSafepointPollAddress(var, gen.config));
gen.append(((HotSpotDebugInfoBuilder) lir.getDebugInfoBuilder()).lockStack());
}
}
use of jdk.vm.ci.meta.AllocatableValue in project graal by oracle.
the class SPARCArithmeticLIRGenerator method emitFloatConvert.
@Override
public Value emitFloatConvert(FloatConvert op, Value inputValue) {
AllocatableValue inputAllocatable = getLIRGen().asAllocatable(inputValue);
AllocatableValue result;
switch(op) {
case D2F:
result = getLIRGen().newVariable(LIRKind.combine(inputValue).changeType(SINGLE));
getLIRGen().append(new SPARCOPFOp(Fdtos, inputAllocatable, result));
break;
case F2D:
result = getLIRGen().newVariable(LIRKind.combine(inputValue).changeType(DOUBLE));
getLIRGen().append(new SPARCOPFOp(Fstod, inputAllocatable, result));
break;
case I2F:
{
AllocatableValue intEncodedFloatReg = getLIRGen().newVariable(LIRKind.combine(inputAllocatable).changeType(SINGLE));
result = getLIRGen().newVariable(intEncodedFloatReg.getValueKind());
moveBetweenFpGp(intEncodedFloatReg, inputAllocatable);
getLIRGen().append(new SPARCOPFOp(Fitos, intEncodedFloatReg, result));
break;
}
case I2D:
{
// Unfortunately we must do int -> float -> double because fitod has float
// and double encoding in one instruction
AllocatableValue convertedFloatReg = getLIRGen().newVariable(LIRKind.combine(inputAllocatable).changeType(SINGLE));
result = getLIRGen().newVariable(LIRKind.combine(inputAllocatable).changeType(DOUBLE));
moveBetweenFpGp(convertedFloatReg, inputAllocatable);
getLIRGen().append(new SPARCOPFOp(Fitod, convertedFloatReg, result));
break;
}
case L2D:
{
AllocatableValue longEncodedDoubleReg = getLIRGen().newVariable(LIRKind.combine(inputAllocatable).changeType(DOUBLE));
moveBetweenFpGp(longEncodedDoubleReg, inputAllocatable);
AllocatableValue convertedDoubleReg = getLIRGen().newVariable(longEncodedDoubleReg.getValueKind());
getLIRGen().append(new SPARCOPFOp(Fxtod, longEncodedDoubleReg, convertedDoubleReg));
result = convertedDoubleReg;
break;
}
case D2I:
{
AllocatableValue convertedFloatReg = getLIRGen().newVariable(LIRKind.combine(inputAllocatable).changeType(SINGLE));
getLIRGen().append(new SPARCArithmetic.FloatConvertOp(FloatConvertOp.FloatConvert.D2I, inputAllocatable, convertedFloatReg));
AllocatableValue convertedIntReg = getLIRGen().newVariable(LIRKind.combine(convertedFloatReg).changeType(WORD));
moveBetweenFpGp(convertedIntReg, convertedFloatReg);
result = convertedIntReg;
break;
}
case F2L:
{
AllocatableValue convertedDoubleReg = getLIRGen().newVariable(LIRKind.combine(inputAllocatable).changeType(DOUBLE));
getLIRGen().append(new SPARCArithmetic.FloatConvertOp(FloatConvertOp.FloatConvert.F2L, inputAllocatable, convertedDoubleReg));
AllocatableValue convertedLongReg = getLIRGen().newVariable(LIRKind.combine(convertedDoubleReg).changeType(XWORD));
moveBetweenFpGp(convertedLongReg, convertedDoubleReg);
result = convertedLongReg;
break;
}
case F2I:
{
AllocatableValue convertedFloatReg = getLIRGen().newVariable(LIRKind.combine(inputAllocatable).changeType(SINGLE));
getLIRGen().append(new SPARCArithmetic.FloatConvertOp(FloatConvertOp.FloatConvert.F2I, inputAllocatable, convertedFloatReg));
AllocatableValue convertedIntReg = getLIRGen().newVariable(LIRKind.combine(convertedFloatReg).changeType(WORD));
moveBetweenFpGp(convertedIntReg, convertedFloatReg);
result = convertedIntReg;
break;
}
case D2L:
{
AllocatableValue convertedDoubleReg = getLIRGen().newVariable(LIRKind.combine(inputAllocatable).changeType(DOUBLE));
getLIRGen().append(new SPARCArithmetic.FloatConvertOp(FloatConvertOp.FloatConvert.D2L, inputAllocatable, convertedDoubleReg));
AllocatableValue convertedLongReg = getLIRGen().newVariable(LIRKind.combine(convertedDoubleReg).changeType(XWORD));
moveBetweenFpGp(convertedLongReg, convertedDoubleReg);
result = convertedLongReg;
break;
}
case L2F:
{
AllocatableValue convertedDoubleReg = getLIRGen().newVariable(LIRKind.combine(inputAllocatable).changeType(DOUBLE));
result = getLIRGen().newVariable(LIRKind.combine(inputAllocatable).changeType(SINGLE));
moveBetweenFpGp(convertedDoubleReg, inputAllocatable);
getLIRGen().append(new SPARCOPFOp(Opfs.Fxtos, convertedDoubleReg, result));
break;
}
default:
throw GraalError.shouldNotReachHere();
}
return result;
}
use of jdk.vm.ci.meta.AllocatableValue 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 jdk.vm.ci.meta.AllocatableValue in project graal by oracle.
the class SPARCArithmeticLIRGenerator method emitZeroExtend.
@Override
public Value emitZeroExtend(Value inputValue, int fromBits, int toBits) {
assert fromBits <= toBits && toBits <= 64;
if (fromBits == toBits) {
return inputValue;
}
Variable result = getLIRGen().newVariable(LIRKind.combine(inputValue).changeType(toBits > WORD.getSizeInBits() ? XWORD : WORD));
AllocatableValue inputAllocatable = getLIRGen().asAllocatable(inputValue);
if (fromBits == 32) {
getLIRGen().append(new SPARCOP3Op(Srl, inputAllocatable, g0.asValue(), result));
} else {
Value mask = getLIRGen().emitConstant(LIRKind.value(XWORD), forLong(mask(fromBits)));
getLIRGen().append(new SPARCOP3Op(And, inputAllocatable, mask, result));
}
return result;
}
Aggregations