Commit cb2708bd authored by Matthias Braun's avatar Matthias Braun
Browse files

ia32/amd64: Share add_parameter_loads code.

parent e2a7d3ae
......@@ -1772,44 +1772,7 @@ static ir_node *gen_Proj_Proj_Start(ir_node *node)
ir_graph *const irg = get_irn_irg(node);
unsigned const pn = get_Proj_num(node);
reg_or_stackslot_t const *const param = &current_cconv->parameters[pn];
arch_register_t const *const reg = param->reg;
if (reg) {
/* argument transmitted in register */
return be_get_Start_proj(irg, reg);
} else {
/* argument transmitted on stack */
ir_mode *mode = get_type_mode(param->type);
ir_node *base = get_frame_base(irg);
amd64_insn_mode_t insn_mode = get_insn_mode_from_mode(mode);
amd64_addr_t addr;
memset(&addr, 0, sizeof(addr));
addr.base_input = 0;
addr.index_input = NO_INPUT;
addr.mem_input = NO_INPUT;
addr.immediate.entity = param->entity;
ir_node *in[] = { base };
ir_node *load;
ir_node *value;
ir_node *const new_block = be_transform_nodes_block(node);
if (mode_is_float(mode)) {
load = new_bd_amd64_movs_xmm(NULL, new_block, ARRAY_SIZE(in),
in, insn_mode, AMD64_OP_ADDR, addr);
value = be_new_Proj(load, pn_amd64_movs_xmm_res);
} else if (get_mode_size_bits(mode) < 64 && mode_is_signed(mode)) {
load = new_bd_amd64_movs(NULL, new_block, ARRAY_SIZE(in),
in, insn_mode, AMD64_OP_ADDR, addr);
value = be_new_Proj(load, pn_amd64_movs_res);
} else {
load = new_bd_amd64_mov_gp(NULL, new_block, ARRAY_SIZE(in),
in, insn_mode, AMD64_OP_ADDR, addr);
value = be_new_Proj(load, pn_amd64_mov_gp_res);
}
arch_set_irn_register_reqs_in(load, reg_mem_reqs);
set_irn_pinned(load, op_pin_state_floats);
return value;
}
return be_get_Start_proj(irg, param->reg);
}
static ir_node *gen_Proj_Proj(ir_node *node)
......@@ -2715,6 +2678,7 @@ void amd64_transform_graph(ir_graph *irg)
amd64_insert_reg_save_area(irg, current_cconv);
amd64_create_stacklayout(irg, current_cconv);
be_add_parameter_entity_stores(irg);
x86_create_parameter_loads(irg, current_cconv);
heights = heights_new(irg);
x86_calculate_non_address_mode_nodes(irg);
......
......@@ -5797,32 +5797,6 @@ static void register_transformers(void)
be_set_upper_bits_clean_function(op_Mux, ia32_mux_upper_bits_clean);
}
static void add_parameter_loads(ir_graph *irg, const x86_cconv_t *cconv)
{
ir_node *start = get_irg_start(irg);
ir_node *start_block = get_irg_start_block(irg);
ir_node *nomem = get_irg_no_mem(irg);
ir_node *frame = get_irg_frame(irg);
ir_node *proj_args = get_Proj_for_pn(start, pn_Start_T_args);
foreach_out_edge_safe(proj_args, edge) {
ir_node *proj = get_edge_src_irn(edge);
if (!is_Proj(proj))
continue;
unsigned pn = get_Proj_num(proj);
const reg_or_stackslot_t *param = &cconv->parameters[pn];
ir_entity *entity = param->entity;
if (entity == NULL)
continue;
ir_type *const type = get_entity_type(entity);
ir_mode *const mode = get_type_mode(type);
dbg_info *const dbgi = get_irn_dbg_info(proj);
ir_node *const member = new_rd_Member(dbgi, start_block, frame, entity);
ir_node *const load = new_rd_Load(dbgi, start_block, nomem, member, mode, type, cons_none);
ir_node *const res = new_r_Proj(load, mode, pn_Load_res);
exchange(proj, res);
}
}
static ir_type *ia32_get_between_type(bool omit_fp)
{
static ir_type *between_type = NULL;
......@@ -5933,7 +5907,7 @@ void ia32_transform_graph(ir_graph *irg)
current_cconv = ia32_decide_calling_convention(mtp, irg);
ia32_create_stacklayout(irg, current_cconv);
be_add_parameter_entity_stores(irg);
add_parameter_loads(irg, current_cconv);
x86_create_parameter_loads(irg, current_cconv);
be_timer_push(T_HEIGHTS);
heights = heights_new(irg);
......
......@@ -10,6 +10,9 @@
*/
#include <stdlib.h>
#include "irnode_t.h"
#include "iredges_t.h"
#include "irgmod.h"
#include "x86_cconv.h"
void x86_free_calling_convention(x86_cconv_t *cconv)
......@@ -20,3 +23,29 @@ void x86_free_calling_convention(x86_cconv_t *cconv)
free(cconv->callee_saves);
free(cconv);
}
void x86_create_parameter_loads(ir_graph *irg, const x86_cconv_t *cconv)
{
ir_node *start = get_irg_start(irg);
ir_node *start_block = get_irg_start_block(irg);
ir_node *nomem = get_irg_no_mem(irg);
ir_node *frame = get_irg_frame(irg);
ir_node *proj_args = get_Proj_for_pn(start, pn_Start_T_args);
foreach_out_edge_safe(proj_args, edge) {
ir_node *proj = get_edge_src_irn(edge);
if (!is_Proj(proj))
continue;
unsigned pn = get_Proj_num(proj);
const reg_or_stackslot_t *param = &cconv->parameters[pn];
ir_entity *entity = param->entity;
if (entity == NULL)
continue;
ir_type *const type = get_entity_type(entity);
ir_mode *const mode = get_type_mode(type);
dbg_info *const dbgi = get_irn_dbg_info(proj);
ir_node *const member = new_rd_Member(dbgi, start_block, frame, entity);
ir_node *const load = new_rd_Load(dbgi, start_block, nomem, member, mode, type, cons_none);
ir_node *const res = new_r_Proj(load, mode, pn_Load_res);
exchange(proj, res);
}
}
......@@ -49,4 +49,6 @@ typedef struct x86_cconv_t
*/
void x86_free_calling_convention(x86_cconv_t *cconv);
void x86_create_parameter_loads(ir_graph *irg, const x86_cconv_t *cconv);
#endif
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