Commit graph

49 commits

Author SHA1 Message Date
Eric Anholt
65122e9e80 ir_constant_variable: New pass to mark constant-assigned variables constant.
This removes a bunch of gratuitous moving around of constant values
from constructors.  Makes a shader ir I was looking at for structure
handling almost readable.
2010-06-01 15:15:04 -07:00
Eric Anholt
49a5d5c4f5 ir_swizzle_swizzle: Reduce swizzle chains to a single swizzle. 2010-06-01 15:15:04 -07:00
Eric Anholt
b145e90369 ir_vec_index_to_swizzle: Pass to convert indexing of vectors to swizzles.
This should remove the burden of handling constant vector indexing
well from backend codegen, and could help with swizzle optimizations.
2010-06-01 15:15:04 -07:00
Ian Romanick
2384937835 Fix function call parameter printer to omit extraneous leading comma
The output of all test cases was verified to be the same using diff.
2010-05-14 16:07:04 -07:00
Ian Romanick
304ea90233 Convert ast_node use of simple_node to exec_list and exec_node 2010-05-10 11:17:53 -07:00
Ian Romanick
3521f0bdd5 Store AST function call parameters in expressions
Previously the list of function call parameters was stored as a
circular list in ast_expression::subexpressions[1].  They are now
stored as a regular list in ast_expression::expressions.
2010-05-10 11:04:02 -07:00
Eric Anholt
bdd9b1f3ff Move optimization pass prototypes to a single header. 2010-05-05 11:47:33 -07:00
Eric Anholt
6255a1f4c6 ir_dead_code_local: Remove redundant assignments within basic blocks.
This cleans up a bunch of junk code in some of the GLSL parser tests,
and could potentially help real-world too (particularly after copy
propagation has happened).
2010-05-05 11:08:18 -07:00
Eric Anholt
5c89f0ecb9 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.
2010-05-04 17:00:42 -07:00
Eric Anholt
3623df68fa 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.
2010-05-03 11:40:26 -07:00
Eric Anholt
81f49a774e Quiet warnings about ir_shader not being handled in places it's not needed. 2010-05-03 11:40:26 -07:00
Ian Romanick
36d8a64a95 IR print visitor: Move logic for printing the whole program to _mesa_print_ir 2010-04-28 18:22:54 -07:00
Kenneth Graunke
e8b399270d 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.
2010-04-28 18:14:53 -07:00
Kenneth Graunke
34350be2cd Add stub ir_reader and new 'i' mode for reading IR rather than GLSL. 2010-04-28 18:14:53 -07:00
Kenneth Graunke
a02c5afce8 Add parens around printed IR so it's an official list of instructions. 2010-04-28 15:34:52 -07:00
Ian Romanick
6aeada7966 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
2010-04-23 13:37:47 -07:00
Ian Romanick
eb56cea3b3 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
2010-04-23 13:32:23 -07:00
Eric Anholt
7d21104a8b 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.
2010-04-19 15:33:52 -07:00
Eric Anholt
5ba9420608 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.
2010-04-14 17:05:13 -07:00
Eric Anholt
2a7b2b22f4 Repeat the optimization passes until we stop making progress. 2010-04-08 13:43:56 -07:00
Eric Anholt
cad9766118 Inline functions consisting of a return of an expression. 2010-04-08 11:24:06 -07:00
Ian Romanick
0c82465395 Treat texture rectangles as an extension that is enabled be default 2010-04-07 17:13:44 -07:00
Ian Romanick
c77b257094 Add support for GL_ARB_draw_buffers extension 2010-04-07 16:59:46 -07:00
Ian Romanick
887a8b07de Clean up error reporting in _mesa_glsl_process_extension 2010-04-07 16:57:56 -07:00
Ian Romanick
1799a0cd41 Emit a warning when an unknown extension is used with #extension 2010-04-07 16:49:25 -07:00
Ian Romanick
56b8b21410 Add _mesa_glsl_warning to emit warnings to the shader log 2010-04-07 16:49:25 -07:00
Ian Romanick
e701761cc8 Begin processing #extension directive
Nowhere near complete.  It just parses correctly at this point.
2010-04-07 16:49:25 -07:00
Ian Romanick
5bfe30a02b Add utility function to get the name of a shader target 2010-04-07 16:49:25 -07:00
Ian Romanick
e9d0f265aa Begin tracking the nesting of loops and switch-statements 2010-04-07 11:42:36 -07:00
Eric Anholt
70b74928a2 Make constant folding descend into if statements. 2010-04-06 11:52:09 -07:00
Eric Anholt
62735694a1 Add a constant folding optimization pass. 2010-04-06 11:42:31 -07:00
Ian Romanick
03d3f3ab71 Remove ast_node::type
It isn't a type (is was enum specifying the kind of node), it was
unused, and it was easily confused with actual type fields.  Kill with fire.
2010-04-02 11:05:16 -07:00
Ian Romanick
92318a9479 Add ast_function::hir
ast_function::hir consists of bits pulled out of
ast_function_definition::hir.  In fact, the later uses the former to
do a lot of its processing.  Several class private data fields were
added to ast_function to facilitate communicate between the two.

