ir.c
// Add memcpy calls for struct/union -> struct/union copies
Add memcpy calls for struct/union -> struct/union copies
Add memcpy calls for struct / union - > struct / union copies
Tac *add_memory_copy_with_memcpy(Function *function, Tac *ir, Value *dst, Value *src1, int size) {
    int function_call_count = make_function_call_count(function);
    Value *call_value = make_function_call_value(function_call_count++);
    ir = insert_instruction_after_from_operation(ir, IR_START_CALL, 0, call_value, 0);
    Value *src1_value;
    if (src1->is_lvalue && src1->vreg)
        src1_value = src1;
    else
        src1_value = insert_address_of_instruction_after(function, &ir, src1);
    Value *dst_value;
    if (dst->is_lvalue && dst->vreg)
        dst_value = dst;
    else
        dst_value = insert_address_of_instruction_after(function, &ir, dst);
    Value *size_value = new_integral_constant(TYPE_LONG, size);
    ir = insert_arg_instruction_after(ir, call_value, dst_value, 0);
    ir = insert_arg_instruction_after(ir, call_value, src1_value, 1);
    ir = insert_arg_instruction_after(ir, call_value, size_value, 2);
    ir = insert_function_call_instructions_after(ir, call_value, memcpy_symbol);
    return ir;
}
Tac * add_memory_copy_with_memcpy ( Function * function , Tac * ir , Value * dst , Value * src1 , int size ) { int function_call_count = make_function_call_count ( function ) ; Value * call_value = make_function_call_value ( function_call_count ++ ) ; ir = insert_instruction_after_from_operation ( ir , IR_START_CALL , 0 , call_value , 0 ) ; Value * src1_value ; if ( src1 -> is_lvalue && src1 -> vreg ) src1_value = src1 ; else src1_value = insert_address_of_instruction_after ( function , & ir , src1 ) ; Value * dst_value ; if ( dst -> is_lvalue && dst -> vreg ) dst_value = dst ; else dst_value = insert_address_of_instruction_after ( function , & ir , dst ) ; Value * size_value = new_integral_constant ( TYPE_LONG , size ) ; ir = insert_arg_instruction_after ( ir , call_value , dst_value , 0 ) ; ir = insert_arg_instruction_after ( ir , call_value , src1_value , 1 ) ; ir = insert_arg_instruction_after ( ir , call_value , size_value , 2 ) ; ir = insert_function_call_instructions_after ( ir , call_value , memcpy_symbol ) ; return ir ; }
Add memcpy calls for struct/union -> struct/union copies
Add memcpy calls for struct / union - > struct / union copies
// Add start call instruction // Load of addresses of src1, dst & make size value // Add arg instructions // Add function call