move util.h to private API, harmonize SIZ(array) vs. ARR_SIZE(array) vs. array_size...
authorMatthias Braun <matze@braunis.de>
Wed, 19 May 2010 12:26:50 +0000 (12:26 +0000)
committerMatthias Braun <matze@braunis.de>
Wed, 19 May 2010 12:26:50 +0000 (12:26 +0000)
[r27548]

13 files changed:
include/libfirm/adt/offset.h [deleted file]
include/libfirm/adt/util.h [deleted file]
ir/adt/util.h [new file with mode: 0644]
ir/ana/irlivechk.c
ir/be/beabi.c
ir/be/benode.c
ir/be/ia32/ia32_dbg_stat.h
ir/ir/irdump.c
ir/opt/iropt_dbg.h
ir/stat/const_stat.c
ir/stat/firmstat.c
ir/stat/firmstat_t.h
ir/stat/stat_dmp.c

diff --git a/include/libfirm/adt/offset.h b/include/libfirm/adt/offset.h
deleted file mode 100644 (file)
index 32033b1..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 1995-2008 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  Implementation of offset_of and container_of
- * @date   31.05.2005
- * @author Sebastian Hack
- */
-#ifndef FIRM_ADT_OFFSET_H
-#define FIRM_ADT_OFFSET_H
-
-/**
- * Get the offset of a member of a struct.
- * @param type   The type of the struct member is in.
- * @param member The name of the member.
- * @return       The offset of member in type in bytes.
- */
-#define firm_offset_of(type, member)           ((char *) &((type *) 0)->member - (char *) 0)
-
-/**
- * Make pointer to the struct from a pointer to a member of that struct.
- * @param ptr     The pointer to the member.
- * @param type    The type of the struct.
- * @param member  The name of the member.
- * @return        A pointer to the struct member is in.
- */
-#define firm_container_of(ptr, type, member)           ((type *) ((char *) (ptr) - firm_offset_of(type, member)))
-
-#endif
diff --git a/include/libfirm/adt/util.h b/include/libfirm/adt/util.h
deleted file mode 100644 (file)
index 678c0dd..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 1995-2008 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
- * @date   31.05.2005
- * @author Sebastian Hack
- * @brief  Some utility macros.
- */
-#ifndef FIRM_ADT_UTIL_H
-#define FIRM_ADT_UTIL_H
-
-/**
- * Get the offset of a member of a struct.
- * @param type   The type of the struct member is in.
- * @param member The name of the member.
- * @return       The offset of member in type in bytes.
- */
-#define offset_of(type, member) \
-  ((char *) &(((type *) 0)->member) - (char *) 0)
-
-/**
- * Make pointer to the struct from a pointer to a member of that struct.
- * @param ptr     The pointer to the member.
- * @param type    The type of the struct.
- * @param member  The name of the member.
- * @return        A pointer to the struct member is in.
- */
-#define container_of(ptr, type, member) \
-       ((type *) ((char *) (ptr) - offset_of(type, member)))
-
-/**
- * Get the number of elements of a static array.
- * @param arr The static array.
- * @return The number of elements in that array.
- */
-#define array_size(arr) \
-  (sizeof(arr) / sizeof((arr)[0]))
-
-#endif
diff --git a/ir/adt/util.h b/ir/adt/util.h
new file mode 100644 (file)
index 0000000..1e93e3f
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 1995-2008 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
+ * @date   31.05.2005
+ * @author Sebastian Hack
+ * @brief  Some utility macros.
+ */
+#ifndef FIRM_ADT_UTIL_H
+#define FIRM_ADT_UTIL_H
+
+#include <stddef.h>
+
+/**
+ * Make pointer to the struct from a pointer to a member of that struct.
+ * @param ptr     The pointer to the member.
+ * @param type    The type of the struct.
+ * @param member  The name of the member.
+ * @return        A pointer to the struct member is in.
+ */
+#define firm_container_of(ptr, type, member) \
+       ((type *) ((char *) (ptr) - offsetof(type, member)))
+
+/**
+ * Returns size of a static array. Warning: This returns invalid values for
+ * dynamically allocated arrays.
+ *
+ * @param a    static array
+ */
+#define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0]))
+
+#endif
index 0e30d5c..696745b 100644 (file)
@@ -87,7 +87,7 @@ struct _lv_chk_t {
 
 static void *init_block_data(ir_phase *ph, const ir_node *irn, void *old)
 {
-       lv_chk_t *lv      = container_of(ph, lv_chk_t, ph);
+       lv_chk_t *lv      = firm_container_of(ph, lv_chk_t, ph);
        bl_info_t *bi     = phase_alloc(ph, sizeof(bi[0]));
 
        bi->id            = get_Block_dom_tree_pre_num(irn);
index 9568bd7..4e53766 100644 (file)
@@ -26,7 +26,6 @@
 #include "config.h"
 
 #include "obst.h"
-#include "offset.h"
 
 #include "irgopt.h"
 
index 839220e..bef1d79 100644 (file)
@@ -37,7 +37,6 @@
 #include "util.h"
 #include "debug.h"
 #include "fourcc.h"
-#include "offset.h"
 #include "bitfiddle.h"
 #include "raw_bitset.h"
 #include "error.h"
index ca36770..5701e5a 100644 (file)
@@ -29,8 +29,7 @@
 #include "irhooks.h"
 #include "dbginfo_t.h"
 #include "firmstat.h"
-
-#define SIZ(x)    sizeof(x)/sizeof((x)[0])
+#include "util.h"
 
 /**
  * Merge the debug info due to a LEA creation.
  * @param oldn2  an additional old node
  * @param n      the new lea
  */
-#define DBG_OPT_LEA2(oldn1, oldn2, n)                              \
-       do {                                                           \
-               ir_node *ons[2];                                           \
-               ons[0] = oldn1;                                            \
-               ons[1] = oldn2;                                            \
-               hook_merge_nodes(&n, 1, ons, SIZ(ons), FS_BE_IA32_LEA);    \
-               __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_backend);  \
+#define DBG_OPT_LEA2(oldn1, oldn2, n)                                    \
+       do {                                                                 \
+               ir_node *ons[2];                                                 \
+               ons[0] = oldn1;                                                  \
+               ons[1] = oldn2;                                                  \
+               hook_merge_nodes(&n, 1, ons, ARRAY_SIZE(ons), FS_BE_IA32_LEA);   \
+               __dbg_info_merge_sets(&n, 1, ons, ARRAY_SIZE(ons), dbg_backend); \
        } while(0)
 
 /**
  * @param oldn3  an additional old node
  * @param n      the new lea
  */
-#define DBG_OPT_LEA3(oldn1, oldn2, oldn3, n)                       \
-       do {                                                           \
-               ir_node *ons[3];                                           \
-               ons[0] = oldn1;                                            \
-               ons[1] = oldn2;                                            \
-               ons[2] = oldn3;                                            \
-               hook_merge_nodes(&n, 1, ons, SIZ(ons), FS_BE_IA32_LEA);    \
-               __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_backend);  \
+#define DBG_OPT_LEA3(oldn1, oldn2, oldn3, n)                             \
+       do {                                                                 \
+               ir_node *ons[3];                                                 \
+               ons[0] = oldn1;                                                  \
+               ons[1] = oldn2;                                                  \
+               ons[2] = oldn3;                                                  \
+               hook_merge_nodes(&n, 1, ons, ARRAY_SIZE(ons), FS_BE_IA32_LEA);   \
+               __dbg_info_merge_sets(&n, 1, ons, ARRAY_SIZE(ons), dbg_backend); \
        } while(0)
 
 /**
  * @param oldn4  an additional old node
  * @param n      the new lea
  */
-#define DBG_OPT_LEA4(oldn1, oldn2, oldn3, oldn4, n)                \
-       do {                                                           \
-               ir_node *ons[4];                                           \
-               ons[0] = oldn1;                                            \
-               ons[1] = oldn2;                                            \
-               ons[2] = oldn3;                                            \
-               ons[3] = oldn4;                                            \
-               hook_merge_nodes(&n, 1, ons, SIZ(ons), FS_BE_IA32_LEA);    \
-               __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_backend);  \
+#define DBG_OPT_LEA4(oldn1, oldn2, oldn3, oldn4, n)                      \
+       do {                                                                 \
+               ir_node *ons[4];                                                 \
+               ons[0] = oldn1;                                                  \
+               ons[1] = oldn2;                                                  \
+               ons[2] = oldn3;                                                  \
+               ons[3] = oldn4;                                                  \
+               hook_merge_nodes(&n, 1, ons, ARRAY_SIZE(ons), FS_BE_IA32_LEA);   \
+               __dbg_info_merge_sets(&n, 1, ons, ARRAY_SIZE(ons), dbg_backend); \
        } while(0)
 
 /**
  * @param store  the old store
  * @param n      the new op
  */
-#define DBG_OPT_AM_D(load, store, n)                               \
-       do {                                                           \
-               ir_node *ons[2];                                           \
-               ons[0] = load;                                             \
-               ons[1] = store;                                            \
-               hook_merge_nodes(&n, 1, ons, SIZ(ons), FS_BE_IA32_AM_D);   \
-               __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_backend);  \
+#define DBG_OPT_AM_D(load, store, n)                                     \
+       do {                                                                 \
+               ir_node *ons[2];                                                 \
+               ons[0] = load;                                                   \
+               ons[1] = store;                                                  \
+               hook_merge_nodes(&n, 1, ons, ARRAY_SIZE(ons), FS_BE_IA32_AM_D);  \
+               __dbg_info_merge_sets(&n, 1, ons, ARRAY_SIZE(ons), dbg_backend); \
        } while(0)
 
 /**
index aa4ffd3..6ec3699 100644 (file)
@@ -60,6 +60,7 @@
 #include "pmap.h"
 #include "eset.h"
 #include "pset.h"
+#include "util.h"
 
 /** Dump only irgs with names that start with this prefix. */
 static ident *dump_file_filter_id = NULL;
@@ -967,8 +968,6 @@ typedef struct _proj_lookup {
        const pns_lookup_t *data;     /**< the data */
 } proj_lookup_t;
 
-#define ARR_SIZE(a)       (sizeof(a)/sizeof(a[0]))
-
 /** the lookup table for Proj(Start) names */
 static const pns_lookup_t start_lut[] = {
 #define X(a)    { pn_Start_##a, #a }
@@ -1107,7 +1106,7 @@ static const pns_lookup_t bound_lut[] = {
 
 /** the Proj lookup table */
 static const proj_lookup_t proj_lut[] = {
-#define E(a)  ARR_SIZE(a), a
+#define E(a)  ARRAY_SIZE(a), a
        { iro_Start,   E(start_lut) },
        { iro_Cond,    E(cond_lut) },
        { iro_Call,    E(call_lut) },
@@ -1162,7 +1161,7 @@ handle_lut:
                else {
                        unsigned i, j, f = 0;
 
-                       for (i = 0; i < ARR_SIZE(proj_lut); ++i) {
+                       for (i = 0; i < ARRAY_SIZE(proj_lut); ++i) {
                                if (code == proj_lut[i].code) {
                                        for (j = 0; j < proj_lut[i].num_data; ++j) {
                                                if (proj_nr == proj_lut[i].data[j].nr) {
index 9157301..f06b815 100644 (file)
 #include "dbginfo_t.h"
 #include "irhooks.h"
 #include "firmstat.h"
-
-/* This file contains makros that generate the calls to
-   update the debug information after a transformation. */
-#define SIZ(x)  sizeof(x)/sizeof(x[0])
+#include "util.h"
 
 /**
  * Merge the debug info due to dead block elimination.
  * @param oldn  the old block
  * @param n     the new block the merges with oldn
  */
-#define DBG_OPT_STG(oldn, n)                                   \
-       do {                                                       \
-         ir_node *ons[2];                                         \
-         ons[0] = oldn;                                           \
-         ons[1] = get_Block_cfgpred(oldn, 0);                     \
-         hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_STG);    \
-         __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_straightening); \
+#define DBG_OPT_STG(oldn, n)                                                 \
+       do {                                                                     \
+         ir_node *ons[2];                                                       \
+         ons[0] = oldn;                                                         \
+         ons[1] = get_Block_cfgpred(oldn, 0);                                   \
+         hook_merge_nodes(&n, 1, ons, ARRAY_SIZE(ons), HOOK_OPT_STG);           \
+         __dbg_info_merge_sets(&n, 1, ons, ARRAY_SIZE(ons), dbg_straightening); \
        } while(0)
 
 /**
  * @param proj2  the second ProjX predecessor
  * @param n      the new Block
  */
-#define DBG_OPT_IFSIM1(oldn, proj1, proj2, n)                     \
-       do {                                                          \
-         ir_node *ons[4];                                            \
-         ons[0] = oldn;                                              \
-         ons[1] = proj1;                                             \
-         ons[2] = proj2;                                             \
-         ons[3] = get_Proj_pred(proj1);                              \
-         hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_IFSIM);     \
-         __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_if_simplification); \
+#define DBG_OPT_IFSIM1(oldn, proj1, proj2, n)                        \
+       do {                                                             \
+         ir_node *ons[4];                                               \
+         ons[0] = oldn;                                                 \
+         ons[1] = proj1;                                                \
+         ons[2] = proj2;                                                \
+         ons[3] = get_Proj_pred(proj1);                                 \
+         hook_merge_nodes(&n, 1, ons, ARRAY_SIZE(ons), HOOK_OPT_IFSIM); \
+         __dbg_info_merge_sets(&n, 1, ons, ARRAY_SIZE(ons), dbg_if_simplification); \
        } while(0)
 
 /**
          ons[0] = oldn;                                              \
          ons[1] = a;                                                 \
          ons[2] = b;                                                 \
-         hook_merge_nodes(&n, 1, ons, SIZ(ons), flag);               \
-         __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_algebraic_simplification); \
+         hook_merge_nodes(&n, 1, ons, ARRAY_SIZE(ons), flag);        \
+         __dbg_info_merge_sets(&n, 1, ons, ARRAY_SIZE(ons), dbg_algebraic_simplification); \
        } while(0)
 
 /**
          ons[0] = oldn;                                              \
          ons[1] = pred;                                              \
          ons[2] = n;                                                 \
-         hook_merge_nodes(&n, 1, ons, SIZ(ons), flag);               \
-         __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_algebraic_simplification); \
+         hook_merge_nodes(&n, 1, ons, ARRAY_SIZE(ons), flag);        \
+         __dbg_info_merge_sets(&n, 1, ons, ARRAY_SIZE(ons), dbg_algebraic_simplification); \
        } while(0)
 
 /**
          ir_node *ons[2];                                            \
          ons[0] = oldn;                                              \
          ons[1] = a;                                                 \
-         hook_merge_nodes(&n, 1, ons, SIZ(ons), flag);               \
-         __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_algebraic_simplification); \
+         hook_merge_nodes(&n, 1, ons, ARRAY_SIZE(ons), flag);        \
+         __dbg_info_merge_sets(&n, 1, ons, ARRAY_SIZE(ons), dbg_algebraic_simplification); \
        } while(0)
 
 /**
  * @param oldst  the old store that will be removed
  * @param st     the other store that overwrites oldst
  */
-#define DBG_OPT_WAW(oldst, st)                                    \
-       do {                                                          \
-         ir_node *ons[2];                                            \
-         ons[0] = oldst;                                             \
-         ons[1] = st;                                                \
-         hook_merge_nodes(&st, 1, ons, SIZ(ons), HOOK_OPT_WAW);      \
-         __dbg_info_merge_sets(&st, 1, ons, SIZ(ons), dbg_write_after_write); \
+#define DBG_OPT_WAW(oldst, st)                                      \
+       do {                                                            \
+         ir_node *ons[2];                                              \
+         ons[0] = oldst;                                               \
+         ons[1] = st;                                                  \
+         hook_merge_nodes(&st, 1, ons, ARRAY_SIZE(ons), HOOK_OPT_WAW); \
+         __dbg_info_merge_sets(&st, 1, ons, ARRAY_SIZE(ons), dbg_write_after_write); \
        } while(0)
 
 /**
  * @param store  the store that will be removed
  * @param load   the load that produces the value that store will write back
  */
-#define DBG_OPT_WAR(store, load)                                  \
-       do {                                                          \
-         ir_node *ons[2];                                            \
-         ons[0] = store;                                             \
-         ons[1] = load;                                              \
-         hook_merge_nodes(&load, 1, ons, SIZ(ons), HOOK_OPT_WAR);    \
-         __dbg_info_merge_sets(&load, 1, ons, SIZ(ons), dbg_write_after_read); \
+#define DBG_OPT_WAR(store, load)                                      \
+       do {                                                              \
+         ir_node *ons[2];                                                \
+         ons[0] = store;                                                 \
+         ons[1] = load;                                                  \
+         hook_merge_nodes(&load, 1, ons, ARRAY_SIZE(ons), HOOK_OPT_WAR); \
+         __dbg_info_merge_sets(&load, 1, ons, ARRAY_SIZE(ons), dbg_write_after_read); \
        } while(0)
 
 /**
  * @param load   the load that will be replaced
  * @param value  the value that will replace the load
  */
-#define DBG_OPT_RAW(load, value)                                  \
-       do {                                                          \
-         ir_node *ons[2];                                            \
-         ons[0] = load;                                              \
-         ons[1] = value;                                             \
-         hook_merge_nodes(&value, 1, ons, SIZ(ons), HOOK_OPT_RAW);   \
-         __dbg_info_merge_sets(&value, 1, ons, SIZ(ons), dbg_read_after_write); \
+#define DBG_OPT_RAW(load, value)                                       \
+       do {                                                               \
+         ir_node *ons[2];                                                 \
+         ons[0] = load;                                                   \
+         ons[1] = value;                                                  \
+         hook_merge_nodes(&value, 1, ons, ARRAY_SIZE(ons), HOOK_OPT_RAW); \
+         __dbg_info_merge_sets(&value, 1, ons, ARRAY_SIZE(ons), dbg_read_after_write); \
        } while(0)
 
 /**
  * @param oldld  the old load that can be replaced
  * @param ld     the load that produces the same values
  */
-#define DBG_OPT_RAR(oldld, ld)                                    \
-       do {                                                          \
-         ir_node *ons[2];                                            \
-         ons[0] = oldld;                                             \
-         ons[1] = ld;                                                \
-         hook_merge_nodes(&ld, 1, ons, SIZ(ons), HOOK_OPT_RAR);      \
-         __dbg_info_merge_sets(&ld, 1, ons, SIZ(ons), dbg_read_after_read); \
+#define DBG_OPT_RAR(oldld, ld)                                      \
+       do {                                                            \
+         ir_node *ons[2];                                              \
+         ons[0] = oldld;                                               \
+         ons[1] = ld;                                                  \
+         hook_merge_nodes(&ld, 1, ons, ARRAY_SIZE(ons), HOOK_OPT_RAR); \
+         __dbg_info_merge_sets(&ld, 1, ons, ARRAY_SIZE(ons), dbg_read_after_read); \
        } while(0)
 
 /**
          ir_node *ons[2];                                            \
          ons[0] = ld;                                                \
          ons[1] = c;                                                 \
-         hook_merge_nodes(&c, 1, ons, SIZ(ons), HOOK_OPT_RC);        \
-         __dbg_info_merge_sets(&ld, 1, ons, SIZ(ons), dbg_read_a_const); \
+         hook_merge_nodes(&c, 1, ons, ARRAY_SIZE(ons), HOOK_OPT_RC); \
+         __dbg_info_merge_sets(&ld, 1, ons, ARRAY_SIZE(ons), dbg_read_a_const); \
        } while(0)
 
 /**
  * @param tuple  the Tuple node
  * @param n      the Proj(Tuple) value
  */
-#define DBG_OPT_TUPLE(proj, tuple, n)                             \
-       do {                                                          \
-         ir_node *ons[3];                                            \
-         ons[0] = proj;                                              \
-         ons[1] = tuple;                                             \
-         ons[2] = n;                                                 \
-         hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_TUPLE);     \
-         __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_opt_auxnode);      \
+#define DBG_OPT_TUPLE(proj, tuple, n)                                      \
+       do {                                                                   \
+         ir_node *ons[3];                                                     \
+         ons[0] = proj;                                                       \
+         ons[1] = tuple;                                                      \
+         ons[2] = n;                                                          \
+         hook_merge_nodes(&n, 1, ons, ARRAY_SIZE(ons), HOOK_OPT_TUPLE);       \
+         __dbg_info_merge_sets(&n, 1, ons, ARRAY_SIZE(ons), dbg_opt_auxnode); \
        } while(0)
 
 /**
  * @param id  the Id node
  * @param n   the predecessor
  */
-#define DBG_OPT_ID(id, n)                                         \
-       do {                                                          \
-         ir_node *ons[2];                                            \
-         ons[0] = id;                                                \
-         ons[1] = n;                                                 \
-         hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_ID);        \
-         __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_opt_auxnode);      \
+#define DBG_OPT_ID(id, n)                                                  \
+       do {                                                                   \
+         ir_node *ons[2];                                                     \
+         ons[0] = id;                                                         \
+         ons[1] = n;                                                          \
+         hook_merge_nodes(&n, 1, ons, ARRAY_SIZE(ons), HOOK_OPT_ID);          \
+         __dbg_info_merge_sets(&n, 1, ons, ARRAY_SIZE(ons), dbg_opt_auxnode); \
        } while(0)
 
 /**
  * @param oldn  the old node
  * @param n     the node that replaces oldn
  */
-#define DBG_OPT_CSE(oldn, n)                                      \
-       do {                                                          \
-         ir_node *ons[2];                                            \
-         ons[0] = oldn;                                              \
-         ons[1] = n;                                                 \
-         hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_CSE);       \
-         __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_opt_cse);   \
+#define DBG_OPT_CSE(oldn, n)                                           \
+       do {                                                               \
+         ir_node *ons[2];                                                 \
+         ons[0] = oldn;                                                   \
+         ons[1] = n;                                                      \
+         hook_merge_nodes(&n, 1, ons, ARRAY_SIZE(ons), HOOK_OPT_CSE);     \
+         __dbg_info_merge_sets(&n, 1, ons, ARRAY_SIZE(ons), dbg_opt_cse); \
        } while(0)
 
 /**
  * @param sel   the Sel node that will be replaced.
  * @param c     the constant node that replaces sel
  */
-#define DBG_OPT_POLY(sel, c)                                          \
-       do {                                                              \
-         ir_node *ons[3];                                                \
-         ons[0] = sel;                                                   \
-         ons[1] = skip_Proj(get_Sel_ptr(sel));                           \
-         ons[2] = c;                                                     \
-         hook_merge_nodes(&c, 1, ons, SIZ(ons), HOOK_OPT_POLY_CALL);     \
-         __dbg_info_merge_sets(&c, 1, ons, SIZ(ons), dbg_rem_poly_call); \
+#define DBG_OPT_POLY(sel, c)                                                 \
+       do {                                                                     \
+         ir_node *ons[3];                                                       \
+         ons[0] = sel;                                                          \
+         ons[1] = skip_Proj(get_Sel_ptr(sel));                                  \
+         ons[2] = c;                                                            \
+         hook_merge_nodes(&c, 1, ons, ARRAY_SIZE(ons), HOOK_OPT_POLY_CALL);     \
+         __dbg_info_merge_sets(&c, 1, ons, ARRAY_SIZE(ons), dbg_rem_poly_call); \
        } while(0)
 
 /**
index ce2f1ca..11473fa 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "firmstat_t.h"
 #include "tv_t.h"
+#include "util.h"
 
 /**
  * calculated the dual logarithm of |value|
@@ -117,8 +118,8 @@ void stat_update_const(stat_info_t *status, ir_node *node, graph_entry_t *graph)
 
                bits = log2abs(get_tarval_long(tv));
 
-               if (bits > ARR_SIZE(status->const_info.int_bits_count))
-                       bits = ARR_SIZE(status->const_info.int_bits_count);
+               if (bits > ARRAY_SIZE(status->const_info.int_bits_count))
+                       bits = ARRAY_SIZE(status->const_info.int_bits_count);
 
                cnt_inc(&status->const_info.int_bits_count[bits]);
        } else if (mode_is_float(mode)) {
@@ -136,10 +137,10 @@ void stat_const_clear(stat_info_t *status)
 {
        size_t i;
 
-       for (i = 0; i < ARR_SIZE(status->const_info.int_bits_count); ++i)
+       for (i = 0; i < ARRAY_SIZE(status->const_info.int_bits_count); ++i)
                cnt_clr(&status->const_info.int_bits_count[i]);
 
-       for (i = 0; i < ARR_SIZE(status->const_info.floats); ++i)
+       for (i = 0; i < ARRAY_SIZE(status->const_info.floats); ++i)
                cnt_clr(&status->const_info.floats[i]);
 
        cnt_clr(&status->const_info.others);
index 8ae906b..6b2906d 100644 (file)
@@ -41,6 +41,7 @@
 #include "stat_dmp.h"
 #include "xmalloc.h"
 #include "irhooks.h"
+#include "util.h"
 
 /*
  * need this to be static:
@@ -2232,7 +2233,7 @@ void stat_dump_snapshot(const char *name, const char *phase)
                stat_dump_param_tbl(status->dist_param_cnt, global);
 
                /* dump the optimization counter and clear them */
-               stat_dump_opt_cnt(status->num_opts, ARR_SIZE(status->num_opts));
+               stat_dump_opt_cnt(status->num_opts, ARRAY_SIZE(status->num_opts));
                clear_optimization_counter();
 
                stat_dump_finish();
index 60b2288..e096aa2 100644 (file)
@@ -38,9 +38,6 @@
 #include "counter.h"
 #include "irhooks.h"
 
-/* some useful macro. */
-#define ARR_SIZE(a)   (sizeof(a)/sizeof((a)[0]))
-
 /*
  * just be make some things clear :-), the
  * poor man "generics"
index 9ccceaa..fd03565 100644 (file)
@@ -28,6 +28,7 @@
 #include "stat_dmp.h"
 #include "irtools.h"
 #include "irhooks.h"
+#include "util.h"
 
 /**
  * names of the optimizations
@@ -234,7 +235,7 @@ static void simple_dump_opcode_hash(dumper_t *dmp, pset *set)
  */
 static const char *get_opt_name(int index)
 {
-       assert(index < (int) ARR_SIZE(opt_names) && "index out of range");
+       assert(index < (int) ARRAY_SIZE(opt_names) && "index out of range");
        assert((int) opt_names[index].kind == index && "opt_names broken");
        return opt_names[index].name;
 }  /* get_opt_name */
@@ -624,7 +625,7 @@ static void simple_dump_const_tbl(dumper_t *dmp, const constant_info_t *tbl)
        fprintf(dmp->f, "\nBit usage for integer constants\n");
        fprintf(dmp->f, "-------------------------------\n");
 
-       for (i = 0; i < ARR_SIZE(tbl->int_bits_count); ++i) {
+       for (i = 0; i < ARRAY_SIZE(tbl->int_bits_count); ++i) {
                fprintf(dmp->f, "%5u %12u\n", (unsigned) (i + 1), cnt_to_uint(&tbl->int_bits_count[i]));
                cnt_add(&sum, &tbl->int_bits_count[i]);
        }  /* for */
@@ -632,7 +633,7 @@ static void simple_dump_const_tbl(dumper_t *dmp, const constant_info_t *tbl)
 
        fprintf(dmp->f, "\nFloating point constants classification\n");
        fprintf(dmp->f, "--------------------------------------\n");
-       for (i = 0; i < ARR_SIZE(tbl->floats); ++i) {
+       for (i = 0; i < ARRAY_SIZE(tbl->floats); ++i) {
                fprintf(dmp->f, "%-10s %12u\n", stat_fc_name(i), cnt_to_uint(&tbl->floats[i]));
                cnt_add(&sum, &tbl->floats[i]);
        }  /* for */