Search in sources :

Example 1 with AMD64AddressValue

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

the class AMD64ArithmeticLIRGenerator method emitStoreConst.

protected void emitStoreConst(AMD64Kind kind, AMD64AddressValue address, ConstantValue value, LIRFrameState state) {
    Constant c = value.getConstant();
    if (JavaConstant.isNull(c)) {
        assert kind == AMD64Kind.DWORD || kind == AMD64Kind.QWORD;
        OperandSize size = kind == AMD64Kind.DWORD ? DWORD : QWORD;
        getLIRGen().append(new AMD64BinaryConsumer.MemoryConstOp(AMD64MIOp.MOV, size, address, 0, state));
        return;
    } else if (c instanceof VMConstant) {
        // only 32-bit constants can be patched
        if (kind == AMD64Kind.DWORD) {
            if (getLIRGen().target().inlineObjects || !(c instanceof JavaConstant)) {
                // if c is a JavaConstant, it's an oop, otherwise it's a metaspace constant
                assert !(c instanceof JavaConstant) || ((JavaConstant) c).getJavaKind() == JavaKind.Object;
                getLIRGen().append(new AMD64BinaryConsumer.MemoryVMConstOp(AMD64MIOp.MOV, address, (VMConstant) c, state));
                return;
            }
        }
    } else {
        JavaConstant jc = (JavaConstant) c;
        assert jc.getJavaKind().isPrimitive();
        AMD64MIOp op = AMD64MIOp.MOV;
        OperandSize size;
        long imm;
        switch(kind) {
            case BYTE:
                op = AMD64MIOp.MOVB;
                size = BYTE;
                imm = jc.asInt();
                break;
            case WORD:
                size = WORD;
                imm = jc.asInt();
                break;
            case DWORD:
                size = DWORD;
                imm = jc.asInt();
                break;
            case QWORD:
                size = QWORD;
                imm = jc.asLong();
                break;
            case SINGLE:
                size = DWORD;
                imm = Float.floatToRawIntBits(jc.asFloat());
                break;
            case DOUBLE:
                size = QWORD;
                imm = Double.doubleToRawLongBits(jc.asDouble());
                break;
            default:
                throw GraalError.shouldNotReachHere("unexpected kind " + kind);
        }
        if (NumUtil.isInt(imm)) {
            getLIRGen().append(new AMD64BinaryConsumer.MemoryConstOp(op, size, address, (int) imm, state));
            return;
        }
    }
    // fallback: load, then store
    emitStore(kind, address, getLIRGen().asAllocatable(value), state);
}
Also used : Constant(jdk.vm.ci.meta.Constant) JavaConstant(jdk.vm.ci.meta.JavaConstant) LIRValueUtil.asJavaConstant(org.graalvm.compiler.lir.LIRValueUtil.asJavaConstant) LIRValueUtil.isJavaConstant(org.graalvm.compiler.lir.LIRValueUtil.isJavaConstant) VMConstant(jdk.vm.ci.meta.VMConstant) VMConstant(jdk.vm.ci.meta.VMConstant) JavaConstant(jdk.vm.ci.meta.JavaConstant) LIRValueUtil.asJavaConstant(org.graalvm.compiler.lir.LIRValueUtil.asJavaConstant) LIRValueUtil.isJavaConstant(org.graalvm.compiler.lir.LIRValueUtil.isJavaConstant) AMD64MIOp(org.graalvm.compiler.asm.amd64.AMD64Assembler.AMD64MIOp) AMD64BinaryConsumer(org.graalvm.compiler.lir.amd64.AMD64BinaryConsumer) OperandSize(org.graalvm.compiler.asm.amd64.AMD64Assembler.OperandSize)

Example 2 with AMD64AddressValue

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

the class AMD64ArithmeticLIRGenerator method emitBaseOffsetLea.

private Variable emitBaseOffsetLea(LIRKind resultKind, Value base, int offset, OperandSize size) {
    Variable result = getLIRGen().newVariable(resultKind);
    AMD64AddressValue address = new AMD64AddressValue(resultKind, getLIRGen().asAllocatable(base), offset);
    getLIRGen().append(new AMD64Move.LeaOp(result, address, size));
    return result;
}
Also used : AMD64AddressValue(org.graalvm.compiler.lir.amd64.AMD64AddressValue) Variable(org.graalvm.compiler.lir.Variable) AMD64Move(org.graalvm.compiler.lir.amd64.AMD64Move)

Example 3 with AMD64AddressValue

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

the class AMD64ArithmeticLIRGenerator method emitStore.

