functions.c
// Add instructions to move struct/union data from a param register to a struct on the stack
Add instructions to move struct/union data from a param register to a struct on the stack
Add instructions to move struct / union data from a param register to a struct on the stack
static int add_struct_or_union_param_move(Function *function, Tac *ir, Type *type, FunctionParamLocations *pl, RegisterSet *register_set) {
    Value *v = new_value();
    v->type = dup_type(type);
    v->is_lvalue = 1;
    v->stack_index = -(++function->stack_register_count);
    insert_instruction_from_operation(ir, IR_DECL_LOCAL_COMP_OBJ, 0, v, 0, 1);
    for (int loc = 0; loc < pl->count; loc++) {
        FunctionParamLocation *location = &(pl->locations[loc]);
        if (location->int_register != -1)
            make_int_struct_or_union_move_from_register_to_stack_instructions(function, ir, type, location, location->int_register, v->stack_index, register_set, 0);
        else if (location->sse_register != -1)
            make_sse_struct_or_union_move_from_register_to_stack_instructions(function, ir, type, location, location->sse_register, v->stack_index, register_set, 0);
        else
            panic("Got unexpected stack offset in add_struct_or_union_param_move");
    }
    return v->stack_index;
}
static int add_struct_or_union_param_move ( Function * function , Tac * ir , Type * type , FunctionParamLocations * pl , RegisterSet * register_set ) { Value * v = new_value ( ) ; v -> type = dup_type ( type ) ; v -> is_lvalue = 1 ; v -> stack_index = - ( ++ function -> stack_register_count ) ; insert_instruction_from_operation ( ir , IR_DECL_LOCAL_COMP_OBJ , 0 , v , 0 , 1 ) ; for ( int loc = 0 ; loc < pl -> count ; loc ++ ) { FunctionParamLocation * location = & ( pl -> locations [ loc ] ) ; if ( location -> int_register != -1 ) make_int_struct_or_union_move_from_register_to_stack_instructions ( function , ir , type , location , location -> int_register , v -> stack_index , register_set , 0 ) ; else if ( location -> sse_register != -1 ) make_sse_struct_or_union_move_from_register_to_stack_instructions ( function , ir , type , location , location -> sse_register , v -> stack_index , register_set , 0 ) ; else panic ( " " ) ; } return v -> stack_index ; }
Add instructions to move struct/union data from a param register to a struct on the stack
Add instructions to move struct / union data from a param register to a struct on the stack
// Allocate space on the stack for the struct