properties updated
[libfirm] / ir / st / st.c
index 7f3e8e6..6065e3c 100644 (file)
@@ -1,40 +1,65 @@
-/* Copyright (c) 2002 by Universität Karlsruhe (TH).  All Rights Reserved */
 /*
-** Time-stamp: <Thursday, 31.10.2002, 16:03:00 goetz@i44pc2.info.uni-karlsruhe.de>
-*/
-
-/***
+ * Copyright (C) 1995-2007 University of Karlsruhe.  All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief      Provide some auxilliary structures for firm graphs.
+ * @author     Florian Liekweg
+ * @date       26.2.2002
+ * @version    $Id$
+ */
+
+/**
    NAME
      st.h
    PURPOSE
      provide some auxilliary structures for firm graphs.
-   NOTES
+   S
      not quite complete
-   HISTORY
-     liekweg - Feb 26, 2002: Created.
-   CVS:
-     $Id$
 ***/
 
-# include "st.h"
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
 
-# include "irgwalk.h"
+#include <assert.h>
 
-#  include <stdio.h>
-# ifdef DEBUG_libfirm
-# endif /* def DEBUG_libfirm */
-#  include <malloc.h>
-# include "misc.h"
+#ifdef HAVE_STDIO_H
+# include <stdio.h>
+#endif
+#ifdef HAVE_STDLIB_H
+# include <stdlib.h>
+#endif
+
+# include "st.h"
+# include "irgwalk.h"
+# include "xmalloc.h"
 
 /* init globals: */
-static dtree_t *trees = 0;
+/*static*/ dtree_t *trees = 0;
 /*
 static dtree_t *last  = 0;
 */
 
 /* --------------------------------------------------------------------
-** Helper Functions
-** -------------------------------------------------------------------- */
+* Helper Functions
+* -------------------------------------------------------------------- */
 /*
   Helper function for get_n_blocks
 */
@@ -48,7 +73,7 @@ static void count_block (ir_node *block, void *env)
 # endif /* def DEBUG_libfirm */
 
   fprintf (stdout, "%s: Block(%p) has # (%i)\n",
-                  __FILE__ ":" __PRETTY_FUNCTION__, block, *n);
+                  __FILE__ ":count_block", (void *)block, *n);
 
   (*n) ++;
 }
@@ -70,7 +95,7 @@ static int get_n_blocks (ir_graph *graph)
   irg_block_walk (end_block, count_block, NULL, &n);
 
   fprintf (stdout, "%s: Graph(%p) has (%i) blocks\n",
-                  __FILE__ ":" __PRETTY_FUNCTION__, graph, n);
+                  __FILE__ ":get_n_blocks", (void *)graph, n);
 
   return (n);
 }
@@ -109,9 +134,9 @@ static dt_t *new_dt (ir_graph *graph)
 
   res->n_blocks = n_blocks;
   res->graph    = graph;
-  res->blocks   = (ir_node**) calloc (n_blocks, sizeof (ir_node*));
-  res->idoms    = (ir_node**) calloc (n_blocks, sizeof (ir_node*));
-  res->masks    = (bs_t*)     calloc (n_blocks, sizeof (bs_t));
+  res->blocks   = xcalloc(n_blocks, sizeof(res->blocks[0]));
+  res->idoms    = xcalloc(n_blocks, sizeof(res->idoms[0]));
+  res->masks    = xcalloc(n_blocks, sizeof(res->masks[0]));
 
   assert (res && "no dt");
 
@@ -127,8 +152,8 @@ static void free_dt (dt_t *dt)
 */
 
 /* --------------------------------------------------------------------
-** Private Functions
-** -------------------------------------------------------------------- */
+* Private Functions
+* -------------------------------------------------------------------- */
 
 /*
   Given a graph, find its dominator tree in the global list:
@@ -315,7 +340,7 @@ static void update_dominators (ir_node *block, void *env)
   /* check preds: */
   for (i = 0; i < n_ins; i ++)
     {
-      ir_node *in  = get_nodes_Block (get_irn_n (block, i));
+      ir_node *in  = get_nodes_block (get_irn_n (block, i));
       bs_t in_mask = get_mask  (dt, in);
 
       new_mask &= in_mask;
@@ -374,7 +399,7 @@ static ir_node *_get_idom (dt_t *dt, ir_node *block)
          {
                ir_node *ndom = 0;
 
-               pred = get_nodes_Block (get_irn_n (block, i));
+               pred = get_nodes_block (get_irn_n (block, i));
                ndom = _get_idom (dt, pred);
 
                if (ndom != idom)
@@ -398,8 +423,8 @@ static ir_node *_get_idom (dt_t *dt, ir_node *block)
 }
 
 /* --------------------------------------------------------------------
-** Public Functions
-** -------------------------------------------------------------------- */
+* Public Functions
+* -------------------------------------------------------------------- */
 
 /*
   Say wether a dominates b
@@ -428,7 +453,7 @@ ir_node *get_idom (ir_graph *g, ir_node *a)
 */
 dom_env_t *get_dom_env (ir_graph *graph, ir_node *a)
 {
-  dom_env_t *env = (dom_env_t*) calloc (1, sizeof (dom_env_t));
+  dom_env_t *env = xcalloc(1, sizeof(*env));
 
   env->graph   = graph;
   env->dt      = get_dominator_tree (graph);