[Mesa-dev] [PATCH 08/15] i965/cfg: Remove ip & cur from brw_cfg.

Matt Turner mattst88 at gmail.com
Mon Dec 2 10:40:30 PST 2013


---
 src/mesa/drivers/dri/i965/brw_cfg.cpp | 33 ++++++++++++++++-----------------
 src/mesa/drivers/dri/i965/brw_cfg.h   | 10 +---------
 2 files changed, 17 insertions(+), 26 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_cfg.cpp b/src/mesa/drivers/dri/i965/brw_cfg.cpp
index b87a6be..9391b36 100644
--- a/src/mesa/drivers/dri/i965/brw_cfg.cpp
+++ b/src/mesa/drivers/dri/i965/brw_cfg.cpp
@@ -83,8 +83,9 @@ cfg_t::cfg_t(exec_list *instructions)
    block_list.make_empty();
    blocks = NULL;
    num_blocks = 0;
-   ip = 0;
-   cur = NULL;
+
+   bblock_t *cur = NULL;
+   int ip = 0;
 
    bblock_t *entry = new_block();
    bblock_t *cur_if = NULL, *cur_else = NULL, *cur_endif = NULL;
@@ -92,7 +93,7 @@ cfg_t::cfg_t(exec_list *instructions)
    exec_list if_stack, else_stack, do_stack, while_stack;
    bblock_t *next;
 
-   set_next_block(entry);
+   set_next_block(&cur, entry, ip);
 
    entry->start = (backend_instruction *) instructions->get_head();
 
@@ -123,7 +124,7 @@ cfg_t::cfg_t(exec_list *instructions)
 	 next->start = (backend_instruction *)inst->next;
 	 cur_if->add_successor(mem_ctx, next);
 
-	 set_next_block(next);
+	 set_next_block(&cur, next, ip);
 	 break;
 
       case BRW_OPCODE_ELSE:
@@ -133,7 +134,7 @@ cfg_t::cfg_t(exec_list *instructions)
 	 next->start = (backend_instruction *)inst->next;
 	 cur_if->add_successor(mem_ctx, next);
 
-	 set_next_block(next);
+	 set_next_block(&cur, next, ip);
 	 break;
 
       case BRW_OPCODE_ENDIF: {
@@ -156,9 +157,7 @@ cfg_t::cfg_t(exec_list *instructions)
             cur->end = prev_inst;
             cur->add_successor(mem_ctx, cur_endif);
 
-            ip--;
-            set_next_block(cur_endif);
-            ip++;
+            set_next_block(&cur, cur_endif, ip - 1);
             break;
          }
 
@@ -214,7 +213,7 @@ cfg_t::cfg_t(exec_list *instructions)
 	 cur->add_successor(mem_ctx, next);
 	 cur_do = next;
 
-	 set_next_block(next);
+	 set_next_block(&cur, next, ip);
 	 break;
 
       case BRW_OPCODE_CONTINUE:
@@ -225,7 +224,7 @@ cfg_t::cfg_t(exec_list *instructions)
 	 if (inst->predicate)
 	    cur->add_successor(mem_ctx, next);
 
-	 set_next_block(next);
+	 set_next_block(&cur, next, ip);
 	 break;
 
       case BRW_OPCODE_BREAK:
@@ -236,14 +235,14 @@ cfg_t::cfg_t(exec_list *instructions)
 	 if (inst->predicate)
 	    cur->add_successor(mem_ctx, next);
 
-	 set_next_block(next);
+	 set_next_block(&cur, next, ip);
 	 break;
 
       case BRW_OPCODE_WHILE:
 	 cur_while->start = (backend_instruction *)inst->next;
 
 	 cur->add_successor(mem_ctx, cur_do);
-	 set_next_block(cur_while);
+	 set_next_block(&cur, cur_while, ip);
 
 	 /* Pop the stack so we're in the previous loop */
 	 cur_do = pop_stack(&do_stack);
@@ -274,17 +273,17 @@ cfg_t::new_block()
 }
 
 void
-cfg_t::set_next_block(bblock_t *block)
+cfg_t::set_next_block(bblock_t **cur, bblock_t *block, int ip)
 {
-   if (cur) {
-      assert(cur->end->next == block->start);
-      cur->end_ip = ip - 1;
+   if (*cur) {
+      assert((*cur)->end->next == block->start);
+      (*cur)->end_ip = ip - 1;
    }
 
    block->start_ip = ip;
    block->block_num = num_blocks++;
    block_list.push_tail(new(mem_ctx) bblock_link(block));
-   cur = block;
+   *cur = block;
 }
 
 void
diff --git a/src/mesa/drivers/dri/i965/brw_cfg.h b/src/mesa/drivers/dri/i965/brw_cfg.h
index d0f091f..7bd3e24 100644
--- a/src/mesa/drivers/dri/i965/brw_cfg.h
+++ b/src/mesa/drivers/dri/i965/brw_cfg.h
@@ -77,19 +77,11 @@ public:
    ~cfg_t();
 
    bblock_t *new_block();
-   void set_next_block(bblock_t *block);
+   void set_next_block(bblock_t **cur, bblock_t *block, int ip);
    void make_block_array();
 
    void dump(backend_visitor *v);
 
-   /** @{
-    *
-    * Used while generating the block list.
-    */
-   bblock_t *cur;
-   int ip;
-   /** @} */
-
    void *mem_ctx;
 
    /** Ordered list (by ip) of basic blocks */
-- 
1.8.3.2



More information about the mesa-dev mailing list