glsl: Move is_built_in flag from ir_function_signature to ir_function.
authorKenneth Graunke <kenneth@whitecape.org>
Sat, 21 Aug 2010 03:04:39 +0000 (20:04 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Thu, 26 Aug 2010 16:19:48 +0000 (09:19 -0700)
Also rename it to "is_builtin" for consistency.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
src/glsl/ir.cpp
src/glsl/ir.h
src/glsl/ir_clone.cpp
src/glsl/ir_constant_expression.cpp
src/glsl/ir_import_prototypes.cpp
src/glsl/ir_print_visitor.cpp
src/glsl/ir_reader.cpp
src/glsl/linker.cpp

index 31e40cac8c69e4bea1407cf671d7ce3e70b0d0e4..8779ec73c9be2c05406ecc30efc964cd141f016f 100644 (file)
@@ -982,7 +982,6 @@ ir_function_signature::ir_function_signature(const glsl_type *return_type)
    : return_type(return_type), is_defined(false), _function(NULL)
 {
    this->ir_type = ir_type_function_signature;
-   this->is_built_in = false;
 }
 
 
@@ -1034,6 +1033,7 @@ ir_function::ir_function(const char *name)
 {
    this->ir_type = ir_type_function;
    this->name = talloc_strdup(this, name);
+   this->is_builtin = false;
 }
 
 
index 500b1524089ae1d906ba2aaf53fd8cd2ef8dbd48..0f887a9327e9570ff532ddf1acc287cd12a9e870 100644 (file)
@@ -342,9 +342,6 @@ public:
    /** Whether or not this function has a body (which may be empty). */
    unsigned is_defined:1;
 
-   /** Whether or not this function signature is a built-in. */
-   unsigned is_built_in:1;
-
    /** Body of instructions in the function. */
    struct exec_list body;
 
@@ -410,6 +407,9 @@ public:
     */
    const char *name;
 
+   /** Whether or not this function is a built-in. */
+   unsigned is_builtin:1;
+
    /**
     * List of ir_function_signature for each overloaded function with this name.
     */
index 0a9e25a295a3815f4e270bfef9a5f75bd48cbb8c..1d690a4da7c966c6544f2364110e371d8ff74205 100644 (file)
@@ -249,6 +249,8 @@ ir_function::clone(void *mem_ctx, struct hash_table *ht) const
 {
    ir_function *copy = new(mem_ctx) ir_function(this->name);
 
+   copy->is_builtin = this->is_builtin;
+
    foreach_list_const(node, &this->signatures) {
       const ir_function_signature *const sig =
         (const ir_function_signature *const) node;
@@ -271,7 +273,6 @@ ir_function_signature::clone(void *mem_ctx, struct hash_table *ht) const
       new(mem_ctx) ir_function_signature(this->return_type);
 
    copy->is_defined = this->is_defined;
-   copy->is_built_in = this->is_built_in;
 
    /* Clone the parameter list.
     */
index f1c175c97aaa8f1f2279fd1221d2ea4b951fe399..5ec60c522f51f7b4ed909fe0e2cbe7da1ab3b104 100644 (file)
@@ -785,7 +785,7 @@ ir_call::constant_expression_value()
     * "Function calls to user-defined functions (non-built-in functions)
     *  cannot be used to form constant expressions."
     */
-   if (!this->callee->is_built_in)
+   if (!this->callee->function()->is_builtin)
       return NULL;
 
    unsigned num_parameters = 0;
index e553e12a4914931004ec8e50dbbb7638a3e6b70b..a39b384071a326643c41a7982944172e9e5b9a67 100644 (file)
@@ -59,6 +59,7 @@ public:
       this->function = this->symbols->get_function(ir->name);
       if (!this->function) {
         this->function = new(this->mem_ctx) ir_function(ir->name);
+        this->function->is_builtin = ir->is_builtin;
 
         list->push_tail(this->function);
 
@@ -86,7 +87,6 @@ public:
         new(mem_ctx) ir_function_signature(ir->return_type);
 
       copy->is_defined = false;
-      copy->is_built_in = ir->is_built_in;
 
       /* Clone the parameter list, but NOT the body.
        */
index 83e640327233d5957f1c8ab996ad1abf7d278644..f47ad875506d3fee51db5917b8a10b208664fcdd 100644 (file)
@@ -153,14 +153,8 @@ void ir_print_visitor::visit(ir_function_signature *ir)
 
 void ir_print_visitor::visit(ir_function *ir)
 {
-   bool found_non_builtin_proto = false;
-
-   foreach_iter(exec_list_iterator, iter, *ir) {
-      ir_function_signature *const sig = (ir_function_signature *) iter.get();
-      if (sig->is_defined || !sig->is_built_in)
-        found_non_builtin_proto = true;
-   }
-   if (!found_non_builtin_proto)
+   /* Don't print built-in functions as part of the IR. */
+   if (ir->is_builtin)
       return;
 
    printf("(function %s\n", ir->name);
index 3e221c0e5ff91387516c9abaa32d02ca83349c2e..366db3277405cfb432a9f0e3351542d5eea944c4 100644 (file)
@@ -209,6 +209,7 @@ read_function(_mesa_glsl_parse_state *st, s_list *list, bool skip_body)
    ir_function *f = st->symbols->get_function(name->value());
    if (f == NULL) {
       f = new(ctx) ir_function(name->value());
+      f->is_builtin = true;
       added = st->symbols->add_function(f->name, f);
       assert(added);
    }
@@ -281,7 +282,6 @@ read_function_sig(_mesa_glsl_parse_state *st, ir_function *f, s_list *list,
    if (sig == NULL && skip_body) {
       /* If scanning for prototypes, generate a new signature. */
       sig = new(ctx) ir_function_signature(return_type);
-      sig->is_built_in = true;
       f->add_signature(sig);
    } else if (sig != NULL) {
       const char *badvar = sig->qualifiers_match(&hir_parameters);
index 0348bd01e849ec3ab6e60e368cd59eef7d103c2b..3de069b53123bdbc69a7f2e68f16438b280ee0da 100644 (file)
@@ -726,14 +726,14 @@ link_intrastage_shaders(GLcontext *ctx,
               ir_function_signature *sig =
                  (ir_function_signature *) iter.get();
 
-              if (!sig->is_defined || sig->is_built_in)
+              if (!sig->is_defined || f->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_built_in) {
+                  && !other_sig->function()->is_builtin) {
                  linker_error_printf(prog,
                                      "function `%s' is multiply defined",
                                      f->name);