Kenneth Graunke [Thu, 8 Apr 2010 00:24:44 +0000 (17:24 -0700)]
Partial IR reader.
Currently reads assignments, constants, expressions, and swizzles.
Kenneth Graunke [Wed, 7 Apr 2010 22:16:20 +0000 (15:16 -0700)]
Set language_version to 130 (the max currently supported) when reading IR.
This is necessary so _mesa_glsl_initialize_types can create appropriate
glsl_types and add them to the symbol table.
In the future, we'll want to set it to the max GLSL version supported by
the current driver.
Kenneth Graunke [Wed, 7 Apr 2010 21:38:03 +0000 (14:38 -0700)]
Add stub ir_reader and new 'i' mode for reading IR rather than GLSL.
Kenneth Graunke [Wed, 7 Apr 2010 20:39:34 +0000 (13:39 -0700)]
Add a simple S-Expression reader and printer.
Kenneth Graunke [Thu, 22 Apr 2010 06:47:07 +0000 (23:47 -0700)]
Use "neg" when printing/reading unary negation rather than "-".
"-" is now only used for binary subtraction.
Kenneth Graunke [Thu, 8 Apr 2010 00:18:29 +0000 (17:18 -0700)]
Move array of operator strings out of ir_print_visitor.cpp.
Also implement a reverse-lookup function for use in the IR reader.
Kenneth Graunke [Wed, 28 Apr 2010 19:44:24 +0000 (12:44 -0700)]
Factor out parameter list replacement for later reuse.
Kenneth Graunke [Wed, 28 Apr 2010 19:04:23 +0000 (12:04 -0700)]
Factor out parameter list matching from ast_function::hir for later reuse.
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.
Kenneth Graunke [Wed, 28 Apr 2010 18:49:12 +0000 (11:49 -0700)]
Factor out qualifier checking code for later reuse.
Kenneth Graunke [Thu, 22 Apr 2010 07:44:12 +0000 (00:44 -0700)]
ir_print_visitor: Re-parenthesize ir_call output.
Kenneth Graunke [Thu, 22 Apr 2010 00:28:46 +0000 (17:28 -0700)]
ir_print_visitor: Print return type of ir_function_signatures.
Kenneth Graunke [Mon, 12 Apr 2010 22:46:10 +0000 (15:46 -0700)]
ir_print_visitor: Print (constant bool (1)) instead of "true"
It might be better to simply handle "true" in the reader, but since
booleans normally aren't printed as "true" or "false", we may as well go
for consistency.
Kenneth Graunke [Mon, 12 Apr 2010 21:52:37 +0000 (14:52 -0700)]
ir_print_visitor: Remove unnecessary parens around expression operands.
Kenneth Graunke [Sat, 10 Apr 2010 00:59:51 +0000 (17:59 -0700)]
ir_print_visitor: Remove unnecessary parens around array size in types.
Kenneth Graunke [Sat, 10 Apr 2010 00:32:14 +0000 (17:32 -0700)]
ir_print_visitor: Fix unclosed parenthesis in (call...
Kenneth Graunke [Sat, 10 Apr 2010 00:29:47 +0000 (17:29 -0700)]
ir_print_visitor: Fix unclosed parenthesis in (assign ...
Also remove useless parens around subexpressions.
Kenneth Graunke [Sat, 10 Apr 2010 00:28:47 +0000 (17:28 -0700)]
Add parens around printed IR so it's an official list of instructions.
Kenneth Graunke [Fri, 9 Apr 2010 23:34:21 +0000 (16:34 -0700)]
ir_print_visitor: Remove unnecessary parenthesis around variable names.
Kenneth Graunke [Wed, 7 Apr 2010 23:56:57 +0000 (16:56 -0700)]
Refactor ir_expression::get_num_operands.
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).
Kenneth Graunke [Wed, 7 Apr 2010 23:36:32 +0000 (16:36 -0700)]
ir_print_visitor: print the type of expressions.
This can be useful for debugging - it allows us to see that the inferred
type is what we think it should be. Furthermore, it will allow the IR
reader to avoid complex, operator-specific type inference.
Kenneth Graunke [Wed, 7 Apr 2010 21:41:13 +0000 (14:41 -0700)]
ir_print_visitor: Remove unnecessary parenthesis around type names.
Parenthesis should only be present for compound types (i.e. arrays
or structures). For atomic types, simply print the symbol.
Kenneth Graunke [Wed, 7 Apr 2010 21:40:44 +0000 (14:40 -0700)]
Print full type for ir_constant instead of base and component count.
vec4 and mat2x2 have the same base type and number of components;
printing the full type allows us to distinguish the two.
Ian Romanick [Mon, 26 Apr 2010 21:59:32 +0000 (14:59 -0700)]
Implement gl_TextureMatrix built-in uniform
Ian Romanick [Mon, 26 Apr 2010 21:59:16 +0000 (14:59 -0700)]
Make private glsl_type singletons public
Ian Romanick [Mon, 26 Apr 2010 21:19:49 +0000 (14:19 -0700)]
Initial implementation of #line
Does not handle comments in #line or line continuation characters, but
it should be good enough for now.
Eric Anholt [Fri, 23 Apr 2010 20:37:48 +0000 (13:37 -0700)]
builtin_functions: Clean up compiler warning about unused name, instructions.
Eric Anholt [Fri, 23 Apr 2010 20:28:21 +0000 (13:28 -0700)]
De-obfuscate some of builtin_types.h.
Eric Anholt [Fri, 23 Apr 2010 00:52:59 +0000 (17:52 -0700)]
ir_function_inlining: Implement inlining in many more cases.
We still don't inline for control flow in the inlined function, and we
don't have any limits on what we will inline.
Eric Anholt [Thu, 22 Apr 2010 16:47:27 +0000 (09:47 -0700)]
Put static pointers to vec[234]_types along with the static float_type.
Otherwise you have to type a lot of get_instance.
Eric Anholt [Fri, 23 Apr 2010 20:24:20 +0000 (13:24 -0700)]
Replace builtin_types.h generation with the generated output.
The script to generate it was longer and more obfuscated than the output.
Eric Anholt [Fri, 23 Apr 2010 01:48:20 +0000 (18:48 -0700)]
Fix the swizzling of vector constructors from scalars.
A refactor turned 'i' into '1', meaning everything writemasked into
the y component.
Eric Anholt [Fri, 23 Apr 2010 01:41:32 +0000 (18:41 -0700)]
ir_function_inlining: Avoid NULL dereference on assignment conditions.
Ian Romanick [Fri, 23 Apr 2010 20:37:47 +0000 (13:37 -0700)]
Zero-out the entire parser state structure at initialization
Among other things, this ensures that all of the extension flags are
initially disabled.
This causes the following tests to pass:
glslparsertest/glsl2/draw_buffers-02.frag
Ian Romanick [Fri, 23 Apr 2010 20:32:23 +0000 (13:32 -0700)]
Add missing 'else's to fix extension processing
The missing else-statements caused all of the extensions execpt
GL_ARB_texture_rectangle to be unsupported.
This causes the following tests to pass:
glslparsertest/glsl2/draw_buffers-04.frag
Kenneth Graunke [Thu, 22 Apr 2010 07:25:55 +0000 (00:25 -0700)]
Fix illegal (var_ref (array_ref ...)) in matrix constructors.
Kenneth Graunke [Thu, 22 Apr 2010 06:58:13 +0000 (23:58 -0700)]
Actually emit temp declaration in vector comparison builtins.
Kenneth Graunke [Wed, 21 Apr 2010 23:02:15 +0000 (16:02 -0700)]
Fix ir_dead_code for function refactoring.
Kenneth Graunke [Wed, 21 Apr 2010 22:00:29 +0000 (15:00 -0700)]
Emit body for constructors in the right place.
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.
Kenneth Graunke [Wed, 21 Apr 2010 22:14:02 +0000 (15:14 -0700)]
Remove ir_label since it is no longer used.
Kenneth Graunke [Wed, 21 Apr 2010 19:30:22 +0000 (12:30 -0700)]
Refactor IR function representation.
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.
Kenneth Graunke [Wed, 21 Apr 2010 22:17:26 +0000 (15:17 -0700)]
Use ir_function_signature::function_name() rather than direct access.
Kenneth Graunke [Wed, 21 Apr 2010 18:52:05 +0000 (11:52 -0700)]
Ensure that both parameter lists are the same length in function overloading.
Fixes new test function-05.glsl, where the second function has matching
parameter types, but less of them.
Ian Romanick [Wed, 21 Apr 2010 22:08:08 +0000 (15:08 -0700)]
Add missing break statement
Eric Anholt [Fri, 16 Apr 2010 23:43:47 +0000 (16:43 -0700)]
Remove dead code assignments and variable declarations.
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.
Eric Anholt [Mon, 19 Apr 2010 18:10:37 +0000 (11:10 -0700)]
Mark some variables as having usage beyond the shader's scope.
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.
Ian Romanick [Fri, 16 Apr 2010 23:42:43 +0000 (16:42 -0700)]
While-loops also start a new scope.
Eric Anholt [Fri, 16 Apr 2010 20:49:04 +0000 (13:49 -0700)]
Avoid generating ir_if for &&, || short-circuiting with constant LHS.
It was breaking constant expression detection for constant
initializers, i.e. CorrectParse2.frag, CorrectParse2.vert.
Eric Anholt [Fri, 16 Apr 2010 19:53:46 +0000 (12:53 -0700)]
Add support for inlining calls done inside of expressions.
Eric Anholt [Fri, 16 Apr 2010 08:10:32 +0000 (01:10 -0700)]
Make && and || only evaluate the RHS when the LHS requires it.
Eric Anholt [Thu, 15 Apr 2010 00:03:03 +0000 (17:03 -0700)]
Add an ir_if simplification pass.
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.
Eric Anholt [Wed, 14 Apr 2010 23:19:19 +0000 (16:19 -0700)]
Check that the return type of function definition matches its prototype.
Doesn't fix any testcases, but fixes a FINISHME.
Eric Anholt [Wed, 14 Apr 2010 23:16:20 +0000 (16:16 -0700)]
Check that function definition parameter qualifiers match proto qualifiers.
Fixes function9.frag.
Eric Anholt [Wed, 14 Apr 2010 22:38:52 +0000 (15:38 -0700)]
Return the rvalue of a variable decl to fix while (bool b = condition) {}
Eric Anholt [Wed, 14 Apr 2010 22:27:39 +0000 (15:27 -0700)]
Fix the type of gl_FogFragCoord.
Eric Anholt [Thu, 8 Apr 2010 22:41:19 +0000 (15:41 -0700)]
Add an implementation of gentype-only clamp().
Eric Anholt [Thu, 8 Apr 2010 22:35:34 +0000 (15:35 -0700)]
Add builtin implementations of vector comparison functions.
Fixes CorrectFunction1.vert, glsl-fs-notequal.frag.
Eric Anholt [Thu, 8 Apr 2010 22:10:37 +0000 (15:10 -0700)]
Add support for builtin gentype mix(gentype a, gentype b)
Fixes glsl-fs-mix.frag, glsl-fs-mix-constant.frag.
Eric Anholt [Thu, 8 Apr 2010 22:02:59 +0000 (15:02 -0700)]
Add buitlin functions for any(), all(), not().
Eric Anholt [Thu, 8 Apr 2010 21:34:38 +0000 (14:34 -0700)]
Add builtin normalize() functions.
Fixes CorrectSqizzle2.vert.
Eric Anholt [Thu, 8 Apr 2010 20:42:48 +0000 (13:42 -0700)]
Repeat the optimization passes until we stop making progress.
Eric Anholt [Thu, 8 Apr 2010 20:40:52 +0000 (13:40 -0700)]
Add inlining support for array dereferences.
Eric Anholt [Wed, 7 Apr 2010 18:46:26 +0000 (11:46 -0700)]
Inline functions consisting of a return of an expression.
Ian Romanick [Thu, 8 Apr 2010 01:03:50 +0000 (18:03 -0700)]
Remove extraneous base-class constructor calls
Eric Anholt [Wed, 7 Apr 2010 21:32:53 +0000 (14:32 -0700)]
Make function bodies rely on the parameter variable declarations.
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.
Eric Anholt [Wed, 7 Apr 2010 22:18:37 +0000 (15:18 -0700)]
Make dot() take the right number of args.
Eric Anholt [Wed, 7 Apr 2010 20:34:15 +0000 (13:34 -0700)]
Fix the returns of builtin functions to actually return.
Eric Anholt [Wed, 7 Apr 2010 20:19:11 +0000 (13:19 -0700)]
Put function bodies under function signatures, instead of flat in the parent.
This will let us know the length of function bodies for the purpose of
inlining (among other uses).
Eric Anholt [Wed, 7 Apr 2010 19:35:34 +0000 (12:35 -0700)]
Clarify the types of various exec_list in ir.h
Ian Romanick [Thu, 8 Apr 2010 00:13:44 +0000 (17:13 -0700)]
Treat texture rectangles as an extension that is enabled be default
Ian Romanick [Wed, 7 Apr 2010 23:59:46 +0000 (16:59 -0700)]
Add support for GL_ARB_draw_buffers extension
Ian Romanick [Wed, 7 Apr 2010 23:57:56 +0000 (16:57 -0700)]
Clean up error reporting in _mesa_glsl_process_extension
Ian Romanick [Wed, 7 Apr 2010 23:53:54 +0000 (16:53 -0700)]
Add tracking for extension based warnings
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.
Ian Romanick [Wed, 7 Apr 2010 21:50:36 +0000 (14:50 -0700)]
Emit a warning when an unknown extension is used with #extension
Ian Romanick [Wed, 7 Apr 2010 21:47:46 +0000 (14:47 -0700)]
Add _mesa_glsl_warning to emit warnings to the shader log
Ian Romanick [Wed, 7 Apr 2010 23:46:25 +0000 (16:46 -0700)]
Begin processing #extension directive
Nowhere near complete. It just parses correctly at this point.
Ian Romanick [Wed, 7 Apr 2010 23:41:40 +0000 (16:41 -0700)]
Use _mesa_glsl_shader_target_name
Ian Romanick [Wed, 7 Apr 2010 23:44:30 +0000 (16:44 -0700)]
Add utility function to get the name of a shader target
Ian Romanick [Wed, 7 Apr 2010 23:09:47 +0000 (16:09 -0700)]
Call glsl_type::get_instance correctly: the number of rows must be at least 1
This causes the following tests to pass:
shaders/glsl-tex-mvp.vert
Ian Romanick [Wed, 7 Apr 2010 21:49:59 +0000 (14:49 -0700)]
Eat whitespace while in the PP state
Ian Romanick [Wed, 7 Apr 2010 20:43:52 +0000 (13:43 -0700)]
Partially fix comment handling in preprocessor directives.
Multi-line /* */ comments are still broken. I think this will wait to
be fixed until we have a real preprocessor.
Ian Romanick [Wed, 7 Apr 2010 23:48:42 +0000 (16:48 -0700)]
Add support for bool to ir_equal and ir_nequal constant handling
Ian Romanick [Wed, 7 Apr 2010 23:47:44 +0000 (16:47 -0700)]
Add gl_ClipDistance in fragment shader
Ian Romanick [Tue, 6 Apr 2010 01:07:27 +0000 (18:07 -0700)]
Generate correct IR for do-while loops
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>
Ian Romanick [Tue, 6 Apr 2010 00:13:47 +0000 (17:13 -0700)]
Process ast_jump_statement into ir_loop_jump
Specifically, handle 'break' and 'continue' inside loops.
This causes the following tests to pass:
glslparsertest/shaders/break.frag
glslparsertest/shaders/continue.frag
Ian Romanick [Tue, 6 Apr 2010 00:13:14 +0000 (17:13 -0700)]
Add dynamic cast for ir_loop
Ian Romanick [Tue, 6 Apr 2010 00:01:53 +0000 (17:01 -0700)]
Begin tracking the nesting of loops and switch-statements
Ian Romanick [Mon, 5 Apr 2010 23:53:19 +0000 (16:53 -0700)]
Use switch based on mode in ast_jump_statement::hir
Ian Romanick [Mon, 5 Apr 2010 23:38:20 +0000 (16:38 -0700)]
Add some newlines when printing ir_loop instructions
Ian Romanick [Mon, 5 Apr 2010 23:37:49 +0000 (16:37 -0700)]
Process ast_iteration_statement into ir_loop
This causes the following tests to pass:
glslparsertest/shaders/dowhile.frag
glslparsertest/shaders/while.frag
glslparsertest/shaders/while1.frag
glslparsertest/shaders/while2.frag
Ian Romanick [Mon, 5 Apr 2010 23:28:15 +0000 (16:28 -0700)]
Add ir_loop_jump to represent 'break' and 'continue' in loops
Ian Romanick [Mon, 5 Apr 2010 23:16:07 +0000 (16:16 -0700)]
Add ir_loop to represent loops
This touches a lot of files because everything derived from ir_visitor
has to be updated. This is the primary disadvantage of the visitor pattern.
Eric Anholt [Tue, 6 Apr 2010 19:13:02 +0000 (12:13 -0700)]
Add some linebreaks in the ir_print_visitor of if statement bodies.
Eric Anholt [Tue, 6 Apr 2010 18:52:09 +0000 (11:52 -0700)]
Make constant folding descend into if statements.
Eric Anholt [Tue, 6 Apr 2010 18:42:01 +0000 (11:42 -0700)]
Descend down the tree in more locations in constant folding.
Eric Anholt [Tue, 6 Apr 2010 18:11:05 +0000 (11:11 -0700)]
Perform constant folding on array indices.
Replaces a constant var deref with a constant value in CorrectParse1.frag.
Eric Anholt [Tue, 6 Apr 2010 17:53:57 +0000 (10:53 -0700)]
Add float/int conversion to ir_constant_expression.cpp.
Gives CorrectParse2.frag one more constant folding.
Eric Anholt [Tue, 6 Apr 2010 17:30:54 +0000 (10:30 -0700)]
Handle constant expressions using derefs of const values.
Fixes CorrectParse1.frag and makes for a ton of folding in
CorrectParse2.frag.
Eric Anholt [Tue, 6 Apr 2010 17:07:20 +0000 (10:07 -0700)]
Fold constant expressions in if conditionals.
Fixes up 3 more expressions in CorrectParse2.frag.
Eric Anholt [Tue, 6 Apr 2010 17:02:27 +0000 (10:02 -0700)]
Add support for =, != to ir_constant_expresion.cpp
This results in constant folding of one more expression in CorrectParse2.frag.
Eric Anholt [Tue, 6 Apr 2010 16:55:45 +0000 (09:55 -0700)]
Add ir_constant_expression.cpp support for <, >, <=, >=.
This results in folding one more constant expression in CorrectParse2.frag.