fn replace_reg(&mut self, from: MuID, to: MuID) {
        // replace defines
        for loc in self.get_define_locations(from) {
            let ref mut inst_to_patch = self.code[loc.line];

            // pick the right reg based on length
            let to_reg = x86_64::get_alias_for_length(to, loc.oplen);
            let to_reg_tag = to_reg.name();
            let to_reg_string = "%".to_string() + &to_reg_tag;

            string_utils::replace(
                &mut inst_to_patch.code,
                loc.index,
                &to_reg_string,
                to_reg_string.len()
            );
        }

        // replace uses
        for loc in self.get_use_locations(from) {
            let ref mut inst_to_patch = self.code[loc.line];

            // pick the right reg based on length
            let to_reg = x86_64::get_alias_for_length(to, loc.oplen);
            let to_reg_tag = to_reg.name();
            let to_reg_string = "%".to_string() + &to_reg_tag;

            string_utils::replace(
                &mut inst_to_patch.code,
                loc.index,
                &to_reg_string,
                to_reg_string.len()
            );
        }
    }
/// replace a temp with a machine register (to_reg must be a machine register)
replace a temp with a machine register (to_reg must be a machine register)
replace a temp with a machine register ( to_reg must be a machine register )
fn replace_reg(&mut self, from: MuID, to: MuID) {
        // replace defines
        for loc in self.get_define_locations(from) {
            let ref mut inst_to_patch = self.code[loc.line];
            // pick the right reg based on length
            let to_reg = x86_64::get_alias_for_length(to, loc.oplen);
            let to_reg_tag = to_reg.name();
            let to_reg_string = "%".to_string() + &to_reg_tag;
            string_utils::replace(
                &mut inst_to_patch.code,
                loc.index,
                &to_reg_string,
                to_reg_string.len()
            );
        }
        // replace uses
        for loc in self.get_use_locations(from) {
            let ref mut inst_to_patch = self.code[loc.line];
            // pick the right reg based on length
            let to_reg = x86_64::get_alias_for_length(to, loc.oplen);
            let to_reg_tag = to_reg.name();
            let to_reg_string = "%".to_string() + &to_reg_tag;
            string_utils::replace(
                &mut inst_to_patch.code,
                loc.index,
                &to_reg_string,
                to_reg_string.len()
            );
        }
    }
fn replace_reg ( & mut self , from : MuID , to : MuID ) { // replace defines for loc in self . get_define_locations ( from ) { let ref mut inst_to_patch = self . code [ loc . line ] ; // pick the right reg based on length let to_reg = x86_64 :: get_alias_for_length ( to , loc . oplen ) ; let to_reg_tag = to_reg . name ( ) ; let to_reg_string = " " . to_string ( ) + & to_reg_tag ; string_utils :: replace ( & mut inst_to_patch . code , loc . index , & to_reg_string , to_reg_string . len ( ) ) ; } // replace uses for loc in self . get_use_locations ( from ) { let ref mut inst_to_patch = self . code [ loc . line ] ; // pick the right reg based on length let to_reg = x86_64 :: get_alias_for_length ( to , loc . oplen ) ; let to_reg_tag = to_reg . name ( ) ; let to_reg_string = " " . to_string ( ) + & to_reg_tag ; string_utils :: replace ( & mut inst_to_patch . code , loc . index , & to_reg_string , to_reg_string . len ( ) ) ; } }
replace a temp with a machine register (to_reg must be a machine register)
replace a temp with a machine register ( to_reg must be a machine register )
&mut self
from
MuID
to
MuID
&mut self
from
MuID
to
MuID