projects
/
libfirm
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Remove unused variable.
[libfirm]
/
ir
/
tr
/
type.c
diff --git
a/ir/tr/type.c
b/ir/tr/type.c
index
c69d24f
..
562cb66
100644
(file)
--- a/
ir/tr/type.c
+++ b/
ir/tr/type.c
@@
-45,9
+45,7
@@
* @see type_t.h type tpop
*/
* @see type_t.h type tpop
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
+#include "config.h"
#ifdef HAVE_STRING_H
# include <string.h>
#ifdef HAVE_STRING_H
# include <string.h>
@@
-110,11
+108,11
@@
void firm_init_type(dbg_info *builtin_db, unsigned def_cc_mask) {
}
/** the global type visited flag */
}
/** the global type visited flag */
-
unsigned long
firm_type_visited;
+
ir_visited_t
firm_type_visited;
-void (set_master_type_visited)(
unsigned long
val) { _set_master_type_visited(val); }
-
unsigned long
(get_master_type_visited)(void) { return _get_master_type_visited(); }
-void (inc_master_type_visited)(void)
{ _inc_master_type_visited(); }
+void (set_master_type_visited)(
ir_visited_t
val) { _set_master_type_visited(val); }
+
ir_visited_t
(get_master_type_visited)(void) { return _get_master_type_visited(); }
+void (inc_master_type_visited)(void) { _inc_master_type_visited(); }
/*
* Creates a new type representation.
/*
* Creates a new type representation.
@@
-423,11
+421,11
@@
set_type_state(ir_type *tp, ir_type_state state) {
tp->flags &= ~tf_layout_fixed;
}
tp->flags &= ~tf_layout_fixed;
}
-
unsigned long
(get_type_visited)(const ir_type *tp) {
+
ir_visited_t
(get_type_visited)(const ir_type *tp) {
return _get_type_visited(tp);
}
return _get_type_visited(tp);
}
-void (set_type_visited)(ir_type *tp,
unsigned long
num) {
+void (set_type_visited)(ir_type *tp,
ir_visited_t
num) {
_set_type_visited(tp, num);
}
_set_type_visited(tp, num);
}
@@
-796,6
+794,7
@@
void free_class_attrs(ir_type *clss) {
void add_class_member(ir_type *clss, ir_entity *member) {
assert(clss && (clss->type_op == type_class));
assert(clss != get_entity_type(member) && "recursive type");
void add_class_member(ir_type *clss, ir_entity *member) {
assert(clss && (clss->type_op == type_class));
assert(clss != get_entity_type(member) && "recursive type");
+ assert(get_type_state(clss) != layout_fixed);
ARR_APP1 (ir_entity *, clss->attr.ca.members, member);
}
ARR_APP1 (ir_entity *, clss->attr.ca.members, member);
}
@@
-1091,6
+1090,7
@@
void add_struct_member(ir_type *strct, ir_entity *member) {
assert(strct && (strct->type_op == type_struct));
assert(get_type_tpop(get_entity_type(member)) != type_method);
assert(strct != get_entity_type(member) && "recursive type");
assert(strct && (strct->type_op == type_struct));
assert(get_type_tpop(get_entity_type(member)) != type_method);
assert(strct != get_entity_type(member) && "recursive type");
+ assert(get_type_state(strct) != layout_fixed);
ARR_APP1 (ir_entity *, strct->attr.sa.members, member);
}
ARR_APP1 (ir_entity *, strct->attr.sa.members, member);
}
@@
-1189,10
+1189,10
@@
ir_type *new_d_type_method(ident *name, int n_param, int n_res, dbg_info *db) {
res->flags |= tf_layout_fixed;
res->size = get_mode_size_bytes(mode_P_code);
res->attr.ma.n_params = n_param;
res->flags |= tf_layout_fixed;
res->size = get_mode_size_bytes(mode_P_code);
res->attr.ma.n_params = n_param;
- res->attr.ma.params =
xcalloc(n_param, sizeof(res->attr.ma.params[0])
);
+ res->attr.ma.params =
XMALLOCNZ(tp_ent_pair, n_param
);
res->attr.ma.value_params = NULL;
res->attr.ma.n_res = n_res;
res->attr.ma.value_params = NULL;
res->attr.ma.n_res = n_res;
- res->attr.ma.res_type =
xcalloc(n_res, sizeof(res->attr.ma.res_type[0])
);
+ res->attr.ma.res_type =
XMALLOCNZ(tp_ent_pair, n_res
);
res->attr.ma.value_ress = NULL;
res->attr.ma.variadicity = variadicity_non_variadic;
res->attr.ma.first_variadic_param = -1;
res->attr.ma.value_ress = NULL;
res->attr.ma.variadicity = variadicity_non_variadic;
res->attr.ma.first_variadic_param = -1;
@@
-1231,11
+1231,11
@@
ir_type *clone_type_method(ir_type *tp, ident *prefix) {
res->assoc_type = tp->assoc_type;
res->size = tp->size;
res->attr.ma.n_params = n_params;
res->assoc_type = tp->assoc_type;
res->size = tp->size;
res->attr.ma.n_params = n_params;
- res->attr.ma.params =
xcalloc(n_params, sizeof(res->attr.ma.params[0])
);
+ res->attr.ma.params =
XMALLOCN(tp_ent_pair, n_params
);
memcpy(res->attr.ma.params, tp->attr.ma.params, n_params * sizeof(res->attr.ma.params[0]));
res->attr.ma.value_params = tp->attr.ma.value_params;
res->attr.ma.n_res = n_res;
memcpy(res->attr.ma.params, tp->attr.ma.params, n_params * sizeof(res->attr.ma.params[0]));
res->attr.ma.value_params = tp->attr.ma.value_params;
res->attr.ma.n_res = n_res;
- res->attr.ma.res_type =
xcalloc(n_res, sizeof(res->attr.ma.res_type[0])
);
+ res->attr.ma.res_type =
XMALLOCN(tp_ent_pair, n_res
);
memcpy(res->attr.ma.res_type, tp->attr.ma.res_type, n_res * sizeof(res->attr.ma.res_type[0]));
res->attr.ma.value_ress = tp->attr.ma.value_ress;
res->attr.ma.variadicity = tp->attr.ma.variadicity;
memcpy(res->attr.ma.res_type, tp->attr.ma.res_type, n_res * sizeof(res->attr.ma.res_type[0]));
res->attr.ma.value_ress = tp->attr.ma.value_ress;
res->attr.ma.variadicity = tp->attr.ma.variadicity;
@@
-1533,6
+1533,7
@@
int get_union_n_members(const ir_type *uni) {
void add_union_member(ir_type *uni, ir_entity *member) {
assert(uni && (uni->type_op == type_union));
assert(uni != get_entity_type(member) && "recursive type");
void add_union_member(ir_type *uni, ir_entity *member) {
assert(uni && (uni->type_op == type_union));
assert(uni != get_entity_type(member) && "recursive type");
+ assert(get_type_state(uni) != layout_fixed);
ARR_APP1(ir_entity *, uni->attr.ua.members, member);
}
ARR_APP1(ir_entity *, uni->attr.ua.members, member);
}
@@
-1594,9
+1595,9
@@
ir_type *new_d_type_array(ident *name, int n_dimensions, ir_type *element_type,
res = new_type(type_array, NULL, name, db);
res->attr.aa.n_dimensions = n_dimensions;
res = new_type(type_array, NULL, name, db);
res->attr.aa.n_dimensions = n_dimensions;
- res->attr.aa.lower_bound =
xcalloc(n_dimensions, sizeof(*res->attr.aa.lower_bound)
);
- res->attr.aa.upper_bound =
xcalloc(n_dimensions, sizeof(*res->attr.aa.upper_bound)
);
- res->attr.aa.order =
xcalloc(n_dimensions, sizeof(*res->attr.aa.order)
);
+ res->attr.aa.lower_bound =
XMALLOCNZ(ir_node*, n_dimensions
);
+ res->attr.aa.upper_bound =
XMALLOCNZ(ir_node*, n_dimensions
);
+ res->attr.aa.order =
XMALLOCNZ(int, n_dimensions
);
current_ir_graph = get_const_code_irg();
unk = new_Unknown(mode_Iu);
current_ir_graph = get_const_code_irg();
unk = new_Unknown(mode_Iu);
@@
-1690,7
+1691,7
@@
void set_array_upper_bound_int(ir_type *array, int dimension, int upper_bound) {
int has_array_lower_bound(const ir_type *array, int dimension) {
assert(array && (array->type_op == type_array));
int has_array_lower_bound(const ir_type *array, int dimension) {
assert(array && (array->type_op == type_array));
- return
(get_irn_op(array->attr.aa.lower_bound[dimension]) != op_Unknown
);
+ return
!is_Unknown(array->attr.aa.lower_bound[dimension]
);
}
ir_node *get_array_lower_bound(const ir_type *array, int dimension) {
}
ir_node *get_array_lower_bound(const ir_type *array, int dimension) {
@@
-1702,13
+1703,13
@@
long get_array_lower_bound_int(const ir_type *array, int dimension) {
ir_node *node;
assert(array && (array->type_op == type_array));
node = array->attr.aa.lower_bound[dimension];
ir_node *node;
assert(array && (array->type_op == type_array));
node = array->attr.aa.lower_bound[dimension];
- assert(
get_irn_op(node) == op_Const
);
+ assert(
is_Const(node)
);
return get_tarval_long(get_Const_tarval(node));
}
int has_array_upper_bound(const ir_type *array, int dimension) {
assert(array && (array->type_op == type_array));
return get_tarval_long(get_Const_tarval(node));
}
int has_array_upper_bound(const ir_type *array, int dimension) {
assert(array && (array->type_op == type_array));
- return
get_irn_op(array->attr.aa.upper_bound[dimension]) != op_Unknown
;
+ return
!is_Unknown(array->attr.aa.upper_bound[dimension])
;
}
ir_node *get_array_upper_bound(const ir_type *array, int dimension) {
}
ir_node *get_array_upper_bound(const ir_type *array, int dimension) {
@@
-1720,7
+1721,7
@@
long get_array_upper_bound_int(const ir_type *array, int dimension) {
ir_node *node;
assert(array && (array->type_op == type_array));
node = array->attr.aa.upper_bound[dimension];
ir_node *node;
assert(array && (array->type_op == type_array));
node = array->attr.aa.upper_bound[dimension];
- assert(
get_irn_op(node) == op_Const
);
+ assert(
is_Const(node)
);
return get_tarval_long(get_Const_tarval(node));
}
return get_tarval_long(get_Const_tarval(node));
}
@@
-2075,9
+2076,10
@@
ir_type *clone_frame_type(ir_type *type) {
res = new_type_frame(type->name);
for (i = 0, n = get_class_n_members(type); i < n; ++i) {
res = new_type_frame(type->name);
for (i = 0, n = get_class_n_members(type); i < n; ++i) {
- ir_entity *ent = get_class_member(type, i);
-
- (void)copy_entity_own(ent, res);
+ ir_entity *ent = get_class_member(type, i);
+ ir_entity *nent = copy_entity_own(ent, res);
+ set_entity_link(ent, nent);
+ set_entity_link(nent, ent);
}
return res;
}
}
return res;
}
@@
-2121,6
+2123,7
@@
ir_entity *frame_alloc_area(ir_type *frame_type, int size, unsigned alignment, i
assert(is_frame_type(frame_type));
assert(get_type_state(frame_type) == layout_fixed);
assert(get_type_alignment_bytes(frame_type) > 0);
assert(is_frame_type(frame_type));
assert(get_type_state(frame_type) == layout_fixed);
assert(get_type_alignment_bytes(frame_type) > 0);
+ set_type_state(frame_type, layout_undefined);
if (! a_byte)
a_byte = new_type_primitive(new_id_from_chars("byte", 4), mode_Bu);
if (! a_byte)
a_byte = new_type_primitive(new_id_from_chars("byte", 4), mode_Bu);
@@
-2147,6
+2150,13
@@
ir_entity *frame_alloc_area(ir_type *frame_type, int size, unsigned alignment, i
/* calculate offset and new type size */
offset = 0;
frame_size += size;
/* calculate offset and new type size */
offset = 0;
frame_size += size;
+
+ /* increase size to match alignment... */
+ if (alignment > frame_align) {
+ frame_align = alignment;
+ set_type_alignment_bytes(frame_type, frame_align);
+ frame_size = (frame_size + frame_align - 1) & ~(frame_align - 1);
+ }
} else {
/* calculate offset and new type size */
offset = (frame_size + alignment - 1) & ~(alignment - 1);
} else {
/* calculate offset and new type size */
offset = (frame_size + alignment - 1) & ~(alignment - 1);
@@
-2159,5
+2169,7
@@
ir_entity *frame_alloc_area(ir_type *frame_type, int size, unsigned alignment, i
/* mark this entity as compiler generated */
set_entity_compiler_generated(area, 1);
/* mark this entity as compiler generated */
set_entity_compiler_generated(area, 1);
+
+ set_type_state(frame_type, layout_fixed);
return area;
}
return area;
}