Search in sources :

Example 51 with Variable

use of org.graalvm.compiler.lir.Variable in project graal by oracle.

the class SPARCArithmeticLIRGenerator method emitBitScanForward.

@Override
public Variable emitBitScanForward(Value operand) {
    Variable result = getLIRGen().newVariable(LIRKind.combine(operand).changeType(SPARCKind.WORD));
    getLIRGen().append(new SPARCBitManipulationOp(BSF, result, getLIRGen().asAllocatable(operand), getLIRGen()));
    return result;
}
Also used : Variable(org.graalvm.compiler.lir.Variable) SPARCBitManipulationOp(org.graalvm.compiler.lir.sparc.SPARCBitManipulationOp)

Example 52 with Variable

use of org.graalvm.compiler.lir.Variable in project graal by oracle.

the class SPARCArithmeticLIRGenerator method emitRem.

@Override
public Value emitRem(Value a, Value b, LIRFrameState state) {
    Variable result = getLIRGen().newVariable(LIRKind.combine(a, b));
    // Intermediate values
    Variable q1;
    Variable q2;
    switch((SPARCKind) a.getPlatformKind()) {
        case WORD:
            // Sign extend a and b
            Value as = emitSignExtend(a);
            Value bs = emitSignExtend(b);
            q1 = emitBinary(as.getValueKind(), Sdivx, as, bs, state);
            q2 = emitBinary(as.getValueKind(), Mulx, q1, bs);
            result = emitSub(as, q2, false);
            break;
        case XWORD:
            q1 = emitBinary(result.getValueKind(), Sdivx, a, b, state);
            q2 = emitBinary(result.getValueKind(), Mulx, q1, b);
            result = emitSub(a, q2, false);
            break;
        case SINGLE:
            ForeignCallLinkage fremCall = getLIRGen().getForeignCalls().lookupForeignCall(ARITHMETIC_FREM);
            result = getLIRGen().emitForeignCall(fremCall, state, a, b);
            break;
        case DOUBLE:
            ForeignCallLinkage dremCall = getLIRGen().getForeignCalls().lookupForeignCall(ARITHMETIC_DREM);
            result = getLIRGen().emitForeignCall(dremCall, state, a, b);
            break;
        default:
            throw GraalError.shouldNotReachHere("missing: " + a.getPlatformKind());
    }
    return result;
}
Also used : Variable(org.graalvm.compiler.lir.Variable) ConstantValue(org.graalvm.compiler.lir.ConstantValue) Value(jdk.vm.ci.meta.Value) AllocatableValue(jdk.vm.ci.meta.AllocatableValue) SPARCAddressValue(org.graalvm.compiler.lir.sparc.SPARCAddressValue) ForeignCallLinkage(org.graalvm.compiler.core.common.spi.ForeignCallLinkage) SPARCKind(jdk.vm.ci.sparc.SPARCKind)

Example 53 with Variable

use of org.graalvm.compiler.lir.Variable in project graal by oracle.

the class SPARCArithmeticLIRGenerator method emitReinterpret.

@Override
public AllocatableValue emitReinterpret(LIRKind to, Value inputVal) {
    SPARCKind fromKind = (SPARCKind) inputVal.getPlatformKind();
    SPARCKind toKind = (SPARCKind) to.getPlatformKind();
    AllocatableValue input = getLIRGen().asAllocatable(inputVal);
    Variable result = getLIRGen().newVariable(to);
    // These cases require a move between CPU and FPU registers:
    if (fromKind.isFloat() != toKind.isFloat()) {
        moveBetweenFpGp(result, input);
        return result;
    } else {
        // Consequently, there is no need for a special zero-extension move.
        return emitConvertMove(to, input);
    }
}
Also used : Variable(org.graalvm.compiler.lir.Variable) SPARCKind(jdk.vm.ci.sparc.SPARCKind) AllocatableValue(jdk.vm.ci.meta.AllocatableValue)

Example 54 with Variable

use of org.graalvm.compiler.lir.Variable in project graal by oracle.

the class SPARCArithmeticLIRGenerator method emitNarrow.

@Override
public Value emitNarrow(Value inputVal, int bits) {
    if (inputVal.getPlatformKind() == XWORD && bits <= 32) {
        LIRKind resultKind = LIRKind.combine(inputVal).changeType(WORD);
        Variable result = getLIRGen().newVariable(resultKind);
        getLIRGen().emitMove(result, inputVal);
        return result;
    } else {
        return inputVal;
    }
}
Also used : Variable(org.graalvm.compiler.lir.Variable) LIRKind(org.graalvm.compiler.core.common.LIRKind)

Example 55 with Variable

use of org.graalvm.compiler.lir.Variable in project graal by oracle.

the class SPARCArithmeticLIRGenerator method emitURem.

@Override
public Value emitURem(Value a, Value b, LIRFrameState state) {
    Variable result = getLIRGen().newVariable(LIRKind.combine(a, b));
    Variable scratch1 = getLIRGen().newVariable(LIRKind.combine(a, b));
    Variable scratch2 = getLIRGen().newVariable(LIRKind.combine(a, b));
    Rem opcode;
    switch(((SPARCKind) a.getPlatformKind())) {
        case WORD:
            opcode = Rem.IUREM;
            break;
        case XWORD:
            opcode = Rem.LUREM;
            break;
        default:
            throw GraalError.shouldNotReachHere();
    }
    getLIRGen().append(new RemOp(opcode, result, getLIRGen().asAllocatable(a), getLIRGen().asAllocatable(b), scratch1, scratch2, state));
    return result;
}
Also used : Variable(org.graalvm.compiler.lir.Variable) RemOp(org.graalvm.compiler.lir.sparc.SPARCArithmetic.RemOp) Rem(org.graalvm.compiler.lir.sparc.SPARCArithmetic.RemOp.Rem)

Aggregations

Variable (org.graalvm.compiler.lir.Variable)113 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)27 LIRKind (org.graalvm.compiler.core.common.LIRKind)19 RegisterValue (jdk.vm.ci.code.RegisterValue)11 Value (jdk.vm.ci.meta.Value)11 Register (jdk.vm.ci.code.Register)10 AMD64Unary (org.graalvm.compiler.lir.amd64.AMD64Unary)9 AMD64Binary (org.graalvm.compiler.lir.amd64.AMD64Binary)8 SPARCAddressValue (org.graalvm.compiler.lir.sparc.SPARCAddressValue)8 AMD64Kind (jdk.vm.ci.amd64.AMD64Kind)7 AMD64AddressValue (org.graalvm.compiler.lir.amd64.AMD64AddressValue)7 SPARCKind (jdk.vm.ci.sparc.SPARCKind)6 ConstantValue (org.graalvm.compiler.lir.ConstantValue)6 JavaConstant (jdk.vm.ci.meta.JavaConstant)5 PlatformKind (jdk.vm.ci.meta.PlatformKind)5 LIRFrameState (org.graalvm.compiler.lir.LIRFrameState)5 LIRValueUtil.asJavaConstant (org.graalvm.compiler.lir.LIRValueUtil.asJavaConstant)5 LIRValueUtil.isJavaConstant (org.graalvm.compiler.lir.LIRValueUtil.isJavaConstant)5 AMD64MathIntrinsicUnaryOp (org.graalvm.compiler.lir.amd64.AMD64MathIntrinsicUnaryOp)5 AMD64Move (org.graalvm.compiler.lir.amd64.AMD64Move)5