symconst_enum_const support added
authorMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Mon, 31 Jul 2006 09:12:07 +0000 (09:12 +0000)
committerMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Mon, 31 Jul 2006 09:12:07 +0000 (09:12 +0000)
[r8074]

ir/ir/ircons.c
ir/ir/irdump.c
ir/ir/irdumptxt.c
ir/ir/irnode.c
ir/ir/irnode.h
ir/ir/irprintf.c

index a96404f..a2a9351 100644 (file)
@@ -3083,7 +3083,8 @@ set_store(ir_node *store)
 {
   ir_node *load, *pload, *pred, *in[2];
 
-  assert(get_irg_phase_state (current_ir_graph) == phase_building);
+  assert(get_irg_phase_state(current_ir_graph) == phase_building);
+  assert(get_irn_mode(store) == mode_M && "storing non-memory node");
 
   if (get_opt_auto_create_sync()) {
     /* handle non-volatile Load nodes by automatically creating Sync's */
index af5b16e..d11ba5d 100644 (file)
@@ -6,7 +6,7 @@
  * Modified by: Goetz Lindenmaier, Hubert Schmidt
  * Created:
  * CVS-ID:      $Id$
- * Copyright:   (c) 1998-2003 Universit�t Karlsruhe
+ * Copyright:   (c) 1998-2006 Universit�t Karlsruhe
  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
  */
 #ifdef HAVE_CONFIG_H
@@ -671,21 +671,26 @@ int dump_node_opcode(FILE *F, ir_node *n)
   } break;
 
   case iro_SymConst: {
-    if (get_SymConst_kind(n) == symconst_addr_name) {
+    switch (get_SymConst_kind(n)) {
+    case symconst_addr_name:
       /* don't use get_SymConst_ptr_info as it mangles the name. */
-      fprintf (F, "SymC %s", get_id_str(get_SymConst_name(n)));
-    } else if (get_SymConst_kind(n) == symconst_addr_ent) {
-      assert(get_SymConst_entity(n));
-      assert(is_entity(get_SymConst_entity(n)));
-      fprintf (F, "SymC &%s", get_entity_name(get_SymConst_entity(n)));
-    } else {
-      assert(get_kind(get_SymConst_type(n)) == k_type);
-      assert(get_type_ident(get_SymConst_type(n)));
-      fprintf (F, "SymC %s ", get_type_name_ex(get_SymConst_type(n), &bad));
-      if (get_SymConst_kind(n) == symconst_type_tag)
-        fprintf (F, "tag");
-      else
-        fprintf (F, "size");
+      fprintf(F, "SymC %s", get_id_str(get_SymConst_name(n)));
+      break;
+    case symconst_addr_ent:
+      fprintf(F, "SymC &%s", get_entity_name(get_SymConst_entity(n)));
+      break;
+    case symconst_type_tag:
+      fprintf(F, "SymC %s tag", get_type_name_ex(get_SymConst_type(n), &bad));
+      break;
+    case symconst_type_size:
+      fprintf(F, "SymC %s size", get_type_name_ex(get_SymConst_type(n), &bad));
+      break;
+    case symconst_type_align:
+      fprintf(F, "SymC %s align", get_type_name_ex(get_SymConst_type(n), &bad));
+      break;
+    case symconst_enum_const:
+      fprintf(F, "SymC %s enum", get_enumeration_name(get_SymConst_enum(n)));
+      break;
     }
   } break;
 
@@ -1842,16 +1847,20 @@ void dump_entity_node(FILE *F, entity *ent, int color)
 static void dump_enum_item(FILE *F, ir_type *tp, int pos)
 {
   char buf[1024];
-  ident *id  = get_enumeration_nameid(tp, pos);
-  tarval *tv = get_enumeration_enum(tp, pos);
+  ir_enum_const *ec = get_enumeration_const(tp, pos);
+  ident         *id = get_enumeration_nameid(ec);
+  tarval        *tv = get_enumeration_value(ec);
 
-  tarval_snprintf(buf, sizeof(buf), tv);
-  fprintf (F, "node: {title: \"");
+  if (tv)
+    tarval_snprintf(buf, sizeof(buf), tv);
+  else
+    strncpy(buf, "<not set>", sizeof(buf));
+  fprintf(F, "node: {title: \"");
   PRINT_ITEMID(tp, pos); fprintf(F, "\"");
-  fprintf (F, DEFAULT_ENUM_ITEM_ATTRIBUTE);
-  fprintf (F, "label: ");
-  fprintf (F, "\"enum item %s\" " ENUM_ITEM_NODE_ATTR, get_id_str(id));
-  fprintf (F, "\n info1: \"value: %s\"}\n", buf);
+  fprintf(F, DEFAULT_ENUM_ITEM_ATTRIBUTE);
+  fprintf(F, "label: ");
+  fprintf(F, "\"enum item %s\" " ENUM_ITEM_NODE_ATTR, get_id_str(id));
+  fprintf(F, "\n info1: \"value: %s\"}\n", buf);
 }
 
 /* dumps a type or entity and it's edges. */
index 5d793ee..5687397 100644 (file)
@@ -6,7 +6,7 @@
  * Modified by: Goetz Lindenmaier, Hubert Schmidt
  * Created:
  * CVS-ID:      $Id$
- * Copyright:   (c) 1998-2003 Universität Karlsruhe
+ * Copyright:   (c) 1998-2006 Universität Karlsruhe
  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
  */
 #ifdef HAVE_CONFIG_H
@@ -302,6 +302,10 @@ int dump_irnode_to_file(FILE *F, ir_node *n) {
       fprintf(F, "  type: ");
       dump_type_to_file(F, get_SymConst_type(n), dump_verbosity_onlynames);
       break;
+    case symconst_enum_const:
+      fprintf(F, "  kind: enumeration\n");
+      fprintf(F, "  name: %s\n", get_enumeration_name(get_SymConst_enum(n)));
+      break;
     }
     fprintf(F, "  type of value: %s \n", get_type_name_ex(get_SymConst_value_type(n), &bad));
   } break;
index 1e92ea1..f28a89b 100644 (file)
@@ -6,7 +6,7 @@
  * Modified by: Goetz Lindenmaier, Michael Beck
  * Created:
  * CVS-ID:      $Id$
- * Copyright:   (c) 1998-2003 Universität Karlsruhe
+ * Copyright:   (c) 1998-2006 Universität Karlsruhe
  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
  */
 
@@ -1045,6 +1045,18 @@ void     set_SymConst_entity (ir_node *node, entity *ent) {
   node->attr.symc.sym.entity_p  = ent;
 }
 
+ir_enum_const *get_SymConst_enum (ir_node *node) {
+  assert (   (node->op == op_SymConst)
+          && (get_SymConst_kind (node) == symconst_enum_const));
+  return node->attr.symc.sym.enum_p;
+}
+
+void           set_SymConst_enum (ir_node *node, ir_enum_const *ec) {
+  assert (   (node->op == op_SymConst)
+          && (get_SymConst_kind(node) == symconst_enum_const));
+  node->attr.symc.sym.enum_p  = ec;
+}
+
 union symconst_symbol
 get_SymConst_symbol (ir_node *node) {
   assert (node->op == op_SymConst);
index e732c1b..4b7767f 100644 (file)
@@ -6,7 +6,7 @@
  * Modified by: Goetz Lindenmaier, Michael Beck
  * Created:
  * CVS-ID:      $Id$
- * Copyright:   (c) 1998-2003 Universität Karlsruhe
+ * Copyright:   (c) 1998-2006 Universität Karlsruhe
  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
  */
 #ifndef _FIRM_IR_IRNODE_H_
@@ -451,9 +451,11 @@ typedef enum {
   symconst_addr_name,   /**< The SymConst is a symbolic pointer to be filled in
                           by the linker.  The pointer is represented by a string.
                           symconst_symbol is ident *. */
-  symconst_addr_ent     /**< The SymConst is a symbolic pointer to be filled in
+  symconst_addr_ent,    /**< The SymConst is a symbolic pointer to be filled in
                           by the linker.  The pointer is represented by an entity.
                           symconst_symbol is entity *. */
+  symconst_enum_const   /**< The SymConst is a enumeration constant of an
+               enumeration type. */
 } symconst_kind;
 
 /** Returns non-zero if s symconst kind has a type attribute */
@@ -465,13 +467,18 @@ typedef enum {
 /** Returns non-zero if s symconst kind has an entity attribute */
 #define SYMCONST_HAS_ENT(kind) ((kind) == symconst_addr_ent)
 
+/** Returns non-zero if s symconst kind has an enum_const attribute */
+#define SYMCONST_HAS_ENUM(kind) ((kind) == symconst_enum_const)
+
 /** SymConst attribute.
  *
- *  This union contains the symbolic information represented by the node.  */
+ *  This union contains the symbolic information represented by the node.
+ */
 typedef union symconst_symbol {
-  ir_type *type_p;
-  ident   *ident_p;
-  entity  *entity_p;
+  ir_type       *type_p;
+  ident         *ident_p;
+  entity        *entity_p;
+  ir_enum_const *enum_p;
 } symconst_symbol;
 
 /** Get the kind of the SymConst. */
@@ -491,6 +498,10 @@ void     set_SymConst_name (ir_node *node, ident *name);
 entity  *get_SymConst_entity (ir_node *node);
 void     set_SymConst_entity (ir_node *node, entity *ent);
 
+/** Only to access SymConst of kind symconst_enum_const.  Else assertion: */
+ir_enum_const *get_SymConst_enum (ir_node *node);
+void           set_SymConst_enum (ir_node *node, ir_enum_const *ec);
+
 /** Sets both: type and ptrinfo.  Needed to treat the node independent of
    its semantics.  Does a memcpy for the memory sym points to. */
 /* write 'union': firmjni then does not create a method... */
index 5ebfd12..9466376 100644 (file)
@@ -5,7 +5,7 @@
  * Author:      Sebastian Hack
  * Created:     29.11.2004
  * CVS-ID:      $Id$
- * Copyright:   (c) 1998-2004 Universität Karlsruhe
+ * Copyright:   (c) 1998-2006 Universität Karlsruhe
  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
  */
 
@@ -340,6 +340,9 @@ static void firm_emit(char *buf, int buflen, char conversion,
           case symconst_addr_ent:    /* entity name */
             snprintf(tv_buf, sizeof(tv_buf), "<%s>", get_entity_name(get_SymConst_entity(X)));
             break;
+          case symconst_enum_const:  /* enumeration constant */
+            snprintf(tv_buf, sizeof(tv_buf), "<ENUM:%s>", get_enumeration_name(get_SymConst_enum(X)));
+            break;
           default:
             tv_buf[0] = '\0';
           }