glsl: Convert ir_function_signature::is_builtin to a method.
authorKenneth Graunke <kenneth@whitecape.org>
Fri, 30 Aug 2013 23:12:55 +0000 (16:12 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Mon, 9 Sep 2013 18:46:51 +0000 (11:46 -0700)
A signature is a built-in if and only if builtin_info != NULL, so we
don't actually need a separate flag bit.  Making a boolean-valued
method allows existing code to ask the same question while not worrying
about the internal representation.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
src/glsl/ir.cpp
src/glsl/ir.h
src/glsl/ir_clone.cpp
src/glsl/ir_constant_expression.cpp
src/glsl/link_functions.cpp
src/glsl/linker.cpp

index ea018eb2d9ed19d11d78c83172d4ed550dc408f9..d9fb808c4b17ad721bd2b045925d69d2d2c8d9dc 100644 (file)
@@ -1585,11 +1585,17 @@ ir_function_signature::ir_function_signature(const glsl_type *return_type,
      _function(NULL)
 {
    this->ir_type = ir_type_function_signature;
-   this->is_builtin = builtin_info != NULL;
    this->origin = NULL;
 }
 
 
+bool
+ir_function_signature::is_builtin() const
+{
+   return builtin_info != NULL;
+}
+
+
 static bool
 modes_match(unsigned a, unsigned b)
 {
@@ -1661,7 +1667,7 @@ ir_function::has_user_signature()
 {
    foreach_list(n, &this->signatures) {
       ir_function_signature *const sig = (ir_function_signature *) n;
-      if (!sig->is_builtin)
+      if (!sig->is_builtin())
         return true;
    }
    return false;
index d785259cc868e7ff754c02b730138f24255c2fcf..a927e90ca1f24418d432644093af316c8e2863ef 100644 (file)
@@ -684,7 +684,7 @@ public:
    unsigned is_defined:1;
 
    /** Whether or not this function signature is a built-in. */
-   unsigned is_builtin:1;
+   bool is_builtin() const;
 
    /** Body of instructions in the function. */
    struct exec_list body;
@@ -1321,7 +1321,7 @@ public:
       ir_type = ir_type_call;
       assert(callee->return_type != NULL);
       actual_parameters->move_nodes_to(& this->actual_parameters);
-      this->use_builtin = callee->is_builtin;
+      this->use_builtin = callee->is_builtin();
    }
 
    virtual ir_call *clone(void *mem_ctx, struct hash_table *ht) const;
index 52e2fb54e416e4d2aa0f77990df21dcce3454eeb..a91afb7ac84c3d23cbeb91f4b5b57c40e9cacfaa 100644 (file)
@@ -329,7 +329,6 @@ ir_function_signature::clone_prototype(void *mem_ctx, struct hash_table *ht) con
       new(mem_ctx) ir_function_signature(this->return_type);
 
    copy->is_defined = false;
-   copy->is_builtin = this->is_builtin;
    copy->builtin_info = this->builtin_info;
    copy->origin = this;
 
index bf019b95577d3ca946136f7e2794d69fc3acd3ae..ec338a8348d7ac6015ee81fd86a650fa2f63047d 100644 (file)
@@ -1840,7 +1840,7 @@ ir_function_signature::constant_expression_value(exec_list *actual_parameters, s
     * "Function calls to user-defined functions (non-built-in functions)
     *  cannot be used to form constant expressions."
     */
-   if (!this->is_builtin)
+   if (!this->is_builtin())
       return NULL;
 
    /*
index dd6f2471630c913b8003cc375aa4281bd3b6aa86..c5398f5ff0416198361ccc5bdf60ffdaee691880 100644 (file)
@@ -116,7 +116,7 @@ public:
         f->exact_matching_signature(&callee->parameters);
       if ((linked_sig == NULL)
          || ((linked_sig != NULL)
-             && (linked_sig->is_builtin != ir->use_builtin))) {
+             && (linked_sig->is_builtin() != ir->use_builtin))) {
         linked_sig = new(linked) ir_function_signature(callee->return_type);
         f->add_signature(linked_sig);
       }
@@ -297,7 +297,7 @@ find_matching_signature(const char *name, const exec_list *actual_parameters,
        * signature that we found isn't a built-in, keep looking.  Also keep
        * looking if we expect a non-built-in but found a built-in.
        */
-      if (use_builtin != sig->is_builtin)
+      if (use_builtin != sig->is_builtin())
            continue;
 
       return sig;
index 8430096aca8722d9fe6e90fa8d79731d29c6da6e..350778a01c6da25bd7e9d786b5cfd4997e8aeb7a 100644 (file)
@@ -1163,14 +1163,14 @@ link_intrastage_shaders(void *mem_ctx,
               ir_function_signature *sig =
                  (ir_function_signature *) iter.get();
 
-              if (!sig->is_defined || sig->is_builtin)
+              if (!sig->is_defined || sig->is_builtin())
                  continue;
 
               ir_function_signature *other_sig =
                  other->exact_matching_signature(& sig->parameters);
 
               if ((other_sig != NULL) && other_sig->is_defined
-                  && !other_sig->is_builtin) {
+                  && !other_sig->is_builtin()) {
                  linker_error(prog, "function `%s' is multiply defined",
                               f->name);
                  return NULL;