local_optimize() now kills unrteachable code if dominance info is available.
[libfirm] / ir / ir / irargs.c
index 2e8af24..80d9404 100644 (file)
 /**
  * identify a firm object type
  */
-static int firm_get_lc_arg_type(const lc_arg_occ_t *occ) {
+static int firm_get_arg_type(const lc_arg_occ_t *occ) {
   /* Firm objects are always pointer */
   return lc_arg_type_ptr;
 }
 
-static int firm_get_lc_arg_type_int(const lc_arg_occ_t *occ) {
+static int firm_get_arg_type_int(const lc_arg_occ_t *occ) {
   return lc_arg_type_int;
 }
 
 
-static int bitset_get_lc_arg_type(const lc_arg_occ_t *occ) {
+static int bitset_get_arg_type(const lc_arg_occ_t *occ) {
   return lc_arg_type_ptr;
 }
 
@@ -99,6 +99,7 @@ static int firm_emit(lc_appendable_t *app,
   char add[64];
   char buf[256];
   char tv[256];
+  entity *ent;
 
   buf[0] = '\0';
   add[0] = '\0';
@@ -161,23 +162,29 @@ static int firm_emit(lc_appendable_t *app,
       snprintf(buf, sizeof(buf), "%s%s", A("op"), get_op_name(X));
       break;
     case k_ir_compound_graph_path:
-      strncat(buf, A("cgp"), sizeof(buf));
-
       n = get_compound_graph_path_length(X);
+
       for (i = 0; i < n; ++i) {
-        entity *ent = get_compound_graph_path_node(X, i);
+        ent = get_compound_graph_path_node(X, i);
+
+        strncat(buf, ".", sizeof(buf));
         strncat(buf, get_entity_name(ent), sizeof(buf));
-        if (i < n - 1)
-          strncat(buf, ".", sizeof(buf));
+        if (is_Array_type(get_entity_owner(ent))) {
+          snprintf(add, sizeof(add), "[%d]",
+            get_compound_graph_path_array_index(X, i));
+          strncat(buf, add, sizeof(buf));
+        }
       }
+      add[0] = '\0';
       break;
+
     default:
       snprintf(buf, sizeof(buf), "UNKWN");
       snprintf(add, sizeof(add), "[%p]", X);
     }
   }
 
-  if(occ->flag_plus)
+  if (occ->flag_plus)
        strncat(buf, add, sizeof(buf));
 
   return lc_arg_append(app, occ, buf, strlen(buf));
@@ -224,18 +231,18 @@ static int firm_emit_pnc(lc_appendable_t *app,
   return lc_arg_append(app, occ, p, strlen(p));
 }
 
-lc_arg_env_t *firm_get_lc_arg_env(void)
+lc_arg_env_t *firm_get_arg_env(void)
 {
 #define X(name, letter) {"firm:" name, letter}
 
   static lc_arg_env_t *env = NULL;
 
-  static lc_arg_handler_t firm_handler   = { firm_get_lc_arg_type, firm_emit };
-  static lc_arg_handler_t ident_handler  = { firm_get_lc_arg_type, firm_emit_ident };
-  static lc_arg_handler_t indent_handler = { firm_get_lc_arg_type_int, firm_emit_indent };
-  static lc_arg_handler_t pnc_handler    = { firm_get_lc_arg_type_int, firm_emit_pnc };
-  static lc_arg_handler_t bitset_handler = { bitset_get_lc_arg_type, bitset_emit };
-  static lc_arg_handler_t debug_handler  = { firm_get_lc_arg_type, firm_emit_dbg };
+  static lc_arg_handler_t firm_handler   = { firm_get_arg_type, firm_emit };
+  static lc_arg_handler_t ident_handler  = { firm_get_arg_type, firm_emit_ident };
+  static lc_arg_handler_t indent_handler = { firm_get_arg_type_int, firm_emit_indent };
+  static lc_arg_handler_t pnc_handler    = { firm_get_arg_type_int, firm_emit_pnc };
+  static lc_arg_handler_t bitset_handler = { bitset_get_arg_type, bitset_emit };
+  static lc_arg_handler_t debug_handler  = { firm_get_arg_type, firm_emit_dbg };
 
   static struct {
     const char *name;
@@ -251,6 +258,7 @@ lc_arg_env_t *firm_get_lc_arg_env(void)
     X("mode",      'm'),
     X("block",     'B'),
     X("pnc",       '='),
+    X("cg_path",   'P'),
   };
 
   int i;
@@ -266,7 +274,7 @@ lc_arg_env_t *firm_get_lc_arg_env(void)
     lc_arg_register(env, "firm:ident", 'I', &ident_handler);
     lc_arg_register(env, "firm:indent", 'D', &indent_handler);
     lc_arg_register(env, "firm:pnc",      '=', &pnc_handler);
-    lc_arg_register(env, "firm:dbg_info", 'g', &debug_handler);
+    lc_arg_register(env, "firm:dbg_info", 'G', &debug_handler);
     /* lc_arg_register(env, "firm:bitset", 'b', &bitset_handler); */
   }