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
3638a994
Commit
3638a994
authored
Oct 29, 2013
by
Christoph Mallon
Browse files
Simplify offset/size calculation in default_layout_compound_type().
Just one variable to hold them is sufficient.
parent
c83ffae1
Changes
1
Hide whitespace changes
Inline
Side-by-side
ir/tr/type.c
View file @
3638a994
...
...
@@ -1473,7 +1473,6 @@ void set_default_size(ir_type *tp, unsigned size)
void
default_layout_compound_type
(
ir_type
*
type
)
{
unsigned
size
=
0
;
int
offset
=
0
;
unsigned
align_all
=
1
;
bool
var_size
=
is_compound_variable_size
(
type
);
for
(
size_t
i
=
0
,
n
=
get_compound_n_members
(
type
);
i
<
n
;
++
i
)
{
...
...
@@ -1494,20 +1493,21 @@ void default_layout_compound_type(ir_type *type)
entity_size
=
0
;
}
unsigned
align
=
get_type_alignment_bytes
(
entity_type
);
unsigned
misalign
=
(
align
?
offset
%
align
:
0
);
offset
+=
(
misalign
?
align
-
misalign
:
0
);
unsigned
const
align
=
get_type_alignment_bytes
(
entity_type
);
align_all
=
MAX
(
align
,
align_all
);
set_entity_offset
(
entity
,
offset
);
if
(
!
is_Union_type
(
type
))
{
offset
+=
entity_size
;
}
else
{
set_entity_offset
(
entity
,
size
);
if
(
is_Union_type
(
type
))
{
size
=
MAX
(
size
,
entity_size
);
}
else
{
if
(
align
!=
0
)
{
unsigned
const
misalign
=
size
%
align
;
if
(
misalign
!=
0
)
size
+=
align
-
misalign
;
}
size
+=
entity_size
;
}
}
if
(
!
is_Union_type
(
type
))
size
=
offset
;
if
(
align_all
>
0
&&
size
%
align_all
)
{
size
+=
align_all
-
(
size
%
align_all
);
...
...
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