Commit f2b6fca4 authored by Matthias Braun's avatar Matthias Braun
Browse files

entity: Introduce spillslot entities

They are not used yet as we need an adapted layout algorithm for them.
parent d4846b5b
......@@ -95,6 +95,9 @@ static void print_entity_name(char *buffer, size_t buffer_size,
case IR_ENTITY_LABEL:
snprintf(buffer, buffer_size, "%slabel", add);
return;
case IR_ENTITY_SPILLSLOT:
snprintf(buffer, buffer_size, "%sspillslot", add);
return;
default:
snprintf(buffer, buffer_size, "%s%s", add, get_entity_ld_name(entity));
return;
......
......@@ -678,6 +678,8 @@ static void write_entity(write_env_t *env, ir_entity *ent)
write_symbol(env, "unknown");
write_long(env, get_entity_nr(ent));
return;
case IR_ENTITY_SPILLSLOT:
panic("Unexpected entity %+F", ent); // Should only exist in backend
}
write_long(env, get_entity_nr(ent));
......@@ -747,6 +749,7 @@ static void write_entity(write_env_t *env, ir_entity *ent)
break;
case IR_ENTITY_UNKNOWN:
case IR_ENTITY_LABEL:
case IR_ENTITY_SPILLSLOT:
break;
}
......@@ -1805,8 +1808,9 @@ static void read_entity(read_env_t *env, ir_entity_kind kind)
entity = new_label_entity(nr);
break;
}
case IR_ENTITY_SPILLSLOT:
case IR_ENTITY_UNKNOWN:
panic("read_entity with IR_ENTITY_UNKNOWN");
panic("read_entity with unexpected kind");
}
set_entity_volatility(entity, volatility);
......
......@@ -118,6 +118,19 @@ ir_entity *new_label_entity(ir_label_t label)
return res;
}
ir_entity *new_spillslot(ir_type *const frame, unsigned const size,
unsigned const alignment)
{
assert(is_frame_type(frame));
ir_type *const type = get_unknown_type();
ir_entity *const res = intern_new_entity(frame, IR_ENTITY_SPILLSLOT, NULL,
type, ir_visibility_private);
set_entity_alignment(res, alignment);
res->attr.spillslot.base.offset = INVALID_OFFSET;
res->attr.spillslot.size = size;
return res;
}
ir_entity *new_alias_entity(ir_type *owner, ident *name, ir_entity *aliased,
ir_type *type, ir_visibility visibility)
{
......@@ -295,6 +308,8 @@ void set_entity_type(ir_entity *ent, ir_type *type)
case IR_ENTITY_UNKNOWN:
case IR_ENTITY_COMPOUND_MEMBER:
break;
case IR_ENTITY_SPILLSLOT:
panic("Cannot set type of this entity");
}
ent->type = type;
}
......@@ -888,6 +903,7 @@ int entity_has_definition(const ir_entity *entity)
case IR_ENTITY_PARAMETER:
case IR_ENTITY_UNKNOWN:
case IR_ENTITY_COMPOUND_MEMBER:
case IR_ENTITY_SPILLSLOT:
return false;
}
panic("invalid entity kind");
......
......@@ -154,6 +154,11 @@ typedef struct alias_ent_attr {
ir_entity *aliased;
} alias_ent_attr;
typedef struct spillslot_ent_attr {
compound_member_ent_attr base;
unsigned size;
} spillslot_ent_attr;
typedef enum ir_entity_kind {
IR_ENTITY_ALIAS,
IR_ENTITY_COMPOUND_MEMBER,
......@@ -161,6 +166,7 @@ typedef enum ir_entity_kind {
IR_ENTITY_METHOD,
IR_ENTITY_NORMAL,
IR_ENTITY_PARAMETER,
IR_ENTITY_SPILLSLOT,
IR_ENTITY_UNKNOWN,
} ir_entity_kind;
......@@ -208,6 +214,8 @@ struct ir_entity {
alias_ent_attr alias;
/** properties shared by global entities */
global_ent_attr global;
/** properties of spill slot entities */
spillslot_ent_attr spillslot;
} attr; /**< type specific attributes */
};
......@@ -220,6 +228,8 @@ void ir_init_entity(ir_prog *irp);
*/
ir_entity *new_label_entity(ir_label_t label);
ir_entity *new_spillslot(ir_type *frame, unsigned size, unsigned alignment);
void set_entity_irg(ir_entity *ent, ir_graph *irg);
/* ----------------------- inline functions ------------------------ */
......@@ -274,6 +284,7 @@ static inline const char *_get_entity_ld_name(const ir_entity *ent)
static inline ir_type *_get_entity_type(const ir_entity *ent)
{
assert(ent->firm_tag == k_entity);
assert(ent->kind != IR_ENTITY_SPILLSLOT);
return ent->type;
}
......@@ -334,7 +345,8 @@ static inline void _set_entity_usage(ir_entity *ent, ir_entity_usage state)
static inline bool is_entity_compound_member(const ir_entity *entity)
{
return entity->kind == IR_ENTITY_COMPOUND_MEMBER
|| entity->kind == IR_ENTITY_PARAMETER;
|| entity->kind == IR_ENTITY_PARAMETER
|| entity->kind == IR_ENTITY_SPILLSLOT;
}
static inline ir_initializer_t *_get_entity_initializer(ir_entity const *const ent)
......@@ -470,6 +482,7 @@ static inline bool is_global_entity(ir_entity const *const entity)
case IR_ENTITY_LABEL:
case IR_ENTITY_PARAMETER:
case IR_ENTITY_UNKNOWN:
case IR_ENTITY_SPILLSLOT:
return false;
}
panic("Invalid entity");
......
......@@ -330,6 +330,17 @@ int check_entity(const ir_entity *entity)
case IR_ENTITY_UNKNOWN:
break;
case IR_ENTITY_SPILLSLOT:
if (is_frame_type(owner)) {
report_error("spillslot %+F must be on frame type", entity);
fine = false;
}
break;
}
if (is_frame_type(owner) && entity_has_definition(entity)) {
report_error("entity %+F on frame %+F has initialized", entity, owner);
fine = false;
}
return fine;
......
......@@ -285,7 +285,7 @@ void set_type_state(ir_type *tp, ir_type_state state)
for (size_t i = 0, n_mem = get_compound_n_members(tp);
i < n_mem; i++) {
ir_entity *entity = get_compound_member(tp, i);
if (is_Method_type(get_entity_type(entity)))
if (is_method_entity(entity))
continue;
assert(get_entity_offset(entity) != INVALID_OFFSET);
}
......@@ -991,7 +991,6 @@ void add_compound_member(ir_type *type, ir_entity *entity)
{
assert(is_compound_type(type));
/* try to detect double-add */
assert(get_entity_type(entity) != type);
ARR_APP1(ir_entity *, type->attr.compound.members, entity);
/* Add segment members to globals map. */
if (is_segment_type(type) && !(type->flags & tf_info)
......
......@@ -112,6 +112,7 @@ static void do_type_walk(ir_type *const tp, ir_entity *const ent,
case IR_ENTITY_PARAMETER:
case IR_ENTITY_LABEL:
case IR_ENTITY_COMPOUND_MEMBER:
case IR_ENTITY_SPILLSLOT:
break;
}
} else {
......
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