Commit 015ef327 authored by Matthias Braun's avatar Matthias Braun
Browse files

introduce got entry entities

parent 653e5fa7
......@@ -97,6 +97,7 @@ typedef enum keyword_t {
kw_int_mode,
kw_irg,
kw_alias,
kw_gotentry,
kw_label,
kw_method,
kw_modes,
......@@ -218,6 +219,7 @@ static void symtbl_init(void)
INSERTKEYWORD(constirg);
INSERTKEYWORD(entity);
INSERTKEYWORD(float_mode);
INSERTKEYWORD(gotentry);
INSERTKEYWORD(int_mode);
INSERTKEYWORD(irg);
INSERTKEYWORD(label);
......@@ -696,6 +698,7 @@ static void write_entity(write_env_t *env, ir_entity *ent)
fputc('\t', env->file);
switch ((ir_entity_kind)ent->entity_kind) {
case IR_ENTITY_ALIAS: write_symbol(env, "alias"); break;
case IR_ENTITY_GOTENTRY: write_symbol(env, "gotentry"); break;
case IR_ENTITY_NORMAL: write_symbol(env, "entity"); break;
case IR_ENTITY_METHOD: write_symbol(env, "method"); break;
case IR_ENTITY_LABEL: write_symbol(env, "label"); break;
......@@ -742,6 +745,9 @@ static void write_entity(write_env_t *env, ir_entity *ent)
case IR_ENTITY_ALIAS:
write_entity_ref(env, get_entity_alias(ent));
break;
case IR_ENTITY_GOTENTRY:
write_entity_ref(env, ent->attr.got.referenced);
break;
case IR_ENTITY_NORMAL:
if (ent->initializer != NULL) {
write_symbol(env, "initializer");
......@@ -1843,6 +1849,11 @@ static void read_entity(read_env_t *env, ir_entity_kind kind)
entity = new_alias_entity(owner, name, aliased, type);
break;
}
case IR_ENTITY_GOTENTRY: {
ir_entity *referenced = read_entity_ref(env);
entity = new_got_entry_entity(referenced);
break;
}
case IR_ENTITY_NORMAL:
entity = new_entity(owner, name, type);
if (ld_name != NULL)
......@@ -1937,6 +1948,9 @@ static void read_typegraph(read_env_t *env)
case kw_alias:
read_entity(env, IR_ENTITY_ALIAS);
break;
case kw_gotentry:
read_entity(env, IR_ENTITY_GOTENTRY);
break;
case kw_label:
read_entity(env, IR_ENTITY_LABEL);
break;
......
......@@ -115,6 +115,18 @@ ir_entity *new_label_entity(ir_label_t label)
return res;
}
ir_entity *new_got_entry_entity(ir_entity *referenced)
{
ir_type *reftype = get_entity_type(referenced);
ir_type *pointer = new_type_pointer(reftype);
ir_type *global_type = get_glob_type();
ir_entity *res = intern_new_entity(global_type, IR_ENTITY_GOTENTRY, NULL,
pointer);
res->attr.got.referenced = referenced;
hook_new_entity(res);
return res;
}
ir_entity *new_alias_entity(ir_type *owner, ident *name, ir_entity *aliased,
ir_type *type)
{
......@@ -901,6 +913,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_GOTENTRY:
return false;
}
panic("invalid entity kind");
......
......@@ -140,6 +140,10 @@ typedef struct alias_ent_attr {
ir_entity *aliased;
} alias_ent_attr;
typedef struct got_ent_attr {
ir_entity *referenced;
} got_ent_attr;
typedef enum ir_entity_kind {
IR_ENTITY_ALIAS,
IR_ENTITY_COMPOUND_MEMBER,
......@@ -148,6 +152,7 @@ typedef enum ir_entity_kind {
IR_ENTITY_NORMAL,
IR_ENTITY_PARAMETER,
IR_ENTITY_UNKNOWN,
IR_ENTITY_GOTENTRY,
} ir_entity_kind;
/**
......@@ -201,6 +206,8 @@ struct ir_entity {
parameter_ent_attr parameter;
/** alias attributes */
alias_ent_attr alias;
/** got entry attributes */
got_ent_attr got;
} attr; /**< type specific attributes */
};
......@@ -215,6 +222,12 @@ void ir_finish_entity(ir_prog *irp);
*/
ir_entity *new_label_entity(ir_label_t label);
/**
* Create an entity representing an entry in the global offset table used for
* position independent code (PIC) code.
*/
ir_entity *new_got_entry_entity(ir_entity *reference);
void set_entity_irg(ir_entity *ent, ir_graph *irg);
/* ----------------------- inline functions ------------------------ */
......
......@@ -343,6 +343,7 @@ int check_entity(const ir_entity *entity)
}
break;
case IR_ENTITY_UNKNOWN:
case IR_ENTITY_GOTENTRY:
break;
}
......
......@@ -125,6 +125,7 @@ static void do_type_walk(type_or_ent tore,
case IR_ENTITY_PARAMETER:
case IR_ENTITY_LABEL:
case IR_ENTITY_COMPOUND_MEMBER:
case IR_ENTITY_GOTENTRY:
break;
}
break;
......
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