Eric Anholt [Wed, 5 May 2010 18:07:21 +0000 (11:07 -0700)]
ir_visit_tree: Make sure we visit dereference targets, too.
Found this with the local dead code pass, which never saw variable
dereferences occurring.
Eric Anholt [Wed, 5 May 2010 16:38:09 +0000 (09:38 -0700)]
ir_copy_propagation: Fix up the doxygen about the file.
Eric Anholt [Wed, 5 May 2010 16:31:53 +0000 (09:31 -0700)]
ir_copy_propagation: Return true if we optimized out any assignments.
This may trigger other optimization phases to make more progress themselves.
Eric Anholt [Wed, 5 May 2010 16:26:46 +0000 (09:26 -0700)]
ir_copy_propagation: Handle swizzles and array derefs on LHS of assign.
This improves the ACP to not get cleared when more complicated assignments
occur, cleaning up more redundant copies in programs.
Eric Anholt [Tue, 4 May 2010 20:04:40 +0000 (13:04 -0700)]
ir_copy_propagation: New pass to rewrite dereferences to avoid copies.
This is pretty basic. Right now it only handles pure assignments --
same type on each side, no swizzling, and only within basic blocks.
Eric Anholt [Tue, 4 May 2010 00:08:01 +0000 (17:08 -0700)]
ir_to_mesa.cpp: Fix missing types on some ir_swizzles.
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.
Eric Anholt [Mon, 3 May 2010 18:41:00 +0000 (11:41 -0700)]
Remove the pedantic C junk.
Mesa doesn't use pedantic ANSI C89, so I have no idea why we would.
Eric Anholt [Fri, 30 Apr 2010 01:00:33 +0000 (18:00 -0700)]
Store warnings and errors in a parser state infolog.
Cleans up compile warning about unused state in _mesa_glsl_warning. We
would want infolog handling roughly like this anyway.
Eric Anholt [Fri, 30 Apr 2010 00:57:28 +0000 (17:57 -0700)]
Quiet warnings about ir_shader not being handled in places it's not needed.
Eric Anholt [Fri, 30 Apr 2010 00:54:52 +0000 (17:54 -0700)]
Use the AM_SILENT_RULES when available.
Eric Anholt [Fri, 30 Apr 2010 00:53:26 +0000 (17:53 -0700)]
glsl_lexer: Quiet warning about unused unput().
Ian Romanick [Mon, 3 May 2010 17:15:02 +0000 (10:15 -0700)]
Merge branch 'fixes'
Kenneth Graunke [Thu, 29 Apr 2010 06:18:25 +0000 (23:18 -0700)]
Use %p rather than %08x when printing pointers to fix compile.
Kenneth Graunke [Sat, 1 May 2010 07:31:35 +0000 (00:31 -0700)]
Fix ir_return cloning to actually use the cloned subexpression.
This caused a nasty bug where the function inliner would create new
variables for each of the formal parameters, but the body would still
reference the old copies.
This was highly visible since the dead code eliminator (rightly) removed
the new declarations, leading to printed IR that referenced non-existent
variable names.
Kenneth Graunke [Sat, 1 May 2010 06:38:50 +0000 (23:38 -0700)]
Fix incorrect comments in function inliner.
Eric Anholt [Thu, 29 Apr 2010 20:54:19 +0000 (13:54 -0700)]
ir_dead_code: Fix segfault on handling a return statement with no value.
Ian Romanick [Wed, 28 Apr 2010 20:14:53 +0000 (13:14 -0700)]
Track and print user defined structure types
Ian Romanick [Wed, 28 Apr 2010 20:04:15 +0000 (13:04 -0700)]
IR print visitor: Move logic for printing the whole program to _mesa_print_ir
Ian Romanick [Wed, 28 Apr 2010 19:01:40 +0000 (12:01 -0700)]
IR print visitor: Just print the name of structures
Treat structure types like other non-array types. We'll have to print
the structure defintion elsewhere.
Eric Anholt [Mon, 26 Apr 2010 22:02:40 +0000 (15:02 -0700)]
ir_function_inlining: Handle inlining of structure dereferences.
Eric Anholt [Mon, 26 Apr 2010 22:01:50 +0000 (15:01 -0700)]
Correctly handle remapping of array dereferences if ->var is a variable.
Ian Romanick [Fri, 23 Apr 2010 22:55:19 +0000 (15:55 -0700)]
Begin handling some varieties of invalid declarations
Ian Romanick [Fri, 23 Apr 2010 20:24:08 +0000 (13:24 -0700)]
Reject conflicting struct declarations, generate struct constructor
Ian Romanick [Fri, 23 Apr 2010 20:21:22 +0000 (13:21 -0700)]
glsl_type::generate_constructor_prototype now generates the function too
Also, change the name of the method to generate_constructor.
Ian Romanick [Wed, 21 Apr 2010 21:33:34 +0000 (14:33 -0700)]
Always return a value from ast_type_specifier::hir
Ian Romanick [Wed, 21 Apr 2010 19:13:48 +0000 (12:13 -0700)]
Support structures in glsl_type::generate_constructor_prototype
Ian Romanick [Wed, 21 Apr 2010 18:54:02 +0000 (11:54 -0700)]
Implement structures and arrays in ir_dereference::is_lvalue
Ian Romanick [Tue, 20 Apr 2010 23:49:03 +0000 (16:49 -0700)]
Ensure that structure fields have non-NULL types
Ian Romanick [Tue, 20 Apr 2010 23:48:24 +0000 (16:48 -0700)]
Ensure that anonymous structures have non-NULL names
Ian Romanick [Mon, 19 Apr 2010 22:41:23 +0000 (15:41 -0700)]
Convert structure field dereferences to HIR
Ian Romanick [Mon, 19 Apr 2010 22:40:49 +0000 (15:40 -0700)]
Add ir_dereference constructor for structure field dereferences
Ian Romanick [Mon, 19 Apr 2010 22:40:01 +0000 (15:40 -0700)]
Add glsl_type::field_type
Query the type of a structure field
Ian Romanick [Mon, 19 Apr 2010 22:13:15 +0000 (15:13 -0700)]
Begin converting structure definitions to IR
Ian Romanick [Mon, 19 Apr 2010 22:11:31 +0000 (15:11 -0700)]
Use IDENTIFIER instead of TYPE_NAME for structure names
Since there is no track of which names are structure names during parsing,
TYPE_NAME cannot be produced by the lexer. Use IDENTIFIER and let the AST
processor sort it out.
Kenneth Graunke [Wed, 28 Apr 2010 20:16:31 +0000 (13:16 -0700)]
ir_reader: Slightly better error message when failing to read swizzles.
Kenneth Graunke [Wed, 28 Apr 2010 19:58:31 +0000 (12:58 -0700)]
ir_reader: Don't print out the S-Expression.
It's no longer useful for debugging.
Kenneth Graunke [Wed, 28 Apr 2010 19:54:21 +0000 (12:54 -0700)]
ir_reader: Read function calls.
Kenneth Graunke [Wed, 28 Apr 2010 19:45:18 +0000 (12:45 -0700)]
ir_reader: Replace function prototypes with the definition.
Previously, we just created a new one, which was wrong.
Kenneth Graunke [Thu, 22 Apr 2010 06:46:22 +0000 (23:46 -0700)]
ir_reader: Fix incorrect error message for expressions.
Kenneth Graunke [Thu, 22 Apr 2010 06:23:23 +0000 (23:23 -0700)]
Make ir_read_error print out the given S-Expression, for context.
Kenneth Graunke [Thu, 22 Apr 2010 06:15:08 +0000 (23:15 -0700)]
ir_reader: Fix for swizzles.
Kenneth Graunke [Thu, 22 Apr 2010 01:14:06 +0000 (18:14 -0700)]
ir_reader: Preliminary work toward reading functions.
Kenneth Graunke [Thu, 22 Apr 2010 00:52:36 +0000 (17:52 -0700)]
ir_reader: Perform a preliminary pass to scan for function prototypes.
Kenneth Graunke [Thu, 22 Apr 2010 00:50:16 +0000 (17:50 -0700)]
ir_reader: Don't initialize globals, builtins, or constructors.
All of these are currently emitted as part of the IR, so by initializing
them, we actually end up with two copies. For constructors, we may
eventually wish to avoid emitting them as part of the IR output.
Kenneth Graunke [Wed, 21 Apr 2010 22:47:34 +0000 (15:47 -0700)]
Make ir_read_error set state->error.
Kenneth Graunke [Mon, 12 Apr 2010 23:02:48 +0000 (16:02 -0700)]
ir_reader: Add support for "break" and "continue" in loops.
Includes threading the ir_loop * context through various functions.
Kenneth Graunke [Mon, 12 Apr 2010 22:48:27 +0000 (15:48 -0700)]
ir_reader: Add initial loop support; doesn't yet support break/continue.
Kenneth Graunke [Mon, 12 Apr 2010 21:27:39 +0000 (14:27 -0700)]
ir_reader: Add support for reading (var_ref ...) and (array_ref ...)
Kenneth Graunke [Mon, 12 Apr 2010 21:25:41 +0000 (14:25 -0700)]
ir_reader: rvalues are instructions too!
Kenneth Graunke [Sat, 10 Apr 2010 08:45:08 +0000 (01:45 -0700)]
ir_reader: Add support for reading conditionals: (if ...)
Kenneth Graunke [Sat, 10 Apr 2010 08:06:44 +0000 (01:06 -0700)]
ir_reader: Add support for reading array types.
Also, constify glsl_type pointers; this was necessary to use
glsl_type::get_array_instance.
Kenneth Graunke [Sat, 10 Apr 2010 00:56:22 +0000 (17:56 -0700)]
ir_reader: Add support for reading (return ...)
Kenneth Graunke [Sat, 10 Apr 2010 00:40:51 +0000 (17:40 -0700)]
ir_reader: Add support for reading variable declarations.
It also now reads a list of instructions, as it should, rather than a
single rvalue.
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.