summaryrefslogtreecommitdiffhomepage
path: root/ir/tr
diff options
context:
space:
mode:
authorChristoph Mallon <christoph.mallon@gmx.de>2016-05-17 13:38:46 +0200
committerChristoph Mallon <christoph.mallon@gmx.de>2016-05-17 14:09:43 +0200
commit9d78d6c9ef7069eb3f179ea6e43e32a05d15201b (patch)
treed13f07b1edc236f48968827001b1ee06c87c340c /ir/tr
parent8572a6c55c6dc699a3162316d8256112b3780ab4 (diff)
tr: Simplify array types.
The length is now set on creation. Neither length nor element type can be changed later on.
Diffstat (limited to 'ir/tr')
-rw-r--r--ir/tr/type.c45
-rw-r--r--ir/tr/type_t.h2
2 files changed, 9 insertions, 38 deletions
diff --git a/ir/tr/type.c b/ir/tr/type.c
index f3c5f669..fde8452 100644
--- a/ir/tr/type.c
+++ b/ir/tr/type.c
@@ -772,58 +772,29 @@ ident *get_segment_ident(ir_type const *type)
return type->name;
}
-ir_type *new_type_array(ir_type *element_type)
+ir_type *new_type_array(ir_type *const element_type, unsigned const n_elements)
{
assert(!is_Method_type(element_type));
- ir_type *res = new_type(tpo_array, sizeof(array_attr), NULL);
+ ir_type *const res = new_type(tpo_array, sizeof(array_attr), NULL);
res->attr.array.element_type = element_type;
- res->attr.array.size = new_r_Unknown(get_const_code_irg(), mode_Iu);
+ res->attr.array.size = n_elements;
set_type_alignment(res, get_type_alignment(element_type));
+ if (n_elements != 0) {
+ set_type_size(res, n_elements * get_type_size(element_type));
+ set_type_state(res, layout_fixed);
+ }
hook_new_type(res);
return res;
}
-void set_array_size(ir_type *array, ir_node *size)
-{
- assert(is_Array_type(array));
- assert(size != NULL);
- array->attr.array.size = size;
-}
-
-void set_array_size_int(ir_type *array, unsigned size)
-{
- ir_graph *irg = get_const_code_irg();
- set_array_size(array, new_r_Const_long(irg, mode_Iu, size));
-}
-
-int has_array_size(const ir_type *array)
-{
- assert(is_Array_type(array));
- return !is_Unknown(array->attr.array.size);
-}
-
-ir_node *get_array_size(const ir_type *array)
+unsigned get_array_size(const ir_type *array)
{
assert(is_Array_type(array));
return array->attr.array.size;
}
-unsigned get_array_size_int(const ir_type *array)
-{
- ir_node *const node = get_array_size(array);
- return get_Const_long(node);
-}
-
-void set_array_element_type(ir_type *array, ir_type *tp)
-{
- assert(is_Array_type(array));
- assert(!is_Method_type(tp));
- array->attr.array.element_type = tp;
- set_type_alignment(array, get_type_alignment(tp));
-}
-
ir_type *get_array_element_type(const ir_type *array)
{
assert(is_Array_type(array));
diff --git a/ir/tr/type_t.h b/ir/tr/type_t.h
index 4725634..e458120 100644
--- a/ir/tr/type_t.h
+++ b/ir/tr/type_t.h
@@ -76,7 +76,7 @@ typedef struct {
/** Array type attributes. */
typedef struct {
- ir_node *size; /**< number of elements in the array. */
+ unsigned size; /**< number of elements in the array. */
ir_type *element_type; /**< The type of the array elements. */
} array_attr;