Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Zwinkau
libfirm
Commits
aea257b0
Commit
aea257b0
authored
Aug 07, 2015
by
Christoph Mallon
Browse files
amd64, arm, ia32, sparc: Remember the number of parameters in the calling convention.
parent
7ac0968c
Changes
13
Hide whitespace changes
Inline
Side-by-side
ir/be/amd64/amd64_cconv.c
View file @
aea257b0
...
...
@@ -162,6 +162,7 @@ x86_cconv_t *amd64_decide_calling_convention(ir_type *function_type,
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
;
...
...
ir/be/amd64/amd64_transform.c
View file @
aea257b0
...
...
@@ -1392,12 +1392,6 @@ static ir_node *gen_Switch(ir_node *node)
static
ir_node
*
gen_Start
(
ir_node
*
node
)
{
ir_graph
*
irg
=
get_irn_irg
(
node
);
ir_entity
*
entity
=
get_irg_entity
(
irg
);
ir_type
*
function_type
=
get_entity_type
(
entity
);
ir_node
*
new_block
=
be_transform_nodes_block
(
node
);
dbg_info
*
dbgi
=
get_irn_dbg_info
(
node
);
x86_cconv_t
const
*
const
cconv
=
current_cconv
;
/* start building list of start constraints */
...
...
@@ -1410,7 +1404,9 @@ static ir_node *gen_Start(ir_node *node)
=
rbitset_popcount
(
cconv
->
callee_saves
,
N_AMD64_REGISTERS
);
n_outs
+=
n_callee_saves
;
ir_node
*
start
=
new_bd_amd64_start
(
dbgi
,
new_block
,
n_outs
);
dbg_info
*
const
dbgi
=
get_irn_dbg_info
(
node
);
ir_node
*
const
new_block
=
be_transform_nodes_block
(
node
);
ir_node
*
const
start
=
new_bd_amd64_start
(
dbgi
,
new_block
,
n_outs
);
size_t
o
=
0
;
...
...
@@ -1421,7 +1417,7 @@ static ir_node *gen_Start(ir_node *node)
be_make_start_out
(
&
start_val
[
REG_RSP
],
start
,
o
++
,
&
amd64_registers
[
REG_RSP
],
true
);
/* function parameters in registers */
for
(
size_t
i
=
0
;
i
<
get_method_n_params
(
function_type
)
;
++
i
)
{
for
(
size_t
i
=
0
,
n
=
cconv
->
n_parameters
;
i
!=
n
;
++
i
)
{
const
reg_or_stackslot_t
*
param
=
&
current_cconv
->
parameters
[
i
];
const
arch_register_t
*
reg
=
param
->
reg
;
if
(
reg
)
...
...
@@ -1551,7 +1547,7 @@ static ir_node *gen_Call(ir_node *node)
int
sync_arity
=
0
;
ir_node
*
new_frame
=
get_stack_pointer_for
(
node
);
assert
(
n_params
==
get_method_n_params
(
type
)
);
assert
(
n_params
==
cconv
->
n_parameters
);
/* construct arguments */
...
...
@@ -2664,15 +2660,11 @@ static ir_type *amd64_get_between_type(bool omit_fp)
static
void
amd64_create_stacklayout
(
ir_graph
*
irg
,
const
x86_cconv_t
*
cconv
)
{
ir_entity
*
entity
=
get_irg_entity
(
irg
);
ir_type
*
function_type
=
get_entity_type
(
entity
);
be_stack_layout_t
*
layout
=
be_get_irg_stack_layout
(
irg
);
/* construct argument type */
i
d
ent
*
const
arg_id
=
new_id_fmt
(
"%s_arg_type"
,
get_entity_ident
(
entity
)
);
i
r_type
*
const
arg_
type
=
new_
type_struct
(
arg_id
);
size_t
const
n_params
=
get_method_n_params
(
function_type
);
for
(
size_t
p
=
0
;
p
<
n_params
;
++
p
)
{
i
r_
ent
ity
*
const
entity
=
get_irg_entity
(
irg
);
i
dent
*
const
arg_
id
=
new_
id_fmt
(
"%s_arg_type"
,
get_entity_ident
(
entity
)
);
ir_type
*
const
arg_type
=
new_type_struct
(
arg_id
);
for
(
size_t
p
=
0
,
n_params
=
cconv
->
n_parameters
;
p
<
n_params
;
++
p
)
{
reg_or_stackslot_t
*
param
=
&
cconv
->
parameters
[
p
];
if
(
param
->
type
==
NULL
)
continue
;
...
...
@@ -2682,6 +2674,7 @@ static void amd64_create_stacklayout(ir_graph *irg, const x86_cconv_t *cconv)
set_entity_offset
(
param
->
entity
,
param
->
offset
);
}
be_stack_layout_t
*
const
layout
=
be_get_irg_stack_layout
(
irg
);
memset
(
layout
,
0
,
sizeof
(
*
layout
));
layout
->
frame_type
=
get_irg_frame_type
(
irg
);
layout
->
between_type
=
amd64_get_between_type
(
cconv
->
omit_fp
);
...
...
ir/be/arm/arm_cconv.c
View file @
aea257b0
...
...
@@ -134,6 +134,7 @@ calling_convention_t *arm_decide_calling_convention(const ir_graph *irg,
calling_convention_t
*
cconv
=
XMALLOCZ
(
calling_convention_t
);
cconv
->
parameters
=
params
;
cconv
->
n_parameters
=
n_params
;
cconv
->
param_stack_size
=
stack_offset
;
cconv
->
n_param_regs
=
n_param_regs_used
;
cconv
->
results
=
results
;
...
...
ir/be/arm/arm_cconv.h
View file @
aea257b0
...
...
@@ -30,6 +30,7 @@ typedef struct reg_or_stackslot_t
typedef
struct
calling_convention_t
{
reg_or_stackslot_t
*
parameters
;
/**< parameter info. */
unsigned
n_parameters
;
/**< number of parameters */
unsigned
param_stack_size
;
/**< needed stack size for parameters */
unsigned
n_param_regs
;
reg_or_stackslot_t
*
results
;
/**< result info. */
...
...
ir/be/arm/arm_emitter.c
View file @
aea257b0
...
...
@@ -663,7 +663,7 @@ static parameter_dbg_info_t *construct_parameter_infos(ir_graph *irg)
ir_entity
*
entity
=
get_irg_entity
(
irg
);
ir_type
*
type
=
get_entity_type
(
entity
);
calling_convention_t
*
cconv
=
arm_decide_calling_convention
(
NULL
,
type
);
size_t
n_params
=
get_method_n_params
(
type
)
;
size_t
n_params
=
cconv
->
n_parameters
;
parameter_dbg_info_t
*
infos
=
XMALLOCNZ
(
parameter_dbg_info_t
,
n_params
);
for
(
size_t
i
=
0
;
i
<
n_params
;
++
i
)
{
...
...
ir/be/arm/arm_transform.c
View file @
aea257b0
...
...
@@ -1657,18 +1657,14 @@ static ir_type *arm_get_between_type(void)
static
void
create_stacklayout
(
ir_graph
*
irg
)
{
ir_entity
*
entity
=
get_irg_entity
(
irg
);
ir_type
*
function_type
=
get_entity_type
(
entity
);
be_stack_layout_t
*
layout
=
be_get_irg_stack_layout
(
irg
);
/* calling conventions must be decided by now */
assert
(
cconv
!=
NULL
);
/* construct argument type */
i
d
ent
*
const
arg_type_id
=
new_id_fmt
(
"%s_arg_type"
,
get_entity_ident
(
entity
)
);
i
r_type
*
const
arg_type
=
new_
type_struct
(
arg_type_id
);
for
(
unsigned
p
=
0
,
n_params
=
get_method_n_params
(
function
_type
);
p
<
n_params
;
++
p
)
{
i
r_
ent
ity
*
const
entity
=
get_irg_entity
(
irg
);
i
dent
*
const
arg_type
_id
=
new_
id_fmt
(
"%s_arg_type"
,
get_entity_ident
(
entity
)
);
ir_type
*
const
arg_type
=
new_type_struct
(
arg
_type
_id
);
for
(
unsigned
p
=
0
,
n_params
=
cconv
->
n_parameters
;
p
<
n_params
;
++
p
)
{
reg_or_stackslot_t
*
param
=
&
cconv
->
parameters
[
p
];
if
(
param
->
type
==
NULL
)
continue
;
...
...
@@ -1680,6 +1676,7 @@ static void create_stacklayout(ir_graph *irg)
/* TODO: what about external functions? we don't know most of the stack
* layout for them. And probably don't need all of this... */
be_stack_layout_t
*
const
layout
=
be_get_irg_stack_layout
(
irg
);
memset
(
layout
,
0
,
sizeof
(
*
layout
));
layout
->
frame_type
=
get_irg_frame_type
(
irg
);
layout
->
between_type
=
arm_get_between_type
();
...
...
@@ -1699,24 +1696,21 @@ static void create_stacklayout(ir_graph *irg)
*/
static
ir_node
*
gen_Start
(
ir_node
*
node
)
{
ir_graph
*
irg
=
get_irn_irg
(
node
);
ir_entity
*
entity
=
get_irg_entity
(
irg
);
ir_type
*
function_type
=
get_entity_type
(
entity
);
ir_node
*
new_block
=
be_transform_nodes_block
(
node
);
dbg_info
*
dbgi
=
get_irn_dbg_info
(
node
);
unsigned
n_outs
=
2
;
/* memory, sp */
n_outs
+=
cconv
->
n_param_regs
;
n_outs
+=
ARRAY_SIZE
(
callee_saves
);
ir_node
*
start
=
new_bd_arm_Start
(
dbgi
,
new_block
,
n_outs
);
unsigned
o
=
0
;
dbg_info
*
const
dbgi
=
get_irn_dbg_info
(
node
);
ir_node
*
const
new_block
=
be_transform_nodes_block
(
node
);
ir_node
*
const
start
=
new_bd_arm_Start
(
dbgi
,
new_block
,
n_outs
);
unsigned
o
=
0
;
be_make_start_mem
(
&
start_mem
,
start
,
o
++
);
be_make_start_out
(
&
start_val
[
REG_SP
],
start
,
o
++
,
&
arm_registers
[
REG_SP
],
true
);
/* function parameters in registers */
for
(
size_t
i
=
0
;
i
<
get_method_n_params
(
function_type
)
;
++
i
)
{
for
(
size_t
i
=
0
,
n
=
cconv
->
n_parameters
;
i
!=
n
;
++
i
)
{
const
reg_or_stackslot_t
*
param
=
&
cconv
->
parameters
[
i
];
const
arch_register_t
*
reg0
=
param
->
reg0
;
if
(
reg0
)
...
...
@@ -1828,7 +1822,7 @@ static ir_node *gen_Call(ir_node *node)
size_t
const
n_caller_saves
=
ARRAY_SIZE
(
caller_saves
);
ir_entity
*
entity
=
NULL
;
assert
(
n_params
==
get_method_n_params
(
type
)
);
assert
(
n_params
==
cconv
->
n_parameters
);
/* memory input */
int
mem_pos
=
in_arity
++
;
...
...
ir/be/ia32/ia32_cconv.c
View file @
aea257b0
...
...
@@ -207,6 +207,7 @@ align_stack:;
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
;
...
...
ir/be/ia32/ia32_transform.c
View file @
aea257b0
...
...
@@ -4171,12 +4171,6 @@ static ir_node *gen_Member(ir_node *node)
static
ir_node
*
gen_Start
(
ir_node
*
node
)
{
ir_graph
*
irg
=
get_irn_irg
(
node
);
ir_entity
*
entity
=
get_irg_entity
(
irg
);
ir_type
*
function_type
=
get_entity_type
(
entity
);
ir_node
*
new_block
=
be_transform_nodes_block
(
node
);
dbg_info
*
dbgi
=
get_irn_dbg_info
(
node
);
x86_cconv_t
const
*
const
cconv
=
current_cconv
;
/* start building list of start constraints */
...
...
@@ -4189,7 +4183,9 @@ static ir_node *gen_Start(ir_node *node)
=
rbitset_popcount
(
cconv
->
callee_saves
,
N_IA32_REGISTERS
);
n_outs
+=
n_callee_saves
;
ir_node
*
start
=
new_bd_ia32_Start
(
dbgi
,
new_block
,
n_outs
);
dbg_info
*
const
dbgi
=
get_irn_dbg_info
(
node
);
ir_node
*
const
new_block
=
be_transform_nodes_block
(
node
);
ir_node
*
const
start
=
new_bd_ia32_Start
(
dbgi
,
new_block
,
n_outs
);
unsigned
o
=
0
;
...
...
@@ -4200,7 +4196,7 @@ static ir_node *gen_Start(ir_node *node)
be_make_start_out
(
&
start_val
[
REG_ESP
],
start
,
o
++
,
&
ia32_registers
[
REG_ESP
],
true
);
/* function parameters in registers */
for
(
size_t
i
=
0
;
i
<
get_method_n_params
(
function_type
)
;
++
i
)
{
for
(
size_t
i
=
0
,
n
=
cconv
->
n_parameters
;
i
!=
n
;
++
i
)
{
const
reg_or_stackslot_t
*
param
=
&
current_cconv
->
parameters
[
i
];
const
arch_register_t
*
reg
=
param
->
reg
;
if
(
reg
)
...
...
@@ -5803,17 +5799,14 @@ static ir_type *ia32_get_between_type(bool omit_fp)
static
void
ia32_create_stacklayout
(
ir_graph
*
irg
,
const
x86_cconv_t
*
cconv
)
{
ir_entity
*
entity
=
get_irg_entity
(
irg
);
ir_type
*
function_type
=
get_entity_type
(
entity
);
be_stack_layout_t
*
layout
=
be_get_irg_stack_layout
(
irg
);
/* construct argument type */
ident
*
arg_id
=
new_id_fmt
(
"%s_arg_type"
,
get_entity_ident
(
entity
));
ir_type
*
arg_type
=
new_type_struct
(
arg_id
);
ir_type
*
frame_type
=
get_irg_frame_type
(
irg
);
ir_entity
*
va_start_entity
=
NULL
;
size_t
n_params
=
get_method_n_params
(
function_type
);
ir_entity
**
param_map
=
ALLOCANZ
(
ir_entity
*
,
n_params
);
ir_entity
*
const
entity
=
get_irg_entity
(
irg
);
ident
*
const
arg_id
=
new_id_fmt
(
"%s_arg_type"
,
get_entity_ident
(
entity
));
ir_type
*
const
arg_type
=
new_type_struct
(
arg_id
);
ir_type
*
const
frame_type
=
get_irg_frame_type
(
irg
);
size_t
const
n_params
=
cconv
->
n_parameters
;
ir_entity
**
const
param_map
=
ALLOCANZ
(
ir_entity
*
,
n_params
);
ir_entity
*
va_start_entity
=
NULL
;
for
(
size_t
f
=
get_compound_n_members
(
frame_type
);
f
--
>
0
;
)
{
ir_entity
*
member
=
get_compound_member
(
frame_type
,
f
);
if
(
!
is_parameter_entity
(
member
))
...
...
@@ -5851,6 +5844,7 @@ static void ia32_create_stacklayout(ir_graph *irg, const x86_cconv_t *cconv)
}
set_type_size_bytes
(
arg_type
,
cconv
->
callframe_size
);
be_stack_layout_t
*
const
layout
=
be_get_irg_stack_layout
(
irg
);
memset
(
layout
,
0
,
sizeof
(
*
layout
));
layout
->
frame_type
=
frame_type
;
layout
->
between_type
=
ia32_get_between_type
(
cconv
->
omit_fp
);
...
...
ir/be/ia32/x86_cconv.h
View file @
aea257b0
...
...
@@ -33,6 +33,7 @@ typedef struct x86_cconv_t
save/restore) */
unsigned
sp_delta
;
reg_or_stackslot_t
*
parameters
;
/**< parameter info. */
unsigned
n_parameters
;
/**< number of parameters */
unsigned
callframe_size
;
/**< stack size for parameters */
unsigned
n_param_regs
;
/**< number of values passed in a
register (gp + xmm) */
...
...
ir/be/sparc/sparc_cconv.c
View file @
aea257b0
...
...
@@ -313,6 +313,7 @@ calling_convention_t *sparc_decide_calling_convention(ir_type *function_type,
}
calling_convention_t
*
cconv
=
XMALLOCZ
(
calling_convention_t
);
cconv
->
n_parameters
=
n_params
;
cconv
->
parameters
=
params
;
cconv
->
param_stack_size
=
stack_offset
;
cconv
->
n_param_regs
=
n_param_regs_used
;
...
...
ir/be/sparc/sparc_cconv.h
View file @
aea257b0
...
...
@@ -39,6 +39,7 @@ struct calling_convention_t
{
bool
omit_fp
;
/**< do not use frame pointer (and no
save/restore) */
unsigned
n_parameters
;
/**< number of parameters */
reg_or_stackslot_t
*
parameters
;
/**< parameter info. */
unsigned
param_stack_size
;
/**< stack size for parameters */
unsigned
n_param_regs
;
/**< number of values passed in a
...
...
ir/be/sparc/sparc_stackframe.c
View file @
aea257b0
...
...
@@ -208,8 +208,7 @@ static ir_type *compute_arg_type(ir_graph *irg, calling_convention_t *cconv,
{
ir_entity
*
va_start_entity
=
NULL
;
const
ir_entity
*
entity
=
get_irg_entity
(
irg
);
const
ir_type
*
mtp
=
get_entity_type
(
entity
);
size_t
n_params
=
get_method_n_params
(
mtp
);
size_t
n_params
=
cconv
->
n_parameters
;
ir_entity
**
param_map
=
ALLOCANZ
(
ir_entity
*
,
n_params
);
ir_type
*
frame_type
=
get_irg_frame_type
(
irg
);
...
...
@@ -265,8 +264,9 @@ static ir_type *compute_arg_type(ir_graph *irg, calling_convention_t *cconv,
if
(
va_start_entity
!=
NULL
)
{
/* sparc_variadic_fixups() fiddled with our type, find out the
* original number of parameters */
ir_type
*
non_lowered
=
get_higher_type
(
mtp
);
size_t
orig_n_params
=
get_method_n_params
(
non_lowered
);
ir_type
const
*
const
mtp
=
get_entity_type
(
entity
);
ir_type
*
const
non_lowered
=
get_higher_type
(
mtp
);
size_t
const
orig_n_params
=
get_method_n_params
(
non_lowered
);
assert
(
is_method_variadic
(
mtp
));
long
offset
;
if
(
orig_n_params
<
n_params
)
{
...
...
ir/be/sparc/sparc_transform.c
View file @
aea257b0
...
...
@@ -1535,12 +1535,6 @@ static ir_node *gen_Unknown(ir_node *node)
*/
static
ir_node
*
gen_Start
(
ir_node
*
node
)
{
ir_graph
*
irg
=
get_irn_irg
(
node
);
ir_entity
*
entity
=
get_irg_entity
(
irg
);
ir_type
*
function_type
=
get_entity_type
(
entity
);
ir_node
*
new_block
=
be_transform_nodes_block
(
node
);
dbg_info
*
dbgi
=
get_irn_dbg_info
(
node
);
/* start building list of start constraints */
/* calculate number of outputs */
...
...
@@ -1554,7 +1548,9 @@ static ir_node *gen_Start(ir_node *node)
n_outs
+=
ARRAY_SIZE
(
omit_fp_callee_saves
);
}
ir_node
*
start
=
new_bd_sparc_Start
(
dbgi
,
new_block
,
n_outs
);
dbg_info
*
const
dbgi
=
get_irn_dbg_info
(
node
);
ir_node
*
const
new_block
=
be_transform_nodes_block
(
node
);
ir_node
*
const
start
=
new_bd_sparc_Start
(
dbgi
,
new_block
,
n_outs
);
size_t
o
=
0
;
...
...
@@ -1574,7 +1570,7 @@ static ir_node *gen_Start(ir_node *node)
be_make_start_out
(
&
start_val
[
REG_FP
],
start
,
o
++
,
fp_reg
,
true
);
/* function parameters in registers */
for
(
size_t
i
=
0
;
i
<
get_method_n_params
(
function_type
)
;
++
i
)
{
for
(
size_t
i
=
0
,
n
=
current_cconv
->
n_parameters
;
i
!=
n
;
++
i
)
{
reg_or_stackslot_t
const
*
const
param
=
&
current_cconv
->
parameters
[
i
];
arch_register_t
const
*
const
reg0
=
param
->
reg0
;
if
(
reg0
)
...
...
@@ -1796,7 +1792,7 @@ static ir_node *gen_Call(ir_node *node)
bool
aggregate_return
=
get_method_calling_convention
(
type
)
&
cc_compound_ret
;
assert
(
n_params
==
get_method_n_params
(
type
)
);
assert
(
n_params
==
cconv
->
n_parameters
);
/* construct arguments */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment