Added has_entity_initializer() and get_initializer_kind_name()
authorMoritz Kroll <Moritz.Kroll@gmx.de>
Tue, 17 Feb 2009 22:33:29 +0000 (22:33 +0000)
committerMoritz Kroll <Moritz.Kroll@gmx.de>
Tue, 17 Feb 2009 22:33:29 +0000 (22:33 +0000)
[r25517]

include/libfirm/typerep.h
ir/tr/entity.c

index 5bab02a..ddb3170 100644 (file)
@@ -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);
 
index a6bf0ab..1cc8b67 100644 (file)
@@ -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);