Commit ae42d217 authored by Christoph Mallon's avatar Christoph Mallon
Browse files

sparc: Directly remember the original type before variadic lowering.

This avoids the detour over [gs]et_higher_type().
parent e60630cd
......@@ -72,8 +72,8 @@ void sparc_finish_graph(ir_graph *irg);
void sparc_lower_64bit(void);
bool sparc_variadic_fixups(ir_graph *irg, calling_convention_t *cconv);
void sparc_layout_param_entities(ir_graph *irg, calling_convention_t *cconv);
calling_convention_t *sparc_prepare_calling_convention(ir_graph *irg);
void sparc_fix_stack_bias(ir_graph *irg);
ir_entity *sparc_get_frame_entity(const ir_node *node);
......
......@@ -147,7 +147,7 @@ void sparc_fix_stack_bias(ir_graph *irg)
* (because otherwise the backend wouldn't store the value of the register
* parameters into memory for the VLA magic)
*/
bool sparc_variadic_fixups(ir_graph *irg, calling_convention_t *cconv)
static bool sparc_variadic_fixups(ir_graph *const irg, calling_convention_t *const cconv)
{
ir_entity *entity = get_irg_entity(irg);
ir_type *mtp = get_entity_type(entity);
......@@ -183,14 +183,11 @@ bool sparc_variadic_fixups(ir_graph *irg, calling_convention_t *cconv)
new_parameter_entity(frame_type, i, gp_reg_type);
}
set_higher_type(new_mtp, mtp);
set_entity_type(entity, new_mtp);
return true;
}
void sparc_layout_param_entities(ir_graph *const irg,
calling_convention_t *const cconv)
static void sparc_layout_param_entities(ir_graph *const irg, calling_convention_t *const cconv, ir_type *const non_lowered)
{
/* search for existing parameter entities */
ir_type *const frame_type = get_irg_frame_type(irg);
......@@ -231,8 +228,7 @@ void sparc_layout_param_entities(ir_graph *const irg,
/* sparc_variadic_fixups() fiddled with our type, find out the
* original number of parameters */
ir_type *const non_lowered = get_higher_type(function_type);
size_t const orig_n_params = get_method_n_params(non_lowered);
size_t const orig_n_params = get_method_n_params(non_lowered);
long offset;
if (orig_n_params < n_params) {
assert(param_map[orig_n_params] != NULL);
......@@ -245,3 +241,16 @@ void sparc_layout_param_entities(ir_graph *const irg,
cconv->va_start_addr = va_start_addr;
}
}
calling_convention_t *sparc_prepare_calling_convention(ir_graph *const irg)
{
ir_entity *const entity = get_irg_entity(irg);
ir_type *const non_lowered = get_entity_type(entity);
calling_convention_t *cconv = sparc_decide_calling_convention(get_entity_type(entity), irg);
if (sparc_variadic_fixups(irg, cconv)) {
sparc_free_calling_convention(cconv);
cconv = sparc_decide_calling_convention(get_entity_type(entity), irg);
}
sparc_layout_param_entities(irg, cconv, non_lowered);
return cconv;
}
......@@ -2447,8 +2447,6 @@ void sparc_transform_graph(ir_graph *irg)
assure_irg_properties(irg, IR_GRAPH_PROPERTY_NO_TUPLES
| IR_GRAPH_PROPERTY_NO_BADS);
ir_entity *entity = get_irg_entity(irg);
sparc_register_transformers();
mode_gp = sparc_reg_classes[CLASS_sparc_gp].mode;
......@@ -2459,14 +2457,7 @@ void sparc_transform_graph(ir_graph *irg)
frame_base = NULL;
be_stack_init(&stack_env);
current_cconv
= sparc_decide_calling_convention(get_entity_type(entity), irg);
if (sparc_variadic_fixups(irg, current_cconv)) {
sparc_free_calling_convention(current_cconv);
current_cconv
= sparc_decide_calling_convention(get_entity_type(entity), irg);
}
sparc_layout_param_entities(irg, current_cconv);
current_cconv = sparc_prepare_calling_convention(irg);
ir_entity *need_stores[current_cconv->n_param_regs];
unsigned n_stores = 0;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment