bechordal_draw: Remove the write-only attribute max_color from struct draw_chordal_env_t.
[libfirm] / win32 / firmEvaluator / firm.c
index a5ec4ef..da0fc9d 100644 (file)
@@ -17,7 +17,7 @@
 #include "array_t.h"
 #define NDEBUG
 #else
-#include "array.h"
+#include "array_t.h"
 #endif
 
 #include "entity_t.h"
@@ -26,7 +26,6 @@
 #include "irmode_t.h"
 #include "tv_t.h"
 #include "irloop_t.h"
-#include "irextbb_t.h"
 #include "irprog_t.h"
 #include "compound_path_t.h"
 #include "tpop_t.h"
@@ -44,7 +43,8 @@
 #define ADD_ADR(p, off)  ((void *)((char *)(p) + (off)))
 
 /** debug output */
-static void debug(char *fmt, ...) {
+static void debug(char *fmt, ...)
+{
   va_list ap;
   char buf[1024];
 
@@ -53,12 +53,13 @@ static void debug(char *fmt, ...) {
 
   OutputDebugString(buf);
   va_end(ap);
-}  /* debug */
+}
 
 /**
  * return the size of a firm object
  */
-int get_firm_object_size(firm_kind kind) {
+int get_firm_object_size(firm_kind kind)
+{
   switch (kind) {
   case k_entity:     /* an entity */
     return sizeof(ir_entity);
@@ -76,16 +77,12 @@ int get_firm_object_size(firm_kind kind) {
     return sizeof(tarval);
   case k_ir_loop:    /* a loop */
     return sizeof(ir_loop);
-  case k_ir_compound_graph_path: /* a compound graph path, see entity.h */
-    return sizeof(compound_graph_path);
-  case k_ir_extblk:  /* an extended block */
-    return sizeof(ir_extblk);
   case k_ir_prog:    /* a program representation (irp) */
     return sizeof(ir_prog);
   default:
     return 0;
   }
-}  /* get_firm_object_size */
+}
 
 /**
  * returns the string length of a string in debuggee space
@@ -106,12 +103,13 @@ static int strlen_debuggee(DEBUGHELPER *pHelper, const void *address, size_t max
       return i;
   }
   return i;
-}  /* strlen_debuggee */
+}
 
 /**
  * Format an ident
  */
-HRESULT format_ident(DEBUGHELPER *pHelper, const void *address, char *pResult, size_t max) {
+HRESULT format_ident(DEBUGHELPER *pHelper, const void *address, char *pResult, size_t max)
+{
   set_entry *data = NULL;
   set_entry id;
   size_t len, slen;
@@ -133,7 +131,7 @@ HRESULT format_ident(DEBUGHELPER *pHelper, const void *address, char *pResult, s
 
   _tcsncpy(pResult, (const char *)data->dptr, max);
   return S_OK;
-}  /* format_ident */
+}
 
 /**
  * Format a tp_op
@@ -165,14 +163,15 @@ static HRESULT format_tp_op(DEBUGHELPER *pHelper, const void *addr, char *pResul
   }
 #undef X
 #undef Y
-}  /* format_tp_op */
+}
 
 /**
  * Checks whether a type is the global type
  *
  * @param type  the address of the type in debuggee's space
  */
-static HRESULT is_global_type(DEBUGHELPER *pHelper, const void *type, int *flag) {
+static HRESULT is_global_type(DEBUGHELPER *pHelper, const void *type, int *flag)
+{
   ir_type tp;
 
   *flag = 0;
@@ -181,12 +180,13 @@ static HRESULT is_global_type(DEBUGHELPER *pHelper, const void *type, int *flag)
 
   *flag = tp.flags & tf_global_type;
   return S_OK;
-}  /* is_global_type */
+}
 
 /**
  * format an entity
  */
-static HRESULT format_entity(DEBUGHELPER *pHelper, int nBase, const void *addr, char *pResult, size_t max, int top) {
+static HRESULT format_entity(DEBUGHELPER *pHelper, int nBase, const void *addr, char *pResult, size_t max, int top)
+{
   ir_entity ent;
   ir_type owner;
   char name[256];
@@ -228,12 +228,27 @@ static HRESULT format_entity(DEBUGHELPER *pHelper, int nBase, const void *addr,
   _tcsncat(pResult, name, max);
 
   return S_OK;
-}  /* format_entity */
+}
+
+/**
+ * format an ir_mode
+ */
+static HRESULT format_mode(DEBUGHELPER *pHelper, const void *addr, char *pResult, size_t max)
+{
+  ir_mode mode;
+
+  if (copy_from_debuggee(addr, pHelper, &mode, sizeof(mode)) != S_OK)
+    return E_FAIL;
+  if (format_ident(pHelper, mode.name, pResult, max) != S_OK)
+    return E_FAIL;
+  return S_OK;
+}
 
 /**
  * format a type
  */
-static HRESULT format_type(DEBUGHELPER *pHelper, int nBase, const void *addr, char *pResult, size_t max, int top) {
+static HRESULT format_type(DEBUGHELPER *pHelper, int nBase, const void *addr, char *pResult, size_t max, int top)
+{
   ir_type tp;
   char name[256];
 
@@ -248,8 +263,14 @@ static HRESULT format_type(DEBUGHELPER *pHelper, int nBase, const void *addr, ch
     _tcsncat(pResult, " ", max);
   }
 
-  if (format_ident(pHelper, tp.name, name, sizeof(name)) != S_OK)
-    return E_FAIL;
+  name[0] = '\0';
+  if (tp.name) {
+    if (format_ident(pHelper, tp.name, name, sizeof(name)) != S_OK)
+      return E_FAIL;
+  } else {
+    if (format_mode(pHelper, tp.mode, name, sizeof(name)) != S_OK)
+      return E_FAIL;
+  }
 
   _tcsncat(pResult, name, max);
   switch (nBase) {
@@ -265,12 +286,13 @@ static HRESULT format_type(DEBUGHELPER *pHelper, int nBase, const void *addr, ch
   _tcsncat(pResult, name, max);
 
   return S_OK;
-}  /* format_type */
+}
 
 /**
  * format an irg
  */
-static HRESULT format_irg(DEBUGHELPER *pHelper, int nBase, const void *addr, char *pResult, size_t max, int top) {
+static HRESULT format_irg(DEBUGHELPER *pHelper, int nBase, const void *addr, char *pResult, size_t max, int top)
+{
   ir_graph irg;
   char name[256];
 
@@ -317,12 +339,13 @@ static HRESULT format_irg(DEBUGHELPER *pHelper, int nBase, const void *addr, cha
   }
   _tcsncat(pResult, name, max);
   return S_OK;
-}  /* format_irg */
+}
 
 /**
  * format an ir_op
  */
-HRESULT format_op(DEBUGHELPER *pHelper, const void *addr, char *pResult, size_t max) {
+HRESULT format_op(DEBUGHELPER *pHelper, const void *addr, char *pResult, size_t max)
+{
   ir_op op;
 
   if (copy_from_debuggee(addr, pHelper, &op, sizeof(op)) != S_OK)
@@ -330,20 +353,7 @@ HRESULT format_op(DEBUGHELPER *pHelper, const void *addr, char *pResult, size_t
   if (format_ident(pHelper, op.name, pResult, max) != S_OK)
     return E_FAIL;
   return S_OK;
-}  /* format_op */
-
-/**
- * format an ir_mode
- */
-static HRESULT format_mode(DEBUGHELPER *pHelper, const void *addr, char *pResult, size_t max) {
-  ir_mode mode;
-
-  if (copy_from_debuggee(addr, pHelper, &mode, sizeof(mode)) != S_OK)
-    return E_FAIL;
-  if (format_ident(pHelper, mode.name, pResult, max) != S_OK)
-    return E_FAIL;
-  return S_OK;
-}  /* format_mode */
+}
 
 /** get a temporary string */
 #define get_string(str)                                         \
@@ -360,7 +370,7 @@ do {                                                            \
     s[len] = '\0';                                              \
     str = s;                                                    \
   }                                                             \
-} while(0)
+} while (0)
 
 /**
  * format a tarval
@@ -463,12 +473,13 @@ static HRESULT format_tarval(DEBUGHELPER *pHelper, int nBase, const void *addr,
     }
   }
   return S_OK;
-}  /* format_tarval */
+}
 
 /**
  * format an ir_node
  */
-static HRESULT format_node(DEBUGHELPER *pHelper, int nBase, const void *addr, char *pResult, size_t max, int top) {
+static HRESULT format_node(DEBUGHELPER *pHelper, int nBase, const void *addr, char *pResult, size_t max, int top)
+{
   ir_node n;
   char name[256];
   ir_op op;
@@ -491,7 +502,7 @@ static HRESULT format_node(DEBUGHELPER *pHelper, int nBase, const void *addr, ch
   /* show show node attributes */
   switch (op.code) {
   case iro_Const:
-    if (format_tarval(pHelper, nBase, n.attr.con.tv, name, sizeof(name)) != S_OK) {
+    if (format_tarval(pHelper, nBase, n.attr.con.tarval, name, sizeof(name)) != S_OK) {
       _tcsncat(pResult, "<???>", max);
     }
     else {
@@ -503,12 +514,6 @@ static HRESULT format_node(DEBUGHELPER *pHelper, int nBase, const void *addr, ch
   case iro_SymConst:
     _tcsncat(pResult, "<", max);
     switch (n.attr.symc.kind) {
-    case symconst_type_tag:
-      _tcsncat(pResult, "TAG:", max);
-      if (format_type(pHelper, nBase, n.attr.symc.sym.type_p, name, sizeof(name), 0) != S_OK)
-        return E_FAIL;
-      _tcsncat(pResult, name, max);
-      break;
     case symconst_type_size:
       _tcsncat(pResult, "SIZE:", max);
       if (format_type(pHelper, nBase, n.attr.symc.sym.type_p, name, sizeof(name), 0) != S_OK)
@@ -521,12 +526,6 @@ static HRESULT format_node(DEBUGHELPER *pHelper, int nBase, const void *addr, ch
         return E_FAIL;
       _tcsncat(pResult, name, max);
       break;
-    case symconst_addr_name:
-      _tcsncat(pResult, "NAME:", max);
-      if (format_ident(pHelper, n.attr.symc.sym.ident_p, name, sizeof(name)) != S_OK)
-        return E_FAIL;
-      _tcsncat(pResult, name, max);
-      break;
     case symconst_addr_ent:
       _tcsncat(pResult, "ENT:", max);
       if (format_entity(pHelper, nBase, n.attr.symc.sym.entity_p, name, sizeof(name), 0) != S_OK)
@@ -590,7 +589,7 @@ static HRESULT format_node(DEBUGHELPER *pHelper, int nBase, const void *addr, ch
   _tcsncat(pResult, name, max);
 
   return S_OK;
-}  /* format_node */
+}
 
 /**
  * format a loop
@@ -602,7 +601,7 @@ static HRESULT format_loop(DEBUGHELPER *pHelper, const void *addr, char *pResult
   if (copy_from_debuggee(addr, pHelper, &loop, sizeof(loop)) != S_OK)
     return E_FAIL;
   return E_FAIL;
-}  /* format_loop */
+}
 
 /**
  * Get an array descriptor
@@ -614,51 +613,7 @@ static HRESULT get_array_desc(DEBUGHELPER *pHelper, const void *address, ir_arr_
     return E_FAIL;
 
   return S_OK;
-}  /* get_array_desc */
-
-/**
- * format an extended block
- */
-static HRESULT format_extblk(DEBUGHELPER *pHelper, int nBase, const void *addr, char *pResult, size_t max){
-  ir_extblk extbb;
-  ir_arr_descr blocks;
-  ir_node *blks = NULL;
-  char name[256];
-  int len;
-
-  if (copy_from_debuggee(addr, pHelper, &extbb, sizeof(extbb)) != S_OK)
-    return E_FAIL;
-  if (extbb.blks == NULL)
-    return E_FAIL;
-
-  if (get_array_desc(pHelper, extbb.blks, &blocks) != S_OK)
-    return E_FAIL;
-
-  len = ARR_LEN(&blocks.v.elts);
-
-  if (len > 0) {
-    if (copy_from_debuggee(extbb.blks, pHelper, &blks, sizeof(blks)) != S_OK)
-      return E_FAIL;
-  }
-
-  if (blks) {
-    switch (nBase) {
-    case 16:
-      _snprintf(name, sizeof(name), "0x%x 0x%x blocks", blks->node_nr, len);
-      break;
-    case 8:
-      _snprintf(name, sizeof(name), "0%o 0%o blocks", blks->node_nr, len);
-      break;
-    default:
-      _snprintf(name, sizeof(name), "%d %d blocks", blks->node_nr, len);
-    }
-    _tcsncpy(pResult, name, max);
-  }
-  else
-    _tcsncpy(pResult, "<EMPTY>", max);
-  return S_OK;
-}  /* format_extblk */
-
+}
 
 /**
  * format a ir_prog
@@ -698,7 +653,7 @@ static HRESULT format_prog(DEBUGHELPER *pHelper, int nBase, const void *addr, ch
   _tcsncpy(pResult, name, max);
 
   return S_OK;
-}  /* format_prog */
+}
 
 /*
  * Format an array descriptor
@@ -735,7 +690,7 @@ HRESULT format_arr_descr(DEBUGHELPER *pHelper, int nBase, const void *addr, char
   _tcsncat(pResult, name, max);
 
   return S_OK;
-}  /* format_arr_descr */
+}
 
 /*
  * format a firm object
@@ -759,16 +714,12 @@ HRESULT FormatFirmObject(DEBUGHELPER *pHelper, int nBase, firm_kind kind, const
     return format_tarval(pHelper, nBase, addr, pResult, max);
   case k_ir_loop:    /* a loop */
     return format_loop(pHelper, addr, pResult, max);
-  case k_ir_compound_graph_path: /* a compound graph path, see entity.h */
-    return E_FAIL;
-  case k_ir_extblk:  /* an extended block */
-    return format_extblk(pHelper, nBase, addr, pResult, max);
   case k_ir_prog:    /* a program representation (irp) */
     return format_prog(pHelper, nBase, addr, pResult, max);
   default:
     return E_FAIL;
   }
-}  /* FormatFirmObject */
+}
 
 #define SEGMENT_SIZE_SHIFT     8
 #define SEGMENT_SIZE           (1 << SEGMENT_SIZE_SHIFT)
@@ -793,13 +744,6 @@ struct pset {
   pset_Element *iter_tail; /**< non-NULL while iterating over elts */
   pset_Element *free_list; /**< list of free Elements */
   struct obstack obst;     /**< obstack for allocation all data */
-#ifdef STATS
-  int naccess, ncollision, ndups;
-  int max_chain_len;
-#endif
-#ifdef DEBUG
-  const char *tag;         /**< an optionally tag for distinguishing sets */
-#endif
 };
 
 typedef struct set_element {
@@ -818,20 +762,14 @@ struct set {
   unsigned iter_i, iter_j;
   set_Element *iter_tail;  /**< non-NULL while iterating over elts */
   struct obstack obst;     /**< obstack for allocation all data */
-#ifdef STATS
-  int naccess, ncollision, ndups;
-  int max_chain_len;
-#endif
-#ifdef DEBUG
-  const char *tag;         /**< an optionally tag for distinguishing sets */
-#endif
 };
 
 /**
  * Find the longest chain of a pset
  */
 static HRESULT find_longest_pset_chain(DEBUGHELPER *pHelper, pset *set,
-                                       int *chains, int *lenght, size_t *size) {
+                                       int *chains, int *lenght, size_t *size)
+{
   unsigned i, j;
   pset_Segment *seg, *curr;
   pset_Element elem;
@@ -865,13 +803,14 @@ static HRESULT find_longest_pset_chain(DEBUGHELPER *pHelper, pset *set,
   *lenght = max_len;
   *size   = dyns;
   return S_OK;
-}  /* find_longest_pset_chain */
+}
 
 /**
  * Find the longest chain of a set
  */
 static HRESULT find_longest_set_chain(DEBUGHELPER *pHelper, set *set,
-                                      int *chains, int *lenght, size_t *size) {
+                                      int *chains, int *lenght, size_t *size)
+{
   unsigned i, j;
   set_Segment *seg, *curr;
   set_Element elem;
@@ -905,7 +844,7 @@ static HRESULT find_longest_set_chain(DEBUGHELPER *pHelper, set *set,
   *lenght = max_len;
   *size   = dyns;
   return S_OK;
-}  /* find_longest_set_chain */
+}
 
 /*
  * Format a pset
@@ -936,7 +875,7 @@ HRESULT format_pset(DEBUGHELPER *pHelper, int nBase, const void *address, char *
   _tcsncpy(pResult, name, max);
 
   return S_OK;
-}  /* format_pset */
+}
 
 /*
  * Format a set
@@ -967,7 +906,7 @@ HRESULT format_set(DEBUGHELPER *pHelper, int nBase, const void *address, char *p
   _tcsncpy(pResult, name, max);
 
   return S_OK;
-}  /* format_set */
+}
 
 struct pdeq {
   unsigned magic;       /**< debug magic, only available in DEBUG builds */
@@ -1004,7 +943,7 @@ static int get_pdeq_len(DEBUGHELPER *pHelper, pdeq *dq)
   };
 
   return n;
-}  /* get_pdeq_len */
+}
 
 /*
  * Format a pdeq
@@ -1035,18 +974,19 @@ HRESULT format_pdeq(DEBUGHELPER *pHelper, int nBase, const void *address, char *
   _tcsncpy(pResult, name, max);
 
   return S_OK;
-}  /* format_pdeq */
+}
 
 /** show the first 2 units */
-static HRESULT fill_bits(DEBUGHELPER *pHelper, bitset_t *bs, char *pResult) {
-  bitset_pos_t i, units = bs->units;
+static HRESULT fill_bits(DEBUGHELPER *pHelper, bitset_t *bs, char *pResult)
+{
+  unsigned i, units = bs->size;
   int l = 0, o = 0, breaked = 0;
   unsigned j;
 
   for (i = 0; i < units; ++i) {
-    bitset_unit_t data;
+    unsigned data;
 
-    if (copy_from_debuggee((void *)(BS_DATA(bs)[i]), pHelper, &data, sizeof(data)) != S_OK)
+    if (copy_from_debuggee((void *)(&bs->data[i]), pHelper, &data, sizeof(data)) != S_OK)
       return E_FAIL;
 
     for (j = 0; j < 32; ++j) {
@@ -1068,7 +1008,7 @@ end:
   }
   sprintf(pResult + l, "}");
   return S_OK;
-}  /* fill_bits */
+}
 
 /*
  * Format a bitset
@@ -1077,7 +1017,7 @@ HRESULT format_bitset(DEBUGHELPER *pHelper, int nBase, const void *address, char
 {
   bitset_t bs;
   char name[256];
-  bitset_pos_t l;
+  unsigned l;
 
   if (copy_from_debuggee(address, pHelper, &bs, sizeof(bs)) != S_OK)
     return E_FAIL;
@@ -1101,4 +1041,4 @@ HRESULT format_bitset(DEBUGHELPER *pHelper, int nBase, const void *address, char
   _tcsncpy(pResult, name, max);
 
   return S_OK;
-}  /* format_bitset */
+}