glsl: Move constant expression handling from calls to signatures.

When translating a call from AST to HIR, we need to decide whether it
can be evaluated to a constant before emitting any code (namely, the
temporary declaration, assignment, and call.)

Soon, ir_call will become a statement taking a dereference of where to
store the return value, rather than an rvalue to be used on the RHS of
an assignment.  It will be more convenient to try evaluation before
creating a call.  ir_function_signature seems like a reasonable place.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
This commit is contained in:
Kenneth Graunke
2011-09-20 00:14:05 -07:00
parent 807e967c61
commit d0fa0cb52c
2 changed files with 25 additions and 8 deletions

View File

@@ -477,6 +477,12 @@ public:
virtual ir_visitor_status accept(ir_hierarchical_visitor *);
/**
* Attempt to evaluate this function as a constant expression, given
* a list of the actual parameters. Returns NULL for non-built-ins.
*/
ir_constant *constant_expression_value(exec_list *actual_parameters);
/**
* Get the name of the function for which this is a signature
*/