fn extend_input_to_reg(ctx: Ctx, spec: InsnInput, ext_spec: ExtSpec) -> Reg {
    let requested_size = match ext_spec {
        ExtSpec::ZeroExtendTo32 | ExtSpec::SignExtendTo32 => 32,
        ExtSpec::ZeroExtendTo64 | ExtSpec::SignExtendTo64 => 64,
    };
    let input_size = ctx.input_ty(spec.insn, spec.input).bits();

    let requested_ty = if requested_size == 32 {
        types::I32
    } else {
        types::I64
    };

    let ext_mode = match (input_size, requested_size) {
        (a, b) if a == b => return put_input_in_reg(ctx, spec),
        (1, 8) => return put_input_in_reg(ctx, spec),
        (a, b) => ExtMode::new(a, b).expect(&format!("invalid extension: {} -> {}", a, b)),
    };

    let src = input_to_reg_mem(ctx, spec);
    let dst = ctx.alloc_tmp(RegClass::I64, requested_ty);
    match ext_spec {
        ExtSpec::ZeroExtendTo32 | ExtSpec::ZeroExtendTo64 => {
            ctx.emit(Inst::movzx_rm_r(
                ext_mode, src, dst, /* infallible */ None,
            ))
        }
        ExtSpec::SignExtendTo32 | ExtSpec::SignExtendTo64 => {
            ctx.emit(Inst::movsx_rm_r(
                ext_mode, src, dst, /* infallible */ None,
            ))
        }
    }
    dst.to_reg()
}
/// Put the given input into a register, marking it as used, and do a zero- or signed- extension if
/// required. (This obviously causes side-effects.)
Put the given input into a register, marking it as used, and do a zero- or signed- extension if
required. (This obviously causes side-effects.)
Put the given input into a register marking it as used and do a zero - or signed - extension if required . ( This obviously causes side - effects . )
fn extend_input_to_reg(ctx: Ctx, spec: InsnInput, ext_spec: ExtSpec) -> Reg {
    let requested_size = match ext_spec {
        ExtSpec::ZeroExtendTo32 | ExtSpec::SignExtendTo32 => 32,
        ExtSpec::ZeroExtendTo64 | ExtSpec::SignExtendTo64 => 64,
    };
    let input_size = ctx.input_ty(spec.insn, spec.input).bits();
    let requested_ty = if requested_size == 32 {
        types::I32
    } else {
        types::I64
    };
    let ext_mode = match (input_size, requested_size) {
        (a, b) if a == b => return put_input_in_reg(ctx, spec),
        (1, 8) => return put_input_in_reg(ctx, spec),
        (a, b) => ExtMode::new(a, b).expect(&format!("invalid extension: {} -> {}", a, b)),
    };
    let src = input_to_reg_mem(ctx, spec);
    let dst = ctx.alloc_tmp(RegClass::I64, requested_ty);
    match ext_spec {
        ExtSpec::ZeroExtendTo32 | ExtSpec::ZeroExtendTo64 => {
            ctx.emit(Inst::movzx_rm_r(
                ext_mode, src, dst, /* infallible */ None,
            ))
        }
        ExtSpec::SignExtendTo32 | ExtSpec::SignExtendTo64 => {
            ctx.emit(Inst::movsx_rm_r(
                ext_mode, src, dst, /* infallible */ None,
            ))
        }
    }
    dst.to_reg()
}
fn extend_input_to_reg ( ctx : Ctx , spec : InsnInput , ext_spec : ExtSpec ) -> Reg { let requested_size = match ext_spec { ExtSpec :: ZeroExtendTo32 | ExtSpec :: SignExtendTo32 => 32 , ExtSpec :: ZeroExtendTo64 | ExtSpec :: SignExtendTo64 => 64 , } ; let input_size = ctx . input_ty ( spec . insn , spec . input ) . bits ( ) ; let requested_ty = if requested_size == 32 { types :: I32 } else { types :: I64 } ; let ext_mode = match ( input_size , requested_size ) { ( a , b ) if a == b => return put_input_in_reg ( ctx , spec ) , ( 1 , 8 ) => return put_input_in_reg ( ctx , spec ) , ( a , b ) => ExtMode :: new ( a , b ) . expect ( & format ! ( " " a b ) ) , } ; let src = input_to_reg_mem ( ctx , spec ) ; let dst = ctx . alloc_tmp ( RegClass :: I64 , requested_ty ) ; match ext_spec { ExtSpec :: ZeroExtendTo32 | ExtSpec :: ZeroExtendTo64 => { ctx . emit ( Inst :: movzx_rm_r ( ext_mode , src , dst , /* infallible */ None , ) ) } ExtSpec :: SignExtendTo32 | ExtSpec :: SignExtendTo64 => { ctx . emit ( Inst :: movsx_rm_r ( ext_mode , src , dst , /* infallible */ None , ) ) } } dst . to_reg ( ) }
Put the given input into a register, marking it as used, and do a zero- or signed- extension if
required.
Put the given input into a register marking it as used and do a zero - or signed - extension if required .
ctx
Ctx
spec
InsnInput
ext_spec
ExtSpec
ctx
Ctx
spec
InsnInput
ext_spec
ExtSpec