Commit 89a0191c authored by Christoph Mallon's avatar Christoph Mallon

be: Factor out common code to make a va_start entity.

parent 7125ea59
......@@ -71,3 +71,12 @@ void be_set_va_list_type_pointer(backend_params *const p)
{
p->vararg.va_list_type = new_type_pointer(get_type_for_mode(mode_ANY));
}
ir_entity *be_make_va_start_entity(ir_type *const frame_type, int const offset)
{
ident *const id = new_id_from_str("$va_start");
ir_type *const unknown = get_unknown_type();
ir_entity *const va_start = new_entity(frame_type, id, unknown);
set_entity_offset(va_start, offset);
return va_start;
}
......@@ -39,4 +39,6 @@ void be_default_lower_va_arg_compound_val(ir_node *node);
void be_set_va_list_type_pointer(backend_params *p);
ir_entity *be_make_va_start_entity(ir_type *frame_type, int offset);
#endif
......@@ -11,6 +11,7 @@
#include <stdlib.h>
#include "betranshlp.h"
#include "bevarargs.h"
#include "irnode_t.h"
#include "iredges_t.h"
#include "irgmod.h"
......@@ -78,11 +79,7 @@ void x86_layout_param_entities(ir_graph *const irg, x86_cconv_t *const cconv,
ir_entity *const entity = get_irg_entity(irg);
ir_type *const function_type = get_entity_type(entity);
if (is_method_variadic(function_type)) {
ir_type *unknown = get_unknown_type();
ident *id = new_id_from_str("$va_start");
ir_entity *va_start_addr = new_entity(frame_type, id, unknown);
int const offset = cconv->param_stacksize + parameters_offset;
set_entity_offset(va_start_addr, offset);
cconv->va_start_addr = va_start_addr;
cconv->va_start_addr = be_make_va_start_entity(frame_type, offset);
}
}
......@@ -28,6 +28,7 @@
#include "beirg.h"
#include "betranshlp.h"
#include "bevarargs.h"
#include "panic.h"
#include "firm_types.h"
#include "iredges_t.h"
......@@ -209,10 +210,6 @@ static void sparc_layout_param_entities(ir_graph *const irg, calling_convention_
ir_entity *const function = get_irg_entity(irg);
ir_type *const function_type = get_entity_type(function);
if (is_method_variadic(function_type)) {
ir_type *unknown = get_unknown_type();
ident *id = new_id_from_str("$va_start");
ir_entity *va_start_addr = new_entity(frame_type, id, unknown);
/* sparc_variadic_fixups() fiddled with our type, find out the
* original number of parameters */
size_t const orig_n_params = get_method_n_params(non_lowered);
......@@ -224,8 +221,7 @@ static void sparc_layout_param_entities(ir_graph *const irg, calling_convention_
offset = cconv->param_stack_size + SPARC_MIN_STACKSIZE;
}
set_entity_offset(va_start_addr, offset);
cconv->va_start_addr = va_start_addr;
cconv->va_start_addr = be_make_va_start_entity(frame_type, offset);
}
free(param_map);
......
Markdown is supported
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