Mesa (master): mesa: Add a macro to bitset for determining bitset size.

Eric Anholt anholt at kemper.freedesktop.org
Fri Apr 12 23:48:22 UTC 2013


Module: Mesa
Branch: master
Commit: df25b4f3cf22282b06e622f3cf1f5855b8f767a8
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=df25b4f3cf22282b06e622f3cf1f5855b8f767a8

Author: Eric Anholt <eric at anholt.net>
Date:   Thu Apr  4 09:47:03 2013 -0700

mesa: Add a macro to bitset for determining bitset size.

Reviewed-by: Matt Turner <mattst88 at gmail.com>

---

 .../drivers/dri/i965/brw_fs_copy_propagation.cpp   |    2 +-
 .../drivers/dri/i965/brw_fs_live_variables.cpp     |    3 +--
 src/mesa/main/bitset.h                             |    4 ++--
 src/mesa/program/register_allocate.c               |    2 +-
 4 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp b/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp
index 96c9b4e..36df759 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp
@@ -104,7 +104,7 @@ fs_copy_prop_dataflow::fs_copy_prop_dataflow(void *mem_ctx, cfg_t *cfg,
 
    acp = rzalloc_array(mem_ctx, struct acp_entry *, num_acp);
 
-   bitset_words = ALIGN(num_acp, BITSET_WORDBITS) / BITSET_WORDBITS;
+   bitset_words = BITSET_WORDS(num_acp);
 
    int next_acp = 0;
    for (int b = 0; b < cfg->num_blocks; b++) {
diff --git a/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp b/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp
index 373aa2d..ca60aa2 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp
@@ -142,8 +142,7 @@ fs_live_variables::fs_live_variables(fs_visitor *v, cfg_t *cfg)
    num_vars = v->virtual_grf_count;
    bd = rzalloc_array(mem_ctx, struct block_data, cfg->num_blocks);
 
-   bitset_words = (ALIGN(v->virtual_grf_count, BITSET_WORDBITS) /
-                   BITSET_WORDBITS);
+   bitset_words = BITSET_WORDS(v->virtual_grf_count);
    for (int i = 0; i < cfg->num_blocks; i++) {
       bd[i].def = rzalloc_array(mem_ctx, BITSET_WORD, bitset_words);
       bd[i].use = rzalloc_array(mem_ctx, BITSET_WORD, bitset_words);
diff --git a/src/mesa/main/bitset.h b/src/mesa/main/bitset.h
index 28b3c12..defb733 100644
--- a/src/mesa/main/bitset.h
+++ b/src/mesa/main/bitset.h
@@ -42,8 +42,8 @@
 
 /* bitset declarations
  */
-#define BITSET_DECLARE(name, size) \
-   BITSET_WORD name[((size) + BITSET_WORDBITS - 1) / BITSET_WORDBITS]
+#define BITSET_WORDS(bits) (ALIGN(bits, BITSET_WORDBITS) / BITSET_WORDBITS)
+#define BITSET_DECLARE(name, bits) BITSET_WORD name[BITSET_WORDS(bits)]
 
 /* bitset operations
  */
diff --git a/src/mesa/program/register_allocate.c b/src/mesa/program/register_allocate.c
index e276b8a..b8472a2 100644
--- a/src/mesa/program/register_allocate.c
+++ b/src/mesa/program/register_allocate.c
@@ -355,7 +355,7 @@ ra_alloc_interference_graph(struct ra_regs *regs, unsigned int count)
    g->stack = rzalloc_array(g, unsigned int, count);
 
    for (i = 0; i < count; i++) {
-      int bitset_count = ALIGN(count, BITSET_WORDBITS) / BITSET_WORDBITS;
+      int bitset_count = BITSET_WORDS(count);
       g->nodes[i].adjacency = rzalloc_array(g, BITSET_WORD, bitset_count);
 
       g->nodes[i].adjacency_list_size = 4;




More information about the mesa-commit mailing list