[Mesa-dev] [PATCH 07/30] i965/ir: Nest definition of live variables block_data structures.

Francisco Jerez currojerez at riseup.net
Mon Mar 14 03:47:11 UTC 2016


These two structures have exactly the same name which prevents the two
files from being included at the same time and could cause serious
trouble in the future if it ever leads to a (silent) violation of the
C++ one definition rule.
---
 src/mesa/drivers/dri/i965/brw_fs_live_variables.h  | 52 +++++++++++-----------
 .../drivers/dri/i965/brw_vec4_live_variables.cpp   |  3 +-
 .../drivers/dri/i965/brw_vec4_live_variables.h     | 51 ++++++++++-----------
 3 files changed, 54 insertions(+), 52 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs_live_variables.h b/src/mesa/drivers/dri/i965/brw_fs_live_variables.h
index 96cadea..882315a 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_live_variables.h
+++ b/src/mesa/drivers/dri/i965/brw_fs_live_variables.h
@@ -32,34 +32,34 @@ struct cfg_t;
 
 namespace brw {
 
-struct block_data {
-   /**
-    * Which variables are defined before being used in the block.
-    *
-    * Note that for our purposes, "defined" means unconditionally, completely
-    * defined.
-    */
-   BITSET_WORD *def;
-
-   /**
-    * Which variables are used before being defined in the block.
-    */
-   BITSET_WORD *use;
-
-   /** Which defs reach the entry point of the block. */
-   BITSET_WORD *livein;
-
-   /** Which defs reach the exit point of the block. */
-   BITSET_WORD *liveout;
-
-   BITSET_WORD flag_def[1];
-   BITSET_WORD flag_use[1];
-   BITSET_WORD flag_livein[1];
-   BITSET_WORD flag_liveout[1];
-};
-
 class fs_live_variables {
 public:
+   struct block_data {
+      /**
+       * Which variables are defined before being used in the block.
+       *
+       * Note that for our purposes, "defined" means unconditionally, completely
+       * defined.
+       */
+      BITSET_WORD *def;
+
+      /**
+       * Which variables are used before being defined in the block.
+       */
+      BITSET_WORD *use;
+
+      /** Which defs reach the entry point of the block. */
+      BITSET_WORD *livein;
+
+      /** Which defs reach the exit point of the block. */
+      BITSET_WORD *liveout;
+
+      BITSET_WORD flag_def[1];
+      BITSET_WORD flag_use[1];
+      BITSET_WORD flag_livein[1];
+      BITSET_WORD flag_liveout[1];
+   };
+
    DECLARE_RALLOC_CXX_OPERATORS(fs_live_variables)
 
    fs_live_variables(fs_visitor *v, const cfg_t *cfg);
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_live_variables.cpp b/src/mesa/drivers/dri/i965/brw_vec4_live_variables.cpp
index 57d5fbb..b4476ef 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_live_variables.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_live_variables.cpp
@@ -292,7 +292,8 @@ vec4_visitor::calculate_live_intervals()
    this->live_intervals = new(mem_ctx) vec4_live_variables(alloc, cfg);
 
    foreach_block (block, cfg) {
-      struct block_data *bd = &live_intervals->block_data[block->num];
+      const struct vec4_live_variables::block_data *bd =
+         &live_intervals->block_data[block->num];
 
       for (int i = 0; i < live_intervals->num_vars; i++) {
          if (BITSET_TEST(bd->livein, i)) {
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_live_variables.h b/src/mesa/drivers/dri/i965/brw_vec4_live_variables.h
index 12d281e..f55bed7 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_live_variables.h
+++ b/src/mesa/drivers/dri/i965/brw_vec4_live_variables.h
@@ -30,34 +30,35 @@
 
 namespace brw {
 
-struct block_data {
-   /**
-    * Which variables are defined before being used in the block.
-    *
-    * Note that for our purposes, "defined" means unconditionally, completely
-    * defined.
-    */
-   BITSET_WORD *def;
-
-   /**
-    * Which variables are used before being defined in the block.
-    */
-   BITSET_WORD *use;
-
-   /** Which defs reach the entry point of the block. */
-   BITSET_WORD *livein;
-
-   /** Which defs reach the exit point of the block. */
-   BITSET_WORD *liveout;
-
-   BITSET_WORD flag_def[1];
-   BITSET_WORD flag_use[1];
-   BITSET_WORD flag_livein[1];
-   BITSET_WORD flag_liveout[1];
-};
 
 class vec4_live_variables {
 public:
+   struct block_data {
+      /**
+       * Which variables are defined before being used in the block.
+       *
+       * Note that for our purposes, "defined" means unconditionally, completely
+       * defined.
+       */
+      BITSET_WORD *def;
+
+      /**
+       * Which variables are used before being defined in the block.
+       */
+      BITSET_WORD *use;
+
+      /** Which defs reach the entry point of the block. */
+      BITSET_WORD *livein;
+
+      /** Which defs reach the exit point of the block. */
+      BITSET_WORD *liveout;
+
+      BITSET_WORD flag_def[1];
+      BITSET_WORD flag_use[1];
+      BITSET_WORD flag_livein[1];
+      BITSET_WORD flag_liveout[1];
+   };
+
    DECLARE_RALLOC_CXX_OPERATORS(vec4_live_variables)
 
    vec4_live_variables(const simple_allocator &alloc, cfg_t *cfg);
-- 
2.7.0



More information about the mesa-dev mailing list