summaryrefslogtreecommitdiffhomepage
path: root/ir/tr
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2015-12-14 06:56:56 +0100
committerMatthias Braun <matze@braunis.de>2015-12-14 07:23:29 +0100
commit859487f06ccef35726df01c0b0ac992feafb8da0 (patch)
tree9a0f53626bc92f2cf123511ae27968fb3760878d /ir/tr
parent373423a434146e5475454db33adb36bc181bae38 (diff)
Introduce globals map
The map maps global symbols to the respective entities in the segment types. This should avoid hacks in some frontends, avoids a sepcial map for compilerlib entities and ensures that frontend and compilerlib entities are in sync.
Diffstat (limited to 'ir/tr')
-rw-r--r--ir/tr/entity.c16
-rw-r--r--ir/tr/entity_t.h7
-rw-r--r--ir/tr/type.c12
-rw-r--r--ir/tr/type_t.h6
4 files changed, 28 insertions, 13 deletions
diff --git a/ir/tr/entity.c b/ir/tr/entity.c
index 0e6f721..b4a8423 100644
--- a/ir/tr/entity.c
+++ b/ir/tr/entity.c
@@ -252,9 +252,19 @@ ident *(get_entity_ld_ident)(const ir_entity *ent)
return _get_entity_ld_ident(ent);
}
-void (set_entity_ld_ident)(ir_entity *ent, ident *ld_ident)
-{
- _set_entity_ld_ident(ent, ld_ident);
+void set_entity_ld_ident(ir_entity *const ent, ident *const ld_ident)
+{
+ ident *old_ident = get_entity_ld_ident(ent);
+ ent->ld_name = ld_ident;
+ if (old_ident != ld_ident) {
+ ir_type *owner = get_entity_owner(ent);
+ if (is_segment_type(owner) && !(owner->flags & tf_info)) {
+ pmap *globals = irp->globals;
+ pmap_insert(globals, old_ident, NULL);
+ assert(!pmap_contains(globals, ld_ident));
+ pmap_insert(globals, ld_ident, ent);
+ }
+ }
}
const char *(get_entity_ld_name)(const ir_entity *ent)
diff --git a/ir/tr/entity_t.h b/ir/tr/entity_t.h
index 74427e9..d16fc24 100644
--- a/ir/tr/entity_t.h
+++ b/ir/tr/entity_t.h
@@ -25,7 +25,6 @@
#define set_entity_ident(ent, id) _set_entity_ident(ent, id)
#define get_entity_owner(ent) _get_entity_owner(ent)
#define get_entity_ld_ident(ent) _get_entity_ld_ident(ent)
-#define set_entity_ld_ident(ent, ld_ident) _set_entity_ld_ident(ent, ld_ident)
#define get_entity_ld_name(ent) _get_entity_ld_name(ent)
#define get_entity_type(ent) _get_entity_type(ent)
#define get_entity_linkage(ent) _get_entity_linkage(ent)
@@ -259,12 +258,6 @@ static inline ident *_get_entity_ld_ident(const ir_entity *ent)
return ent->name;
}
-static inline void _set_entity_ld_ident(ir_entity *ent, ident *ld_ident)
-{
- assert(ent->kind == k_entity);
- ent->ld_name = ld_ident;
-}
-
static inline const char *_get_entity_ld_name(const ir_entity *ent)
{
assert(ent->kind == k_entity);
diff --git a/ir/tr/type.c b/ir/tr/type.c
index 8a72f90..fda0b07 100644
--- a/ir/tr/type.c
+++ b/ir/tr/type.c
@@ -976,6 +976,10 @@ void remove_compound_member(ir_type *type, ir_entity *member)
for (; i < n - 1; ++i)
type->attr.ca.members[i] = type->attr.ca.members[i+1];
ARR_SETLEN(ir_entity*, type->attr.ca.members, n-1);
+ if (is_segment_type(type) && !(type->flags & tf_info)) {
+ pmap *globals = irp->globals;
+ pmap_insert(globals, get_entity_ld_ident(member), NULL);
+ }
break;
}
}
@@ -987,6 +991,14 @@ void add_compound_member(ir_type *type, ir_entity *entity)
/* try to detect double-add */
assert(get_entity_type(entity) != type);
ARR_APP1(ir_entity *, type->attr.ca.members, entity);
+ /* Add segment members to globals map. */
+ if (is_segment_type(type) && !(type->flags & tf_info)) {
+ ident *id = get_entity_ld_ident(entity);
+ pmap *globals = irp->globals;
+ /* Globals must have unique names. */
+ assert(!pmap_contains(globals, id));
+ pmap_insert(globals, id, entity);
+ }
}
int is_code_type(ir_type const *const type)
diff --git a/ir/tr/type_t.h b/ir/tr/type_t.h
index af5ae54..7922dc0 100644
--- a/ir/tr/type_t.h
+++ b/ir/tr/type_t.h
@@ -13,10 +13,10 @@
#define FIRM_TR_TYPE_T_H
#include <stdbool.h>
-#include "typerep.h"
-#include "firm_common.h"
#include "array.h"
+#include "firm_common.h"
+#include "typerep.h"
#define get_master_type_visited() get_master_type_visited_()
#define get_type_link(tp) get_type_link_(tp)
@@ -104,7 +104,7 @@ typedef enum type_flags {
tf_frame_type = 1U << 3, /**< Set if this is a frame type. */
tf_global_type = 1U << 4, /**< Set only for the global type */
tf_tls_type = 1U << 5, /**< Set only for the tls type */
- tf_info = 1U << 6, /**< infos (for example constructor, destructor pointers) */
+ tf_info = 1U << 6, /**< infos (for example constructor, destructor pointers), all members are anonymous */
tf_variable_size = 1U << 7, /**< compound or array type may have variable size last element */
tf_lowered_dw = 1U << 8, /**< hack to identify lowered doubleword params */
} type_flags;