pub fn emit_mul_u64(backend: &mut CodeGenerator, dest: &P<Value>, src: &P<Value>, val: u64) {
    if val == 0 {
        // dest = 0
        backend.emit_mov_imm(&dest, 0);
    } else if val == 1 {
        // dest = src
        if dest.id() != src.id() {
            backend.emit_mov(&dest, &src);
        }
    } else if val.is_power_of_two() {
        // dest = src << log2(val)
        backend.emit_lsl_imm(&dest, &src, log2(val as u64) as u8);
    } else {
        // dest = src * val
        emit_mov_u64(backend, &dest, val as u64);
        backend.emit_mul(&dest, &src, &dest);
    }
}
// TODO: Will this be correct if src is treated as signed (i think so...)
Will this be correct if src is treated as signed (i think so...)
Will this be correct if src is treated as signed ( i think so ... )
pub fn emit_mul_u64(backend: &mut CodeGenerator, dest: &P<Value>, src: &P<Value>, val: u64) {
    if val == 0 {
        // dest = 0
        backend.emit_mov_imm(&dest, 0);
    } else if val == 1 {
        // dest = src
        if dest.id() != src.id() {
            backend.emit_mov(&dest, &src);
        }
    } else if val.is_power_of_two() {
        // dest = src << log2(val)
        backend.emit_lsl_imm(&dest, &src, log2(val as u64) as u8);
    } else {
        // dest = src * val
        emit_mov_u64(backend, &dest, val as u64);
        backend.emit_mul(&dest, &src, &dest);
    }
}
pub fn emit_mul_u64 ( backend : & mut CodeGenerator , dest : & P < Value > , src : & P < Value > , val : u64 ) { if val == 0 { // dest = 0 backend . emit_mov_imm ( & dest , 0 ) ; } else if val == 1 { // dest = src if dest . id ( ) != src . id ( ) { backend . emit_mov ( & dest , & src ) ; } } else if val . is_power_of_two ( ) { // dest = src << log2(val) backend . emit_lsl_imm ( & dest , & src , log2 ( val as u64 ) as u8 ) ; } else { // dest = src * val emit_mov_u64 ( backend , & dest , val as u64 ) ; backend . emit_mul ( & dest , & src , & dest ) ; } }
TODO: Will this be correct if src is treated as signed (i think so...)
TODO : Will this be correct if src is treated as signed ( i think so ... )
backend
&mut CodeGenerator
dest
&P<Value>
src
&P<Value>
val
u64
backend
&mut CodeGenerator
dest
&P<Value>
src
&P<Value>
val
u64