fn insert_bytes(
        &mut self,
        dest: &P<Value>,
        src: &P<Value>,
        offset: i64,
        f_context: &mut FunctionContext,
        vm: &VM
    ) {
        if dest.is_mem() {
            let dest_loc = match dest.v {
                Value_::Memory(ref mem) => {
                    let mem = memory_location_shift(
                        self.backend.as_mut(),
                        mem.clone(),
                        offset,
                        f_context,
                        vm
                    );
                    make_value_from_memory(mem, &src.ty, vm)
                }
                _ => panic!("Wrong kind of memory value")
            };
            emit_move_value_to_value(self.backend.as_mut(), &dest_loc, &src, f_context, vm);
        } else if is_machine_reg(dest) {
            // Repeat this for each 8'bytes of src

            // Size of each dest unit
            let dest_size = get_bit_size(&dest.ty, vm) as i64;
            let src_size = get_bit_size(&src.ty, vm) as i64;

            // How many registers past the first 1 do we need to copy to
            let reg_distance = offset * 8 / dest_size;
            let reg_offset = offset * 8 % dest_size;

            let dest_reg = get_register_from_id(dest.id() + 2 * (reg_distance as usize));

            if src_size > dest_size + reg_offset {
                if is_int_ex_reg(src) {
                    if reg_offset == 0 {
                        let (src_l, src_h) = split_int128(src, f_context, vm);
                        let dest_reg_h = get_register_from_id(dest_reg.id() + 2);
                        // nothing special needs to be done
                        emit_move_value_to_value(
                            self.backend.as_mut(),
                            &dest_reg,
                            &src_l,
                            f_context,
                            vm
                        );
                        emit_move_value_to_value(
                            self.backend.as_mut(),
                            &dest_reg_h,
                            &src_h,
                            f_context,
                            vm
                        );
                    } else {
                        // This is not possible according the Aaarch64 PCS, since it would involve a
                        // 128-bit integer which starts part way through a register, but a 128-bit
                        // integer must be aligned to 16-bytes, and so must start at the start of an
                        // even register.
                        panic!("A 128-bit integer must start at the start of a register");
                    }
                } else {
                    // We need to copy to multiple registers
                    unimplemented!();
                }
            } else {
                if reg_offset == 0 && dest_size == src_size {
                    // nothing special needs to be done
                    emit_move_value_to_value(self.backend.as_mut(), &dest_reg, &src, f_context, vm);
                } else {
                    let tmp_src = if is_fp_reg(&src) {
                        make_temporary(f_context, src.ty.clone(), vm)
                    } else {
                        src.clone()
                    };

                    if is_fp_reg(&src) {
                        // A temporary is being used, move src to it
                        emit_move_value_to_value(
                            self.backend.as_mut(),
                            &tmp_src,
                            &src,
                            f_context,
                            vm
                        );
                    }

                    if is_int_reg(&dest_reg) {
                        // Copy to dest_reg, 'src_size' bits starting at 'reg_offset' in src
                        // (leaving other bits unchanged)
                        self.backend
                            .emit_bfi(&dest_reg, &tmp_src, reg_offset as u8, src_size as u8);
                    } else if is_fp_reg(&dest_reg) {
                        // floating point register, need to move dest to an int register first
                        let tmp_dest = make_temporary(f_context, tmp_src.ty.clone(), vm);
                        self.backend.emit_fmov(&tmp_dest, &dest_reg);
                        self.backend
                            .emit_bfi(&tmp_dest, &tmp_src, reg_offset as u8, src_size as u8);

                        // Now move it back to the FPR
                        self.backend.emit_fmov(&dest_reg, &tmp_dest);
                    } else {
                        unimplemented!();
                    }
                }
            }
        } else {
            panic!("This function should only be used to move to a machine register or memory");
        }
    }