This causes the following tests to pass:

    glslparsertest/shaders/CorrectModule.frag

This causes the following tests to fail.  These shaders were
previously failing to compile, but they were all failing for the wrong
reasons.

    glslparsertest/shaders/function9.frag
    glslparsertest/shaders/function10.frag
2010-03-31 18:23:21 -07:00
Ian Romanick
5185a5f7d5 Add generate_temporary to generate an anonymous temporary 2010-03-29 15:20:42 -07:00
Ian Romanick
d14642739e IR print visitor: Remove most of the newlines from the printed output
This makes it a lot easier to read... if you have a really wide display.
2010-03-25 18:40:48 -07:00
Eric Anholt
7c15bb2465 Make the standalone parser return an exit code so we can automate testing. 2010-03-25 14:37:25 -07:00
Ian Romanick
71d0bbfcb2 Disallow passing NULL for state to _mesa_glsl_error
The two places that were still passing NULL had a state pointer to
pass.  Not passing it in these places prevented termination of
compilation of erroneous programs.
2010-03-23 13:21:19 -07:00
Ian Romanick
8bde4cec6b Use glsl_symbol_table instead of using _mesa_symbol_table directly 2010-03-19 11:57:24 -07:00
Ian Romanick
bbddcb3092 Factor ast_type_specifier code out to ast_type.cpp 2010-03-15 14:09:23 -07:00
Ian Romanick
1f58518059 Track generation of errors and halt compilation appropriately 2010-03-11 14:08:33 -08:00
Ian Romanick
d949a9afb0 Move top-level AST to HIR conversion to _mesa_ast_to_hir 2010-03-10 09:55:22 -08:00
Ian Romanick
8e6cd3bf54 Require the shader target be specified to the driver program 2010-03-10 09:31:30 -08:00
Ian Romanick
1c4156ffac Use ir_print_visitor to dump IR tree 2010-03-10 09:27:03 -08:00
Ian Romanick
0044e7edce Conver IR structures to use exec_list instead of simple_node 2010-03-08 23:44:54 -08:00
Ian Romanick
18238de6c3 Make AST->HIR conversion a method of ast_node, re-enable 2010-03-01 13:49:10 -08:00
Ian Romanick
d59673c9de autoconf for the ... 2010-02-25 17:17:23 -08:00
Ian Romanick
e41a1cd4d5 Replace tacky wrapper macros with tacky in-line type-casts 2010-02-25 12:49:55 -08:00
Ian Romanick
88349b22ca Add ast_expression_bin subclass of ast_expression
The ast_expression_bin subclass is used for all binary expressions
such as addition, subtraction, and comparisons.  Several other
subclasses are soon to follow.
2010-02-22 19:10:25 -08:00
Ian Romanick
d5f4f09e76 Rename .cc files to .cpp 2010-02-22 18:43:08 -08:00
Renamed from glsl_parser_extras.cc (Browse further)