Search in sources :

Example 46 with Variable

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

the class SPARCArithmeticLIRGenerator method emitUnary.

private Variable emitUnary(Op3s op3, Value input) {
    Variable result = getLIRGen().newVariable(LIRKind.combine(input));
    getLIRGen().append(SPARCOP3Op.newUnary(op3, getLIRGen().loadSimm13(input), result));
    return result;
}
Also used : Variable(org.graalvm.compiler.lir.Variable)

Example 47 with Variable

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

the class SPARCArithmeticLIRGenerator method emitStore.

@Override
public void emitStore(ValueKind<?> kind, Value address, Value inputVal, LIRFrameState state) {
    SPARCAddressValue storeAddress = getLIRGen().asAddressValue(address);
    if (isJavaConstant(inputVal)) {
        JavaConstant c = asJavaConstant(inputVal);
        if (c.isDefaultForKind()) {
            getLIRGen().append(new StoreConstantOp(kind.getPlatformKind(), storeAddress, c, state));
            return;
        }
    }
    Variable input = getLIRGen().load(inputVal);
    getLIRGen().append(new StoreOp(kind.getPlatformKind(), storeAddress, input, state));
}
Also used : Variable(org.graalvm.compiler.lir.Variable) SPARCAddressValue(org.graalvm.compiler.lir.sparc.SPARCAddressValue) JavaConstant(jdk.vm.ci.meta.JavaConstant) LIRValueUtil.asJavaConstant(org.graalvm.compiler.lir.LIRValueUtil.asJavaConstant) LIRValueUtil.isJavaConstant(org.graalvm.compiler.lir.LIRValueUtil.isJavaConstant) StoreOp(org.graalvm.compiler.lir.sparc.SPARCMove.StoreOp) StoreConstantOp(org.graalvm.compiler.lir.sparc.SPARCMove.StoreConstantOp)

Example 48 with Variable

use of org.graalvm.compiler.lir.Variable 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;
    }
}
Also used : Variable(org.graalvm.compiler.lir.Variable) JavaConstant(jdk.vm.ci.meta.JavaConstant) LIRValueUtil.asJavaConstant(org.graalvm.compiler.lir.LIRValueUtil.asJavaConstant) LIRValueUtil.isJavaConstant(org.graalvm.compiler.lir.LIRValueUtil.isJavaConstant) LIRKind(org.graalvm.compiler.core.common.LIRKind) ConstantValue(org.graalvm.compiler.lir.ConstantValue) AllocatableValue(jdk.vm.ci.meta.AllocatableValue) SPARCOP3Op(org.graalvm.compiler.lir.sparc.SPARCOP3Op)

Example 49 with Variable

use of org.graalvm.compiler.lir.Variable 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 50 with Variable

use of org.graalvm.compiler.lir.Variable 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;
}
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) AllocatableValue(jdk.vm.ci.meta.AllocatableValue) SPARCOP3Op(org.graalvm.compiler.lir.sparc.SPARCOP3Op)

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