// Copies src to dest+off, dest can be a memory location or a machine register
// (in the case of a machine register, sucessivie registers of the same size are considered
// part of dest).
// WARNING: It is assumed that dest and src do not overlap
Copies src to dest+off, dest can be a memory location or a machine register
(in the case of a machine register, sucessivie registers of the same size are considered
part of dest).
WARNING: It is assumed that dest and src do not overlap
Copies src to dest + off dest can be a memory location or a machine register ( in the case of a machine register sucessivie registers of the same size are considered part of dest ) . WARNING : It is assumed that dest and src do not overlap
fn insert_bytes(
        &mut self,
        dest: &P<Value>,
        src: &P<Value>,
        offset: i64,
        f_context: &mut FunctionContext,
        vm: &VM
    ) {
        if dest.is_mem() {
            let dest_loc = match dest.v {
                Value_::Memory(ref mem) => {
                    let mem = memory_location_shift(
                        self.backend.as_mut(),
                        mem.clone(),
                        offset,
                        f_context,
                        vm
                    );
                    make_value_from_memory(mem, &src.ty, vm)
                }
                _ => panic!("Wrong kind of memory value")
            };
            emit_move_value_to_value(self.backend.as_mut(), &dest_loc, &src, f_context, vm);
        } else if is_machine_reg(dest) {
            // Repeat this for each 8'bytes of src
            // Size of each dest unit
            let dest_size = get_bit_size(&dest.ty, vm) as i64;
            let src_size = get_bit_size(&src.ty, vm) as i64;
            // How many registers past the first 1 do we need to copy to
            let reg_distance = offset * 8 / dest_size;
            let reg_offset = offset * 8 % dest_size;
            let dest_reg = get_register_from_id(dest.id() + 2 * (reg_distance as usize));
            if src_size > dest_size + reg_offset {
                if is_int_ex_reg(src) {
                    if reg_offset == 0 {
                        let (src_l, src_h) = split_int128(src, f_context, vm);
                        let dest_reg_h = get_register_from_id(dest_reg.id() + 2);
                        // nothing special needs to be done
                        emit_move_value_to_value(
                            self.backend.as_mut(),
                            &dest_reg,
                            &src_l,
                            f_context,
                            vm
                        );
                        emit_move_value_to_value(
                            self.backend.as_mut(),
                            &dest_reg_h,
                            &src_h,
                            f_context,
                            vm
                        );
                    } else {
                        // This is not possible according the Aaarch64 PCS, since it would involve a
                        // 128-bit integer which starts part way through a register, but a 128-bit
                        // integer must be aligned to 16-bytes, and so must start at the start of an
                        // even register.
                        panic!("A 128-bit integer must start at the start of a register");
                    }
                } else {
                    // We need to copy to multiple registers
                    unimplemented!();
                }
            } else {
                if reg_offset == 0 && dest_size == src_size {
                    // nothing special needs to be done
                    emit_move_value_to_value(self.backend.as_mut(), &dest_reg, &src, f_context, vm);
                } else {
                    let tmp_src = if is_fp_reg(&src) {
                        make_temporary(f_context, src.ty.clone(), vm)
                    } else {
                        src.clone()
                    };
                    if is_fp_reg(&src) {
                        // A temporary is being used, move src to it
                        emit_move_value_to_value(
                            self.backend.as_mut(),
                            &tmp_src,
                            &src,
                            f_context,
                            vm
                        );
                    }
                    if is_int_reg(&dest_reg) {
                        // Copy to dest_reg, 'src_size' bits starting at 'reg_offset' in src
                        // (leaving other bits unchanged)
                        self.backend
                            .emit_bfi(&dest_reg, &tmp_src, reg_offset as u8, src_size as u8);
                    } else if is_fp_reg(&dest_reg) {
                        // floating point register, need to move dest to an int register first
                        let tmp_dest = make_temporary(f_context, tmp_src.ty.clone(), vm);
                        self.backend.emit_fmov(&tmp_dest, &dest_reg);
                        self.backend
                            .emit_bfi(&tmp_dest, &tmp_src, reg_offset as u8, src_size as u8);
                        // Now move it back to the FPR
                        self.backend.emit_fmov(&dest_reg, &tmp_dest);
                    } else {
                        unimplemented!();
                    }
                }
            }
        } else {
            panic!("This function should only be used to move to a machine register or memory");
        }
    }
