fehler76: assertion when converting float constant to int
[libfirm] / ir / tr / entity.c
index 4e8ef8b..3b9f828 100644 (file)
 
 #include "callgraph.h"  /* for dumping debug output */
 
-/*******************************************************************/
+/**
+ * An interval initializer.
+ */
+typedef struct interval_initializer interval_initializer;
+
+/**
+ * A value initializer.
+ */
+typedef struct value_initializer value_initializer;
+
+struct interval_initializer {
+       int                  first_index; /**< The first index of the initialized interval. */
+       int                  last_index;  /**< The last index of the initialized interval. */
+       interval_initializer *next;       /**< Points to the next interval initializer. */
+};
+
+struct value_initializer {
+       ir_entity *ent;           /**< The initialized entity. */
+       value_initializer *next;  /**< Points to the next value initializer. */
+};
+
+typedef union initializer {
+       ir_node              *value;     /**< The value of the initializer. */
+       ir_node              **values;   /**< The values of an interval. */
+       value_initializer    *val_init;  /**< Points the the head of the next value initializers. */
+       interval_initializer *int_init;  /**< Points to the head of the next value initializers. */
+} initializer;
+
+/*-----------------------------------------------------------------*/
 /** general                                                       **/
-/*******************************************************************/
+/*-----------------------------------------------------------------*/
 
 ir_entity *unknown_entity = NULL;
 
 ir_entity *get_unknown_entity(void) { return unknown_entity; }
 
+/** The name of the unknown entity. */
 #define UNKNOWN_ENTITY_NAME "unknown_entity"
 
 /*-----------------------------------------------------------------*/
@@ -114,6 +143,7 @@ new_rd_entity(dbg_info *db, ir_type *owner, ident *name, ir_type *type)
        res->allocation           = allocation_automatic;
        res->visibility           = visibility_local;
        res->volatility           = volatility_non_volatile;
+       res->align                = align_is_aligned;
        res->stickyness           = stickyness_unsticky;
        res->peculiarity          = peculiarity_existent;
        res->address_taken        = ir_address_taken_unknown;
@@ -202,7 +232,7 @@ static void free_entity_attrs(ir_entity *ent) {
        }
        if (is_compound_entity(ent)) {
                if (ent->attr.cmpd_attr.val_paths) {
-                       for (i = 0; i < get_compound_ent_n_values(ent); i++)
+                       for (i = get_compound_ent_n_values(ent) - 1; i >= 0; --i)
                                if (ent->attr.cmpd_attr.val_paths[i]) {
                                        /* free_compound_graph_path(ent->attr.cmpd_attr.val_paths[i]) ;  * @@@ warum nich? */
                                        /* Geht nich: wird mehrfach verwendet!!! ==> mehrfach frei gegeben. */
@@ -452,7 +482,7 @@ void
        _set_entity_volatility(ent, vol);
 }  /* set_entity_volatility */
 
-/* return the name of the volatility */
+/* Return the name of the volatility. */
 const char *get_volatility_name(ir_volatility var)
 {
 #define X(a)    case a: return #a
@@ -464,6 +494,28 @@ const char *get_volatility_name(ir_volatility var)
 #undef X
 }  /* get_volatility_name */
 
+ir_align
+(get_entity_align)(const ir_entity *ent) {
+       return _get_entity_align(ent);
+}  /* get_entity_align */
+
+void
+(set_entity_align)(ir_entity *ent, ir_align a) {
+       _set_entity_align(ent, a);
+}  /* set_entity_align */
+
+/* Return the name of the alignment. */
+const char *get_align_name(ir_align a)
+{
+#define X(a)    case a: return #a
+       switch (a) {
+       X(align_non_aligned);
+       X(align_is_aligned);
+       default: return "BAD VALUE";
+       }
+#undef X
+}  /* get_align_name */
+
 ir_peculiarity
 (get_entity_peculiarity)(const ir_entity *ent) {
        return _get_entity_peculiarity(ent);
@@ -803,7 +855,8 @@ static int equal_paths(compound_graph_path *path1, int *visited_indices, compoun
  * Returns the position of a value with the given path.
  * The path must contain array indices for all array element entities.
  *
- * @todo  This implementation is very low and should be replaced when the new tree oriented
+ * @todo  This implementation is very slow (O(number of initializers^2) and should
+ *        be replaced when the new tree oriented
  *        value representation is finally implemented.
  */
 static int get_compound_ent_pos_by_path(ir_entity *ent, compound_graph_path *path) {
@@ -1281,6 +1334,14 @@ ir_type *(get_entity_repr_class)(const ir_entity *ent) {
        return _get_entity_repr_class(ent);
 }  /* get_entity_repr_class */
 
+dbg_info *(get_entity_dbg_info)(const ir_entity *ent) {
+       return _get_entity_dbg_info(ent);
+}  /* get_entity_dbg_info */
+
+void (set_entity_dbg_info)(ir_entity *ent, dbg_info *db) {
+       _set_entity_dbg_info(ent, db);
+}  /* set_entity_dbg_info */
+
 /* Initialize entity module. */
 void firm_init_entity(void)
 {