Search in sources :

Example 1 with AMD64RMOp

use of org.graalvm.compiler.asm.amd64.AMD64Assembler.AMD64RMOp in project graal by oracle.

the class AMD64ArithmeticLIRGenerator method emitCompareOp.

@Override
public void emitCompareOp(AMD64Kind cmpKind, Variable left, Value right) {
    OperandSize size;
    switch(cmpKind) {
        case BYTE:
            size = BYTE;
            break;
        case WORD:
            size = WORD;
            break;
        case DWORD:
            size = DWORD;
            break;
        case QWORD:
            size = QWORD;
            break;
        case SINGLE:
            getLIRGen().append(new AMD64BinaryConsumer.Op(SSEOp.UCOMIS, PS, left, getLIRGen().asAllocatable(right)));
            return;
        case DOUBLE:
            getLIRGen().append(new AMD64BinaryConsumer.Op(SSEOp.UCOMIS, PD, left, getLIRGen().asAllocatable(right)));
            return;
        default:
            throw GraalError.shouldNotReachHere("unexpected kind: " + cmpKind);
    }
    if (isConstantValue(right)) {
        Constant c = LIRValueUtil.asConstant(right);
        if (JavaConstant.isNull(c)) {
            getLIRGen().append(new AMD64BinaryConsumer.Op(TEST, size, left, left));
            return;
        } else if (c instanceof VMConstant) {
            VMConstant vc = (VMConstant) c;
            if (size == DWORD && !GeneratePIC.getValue(getOptions())) {
                getLIRGen().append(new AMD64BinaryConsumer.VMConstOp(CMP.getMIOpcode(DWORD, false), left, vc));
            } else {
                getLIRGen().append(new AMD64BinaryConsumer.DataOp(CMP.getRMOpcode(size), size, left, vc));
            }
            return;
        } else if (c instanceof JavaConstant) {
            JavaConstant jc = (JavaConstant) c;
            if (jc.isDefaultForKind()) {
                AMD64RMOp op = size == BYTE ? TESTB : TEST;
                getLIRGen().append(new AMD64BinaryConsumer.Op(op, size, left, left));
                return;
            } else if (NumUtil.is32bit(jc.asLong())) {
                getLIRGen().append(new AMD64BinaryConsumer.ConstOp(CMP, size, left, (int) jc.asLong()));
                return;
            }
        }
    }
    // fallback: load, then compare
    getLIRGen().append(new AMD64BinaryConsumer.Op(CMP.getRMOpcode(size), size, left, getLIRGen().asAllocatable(right)));
}
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) AMD64RMOp(org.graalvm.compiler.asm.amd64.AMD64Assembler.AMD64RMOp) JavaConstant(jdk.vm.ci.meta.JavaConstant) LIRValueUtil.asJavaConstant(org.graalvm.compiler.lir.LIRValueUtil.asJavaConstant) LIRValueUtil.isJavaConstant(org.graalvm.compiler.lir.LIRValueUtil.isJavaConstant) AMD64BinaryConsumer(org.graalvm.compiler.lir.amd64.AMD64BinaryConsumer) OperandSize(org.graalvm.compiler.asm.amd64.AMD64Assembler.OperandSize)

Example 2 with AMD64RMOp

use of org.graalvm.compiler.asm.amd64.AMD64Assembler.AMD64RMOp in project graal by oracle.

the class AMD64NodeMatchRules method emitSignExtendMemory.

private ComplexMatchResult emitSignExtendMemory(Access access, int fromBits, int toBits, ValueKind<?> addressKind) {
    assert fromBits <= toBits && toBits <= 64;
    AMD64Kind kind = null;
    AMD64RMOp op;
    OperandSize size;
    if (fromBits == toBits) {
        return null;
    } else if (toBits > 32) {
        kind = AMD64Kind.QWORD;
        size = OperandSize.QWORD;
        // sign extend to 64 bits
        switch(fromBits) {
            case 8:
                op = MOVSXB;
                break;
            case 16:
                op = MOVSX;
                break;
            case 32:
                op = MOVSXD;
                break;
            default:
                throw GraalError.unimplemented("unsupported sign extension (" + fromBits + " bit -> " + toBits + " bit)");
        }
    } else {
        kind = AMD64Kind.DWORD;
        size = OperandSize.DWORD;
        // sign extend to 32 bits (smaller values are internally represented as 32 bit values)
        switch(fromBits) {
            case 8:
                op = MOVSXB;
                break;
            case 16:
                op = MOVSX;
                break;
            case 32:
                return null;
            default:
                throw GraalError.unimplemented("unsupported sign extension (" + fromBits + " bit -> " + toBits + " bit)");
        }
    }
    if (kind != null && op != null) {
        return emitConvertMemoryOp(kind, op, size, access, addressKind);
    }
    return null;
}
Also used : AMD64Kind(jdk.vm.ci.amd64.AMD64Kind) AMD64RMOp(org.graalvm.compiler.asm.amd64.AMD64Assembler.AMD64RMOp) OperandSize(org.graalvm.compiler.asm.amd64.AMD64Assembler.OperandSize)

Example 3 with AMD64RMOp

use of org.graalvm.compiler.asm.amd64.AMD64Assembler.AMD64RMOp in project graal by oracle.

the class AMD64LIRGenerator method emitCompareRegMemoryOp.

private boolean emitCompareRegMemoryOp(OperandSize size, AllocatableValue a, AMD64AddressValue b, LIRFrameState state) {
    AMD64RMOp op = CMP.getRMOpcode(size);
    append(new AMD64BinaryConsumer.MemoryRMOp(op, size, a, b, state));
    return false;
}
Also used : AMD64RMOp(org.graalvm.compiler.asm.amd64.AMD64Assembler.AMD64RMOp) AMD64BinaryConsumer(org.graalvm.compiler.lir.amd64.AMD64BinaryConsumer)

Aggregations

AMD64RMOp (org.graalvm.compiler.asm.amd64.AMD64Assembler.AMD64RMOp)3 OperandSize (org.graalvm.compiler.asm.amd64.AMD64Assembler.OperandSize)2 AMD64BinaryConsumer (org.graalvm.compiler.lir.amd64.AMD64BinaryConsumer)2 AMD64Kind (jdk.vm.ci.amd64.AMD64Kind)1 Constant (jdk.vm.ci.meta.Constant)1 JavaConstant (jdk.vm.ci.meta.JavaConstant)1 VMConstant (jdk.vm.ci.meta.VMConstant)1 LIRValueUtil.asJavaConstant (org.graalvm.compiler.lir.LIRValueUtil.asJavaConstant)1 LIRValueUtil.isJavaConstant (org.graalvm.compiler.lir.LIRValueUtil.isJavaConstant)1