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
a38e2989
Commit
a38e2989
authored
Jan 22, 2010
by
Matthias Braun
Browse files
add a default_layout_compound_type; the backend layouts the frametype now if it hasn't happened yet
[r26991]
parent
b48fc049
Changes
3
Hide whitespace changes
Inline
Side-by-side
include/libfirm/typerep.h
View file @
a38e2989
...
...
@@ -2500,6 +2500,11 @@ typedef void entity_walk_func(ir_entity *ent, void *env);
*/
void
walk_types_entities
(
ir_type
*
tp
,
entity_walk_func
*
doit
,
void
*
env
);
/**
* layout members of a struct/union or class type in a default way.
*/
void
default_layout_compound_type
(
ir_type
*
tp
);
/**
* If we have the closed world assumption, we can calculate the
* finalization of classes and entities by inspecting the class hierarchy.
...
...
ir/be/beabi.c
View file @
a38e2989
...
...
@@ -1835,6 +1835,11 @@ static void modify_irg(be_abi_irg_t *env)
ctx
.
link_class
=
env
->
arch_env
->
link_class
;
ctx
.
frame_tp
=
get_irg_frame_type
(
irg
);
/* layout the stackframe now */
if
(
get_type_state
(
ctx
.
frame_tp
)
==
layout_undefined
)
{
default_layout_compound_type
(
ctx
.
frame_tp
);
}
/* we will possible add new entities to the frame: set the layout to undefined */
assert
(
get_type_state
(
ctx
.
frame_tp
)
==
layout_fixed
);
set_type_state
(
ctx
.
frame_tp
,
layout_undefined
);
...
...
ir/tr/type.c
View file @
a38e2989
...
...
@@ -2239,6 +2239,43 @@ void set_default_size(ir_type *tp, unsigned size)
tp
->
size
=
size
;
}
void
default_layout_compound_type
(
ir_type
*
type
)
{
int
i
;
int
n
=
get_compound_n_members
(
type
);
int
size
=
0
;
unsigned
align_all
=
1
;
for
(
i
=
0
;
i
<
n
;
++
i
)
{
ir_entity
*
entity
=
get_compound_member
(
type
,
i
);
ir_type
*
entity_type
=
get_entity_type
(
entity
);
unsigned
align
;
unsigned
misalign
;
if
(
is_Method_type
(
entity_type
))
continue
;
assert
(
get_type_state
(
entity_type
)
==
layout_fixed
);
align
=
get_type_alignment_bytes
(
entity_type
);
align_all
=
align
>
align_all
?
align
:
align_all
;
misalign
=
(
align
?
size
%
align
:
0
);
size
+=
(
misalign
?
align
-
misalign
:
0
);
set_entity_offset
(
entity
,
size
);
if
(
!
is_Union_type
(
type
))
{
size
+=
get_type_size_bytes
(
entity_type
);
}
}
if
(
align_all
>
0
&&
size
%
align_all
)
{
size
+=
align_all
-
(
size
%
align_all
);
}
if
(
align_all
>
get_type_alignment_bytes
(
type
))
{
set_type_alignment_bytes
(
type
,
align_all
);
}
set_type_size_bytes
(
type
,
size
);
set_type_state
(
type
,
layout_fixed
);
}
ir_entity
*
frame_alloc_area
(
ir_type
*
frame_type
,
int
size
,
unsigned
alignment
,
int
at_start
)
{
...
...
Write
Preview
Supports
Markdown
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