[Mesa-dev] [PATCH 4/5] glsl: Remove ir_call::get_callee() and set_callee().

Kenneth Graunke kenneth at whitecape.org
Tue Sep 20 18:28:18 PDT 2011


Previously, set_callee() performed some assertions about the type of the
ir_call; protecting the bare pointer ensured these checks would be run.

However, ir_call no longer has a type, so the getter and setter methods
don't actually do anything useful.  Remove them in favor of accessing
callee directly, as is done with most other fields in our IR.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 src/glsl/ir.cpp                            |    5 -----
 src/glsl/ir.h                              |   20 +++++---------------
 src/glsl/ir_clone.cpp                      |    4 ++--
 src/glsl/ir_function_can_inline.cpp        |    2 +-
 src/glsl/ir_function_detect_recursion.cpp  |    2 +-
 src/glsl/ir_validate.cpp                   |    2 +-
 src/glsl/link_functions.cpp                |    6 +++---
 src/glsl/linker.cpp                        |    2 +-
 src/glsl/opt_constant_folding.cpp          |    2 +-
 src/glsl/opt_constant_propagation.cpp      |    2 +-
 src/glsl/opt_constant_variable.cpp         |    2 +-
 src/glsl/opt_copy_propagation.cpp          |    2 +-
 src/glsl/opt_copy_propagation_elements.cpp |    2 +-
 src/glsl/opt_dead_functions.cpp            |    2 +-
 src/glsl/opt_tree_grafting.cpp             |    2 +-
 src/mesa/program/ir_to_mesa.cpp            |    2 +-
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp |    2 +-
 17 files changed, 23 insertions(+), 38 deletions(-)

diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp
index 92a7601..63dfcd8 100644
--- a/src/glsl/ir.cpp
+++ b/src/glsl/ir.cpp
@@ -1455,11 +1455,6 @@ ir_function::has_user_signature()
    return false;
 }
 
-void
-ir_call::set_callee(ir_function_signature *sig)
-{
-   this->callee = sig;
-}
 
 void
 visit_exec_list(exec_list *list, ir_visitor *visitor)
diff --git a/src/glsl/ir.h b/src/glsl/ir.h
index 11deaf6..96b900e 100644
--- a/src/glsl/ir.h
+++ b/src/glsl/ir.h
@@ -1026,19 +1026,6 @@ public:
    }
 
    /**
-    * Get the function signature bound to this function call
-    */
-   ir_function_signature *get_callee()
-   {
-      return callee;
-   }
-
-   /**
-    * Set the function call target
-    */
-   void set_callee(ir_function_signature *sig);
-
-   /**
     * Generates an inline version of the function before @ir,
     * storing the return value in return_deref.
     */
@@ -1050,6 +1037,11 @@ public:
     */
    ir_dereference *return_deref;
 
+   /**
+    * The specific function signature being called.
+    */
+   ir_function_signature *callee;
+
    /* List of ir_rvalue of paramaters passed in this call. */
    exec_list actual_parameters;
 
@@ -1062,8 +1054,6 @@ private:
    {
       this->ir_type = ir_type_call;
    }
-
-   ir_function_signature *callee;
 };
 
 
diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp
index 3993ff3..7caebad 100644
--- a/src/glsl/ir_clone.cpp
+++ b/src/glsl/ir_clone.cpp
@@ -389,9 +389,9 @@ public:
        * table.  If it is found, replace it with the value from the table.
        */
       ir_function_signature *sig =
-	 (ir_function_signature *) hash_table_find(this->ht, ir->get_callee());
+	 (ir_function_signature *) hash_table_find(this->ht, ir->callee);
       if (sig != NULL)
-	 ir->set_callee(sig);
+	 ir->callee = sig;
 
       /* Since this may be used before function call parameters are flattened,
        * the children also need to be processed.
diff --git a/src/glsl/ir_function_can_inline.cpp b/src/glsl/ir_function_can_inline.cpp
index c367c30..7b15d5d 100644
--- a/src/glsl/ir_function_can_inline.cpp
+++ b/src/glsl/ir_function_can_inline.cpp
@@ -59,7 +59,7 @@ bool
 can_inline(ir_call *call)
 {
    ir_function_can_inline_visitor v;
-   const ir_function_signature *callee = call->get_callee();
+   const ir_function_signature *callee = call->callee;
    if (!callee->is_defined)
       return false;
 
diff --git a/src/glsl/ir_function_detect_recursion.cpp b/src/glsl/ir_function_detect_recursion.cpp
index 890bc45..0a5e647 100644
--- a/src/glsl/ir_function_detect_recursion.cpp
+++ b/src/glsl/ir_function_detect_recursion.cpp
@@ -217,7 +217,7 @@ public:
       if (this->current == NULL)
 	 return visit_continue;
 
-      function *const target = this->get_function(call->get_callee());
+      function *const target = this->get_function(call->callee);
 
       /* Create a link from the caller to the callee.
        */
diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp
index 848305c..7ea878b 100644
--- a/src/glsl/ir_validate.cpp
+++ b/src/glsl/ir_validate.cpp
@@ -535,7 +535,7 @@ ir_validate::visit_enter(ir_assignment *ir)
 ir_visitor_status
 ir_validate::visit_enter(ir_call *ir)
 {
-   ir_function_signature *const callee = ir->get_callee();
+   ir_function_signature *const callee = ir->callee;
 
    if (callee->return_type != glsl_type::void_type) {
       if (ir->return_deref == NULL) {
diff --git a/src/glsl/link_functions.cpp b/src/glsl/link_functions.cpp
index acee327..6b3e154 100644
--- a/src/glsl/link_functions.cpp
+++ b/src/glsl/link_functions.cpp
@@ -68,7 +68,7 @@ public:
        * Doing so will modify the original shader.  This may prevent that
        * shader from being linkable in other programs.
        */
-      const ir_function_signature *const callee = ir->get_callee();
+      const ir_function_signature *const callee = ir->callee;
       assert(callee != NULL);
       const char *const name = callee->function_name();
 
@@ -79,7 +79,7 @@ public:
 	 find_matching_signature(name, &callee->parameters, &linked, 1,
 				 ir->use_builtin);
       if (sig != NULL) {
-	 ir->set_callee(sig);
+	 ir->callee = sig;
 	 return visit_continue;
       }
 
@@ -168,7 +168,7 @@ public:
        */
       linked_sig->accept(this);
 
-      ir->set_callee(linked_sig);
+      ir->callee = linked_sig;
 
       return visit_continue;
    }
diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index 1606a67..73ba11c 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -101,7 +101,7 @@ public:
 
    virtual ir_visitor_status visit_enter(ir_call *ir)
    {
-      exec_list_iterator sig_iter = ir->get_callee()->parameters.iterator();
+      exec_list_iterator sig_iter = ir->callee->parameters.iterator();
       foreach_iter(exec_list_iterator, iter, *ir) {
 	 ir_rvalue *param_rval = (ir_rvalue *)iter.get();
 	 ir_variable *sig_param = (ir_variable *)sig_iter.get();
diff --git a/src/glsl/opt_constant_folding.cpp b/src/glsl/opt_constant_folding.cpp
index db8cd5c..dcad599 100644
--- a/src/glsl/opt_constant_folding.cpp
+++ b/src/glsl/opt_constant_folding.cpp
@@ -118,7 +118,7 @@ ir_visitor_status
 ir_constant_folding_visitor::visit_enter(ir_call *ir)
 {
    /* Attempt to constant fold parameters */
-   exec_list_iterator sig_iter = ir->get_callee()->parameters.iterator();
+   exec_list_iterator sig_iter = ir->callee->parameters.iterator();
    foreach_iter(exec_list_iterator, iter, *ir) {
       ir_rvalue *param_rval = (ir_rvalue *)iter.get();
       ir_variable *sig_param = (ir_variable *)sig_iter.get();
diff --git a/src/glsl/opt_constant_propagation.cpp b/src/glsl/opt_constant_propagation.cpp
index af77e49..d381263 100644
--- a/src/glsl/opt_constant_propagation.cpp
+++ b/src/glsl/opt_constant_propagation.cpp
@@ -259,7 +259,7 @@ ir_visitor_status
 ir_constant_propagation_visitor::visit_enter(ir_call *ir)
 {
    /* Do constant propagation on call parameters, but skip any out params */
-   exec_list_iterator sig_param_iter = ir->get_callee()->parameters.iterator();
+   exec_list_iterator sig_param_iter = ir->callee->parameters.iterator();
    foreach_iter(exec_list_iterator, iter, ir->actual_parameters) {
       ir_variable *sig_param = (ir_variable *)sig_param_iter.get();
       ir_rvalue *param = (ir_rvalue *)iter.get();
diff --git a/src/glsl/opt_constant_variable.cpp b/src/glsl/opt_constant_variable.cpp
index 18c2801..f3bc867 100644
--- a/src/glsl/opt_constant_variable.cpp
+++ b/src/glsl/opt_constant_variable.cpp
@@ -128,7 +128,7 @@ ir_visitor_status
 ir_constant_variable_visitor::visit_enter(ir_call *ir)
 {
    /* Mark any out parameters as assigned to */
-   exec_list_iterator sig_iter = ir->get_callee()->parameters.iterator();
+   exec_list_iterator sig_iter = ir->callee->parameters.iterator();
    foreach_iter(exec_list_iterator, iter, *ir) {
       ir_rvalue *param_rval = (ir_rvalue *)iter.get();
       ir_variable *param = (ir_variable *)sig_iter.get();
diff --git a/src/glsl/opt_copy_propagation.cpp b/src/glsl/opt_copy_propagation.cpp
index efa3afd..923619d 100644
--- a/src/glsl/opt_copy_propagation.cpp
+++ b/src/glsl/opt_copy_propagation.cpp
@@ -181,7 +181,7 @@ ir_visitor_status
 ir_copy_propagation_visitor::visit_enter(ir_call *ir)
 {
    /* Do copy propagation on call parameters, but skip any out params */
-   exec_list_iterator sig_param_iter = ir->get_callee()->parameters.iterator();
+   exec_list_iterator sig_param_iter = ir->callee->parameters.iterator();
    foreach_iter(exec_list_iterator, iter, ir->actual_parameters) {
       ir_variable *sig_param = (ir_variable *)sig_param_iter.get();
       ir_instruction *ir = (ir_instruction *)iter.get();
diff --git a/src/glsl/opt_copy_propagation_elements.cpp b/src/glsl/opt_copy_propagation_elements.cpp
index a91e624..894bf3f 100644
--- a/src/glsl/opt_copy_propagation_elements.cpp
+++ b/src/glsl/opt_copy_propagation_elements.cpp
@@ -278,7 +278,7 @@ ir_visitor_status
 ir_copy_propagation_elements_visitor::visit_enter(ir_call *ir)
 {
    /* Do copy propagation on call parameters, but skip any out params */
-   exec_list_iterator sig_param_iter = ir->get_callee()->parameters.iterator();
+   exec_list_iterator sig_param_iter = ir->callee->parameters.iterator();
    foreach_iter(exec_list_iterator, iter, ir->actual_parameters) {
       ir_variable *sig_param = (ir_variable *)sig_param_iter.get();
       ir_instruction *ir = (ir_instruction *)iter.get();
diff --git a/src/glsl/opt_dead_functions.cpp b/src/glsl/opt_dead_functions.cpp
index 51c77e3..017a286 100644
--- a/src/glsl/opt_dead_functions.cpp
+++ b/src/glsl/opt_dead_functions.cpp
@@ -103,7 +103,7 @@ ir_dead_functions_visitor::visit_enter(ir_function_signature *ir)
 ir_visitor_status
 ir_dead_functions_visitor::visit_enter(ir_call *ir)
 {
-   signature_entry *entry = this->get_signature_entry(ir->get_callee());
+   signature_entry *entry = this->get_signature_entry(ir->callee);
 
    entry->used = true;
 
diff --git a/src/glsl/opt_tree_grafting.cpp b/src/glsl/opt_tree_grafting.cpp
index 22a1749..d01bda4 100644
--- a/src/glsl/opt_tree_grafting.cpp
+++ b/src/glsl/opt_tree_grafting.cpp
@@ -188,7 +188,7 @@ ir_tree_grafting_visitor::visit_enter(ir_function_signature *ir)
 ir_visitor_status
 ir_tree_grafting_visitor::visit_enter(ir_call *ir)
 {
-   exec_list_iterator sig_iter = ir->get_callee()->parameters.iterator();
+   exec_list_iterator sig_iter = ir->callee->parameters.iterator();
    /* Reminder: iterating ir_call iterates its parameters. */
    foreach_iter(exec_list_iterator, iter, *ir) {
       ir_variable *sig_param = (ir_variable *)sig_iter.get();
diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index 5e565e4..eae463e 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -2020,7 +2020,7 @@ void
 ir_to_mesa_visitor::visit(ir_call *ir)
 {
    ir_to_mesa_instruction *call_inst;
-   ir_function_signature *sig = ir->get_callee();
+   ir_function_signature *sig = ir->callee;
    function_entry *entry = get_function_signature(sig);
    int i;
 
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index f68270d..9c970ed 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -2460,7 +2460,7 @@ void
 glsl_to_tgsi_visitor::visit(ir_call *ir)
 {
    glsl_to_tgsi_instruction *call_inst;
-   ir_function_signature *sig = ir->get_callee();
+   ir_function_signature *sig = ir->callee;
    function_entry *entry = get_function_signature(sig);
    int i;
 
-- 
1.7.6.1



More information about the mesa-dev mailing list