Commit 3a696605 authored by Matthias Braun's avatar Matthias Braun
Browse files

x86: Improve x86_cconv comments and rename callframe_size to param_stacksize

parent ccb254d3
......@@ -195,17 +195,17 @@ x86_cconv_t *amd64_decide_calling_convention(ir_type *function_type,
++n_reg_results;
}
x86_cconv_t *cconv = XMALLOCZ(x86_cconv_t);
cconv->parameters = params;
cconv->n_parameters = n_params;
cconv->callframe_size = stack_offset;
cconv->n_param_regs = n_param_regs_used;
cconv->n_xmm_regs = float_param_regnum;
cconv->results = results;
cconv->omit_fp = omit_fp;
cconv->caller_saves = caller_saves;
cconv->callee_saves = callee_saves;
cconv->n_reg_results = n_reg_results;
x86_cconv_t *cconv = XMALLOCZ(x86_cconv_t);
cconv->parameters = params;
cconv->n_parameters = n_params;
cconv->param_stacksize = stack_offset;
cconv->n_param_regs = n_param_regs_used;
cconv->n_xmm_regs = float_param_regnum;
cconv->results = results;
cconv->omit_fp = omit_fp;
cconv->caller_saves = caller_saves;
cconv->callee_saves = callee_saves;
cconv->n_reg_results = n_reg_results;
if (irg != NULL) {
be_irg_t *birg = be_birg_from_irg(irg);
......
......@@ -1787,7 +1787,9 @@ static ir_node *gen_Call(ir_node *const node)
/* construct an IncSP -> we have to always be sure that the stack is
* aligned even if we don't push arguments on it */
ir_node *const stack = get_initial_sp(irg);
ir_node *const callframe = amd64_new_IncSP(new_block, stack, cconv->callframe_size, AMD64_PO2_STACK_ALIGNMENT);
ir_node *const callframe
= amd64_new_IncSP(new_block, stack, cconv->param_stacksize,
AMD64_PO2_STACK_ALIGNMENT);
/* match callee */
amd64_addr_t addr;
......@@ -1981,7 +1983,8 @@ no_call_mem:
/* IncSP to destroy the call stackframe */
ir_node *const call_stack = be_new_Proj(call, pn_amd64_call_stack);
ir_node *const incsp = amd64_new_IncSP(new_block, call_stack, -cconv->callframe_size, 0);
ir_node *const incsp = amd64_new_IncSP(new_block, call_stack,
-cconv->param_stacksize, 0);
be_stack_record_chain(&stack_env, callframe, n_be_IncSP_pred, incsp);
x86_free_calling_convention(cconv);
......@@ -3295,7 +3298,7 @@ static void amd64_create_stacklayout(ir_graph *irg, const x86_cconv_t *cconv)
if (is_method_variadic(function_type)) {
ir_entity *stack_args_param = new_parameter_entity(
arg_type, IR_VA_START_PARAMETER_NUMBER, get_unknown_type());
set_entity_offset(stack_args_param, cconv->callframe_size);
set_entity_offset(stack_args_param, cconv->param_stacksize);
amd64_set_va_stack_args_param(stack_args_param);
}
......
......@@ -180,19 +180,19 @@ align_stack:;
calling_convention cc = get_method_calling_convention(function_type);
x86_cconv_t *cconv = XMALLOCZ(x86_cconv_t);
cconv->sp_delta = (cc & cc_compound_ret) && !(cc & cc_reg_param)
? IA32_REGISTER_SIZE : 0;
cconv->parameters = params;
cconv->n_parameters = n_params;
cconv->callframe_size = stack_offset;
cconv->n_param_regs = n_param_regs_used;
cconv->n_xmm_regs = float_param_regnum;
cconv->results = results;
cconv->omit_fp = omit_fp;
cconv->caller_saves = caller_saves;
cconv->callee_saves = callee_saves;
cconv->n_reg_results = n_reg_results;
x86_cconv_t *cconv = XMALLOCZ(x86_cconv_t);
cconv->sp_delta = (cc & cc_compound_ret) && !(cc & cc_reg_param)
? IA32_REGISTER_SIZE : 0;
cconv->parameters = params;
cconv->n_parameters = n_params;
cconv->param_stacksize = stack_offset;
cconv->n_param_regs = n_param_regs_used;
cconv->n_xmm_regs = float_param_regnum;
cconv->results = results;
cconv->omit_fp = omit_fp;
cconv->caller_saves = caller_saves;
cconv->callee_saves = callee_saves;
cconv->n_reg_results = n_reg_results;
if (irg != NULL) {
be_irg_t *birg = be_birg_from_irg(irg);
......
......@@ -4972,11 +4972,12 @@ static ir_node *gen_Call(ir_node *node)
ir_node *const block = be_transform_node(old_block);
ir_node *const stack = get_initial_sp(irg);
unsigned const po2_stack_alignment = ia32_cg_config.po2_stack_alignment;
unsigned const callframe_size = cconv->callframe_size;
bool const needs_stack = callframe_size != 0 || po2_stack_alignment != 0;
unsigned const param_stacksize = cconv->param_stacksize;
bool const needs_stack = param_stacksize != 0
|| po2_stack_alignment != 0;
ir_node *const callframe =
!needs_stack ? stack :
ia32_new_IncSP(block, stack, callframe_size, ia32_cg_config.po2_stack_alignment);
ia32_new_IncSP(block, stack, param_stacksize, ia32_cg_config.po2_stack_alignment);
in[n_ia32_Call_stack] = callframe;
in_req[n_ia32_Call_stack] = sp->single_req;
......@@ -5090,7 +5091,7 @@ static ir_node *gen_Call(ir_node *node)
/* IncSp to destroy callframe. */
ir_node *new_stack = be_new_Proj(call, pn_ia32_Call_stack);
unsigned const reduce_size = callframe_size - cconv->sp_delta;
unsigned const reduce_size = param_stacksize - cconv->sp_delta;
if (reduce_size > 0 || po2_stack_alignment != 0)
new_stack = ia32_new_IncSP(block, new_stack, -(int)reduce_size, 0);
ir_node *const old_stack = needs_stack ? callframe : call;
......@@ -5858,10 +5859,10 @@ static void ia32_create_stacklayout(ir_graph *irg, const x86_cconv_t *cconv)
if (is_method_variadic(function_type)) {
ir_type *unknown = get_unknown_type();
va_start_entity = new_parameter_entity(arg_type, IR_VA_START_PARAMETER_NUMBER, unknown);
set_entity_offset(va_start_entity, cconv->callframe_size);
set_entity_offset(va_start_entity, cconv->param_stacksize);
}
set_type_size(arg_type, cconv->callframe_size);
set_type_size(arg_type, cconv->param_stacksize);
be_stack_layout_t *const layout = be_get_irg_stack_layout(irg);
memset(layout, 0, sizeof(*layout));
......
......@@ -19,10 +19,11 @@
typedef struct reg_or_stackslot_t
{
const arch_register_t *reg;
ir_type *type; /**< indicates that an entity of the
specific type is needed */
unsigned offset; /**< if transmitted via stack, the offset
for this parameter. */
/** Type of parameter if it is transfered on the stack, otherwise NULL. */
ir_type *type;
/** Offset of parameter relative to the stackpointer immediately before the
* call. Undefined if a register is used. */
unsigned offset;
ir_entity *entity; /**< entity in frame type */
} reg_or_stackslot_t;
......@@ -34,7 +35,7 @@ typedef struct x86_cconv_t
unsigned sp_delta;
reg_or_stackslot_t *parameters; /**< parameter info. */
unsigned n_parameters; /**< number of parameters */
unsigned callframe_size; /**< stack size for parameters */
unsigned param_stacksize; /**< stack size for parameters */
unsigned n_param_regs; /**< number of values passed in a
register (gp + xmm) */
unsigned n_xmm_regs; /**< number of xmm registers used */
......
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