Previously, the body of some vector constructors were added to the wrong
function signature, and the body of matrix constructors were just being
dumped in the main instruction stream.
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.
Previously, generating inlined function bodies was going to be
difficult, as there was no mapping between the body's declaration of
variables where parameter values were supposed to live and the
parameter variables that a caller would use in paramater setup.
Presumably this also have been a problem for actual codegen.
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.
Previously the same code was generated for a while loop and a do-while
loop. This pulls the code that generates the conditional break into a
separate method. This method is called either at the beginning or the
end depending on the loop type.
Reported-by: Kenneth Graunke <kenneth@whitecape.org>
Specifically, handle 'break' and 'continue' inside loops.
This causes the following tests to pass:
glslparsertest/shaders/break.frag
glslparsertest/shaders/continue.frag