From 033fb7438950afb59a282afbcb630100781b22e2 Mon Sep 17 00:00:00 2001 From: Moritz Kroll Date: Tue, 17 Feb 2009 22:33:29 +0000 Subject: [PATCH] Added has_entity_initializer() and get_initializer_kind_name() [r25517] --- include/libfirm/typerep.h | 6 ++++++ ir/tr/entity.c | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/include/libfirm/typerep.h b/include/libfirm/typerep.h index 5bab02a6b..ddb31708a 100644 --- a/include/libfirm/typerep.h +++ b/include/libfirm/typerep.h @@ -444,6 +444,9 @@ typedef enum ir_initializer_kind_t { /** returns kind of an initializer */ ir_initializer_kind_t get_initializer_kind(const ir_initializer_t *initializer); +/** Return the name of the initializer kind. */ +const char *get_initializer_kind_name(ir_initializer_kind_t ini); + /** * returns the null initializer (there's only one instance of it in a program ) */ @@ -548,6 +551,9 @@ void set_compound_ent_value(ir_entity *ent, ir_node *val, ir_entity *member, int /** Sets the new style initializers of an entity. */ void set_entity_initializer(ir_entity *entity, ir_initializer_t *initializer); +/** Returns true, if an entity has new style initializers. */ +int has_entity_initializer(const ir_entity *entity); + /** Return the new style initializers of an entity. */ ir_initializer_t *get_entity_initializer(const ir_entity *entity); diff --git a/ir/tr/entity.c b/ir/tr/entity.c index a6bf0abe9..1cc8b6776 100644 --- a/ir/tr/entity.c +++ b/ir/tr/entity.c @@ -679,6 +679,20 @@ ir_node *copy_const_value(dbg_info *dbg, ir_node *n) { return nn; } /* copy_const_value */ +/** Return the name of the initializer kind. */ +const char *get_initializer_kind_name(ir_initializer_kind_t ini) +{ +#define X(a) case a: return #a + switch (ini) { + X(IR_INITIALIZER_CONST); + X(IR_INITIALIZER_TARVAL); + X(IR_INITIALIZER_NULL); + X(IR_INITIALIZER_COMPOUND); + default: return "BAD VALUE"; + } +#undef X +} + static ir_initializer_t null_initializer = { IR_INITIALIZER_NULL }; ir_initializer_t *get_initializer_null(void) @@ -783,6 +797,11 @@ void set_entity_initializer(ir_entity *entity, ir_initializer_t *initializer) check_entity_initializer(entity); } +int has_entity_initializer(const ir_entity *entity) +{ + return entity->has_initializer; +} + ir_initializer_t *get_entity_initializer(const ir_entity *entity) { assert(entity->has_initializer); -- 2.20.1