Search in sources :

Example 1 with MOVSX

use of org.graalvm.compiler.asm.amd64.AMD64Assembler.AMD64RMOp.MOVSX 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)

Aggregations

AMD64Kind (jdk.vm.ci.amd64.AMD64Kind)1 AMD64RMOp (org.graalvm.compiler.asm.amd64.AMD64Assembler.AMD64RMOp)1 OperandSize (org.graalvm.compiler.asm.amd64.AMD64Assembler.OperandSize)1