[Mesa-dev] [PATCH 06/13] i965 vs: Move the call to reg_allocate() inside of generate_code().

Paul Berry stereotype441 at gmail.com
Wed Nov 16 11:07:13 PST 2011


Previously, vec4_visitor::run() was responsible for calling
reg_allocate() right before generate_code().  However, since there is
no reason for run() to do any further manipulation of the instructions
between calling reg_allocate() and generate_code(), it's just as
simple to have generate_code() call reg_allocate().

This helps pave the way for separating the IR visiting parts of
vec4_visitor 9which include run()) from the code generation parts
(which include generate_code() and register_allocate()) by reducing
the number of function calls between the two parts.
---
 src/mesa/drivers/dri/i965/brw_vec4.h        |    2 +-
 src/mesa/drivers/dri/i965/brw_vec4_emit.cpp |   18 ++++++++++--------
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h b/src/mesa/drivers/dri/i965/brw_vec4.h
index c546235..3e30514 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.h
+++ b/src/mesa/drivers/dri/i965/brw_vec4.h
@@ -506,7 +506,7 @@ public:
    bool try_emit_sat(ir_expression *ir);
    void resolve_ud_negate(src_reg *reg);
 
-   void generate_code();
+   int generate_code(int first_non_payload_grf);
    void generate_vs_instruction(vec4_instruction *inst,
 				struct brw_reg dst,
 				struct brw_reg *src);
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp b/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp
index 81e7ab7..284cb86 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp
@@ -657,18 +657,13 @@ vec4_visitor::run()
       return false;
 
    int first_non_payload_grf = setup_payload();
-   prog_data->total_grf = reg_allocate(first_non_payload_grf);
-
-   if (failed)
-      return false;
-
-   generate_code();
+   prog_data->total_grf = generate_code(first_non_payload_grf);
 
    return !failed;
 }
 
-void
-vec4_visitor::generate_code()
+int
+vec4_visitor::generate_code(int first_non_payload_grf)
 {
    int last_native_inst = 0;
    const char *last_annotation_string = NULL;
@@ -683,6 +678,11 @@ vec4_visitor::generate_code()
 
    brw_set_access_mode(p, BRW_ALIGN_16);
 
+   int total_grf = reg_allocate(first_non_payload_grf);
+
+   if (failed)
+      return 0;
+
    if (unlikely(INTEL_DEBUG & DEBUG_VS)) {
       printf("Native code for vertex shader %d:\n", prog->Name);
    }
@@ -906,6 +906,8 @@ vec4_visitor::generate_code()
 	 }
       }
    }
+
+   return total_grf;
 }
 
 extern "C" {
-- 
1.7.6.4



More information about the mesa-dev mailing list