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

Kenneth Graunke kenneth at whitecape.org
Wed Mar 28 20:33:07 PDT 2012


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                              |   21 +++++----------------
 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/lower_clip_distance.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 +-
 18 files changed, 24 insertions(+), 40 deletions(-)

diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp
index 3595e74..1ba8751 100644
--- a/src/glsl/ir.cpp
+++ b/src/glsl/ir.cpp
@@ -1467,11 +1467,6 @@ ir_rvalue::error_value(void *mem_ctx)
    return v;
 }
 
-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 054e2ac..6adfaa3 100644
--- a/src/glsl/ir.h
+++ b/src/glsl/ir.h
@@ -1072,19 +1072,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.
     */
@@ -1096,14 +1083,16 @@ public:
     */
    ir_dereference_variable *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;
 
    /** Should this call only bind to a built-in function? */
    bool use_builtin;
-
-private:
-   ir_function_signature *callee;
 };
 
 
diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp
index 8a9701c..26b0d8f 100644
--- a/src/glsl/ir_clone.cpp
+++ b/src/glsl/ir_clone.cpp
@@ -398,9 +398,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 385ef12..0803851 100644
--- a/src/glsl/ir_validate.cpp
+++ b/src/glsl/ir_validate.cpp
@@ -541,7 +541,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->ir_type != ir_type_function_signature) {
       printf("IR called by ir_call is not ir_function_signature!\n");
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 d56eb97..49b6b8f 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/lower_clip_distance.cpp b/src/glsl/lower_clip_distance.cpp
index 143e378..0316914 100644
--- a/src/glsl/lower_clip_distance.cpp
+++ b/src/glsl/lower_clip_distance.cpp
@@ -276,7 +276,7 @@ lower_clip_distance_visitor::visit_leave(ir_call *ir)
 {
    void *ctx = ralloc_parent(ir);
 
-   const exec_node *formal_param_node = ir->get_callee()->parameters.head;
+   const exec_node *formal_param_node = ir->callee->parameters.head;
    const exec_node *actual_param_node = ir->actual_parameters.head;
    while (!actual_param_node->is_tail_sentinel()) {
       ir_variable *formal_param = (ir_variable *) formal_param_node;
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 ebfd4fd..314db4e 100644
--- a/src/glsl/opt_copy_propagation_elements.cpp
+++ b/src/glsl/opt_copy_propagation_elements.cpp
@@ -288,7 +288,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 e70a224..d86eab8 100644
--- a/src/glsl/opt_tree_grafting.cpp
+++ b/src/glsl/opt_tree_grafting.cpp
@@ -202,7 +202,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 6a90d5a..697313f 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -2002,7 +2002,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 b022785..6745554 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -2439,7 +2439,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.7.6



More information about the mesa-dev mailing list