Commit f6330956 authored by Christoph Mallon's avatar Christoph Mallon
Browse files

Remove 'tf_variable_size'.

Just check that the size of the array is 0 instead.
parent cdd69f9f
...@@ -1351,19 +1351,6 @@ FIRM_API unsigned get_array_size(const ir_type *array); ...@@ -1351,19 +1351,6 @@ FIRM_API unsigned get_array_size(const ir_type *array);
/** Returns the array element type. */ /** Returns the array element type. */
FIRM_API ir_type *get_array_element_type(const ir_type *array); FIRM_API ir_type *get_array_element_type(const ir_type *array);
/**
* Sets the array variable size flag.
* If this flag is set then no upper/lower bounds need to be set and
* get_type_size() returns -1
*/
FIRM_API void set_array_variable_size(ir_type *array, int variable_size_flag);
/**
* Returns the array variable size flag.
* @see set_array_variable_size()
*/
FIRM_API int is_array_variable_size(const ir_type *array);
/** Returns true if a type is an array type. */ /** Returns true if a type is an array type. */
FIRM_API int is_Array_type(const ir_type *array); FIRM_API int is_Array_type(const ir_type *array);
...@@ -1498,20 +1485,6 @@ FIRM_API size_t get_compound_member_index(ir_type const *tp, ...@@ -1498,20 +1485,6 @@ FIRM_API size_t get_compound_member_index(ir_type const *tp,
/** Remove a member from a compound type. */ /** Remove a member from a compound type. */
FIRM_API void remove_compound_member(ir_type *compound, ir_entity *entity); FIRM_API void remove_compound_member(ir_type *compound, ir_entity *entity);
/**
* Sets the variable size flag of a compound type.
* The last member of a variable size compound type may be an array type
* without explicit size. So the get_type_size() of a variable size compound
* type only returns a minimum size for the type (the size if the last members
* size is 0)
*/
FIRM_API void set_compound_variable_size(ir_type *compound, int variable_size);
/**
* Returns the variable size flag. @see set_compound_variable_size()
*/
FIRM_API int is_compound_variable_size(const ir_type *compound);
/** /**
* layout members of a struct/union or class type in a default way. * layout members of a struct/union or class type in a default way.
*/ */
......
...@@ -873,7 +873,7 @@ static size_t get_initializer_size(const ir_initializer_t *initializer, ...@@ -873,7 +873,7 @@ static size_t get_initializer_size(const ir_initializer_t *initializer,
return get_type_size(type); return get_type_size(type);
case IR_INITIALIZER_COMPOUND: case IR_INITIALIZER_COMPOUND:
if (is_Array_type(type)) { if (is_Array_type(type)) {
if (is_array_variable_size(type)) { if (get_array_size(type) == 0) {
ir_type *element_type = get_array_element_type(type); ir_type *element_type = get_array_element_type(type);
unsigned element_size = get_type_size(element_type); unsigned element_size = get_type_size(element_type);
unsigned element_align = get_type_alignment(element_type); unsigned element_align = get_type_alignment(element_type);
...@@ -888,15 +888,15 @@ static size_t get_initializer_size(const ir_initializer_t *initializer, ...@@ -888,15 +888,15 @@ static size_t get_initializer_size(const ir_initializer_t *initializer,
} else { } else {
assert(is_compound_type(type)); assert(is_compound_type(type));
size_t size = get_type_size(type); size_t size = get_type_size(type);
if (is_compound_variable_size(type)) { /* Last initializer may be an array of flexible size. */
/* last initializer has to be an array of variable size */ size_t const n = get_initializer_compound_n_entries(initializer);
size_t l = get_initializer_compound_n_entries(initializer) - 1; if (n != 0) {
const ir_initializer_t *last ir_entity *const last_ent = get_compound_member(type, n - 1);
= get_initializer_compound_value(initializer, l); ir_type *const last_type = get_entity_type(last_ent);
const ir_entity *last_ent = get_compound_member(type, l); if (is_Array_type(last_type) && get_array_size(last_type) == 0) {
ir_type *last_type = get_entity_type(last_ent); ir_initializer_t const *const last = get_initializer_compound_value(initializer, n - 1);
assert(is_array_variable_size(last_type)); size += get_initializer_size(last, last_type);
size += get_initializer_size(last, last_type); }
} }
return size; return size;
} }
......
...@@ -782,19 +782,6 @@ ir_type *get_array_element_type(const ir_type *array) ...@@ -782,19 +782,6 @@ ir_type *get_array_element_type(const ir_type *array)
return array->attr.array.element_type; return array->attr.array.element_type;
} }
int is_array_variable_size(const ir_type *array)
{
assert(is_Array_type(array));
return (array->flags & tf_variable_size) != 0;
}
void set_array_variable_size(ir_type *array, int flag)
{
assert(is_Array_type(array));
array->flags = (array->flags & ~tf_variable_size)
| (flag != 0 ? tf_variable_size : 0);
}
int (is_Array_type)(const ir_type *array) int (is_Array_type)(const ir_type *array)
{ {
return is_array_type_(array); return is_array_type_(array);
...@@ -887,19 +874,6 @@ size_t get_compound_member_index(ir_type const *const type, ...@@ -887,19 +874,6 @@ size_t get_compound_member_index(ir_type const *const type,
return INVALID_MEMBER_INDEX; return INVALID_MEMBER_INDEX;
} }
void set_compound_variable_size(ir_type *tp, int variable_size_flag)
{
assert(is_compound_type(tp));
tp->flags = (tp->flags & ~tf_variable_size)
| (variable_size_flag != 0 ? tf_variable_size : 0);
}
int is_compound_variable_size(const ir_type *tp)
{
assert(is_compound_type(tp));
return (tp->flags & tf_variable_size) != 0;
}
int is_compound_type(const ir_type *tp) int is_compound_type(const ir_type *tp)
{ {
assert(tp->kind == k_type); assert(tp->kind == k_type);
...@@ -999,7 +973,6 @@ void default_layout_compound_type(ir_type *type) ...@@ -999,7 +973,6 @@ void default_layout_compound_type(ir_type *type)
{ {
unsigned size = 0; unsigned size = 0;
unsigned align_all = 1; 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) { for (size_t i = 0, n = get_compound_n_members(type); i < n; ++i) {
ir_entity *entity = get_compound_member(type, i); ir_entity *entity = get_compound_member(type, i);
ir_type *entity_type = get_entity_type(entity); ir_type *entity_type = get_entity_type(entity);
...@@ -1011,11 +984,11 @@ void default_layout_compound_type(ir_type *type) ...@@ -1011,11 +984,11 @@ void default_layout_compound_type(ir_type *type)
} }
unsigned entity_size; unsigned entity_size;
if (i+1 < n || !var_size) { if (i + 1 == n && is_Array_type(entity_type) && get_array_size(entity_type) == 0) {
entity_size = 0;
} else {
assert(get_type_state(entity_type) == layout_fixed); assert(get_type_state(entity_type) == layout_fixed);
entity_size = get_type_size(entity_type); entity_size = get_type_size(entity_type);
} else {
entity_size = 0;
} }
unsigned const align = get_type_alignment(entity_type); unsigned const align = get_type_alignment(entity_type);
......
...@@ -94,8 +94,7 @@ typedef enum type_flags { ...@@ -94,8 +94,7 @@ typedef enum type_flags {
tf_frame_type = 1U << 3, /**< Set if this is a frame type. */ tf_frame_type = 1U << 3, /**< Set if this is a frame type. */
tf_info = 1U << 4, /**< infos (for example constructor, destructor pointers), all members are anonymous */ tf_info = 1U << 4, /**< infos (for example constructor, destructor pointers), all members are anonymous */
tf_variable_size = 1U << 5, /**< compound or array type may have variable size last element */ tf_lowered_dw = 1U << 5, /**< hack to identify lowered doubleword params */
tf_lowered_dw = 1U << 6, /**< hack to identify lowered doubleword params */
} type_flags; } type_flags;
ENUM_BITSET(type_flags) ENUM_BITSET(type_flags)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment