Search in sources :

Example 21 with LIRKind

use of org.graalvm.compiler.core.common.LIRKind in project graal by oracle.

the class JVMCIInfopointErrorTest method testInvalidShortDerivedOop.

@Test(expected = Error.class)
public void testInvalidShortDerivedOop() {
    test((tool, state, safepoint) -> {
        Variable baseOop = tool.newVariable(LIRKind.fromJavaKind(tool.target().arch, JavaKind.Object));
        tool.append(new ValueDef(baseOop));
        PlatformKind kind = tool.target().arch.getPlatformKind(JavaKind.Short);
        LIRKind lirKind = LIRKind.derivedReference(kind, baseOop, false);
        Variable var = tool.newVariable(lirKind);
        tool.append(new ValueDef(var));
        safepoint.accept(state);
        tool.append(new ValueUse(var));
    });
}
Also used : Variable(org.graalvm.compiler.lir.Variable) PlatformKind(jdk.vm.ci.meta.PlatformKind) LIRKind(org.graalvm.compiler.core.common.LIRKind) GraalCompilerTest(org.graalvm.compiler.core.test.GraalCompilerTest) Test(org.junit.Test)

Example 22 with LIRKind

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

Example 23 with LIRKind

use of org.graalvm.compiler.core.common.LIRKind in project graal by oracle.

the class SPARCArithmeticLIRGenerator method emitShr.

@Override
public Variable emitShr(Value a, Value b) {
    SPARCKind aKind = (SPARCKind) a.getPlatformKind();
    LIRKind resultKind = LIRKind.combine(a, b).changeType(aKind);
    Op3s op;
    switch(aKind) {
        case WORD:
            op = Op3s.Sra;
            break;
        case XWORD:
            op = Op3s.Srax;
            break;
        default:
            throw GraalError.shouldNotReachHere();
    }
    return emitBinary(resultKind, op, a, b);
}
Also used : Op3s(org.graalvm.compiler.asm.sparc.SPARCAssembler.Op3s) LIRKind(org.graalvm.compiler.core.common.LIRKind) SPARCKind(jdk.vm.ci.sparc.SPARCKind)

Example 24 with LIRKind

use of org.graalvm.compiler.core.common.LIRKind 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 25 with LIRKind

use of org.graalvm.compiler.core.common.LIRKind in project graal by oracle.

the class SPARCArithmeticLIRGenerator method emitShl.

@Override
public Variable emitShl(Value a, Value b) {
    SPARCKind aKind = (SPARCKind) a.getPlatformKind();
    LIRKind resultKind = LIRKind.combine(a, b).changeType(aKind);
    Op3s op;
    switch(aKind) {
        case WORD:
            op = Op3s.Sll;
            break;
        case XWORD:
            op = Op3s.Sllx;
            break;
        default:
            throw GraalError.shouldNotReachHere(String.format("Unsupported kind %s", aKind));
    }
    return emitBinary(resultKind, op, a, b);
}
Also used : Op3s(org.graalvm.compiler.asm.sparc.SPARCAssembler.Op3s) LIRKind(org.graalvm.compiler.core.common.LIRKind) SPARCKind(jdk.vm.ci.sparc.SPARCKind)

Aggregations

LIRKind (org.graalvm.compiler.core.common.LIRKind)60 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)20 Variable (org.graalvm.compiler.lir.Variable)19 Value (jdk.vm.ci.meta.Value)15 RegisterValue (jdk.vm.ci.code.RegisterValue)11 TargetDescription (jdk.vm.ci.code.TargetDescription)7 PlatformKind (jdk.vm.ci.meta.PlatformKind)7 LIRGeneratorTool (org.graalvm.compiler.lir.gen.LIRGeneratorTool)7 AMD64Kind (jdk.vm.ci.amd64.AMD64Kind)6 JavaConstant (jdk.vm.ci.meta.JavaConstant)4 SPARCKind (jdk.vm.ci.sparc.SPARCKind)4 ComplexMatchValue (org.graalvm.compiler.core.match.ComplexMatchValue)4 AArch64AddressValue (org.graalvm.compiler.lir.aarch64.AArch64AddressValue)4 AMD64AddressValue (org.graalvm.compiler.lir.amd64.AMD64AddressValue)4 ComplexMatchResult (org.graalvm.compiler.core.match.ComplexMatchResult)3 MatchRule (org.graalvm.compiler.core.match.MatchRule)3 ConstantValue (org.graalvm.compiler.lir.ConstantValue)3 AMD64MulDivOp (org.graalvm.compiler.lir.amd64.AMD64MulDivOp)3 SubstrateRegisterConfig (com.oracle.svm.core.graal.meta.SubstrateRegisterConfig)2 Op3s (org.graalvm.compiler.asm.sparc.SPARCAssembler.Op3s)2