add lower_const_code, make begnuas skip Id nodes
authorMatthias Braun <matze@braunis.de>
Sat, 16 Feb 2008 15:32:49 +0000 (15:32 +0000)
committerMatthias Braun <matze@braunis.de>
Sat, 16 Feb 2008 15:32:49 +0000 (15:32 +0000)
[r17751]

include/libfirm/lowering.h
ir/be/begnuas.c
ir/ir/irgwalk.c
ir/lower/lower_hl.c

index 0def121..d6aadcb 100644 (file)
@@ -208,6 +208,11 @@ void lower_highlevel_graph(ir_graph *irg, int lower_bitfields);
  */
 void lower_highlevel(int lower_bitfields);
 
+/**
+ * does the same as lower_highlevel for all nodes on the const code irg
+ */
+void lower_const_code(void);
+
 typedef struct lower_mode_b_config_t {
        /* mode that is used to transport 0/1 values */
        ir_mode *lowered_mode;
index e8f3760..b0bf564 100644 (file)
@@ -259,6 +259,8 @@ static void do_dump_atomic_init(be_gas_decl_env_t *env, obstack_t *obst,
        ir_label_t label;
        ir_entity *ent;
 
+       init = skip_Id(init);
+
        switch (get_irn_opcode(init)) {
 
        case iro_Cast:
index a03a582..b1d37e8 100644 (file)
 #endif
 
 #include "irnode_t.h"
-#include "irgraph_t.h" /* visited flag */
+#include "irgraph_t.h"
 #include "irprog.h"
 #include "irgwalk.h"
 #include "irhooks.h"
 #include "ircgcons.h"
+#include "entity_t.h"
 
+#include "error.h"
 #include "pset_new.h"
 #include "array.h"
 
@@ -675,6 +677,29 @@ typedef struct walk_env {
        void *env;
 } walk_env;
 
+static void walk_initializer(ir_initializer_t *initializer, walk_env *env)
+{
+       switch(initializer->kind) {
+    case IR_INITIALIZER_CONST:
+       irg_walk(initializer->consti.value, env->pre, env->post, env->env);
+        return;
+    case IR_INITIALIZER_TARVAL:
+    case IR_INITIALIZER_NULL:
+        return;
+
+    case IR_INITIALIZER_COMPOUND: {
+        size_t i;
+        for(i = 0; i < initializer->compound.n_initializers; ++i) {
+            ir_initializer_t *subinitializer
+                = initializer->compound.initializers[i];
+            walk_initializer(subinitializer, env);
+        }
+        return;
+    }
+       }
+       panic("invalid initializer found");
+}
+
 /**
  * Walk to all constant expressions in this entity.
  */
@@ -683,7 +708,9 @@ static void walk_entity(ir_entity *ent, void *env)
        walk_env *my_env = (walk_env *)env;
 
        if (get_entity_variability(ent) != variability_uninitialized) {
-               if (is_atomic_entity(ent)) {
+               if (ent->has_initializer) {
+                       walk_initializer(ent->attr.initializer, my_env);
+               } else if (is_atomic_entity(ent)) {
                        irg_walk(get_atomic_ent_value(ent), my_env->pre, my_env->post, my_env->env);
                } else {
                        int i, n_vals = get_compound_ent_n_values(ent);
index 0f93df7..a0c2e08 100644 (file)
@@ -593,6 +593,10 @@ void lower_highlevel_graph(ir_graph *irg, int lower_bitfields) {
        set_irg_phase_low(irg);
 }  /* lower_highlevel */
 
+void lower_const_code(void) {
+       walk_const_code(NULL, lower_irnode, NULL);
+}
+
 /*
  * Replaces SymConsts by a real constant if possible.
  * Replace Sel nodes by address computation.  Also resolves array access.
@@ -606,4 +610,5 @@ void lower_highlevel(int lower_bitfields) {
                ir_graph *irg = get_irp_irg(i);
                lower_highlevel_graph(irg, lower_bitfields);
        }
+       lower_const_code();
 }  /* lower_highlevel */