glsl: fix the type of ir_constant_data::u16
[mesa.git] / src / compiler / glsl / link_functions.cpp
index b4aae5e015d6e5eb31ae328147263129399cac99..4998d39dc597a16e99f411fc28566c83a52ef836 100644 (file)
@@ -21,7 +21,6 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
-#include "main/core.h"
 #include "glsl_symbol_table.h"
 #include "glsl_parser_extras.h"
 #include "ir.h"
 #include "util/set.h"
 #include "util/hash_table.h"
 #include "linker.h"
+#include "main/mtypes.h"
 
 static ir_function_signature *
 find_matching_signature(const char *name, const exec_list *actual_parameters,
-                        glsl_symbol_table *symbols, bool use_builtin);
+                        glsl_symbol_table *symbols);
 
 namespace {
 
@@ -47,8 +47,7 @@ public:
       this->success = true;
       this->linked = linked;
 
-      this->locals = _mesa_set_create(NULL, _mesa_hash_pointer,
-                                      _mesa_key_pointer_equal);
+      this->locals = _mesa_pointer_set_create(NULL);
    }
 
    ~call_link_visitor()
@@ -74,12 +73,15 @@ public:
       assert(callee != NULL);
       const char *const name = callee->function_name();
 
+      /* We don't actually need to find intrinsics; they're not real */
+      if (callee->is_intrinsic())
+         return visit_continue;
+
       /* Determine if the requested function signature already exists in the
        * final linked shader.  If it does, use it as the target of the call.
        */
       ir_function_signature *sig =
-         find_matching_signature(name, &callee->parameters, linked->symbols,
-                                 ir->use_builtin);
+         find_matching_signature(name, &callee->parameters, linked->symbols);
       if (sig != NULL) {
         ir->callee = sig;
         return visit_continue;
@@ -90,8 +92,7 @@ public:
        */
       for (unsigned i = 0; i < num_shaders; i++) {
          sig = find_matching_signature(name, &ir->actual_parameters,
-                                       shader_list[i]->symbols,
-                                       ir->use_builtin);
+                                       shader_list[i]->symbols);
          if (sig)
             break;
       }
@@ -122,9 +123,7 @@ public:
 
       ir_function_signature *linked_sig =
         f->exact_matching_signature(NULL, &callee->parameters);
-      if ((linked_sig == NULL)
-         || ((linked_sig != NULL)
-             && (linked_sig->is_builtin() != ir->use_builtin))) {
+      if (linked_sig == NULL) {
         linked_sig = new(linked) ir_function_signature(callee->return_type);
         f->add_signature(linked_sig);
       }
@@ -148,8 +147,7 @@ public:
        * replace signature stored in a function.  One could easily be added,
        * but this avoids the need.
        */
-      struct hash_table *ht = _mesa_hash_table_create(NULL, _mesa_hash_pointer,
-                                                      _mesa_key_pointer_equal);
+      struct hash_table *ht = _mesa_pointer_hash_table_create(NULL);
 
       exec_list formal_parameters;
       foreach_in_list(const ir_instruction, original, &sig->parameters) {
@@ -161,7 +159,7 @@ public:
 
       linked_sig->replace_parameters(&formal_parameters);
 
-      linked_sig->is_intrinsic = sig->is_intrinsic;
+      linked_sig->intrinsic_id = sig->intrinsic_id;
 
       if (sig->is_defined) {
          foreach_in_list(const ir_instruction, original, &sig->body) {
@@ -314,22 +312,16 @@ private:
  */
 ir_function_signature *
 find_matching_signature(const char *name, const exec_list *actual_parameters,
-                        glsl_symbol_table *symbols, bool use_builtin)
+                        glsl_symbol_table *symbols)
 {
    ir_function *const f = symbols->get_function(name);
 
    if (f) {
       ir_function_signature *sig =
-         f->matching_signature(NULL, actual_parameters, use_builtin);
-
-      if (sig && (sig->is_defined || sig->is_intrinsic)) {
-         /* If this function expects to bind to a built-in function and the
-          * 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())
-            return sig;
-      }
+         f->matching_signature(NULL, actual_parameters, false);
+
+      if (sig && (sig->is_defined || sig->is_intrinsic()))
+         return sig;
    }
 
    return NULL;