[Mesa-dev] [PATCH 02/21] glsl: Convert ir_function_signature::is_builtin to a method.
Kenneth Graunke
kenneth at whitecape.org
Wed Sep 4 15:22:25 PDT 2013
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 at whitecape.org>
---
src/glsl/ir.cpp | 10 ++++++++--
src/glsl/ir.h | 4 ++--
src/glsl/ir_clone.cpp | 1 -
src/glsl/ir_constant_expression.cpp | 2 +-
src/glsl/link_functions.cpp | 4 ++--
src/glsl/linker.cpp | 4 ++--
6 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp
index ea018eb..d9fb808 100644
--- a/src/glsl/ir.cpp
+++ b/src/glsl/ir.cpp
@@ -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;
diff --git a/src/glsl/ir.h b/src/glsl/ir.h
index d785259..a927e90 100644
--- a/src/glsl/ir.h
+++ b/src/glsl/ir.h
@@ -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;
diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp
index 967ad70..1361f15 100644
--- a/src/glsl/ir_clone.cpp
+++ b/src/glsl/ir_clone.cpp
@@ -327,7 +327,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;
diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp
index bf019b9..ec338a8 100644
--- a/src/glsl/ir_constant_expression.cpp
+++ b/src/glsl/ir_constant_expression.cpp
@@ -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;
/*
diff --git a/src/glsl/link_functions.cpp b/src/glsl/link_functions.cpp
index 6b3e154..3d94e49 100644
--- a/src/glsl/link_functions.cpp
+++ b/src/glsl/link_functions.cpp
@@ -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);
}
@@ -265,7 +265,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;
diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index 8430096..350778a 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -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;
--
1.8.3.4
More information about the mesa-dev
mailing list