summaryrefslogtreecommitdiffhomepage
path: root/ir/tr
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2016-02-14 10:51:42 +0100
committerMatthias Braun <matze@braunis.de>2016-02-14 23:59:10 +0100
commitc6eb86b9f3b32a8f72f42848a7113d73448c6c6b (patch)
tree165221e4d536270d04ca9cec42c68bc415f4feeb /ir/tr
parente9be161ef498eaf97699f59d880f2413f557b28f (diff)
entity: Introduce INVALID_OFFSET constant
The soon to be introduced spillslot entities can be at negative offset, so the previously used -1 as convention for invalid offsets is not a good idea anymore.
Diffstat (limited to 'ir/tr')
-rw-r--r--ir/tr/entity.c4
-rw-r--r--ir/tr/entity_t.h3
-rw-r--r--ir/tr/type.c2
3 files changed, 6 insertions, 3 deletions
diff --git a/ir/tr/entity.c b/ir/tr/entity.c
index 07092f4..6ed2cea 100644
--- a/ir/tr/entity.c
+++ b/ir/tr/entity.c
@@ -73,7 +73,7 @@ static ir_entity *new_entity_vis(ir_type *owner, ident *name, ir_type *type,
} else if (is_compound_type(owner) && !is_segment_type(owner)) {
res = intern_new_entity(owner, IR_ENTITY_COMPOUND_MEMBER, name, type,
vis);
- res->attr.compound_member.offset = -1;
+ res->attr.compound_member.offset = INVALID_OFFSET;
} else {
res = intern_new_entity(owner, IR_ENTITY_NORMAL, name, type, vis);
res->attr.global.jit_addr = (void*)-1;
@@ -103,7 +103,7 @@ ir_entity *new_parameter_entity(ir_type *owner, size_t pos, ir_type *type)
ident *name = new_id_fmt("parameter.%lu", (unsigned long)pos);
ir_entity *res = intern_new_entity(owner, IR_ENTITY_PARAMETER, name, type,
ir_visibility_private);
- res->attr.compound_member.offset = -1;
+ res->attr.compound_member.offset = INVALID_OFFSET;
res->attr.parameter.number = pos;
hook_new_entity(res);
return res;
diff --git a/ir/tr/entity_t.h b/ir/tr/entity_t.h
index 03907f1..c18e966 100644
--- a/ir/tr/entity_t.h
+++ b/ir/tr/entity_t.h
@@ -14,6 +14,7 @@
#include <assert.h>
#include <stdbool.h>
#include <stdint.h>
+#include <limits.h>
#include "compiler.h"
#include "ident.h"
@@ -58,6 +59,8 @@
#define get_entity_dbg_info(ent) _get_entity_dbg_info(ent)
#define set_entity_dbg_info(ent, db) _set_entity_dbg_info(ent, db)
+#define INVALID_OFFSET INT_MAX
+
typedef struct ir_initializer_base_t {
ir_initializer_kind_t kind;
} ir_initializer_base_t;
diff --git a/ir/tr/type.c b/ir/tr/type.c
index a5a9805..4a48141 100644
--- a/ir/tr/type.c
+++ b/ir/tr/type.c
@@ -287,7 +287,7 @@ void set_type_state(ir_type *tp, ir_type_state state)
ir_entity *entity = get_compound_member(tp, i);
if (is_Method_type(get_entity_type(entity)))
continue;
- assert(get_entity_offset(entity) > -1);
+ assert(get_entity_offset(entity) != INVALID_OFFSET);
}
}
#endif