fn insert_bytes ( & mut self , dest : & P < Value > , src : & P < Value > , offset : i64 , f_context : & mut FunctionContext , vm : & VM ) { if dest . is_mem ( ) { let dest_loc = match dest . v { Value_ :: Memory ( ref mem ) => { let mem = memory_location_shift ( self . backend . as_mut ( ) , mem . clone ( ) , offset , f_context , vm ) ; make_value_from_memory ( mem , & src . ty , vm ) } _ => panic ! ( " " ) } ; emit_move_value_to_value ( self . backend . as_mut ( ) , & dest_loc , & src , f_context , vm ) ; } else if is_machine_reg ( dest ) { // Repeat this for each 8'bytes of src // Size of each dest unit let dest_size = get_bit_size ( & dest . ty , vm ) as i64 ; let src_size = get_bit_size ( & src . ty , vm ) as i64 ; // How many registers past the first 1 do we need to copy to let reg_distance = offset * 8 / dest_size ; let reg_offset = offset * 8 % dest_size ; let dest_reg = get_register_from_id ( dest . id ( ) + 2 * ( reg_distance as usize ) ) ; if src_size > dest_size + reg_offset { if is_int_ex_reg ( src ) { if reg_offset == 0 { let ( src_l , src_h ) = split_int128 ( src , f_context , vm ) ; let dest_reg_h = get_register_from_id ( dest_reg . id ( ) + 2 ) ; // nothing special needs to be done emit_move_value_to_value ( self . backend . as_mut ( ) , & dest_reg , & src_l , f_context , vm ) ; emit_move_value_to_value ( self . backend . as_mut ( ) , & dest_reg_h , & src_h , f_context , vm ) ; } else { // This is not possible according the Aaarch64 PCS, since it would involve a // 128-bit integer which starts part way through a register, but a 128-bit // integer must be aligned to 16-bytes, and so must start at the start of an // even register. panic ! ( " " ) ; } } else { // We need to copy to multiple registers unimplemented ! ( ) ; } } else { if reg_offset == 0 && dest_size == src_size { // nothing special needs to be done emit_move_value_to_value ( self . backend . as_mut ( ) , & dest_reg , & src , f_context , vm ) ; } else { let tmp_src = if is_fp_reg ( & src ) { make_temporary ( f_context , src . ty . clone ( ) , vm ) } else { src . clone ( ) } ; if is_fp_reg ( & src ) { // A temporary is being used, move src to it emit_move_value_to_value ( self . backend . as_mut ( ) , & tmp_src , & src , f_context , vm ) ; } if is_int_reg ( & dest_reg ) { // Copy to dest_reg, 'src_size' bits starting at 'reg_offset' in src // (leaving other bits unchanged) self . backend . emit_bfi ( & dest_reg , & tmp_src , reg_offset as u8 , src_size as u8 ) ; } else if is_fp_reg ( & dest_reg ) { // floating point register, need to move dest to an int register first let tmp_dest = make_temporary ( f_context , tmp_src . ty . clone ( ) , vm ) ; self . backend . emit_fmov ( & tmp_dest , & dest_reg ) ; self . backend . emit_bfi ( & tmp_dest , & tmp_src , reg_offset as u8 , src_size as u8 ) ; // Now move it back to the FPR self . backend . emit_fmov ( & dest_reg , & tmp_dest ) ; } else { unimplemented ! ( ) ; } } } } else { panic ! ( " " ) ; } }
Copies src to dest+off, dest can be a memory location or a machine register
(in the case of a machine register, sucessivie registers of the same size are considered
part of dest).
Copies src to dest + off dest can be a memory location or a machine register ( in the case of a machine register sucessivie registers of the same size are considered part of dest ) .
&mut self
dest
&P<Value>
src
&P<Value>
offset
i64
f_context
&mut FunctionContext
vm
&VM
&mut self
dest
&P<Value>
src
&P<Value>
offset
i64
f_context
&mut FunctionContext
vm
&VM