@Override
public void emitStore(ValueKind<?> lirKind, Value address, Value input, LIRFrameState state) {
    AMD64AddressValue storeAddress = getAMD64LIRGen().asAddressValue(address);
    AMD64Kind kind = (AMD64Kind) lirKind.getPlatformKind();
    if (isConstantValue(input)) {
        emitStoreConst(kind, storeAddress, asConstantValue(input), state);
    } else {
        emitStore(kind, storeAddress, getLIRGen().asAllocatable(input), state);
    }
}
Also used : AMD64AddressValue(org.graalvm.compiler.lir.amd64.AMD64AddressValue) AMD64Kind(jdk.vm.ci.amd64.AMD64Kind)

Example 4 with AMD64AddressValue

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

the class AMD64ArithmeticLIRGenerator method emitLoad.

@Override
public Variable emitLoad(LIRKind kind, Value address, LIRFrameState state) {
    AMD64AddressValue loadAddress = getAMD64LIRGen().asAddressValue(address);
    Variable result = getLIRGen().newVariable(getLIRGen().toRegisterKind(kind));
    switch((AMD64Kind) kind.getPlatformKind()) {
        case BYTE:
            getLIRGen().append(new AMD64Unary.MemoryOp(MOVSXB, DWORD, result, loadAddress, state));
            break;
        case WORD:
            getLIRGen().append(new AMD64Unary.MemoryOp(MOVSX, DWORD, result, loadAddress, state));
            break;
        case DWORD:
            getLIRGen().append(new AMD64Unary.MemoryOp(MOV, DWORD, result, loadAddress, state));
            break;
        case QWORD:
            getLIRGen().append(new AMD64Unary.MemoryOp(MOV, QWORD, result, loadAddress, state));
            break;
        case SINGLE:
            getLIRGen().append(new AMD64Unary.MemoryOp(MOVSS, SS, result, loadAddress, state));
            break;
        case DOUBLE:
            getLIRGen().append(new AMD64Unary.MemoryOp(MOVSD, SD, result, loadAddress, state));
            break;
        default:
            throw GraalError.shouldNotReachHere();
    }
    return result;
}
Also used : AMD64AddressValue(org.graalvm.compiler.lir.amd64.AMD64AddressValue) AMD64Unary(org.graalvm.compiler.lir.amd64.AMD64Unary) AMD64Kind(jdk.vm.ci.amd64.AMD64Kind) Variable(org.graalvm.compiler.lir.Variable)

Example 5 with AMD64AddressValue

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

the class AMD64ArithmeticLIRGenerator method emitBinaryMemory.

public Value emitBinaryMemory(AMD64RRMOp op, OperandSize size, AllocatableValue a, AMD64AddressValue location, LIRFrameState state) {
    Variable result = getLIRGen().newVariable(LIRKind.combine(a));
    getLIRGen().append(new AMD64Binary.MemoryThreeOp(op, size, result, a, location, state));
    return result;
}
Also used : Variable(org.graalvm.compiler.lir.Variable) AMD64Binary(org.graalvm.compiler.lir.amd64.AMD64Binary)

Aggregations

AMD64AddressValue (org.graalvm.compiler.lir.amd64.AMD64AddressValue)15 AMD64Kind (jdk.vm.ci.amd64.AMD64Kind)10 Variable (org.graalvm.compiler.lir.Variable)9 LIRKind (org.graalvm.compiler.core.common.LIRKind)6 RegisterValue (jdk.vm.ci.code.RegisterValue)5 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)5 JavaConstant (jdk.vm.ci.meta.JavaConstant)4 Value (jdk.vm.ci.meta.Value)4 NodeLIRBuilder (org.graalvm.compiler.core.gen.NodeLIRBuilder)4 ComplexMatchResult (org.graalvm.compiler.core.match.ComplexMatchResult)4 AMD64BinaryConsumer (org.graalvm.compiler.lir.amd64.AMD64BinaryConsumer)4 BranchOp (org.graalvm.compiler.lir.amd64.AMD64ControlFlow.BranchOp)4 AMD64MIOp (org.graalvm.compiler.asm.amd64.AMD64Assembler.AMD64MIOp)3 AMD64RMOp (org.graalvm.compiler.asm.amd64.AMD64Assembler.AMD64RMOp)3 OperandSize (org.graalvm.compiler.asm.amd64.AMD64Assembler.OperandSize)3 CanonicalCondition (org.graalvm.compiler.core.common.calc.CanonicalCondition)3 Condition (org.graalvm.compiler.core.common.calc.Condition)3 AMD64Move (org.graalvm.compiler.lir.amd64.AMD64Move)3 AMD64 (jdk.vm.ci.amd64.AMD64)2 CPUFeature (jdk.vm.ci.amd64.AMD64.CPUFeature)2