fn replace_use_tmp_for_inst(&mut self, from: MuID, to: MuID, inst: usize) {
        let to_reg_string: MuName = REG_PLACEHOLDER.clone();

        let asm = &mut self.code[inst];

        // if this reg is used, replace the use
        if asm.uses.contains_key(&from) {
            let use_locs = asm.uses.get(&from).unwrap().to_vec();
            // replace temps
            for loc in use_locs.iter() {
                string_utils::replace(
                    &mut asm.code,
                    loc.index,
                    &to_reg_string,
                    to_reg_string.len()
                );
            }

            // remove old key, insert new one
            asm.uses.remove(&from);
            asm.uses.insert(to, use_locs);
        }
    }
/// replace a temp that is used in the inst with another temp
replace a temp that is used in the inst with another temp
replace a temp that is used in the inst with another temp
fn replace_use_tmp_for_inst(&mut self, from: MuID, to: MuID, inst: usize) {
        let to_reg_string: MuName = REG_PLACEHOLDER.clone();
        let asm = &mut self.code[inst];
        // if this reg is used, replace the use
        if asm.uses.contains_key(&from) {
            let use_locs = asm.uses.get(&from).unwrap().to_vec();
            // replace temps
            for loc in use_locs.iter() {
                string_utils::replace(
                    &mut asm.code,
                    loc.index,
                    &to_reg_string,
                    to_reg_string.len()
                );
            }
            // remove old key, insert new one
            asm.uses.remove(&from);
            asm.uses.insert(to, use_locs);
        }
    }
fn replace_use_tmp_for_inst ( & mut self , from : MuID , to : MuID , inst : usize ) { let to_reg_string : MuName = REG_PLACEHOLDER . clone ( ) ; let asm = & mut self . code [ inst ] ; // if this reg is used, replace the use if asm . uses . contains_key ( & from ) { let use_locs = asm . uses . get ( & from ) . unwrap ( ) . to_vec ( ) ; // replace temps for loc in use_locs . iter ( ) { string_utils :: replace ( & mut asm . code , loc . index , & to_reg_string , to_reg_string . len ( ) ) ; } // remove old key, insert new one asm . uses . remove ( & from ) ; asm . uses . insert ( to , use_locs ) ; } }
replace a temp that is used in the inst with another temp
replace a temp that is used in the inst with another temp
&mut self
from
MuID
to
MuID
inst
usize
&mut self
from
MuID
to
MuID
inst
usize