use of org.graalvm.compiler.lir.sparc.SPARCOPFOp 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 org.graalvm.compiler.lir.sparc.SPARCOPFOp in project graal by oracle.
the class SPARCArithmeticLIRGenerator method emitMathAbs.
@Override
public Value emitMathAbs(Value inputValue) {
Variable result = getLIRGen().newVariable(LIRKind.combine(inputValue));
SPARCKind kind = (SPARCKind) inputValue.getPlatformKind();
Opfs opf;
switch(kind) {
case SINGLE:
opf = Opfs.Fabss;
break;
case DOUBLE:
opf = Opfs.Fabsd;
break;
default:
throw GraalError.shouldNotReachHere("Input kind: " + kind);
}
getLIRGen().append(new SPARCOPFOp(opf, g0.asValue(), getLIRGen().asAllocatable(inputValue), result));
return result;
}
use of org.graalvm.compiler.lir.sparc.SPARCOPFOp in project graal by oracle.
the class SPARCArithmeticLIRGenerator method emitUnary.
private Variable emitUnary(Opfs opf, Value inputValue) {
Variable result = getLIRGen().newVariable(LIRKind.combine(inputValue));
getLIRGen().append(new SPARCOPFOp(opf, g0.asValue(), getLIRGen().asAllocatable(inputValue), result));
return result;
}
use of org.graalvm.compiler.lir.sparc.SPARCOPFOp in project graal by oracle.
the class SPARCArithmeticLIRGenerator method emitBinary.
private Variable emitBinary(ValueKind<?> resultKind, Opfs opf, Value a, Value b, LIRFrameState state) {
Variable result = getLIRGen().newVariable(resultKind);
getLIRGen().append(new SPARCOPFOp(opf, getLIRGen().asAllocatable(a), getLIRGen().asAllocatable(b), result, state));
return result;
}
use of org.graalvm.compiler.lir.sparc.SPARCOPFOp in project graal by oracle.
the class SPARCArithmeticLIRGenerator method emitMathSqrt.
@Override
public Value emitMathSqrt(Value inputValue) {
Variable result = getLIRGen().newVariable(LIRKind.combine(inputValue));
SPARCKind kind = (SPARCKind) inputValue.getPlatformKind();
Opfs opf;
switch(kind) {
case SINGLE:
opf = Opfs.Fsqrts;
break;
case DOUBLE:
opf = Opfs.Fsqrtd;
break;
default:
throw GraalError.shouldNotReachHere("Input kind: " + kind);
}
getLIRGen().append(new SPARCOPFOp(opf, g0.asValue(), getLIRGen().asAllocatable(inputValue), result));
return result;
}
Aggregations