Search in sources :

Example 1 with SPARCOPFOp

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;
}
Also used : SPARCOPFOp(org.graalvm.compiler.lir.sparc.SPARCOPFOp) FloatConvertOp(org.graalvm.compiler.lir.sparc.SPARCArithmetic.FloatConvertOp) AllocatableValue(jdk.vm.ci.meta.AllocatableValue)

Example 2 with SPARCOPFOp

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;
}
Also used : SPARCOPFOp(org.graalvm.compiler.lir.sparc.SPARCOPFOp) Variable(org.graalvm.compiler.lir.Variable) Opfs(org.graalvm.compiler.asm.sparc.SPARCAssembler.Opfs) SPARCKind(jdk.vm.ci.sparc.SPARCKind)

Example 3 with SPARCOPFOp

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;
}
Also used : SPARCOPFOp(org.graalvm.compiler.lir.sparc.SPARCOPFOp) Variable(org.graalvm.compiler.lir.Variable)

Example 4 with SPARCOPFOp

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;
}
Also used : SPARCOPFOp(org.graalvm.compiler.lir.sparc.SPARCOPFOp) Variable(org.graalvm.compiler.lir.Variable)

Example 5 with SPARCOPFOp

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;
}
Also used : SPARCOPFOp(org.graalvm.compiler.lir.sparc.SPARCOPFOp) Variable(org.graalvm.compiler.lir.Variable) Opfs(org.graalvm.compiler.asm.sparc.SPARCAssembler.Opfs) SPARCKind(jdk.vm.ci.sparc.SPARCKind)

Aggregations

SPARCOPFOp (org.graalvm.compiler.lir.sparc.SPARCOPFOp)5 Variable (org.graalvm.compiler.lir.Variable)4 SPARCKind (jdk.vm.ci.sparc.SPARCKind)2 Opfs (org.graalvm.compiler.asm.sparc.SPARCAssembler.Opfs)2 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)1 FloatConvertOp (org.graalvm.compiler.lir.sparc.SPARCArithmetic.FloatConvertOp)1