functions.c
// For functions with variadic arguments, move registers into the register save area.
// The register save area has been allocated on the stack by the parser with the
// value set in function->register_save_area.
For functions with variadic arguments, move registers into the register save area.
The register save area has been allocated on the stack by the parser with the
value set in function->register_save_area.
For functions with variadic arguments move registers into the register save area . The register save area has been allocated on the stack by the parser with the value set in function - > register_save_area .
static void add_function_vararg_param_moves(Function *function, FunctionParamAllocation *fpa) {
    for (int i = fpa->single_int_register_arg_count; i < 6; i++) {
        Value *src = new_value();
        src->vreg = ++function->vreg_count;
        src->type = new_type(TYPE_LONG);
        src->live_range_preg = int_arg_registers[i];
        Value *dst = dup_value(function->register_save_area);
        dst->type = new_type(TYPE_LONG);
        dst->offset = i * 8;
        ir = insert_instruction_after_from_operation(ir, IR_MOVE, dst, src, 0);
    }
    Value *ldone = new_label_dst();
    Value *rax = new_value();
    rax->vreg = ++function->vreg_count;
    rax->type = new_type(TYPE_CHAR);
    rax->live_range_preg = LIVE_RANGE_PREG_RAX_INDEX;
    ir = insert_instruction_after_from_operation(ir, IR_JZ, 0, rax, ldone);
    for (int i = fpa->single_sse_register_arg_count; i < 8; i++) {
        Value *src = new_value();
        src->vreg = ++function->vreg_count;
        src->type = new_type(TYPE_DOUBLE);
        src->live_range_preg = sse_arg_registers[i];
        Value *temp_int = new_value();
        temp_int->type = new_type(TYPE_LONG);
        temp_int->vreg = ++function->vreg_count;
        ir = insert_instruction_after_from_operation(ir, IR_MOVE_PREG_CLASS, temp_int, src, 0);
        Value *dst = dup_value(function->register_save_area);
        dst->type = new_type(TYPE_LONG);
        dst->offset = 48 + i * 16;
        ir = insert_instruction_after_from_operation(ir, IR_MOVE, dst, temp_int, 0);
    }
    ir = insert_instruction_after_from_operation(ir, IR_NOP, 0, 0, 0);
    ir->label = ldone->label;
}
static void add_function_vararg_param_moves ( Function * function , FunctionParamAllocation * fpa ) { for ( int i = fpa -> single_int_register_arg_count ; i < 6 ; i ++ ) { Value * src = new_value ( ) ; src -> vreg = ++ function -> vreg_count ; src -> type = new_type ( TYPE_LONG ) ; src -> live_range_preg = int_arg_registers [ i ] ; Value * dst = dup_value ( function -> register_save_area ) ; dst -> type = new_type ( TYPE_LONG ) ; dst -> offset = i * 8 ; ir = insert_instruction_after_from_operation ( ir , IR_MOVE , dst , src , 0 ) ; } Value * ldone = new_label_dst ( ) ; Value * rax = new_value ( ) ; rax -> vreg = ++ function -> vreg_count ; rax -> type = new_type ( TYPE_CHAR ) ; rax -> live_range_preg = LIVE_RANGE_PREG_RAX_INDEX ; ir = insert_instruction_after_from_operation ( ir , IR_JZ , 0 , rax , ldone ) ; for ( int i = fpa -> single_sse_register_arg_count ; i < 8 ; i ++ ) { Value * src = new_value ( ) ; src -> vreg = ++ function -> vreg_count ; src -> type = new_type ( TYPE_DOUBLE ) ; src -> live_range_preg = sse_arg_registers [ i ] ; Value * temp_int = new_value ( ) ; temp_int -> type = new_type ( TYPE_LONG ) ; temp_int -> vreg = ++ function -> vreg_count ; ir = insert_instruction_after_from_operation ( ir , IR_MOVE_PREG_CLASS , temp_int , src , 0 ) ; Value * dst = dup_value ( function -> register_save_area ) ; dst -> type = new_type ( TYPE_LONG ) ; dst -> offset = 48 + i * 16 ; ir = insert_instruction_after_from_operation ( ir , IR_MOVE , dst , temp_int , 0 ) ; } ir = insert_instruction_after_from_operation ( ir , IR_NOP , 0 , 0 , 0 ) ; ir -> label = ldone -> label ; }
For functions with variadic arguments, move registers into the register save area.
For functions with variadic arguments move registers into the register save area .
// Add moves for ints registers to register save area // Skip SSE register copying if al is zero with a jump to "done" // add moves for SSE registers to register save area // Add done label