Move the accept method for hierarchical visitors from ir_dereference
to the derived classes. This was mostly straight-forward, but I
suspect that ir_dead_code_local may be broken now.
Create separate subclasses of ir_dereference for variable, array, and
record dereferences. As a side effect, array and record dereferences
no longer point to ir_variable objects directly. Instead they each
point to an ir_dereference_variable object.
This is the first of several steps in the refactoring process. The
intention is that ir_dereference will eventually become an abstract
base class.
Debugging this took forever as I only looked at constructors in ir.cpp
to find who wasn't setting up ->type. I dislike hiding code (as
opposed to prototypes and definitions) in C++ header files, but in
this case I have only myself to blame.
Unfortunately, we still have two kinds of matching - one, with implicit
conversions (for use in calls) and another without them (for finding a
prototype to overwrite when processing a function body). This commit
does not attempt to coalesce the two.
A new static version takes an ir_expression_operation enum, and the
original non-static version now uses it. This will make it easier to
read operations (where the ir_expression doesn't yet exist).
Now, ir_function is emitted as part of the IR instructions, rather than
simply existing in the symbol table. Individual ir_function_signatures
are not emitted themselves, but only as part of ir_function.
This pass only works on assignments where the variable is never
referenced. There is no code flow analysis, so it can't do a better
job of avoiding redundant assignments.
For now, the optimizer only does do_dead_code_unlinked(), so it won't
trim the builtin variable list or initializers outside of the scope of
functions. This is because we don't have the visibility into other
functions that might get linked in in order to eliminate work on
global variables.
This will be important to optimization passes. We don't want to
dead-code eliminate writes to out varyings, or propagate uninitialized
values of uniforms.
This is relatively simple at the moment, recognizing only constant
values, and not (for example) values that are restricted to a range
that make the branching constant. However, it does remove 59 lines
from the printout of CorrectParse2.vert.
Using '#extension foo: warn' instructs the compiler to generate a
warning when some feature of the extension 'foo' is used. This patch
adds some infrastructure needed to support that for variables.
Similar changes will be needed for types and built-in functions.
In GLSL 1.10 this was not allowed, but in GLSL 1.20 and later it is.
This causes the following tests to pass:
glslparsertest/glsl2/array-09.vert
glslparsertest/glsl2/array-13.vert
For unsized arrays, we can't flag out-of-bounds accesses until the
array is redeclared with a size. Track the maximum accessed element
and generate an error if the declaration specifies a size that would
cause that access to be out-of-bounds.
This causes the following tests to pass:
glslparsertest/shaders/array10.frag