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
bb951a84
Commit
bb951a84
authored
Aug 17, 2005
by
Michael Beck
Browse files
resreuctures compound path to make allocation/deallocation simplier
[r6455]
parent
47a26520
Changes
2
Hide whitespace changes
Inline
Side-by-side
ir/tr/entity.c
View file @
bb951a84
...
...
@@ -585,12 +585,11 @@ new_compound_graph_path(type *tp, int length) {
assert
(
is_type
(
tp
)
&&
is_compound_type
(
tp
));
assert
(
length
>
0
);
res
=
xmalloc
(
sizeof
(
*
res
)
+
(
length
-
1
)
*
sizeof
(
res
->
nodes
[
0
]));
memset
(
res
,
0
,
sizeof
(
*
res
)
+
(
length
-
1
)
*
sizeof
(
res
->
nodes
[
0
]));
res
=
xmalloc
(
sizeof
(
*
res
)
+
(
length
-
1
)
*
sizeof
(
res
->
list
[
0
]));
memset
(
res
,
0
,
sizeof
(
*
res
)
+
(
length
-
1
)
*
sizeof
(
res
->
list
[
0
]));
res
->
kind
=
k_ir_compound_graph_path
;
res
->
tp
=
tp
;
res
->
len
=
length
;
res
->
arr_indicees
=
xcalloc
(
length
,
sizeof
(
res
->
arr_indicees
[
0
]));
return
res
;
}
...
...
@@ -599,7 +598,6 @@ new_compound_graph_path(type *tp, int length) {
void
free_compound_graph_path
(
compound_graph_path
*
gr
)
{
assert
(
gr
&&
is_compound_graph_path
(
gr
));
gr
->
kind
=
k_BAD
;
free
(
gr
->
arr_indicees
);
free
(
gr
);
}
...
...
@@ -640,7 +638,7 @@ entity *
get_compound_graph_path_node
(
compound_graph_path
*
gr
,
int
pos
)
{
assert
(
gr
&&
is_compound_graph_path
(
gr
));
assert
(
pos
>=
0
&&
pos
<
gr
->
len
);
return
gr
->
nodes
[
pos
]
;
return
gr
->
list
[
pos
].
node
;
}
void
...
...
@@ -648,7 +646,7 @@ set_compound_graph_path_node(compound_graph_path *gr, int pos, entity *node) {
assert
(
gr
&&
is_compound_graph_path
(
gr
));
assert
(
pos
>=
0
&&
pos
<
gr
->
len
);
assert
(
is_entity
(
node
));
gr
->
nodes
[
pos
]
=
node
;
gr
->
list
[
pos
].
node
=
node
;
assert
(
is_proper_compound_graph_path
(
gr
,
pos
));
}
...
...
@@ -656,14 +654,14 @@ int
get_compound_graph_path_array_index
(
compound_graph_path
*
gr
,
int
pos
)
{
assert
(
gr
&&
is_compound_graph_path
(
gr
));
assert
(
pos
>=
0
&&
pos
<
gr
->
len
);
return
gr
->
arr_indicees
[
pos
]
;
return
gr
->
list
[
pos
].
index
;
}
void
set_compound_graph_path_array_index
(
compound_graph_path
*
gr
,
int
pos
,
int
index
)
{
assert
(
gr
&&
is_compound_graph_path
(
gr
));
assert
(
pos
>=
0
&&
pos
<
gr
->
len
);
gr
->
arr_indicees
[
pos
]
=
index
;
gr
->
list
[
pos
].
index
=
index
;
}
/* A value of a compound entity is a pair of value and the corresponding path to a member of
...
...
@@ -778,10 +776,10 @@ remove_compound_ent_value(entity *ent, entity *value_ent) {
assert
(
is_compound_entity
(
ent
)
&&
(
ent
->
variability
!=
variability_uninitialized
));
for
(
i
=
0
;
i
<
(
ARR_LEN
(
ent
->
val_paths
));
i
++
)
{
compound_graph_path
*
path
=
ent
->
val_paths
[
i
];
if
(
path
->
nodes
[
path
->
len
-
1
]
==
value_ent
)
{
if
(
path
->
list
[
path
->
len
-
1
]
.
node
==
value_ent
)
{
for
(;
i
<
(
ARR_LEN
(
ent
->
val_paths
))
-
1
;
i
++
)
{
ent
->
val_paths
[
i
]
=
ent
->
val_paths
[
i
+
1
];
ent
->
values
[
i
]
=
ent
->
values
[
i
+
1
];
ent
->
values
[
i
]
=
ent
->
values
[
i
+
1
];
}
ARR_SETLEN
(
entity
*
,
ent
->
val_paths
,
ARR_LEN
(
ent
->
val_paths
)
-
1
);
ARR_SETLEN
(
ir_node
*
,
ent
->
values
,
ARR_LEN
(
ent
->
values
)
-
1
);
...
...
@@ -796,7 +794,7 @@ add_compound_ent_value(entity *ent, ir_node *val, entity *member) {
type
*
owner_tp
=
get_entity_owner
(
ent
);
assert
(
is_compound_entity
(
ent
)
&&
(
ent
->
variability
!=
variability_uninitialized
));
path
=
new_compound_graph_path
(
owner_tp
,
1
);
path
->
node
s
[
0
]
=
member
;
path
->
list
[
0
].
node
=
member
;
if
(
is_Array_type
(
owner_tp
))
{
int
max
;
int
i
;
...
...
@@ -809,7 +807,7 @@ add_compound_ent_value(entity *ent, ir_node *val, entity *member) {
max
=
index
;
}
}
path
->
arr_indicees
[
0
]
=
max
+
1
;
path
->
list
[
0
].
index
=
max
+
1
;
}
add_compound_ent_value_w_path
(
ent
,
val
,
path
);
}
...
...
ir/tr/entity_t.h
View file @
bb951a84
...
...
@@ -52,10 +52,11 @@ struct compound_graph_path {
firm_kind
kind
;
/**< dynamic type tag for compound graph path. */
type
*
tp
;
/**< The type this path belongs to. */
int
len
;
/**< length of the path */
int
*
arr_indicees
;
/**< List of array indeces. To compute position of
array elements */
entity
*
nodes
[
1
];
/**< List of entities of length len to express the
access path. */
struct
tuple
{
int
index
;
/**< Array index. To compute position of array elements */
entity
*
node
;
/**< entity */
}
list
[
1
];
/**< List of entitiy/index tuple of length len to express the
access path. */
};
/** the type of an entity */
...
...
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