Commit graph

431 commits

Author SHA1 Message Date
Kenneth Graunke
4c7367b3f9 Add a perl script to generate builtin_function.cpp.
Usage: ./builtins/tools/generate_builtins.pl > builtin_function.cpp
2010-05-14 16:34:46 -07:00
Kenneth Graunke
a40e68b256 Fix bogus expression typing in various builtins. 2010-05-14 16:34:46 -07:00
Kenneth Graunke
e4afc64290 Initial commit of IR for builtins.
These were all generated by Eric's existing builtin_functions.cpp; I split
the uvec* signatures out of 110 into the 130 folder.
2010-05-14 16:34:46 -07:00
Kenneth Graunke
f6c90d8b34 ir_reader: Set function signatures as defined. 2010-05-14 16:34:46 -07:00
Eric Anholt
c05bc5b7cc FS gl_FragCoord and and gl_FrontFacing are FS ins, not outs. 2010-05-14 16:11:37 -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
2b97dc657a Replace many uses of foreach_list with foreach_list_typed 2010-05-10 17:42:05 -07:00
Ian Romanick
4cfbad9e4d exec_list: Add foreach_list_typed and foreach_list_typed_const
These variations are parameterized by the type of the nodes in the
list.  This enables skipping the explicit usage of exec_node_data in
the loop body.
2010-05-10 17:40:41 -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
752c905b8c exec_list: Add simpler exec_list for-each macros 2010-05-10 11:17:23 -07:00
Ian Romanick
43bfc2b6b5 exec_list: Add macros to get ptr to structure containing a node
This has some ugly hackery to work-around C++ fail.  I have
emperically determined that it works in all the cases that matter.
2010-05-10 11:16:24 -07:00
Ian Romanick
4f9d72fa9e Loop bodies, then-statements, and else-statements are not lists
The statement making up a loop body, a then-statement, or an
else-statement are single nodes.  If the statement is a block, the
single node will be an ast_compound_statement.  There is no need to
loop at the top level when processing these statements.
2010-05-10 11:10:26 -07:00
Ian Romanick
f4e06981cc Remove unnecessary include of simple_list.h 2010-05-10 11:04:22 -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
dc1dbd65e1 ir_visit_tree: Make sure we visit dereference targets, too.
Found this with the local dead code pass, which never saw variable
dereferences occurring.
2010-05-05 11:08:18 -07:00
Eric Anholt
aef0aaee67 ir_copy_propagation: Fix up the doxygen about the file. 2010-05-05 09:38:09 -07:00
Eric Anholt
8e75de3164 ir_copy_propagation: Return true if we optimized out any assignments.
This may trigger other optimization phases to make more progress themselves.
2010-05-05 09:32:44 -07:00
Eric Anholt
4e2c0b99d9 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.
2010-05-05 09:27:50 -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
05a4e59c24 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.
2010-05-03 17:09:31 -07:00
Eric Anholt
3bc8b68436 Remove the pedantic C junk.
Mesa doesn't use pedantic ANSI C89, so I have no idea why we would.
2010-05-03 11:41:00 -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
Eric Anholt
7f436a837c Use the AM_SILENT_RULES when available. 2010-05-03 11:40:26 -07:00
Eric Anholt
a35e62d97a glsl_lexer: Quiet warning about unused unput(). 2010-05-03 11:40:25 -07:00
Ian Romanick
970353e047 Merge branch 'fixes' 2010-05-03 10:15:02 -07:00
Kenneth Graunke
b0e0da5f07 Use %p rather than %08x when printing pointers to fix compile. 2010-05-01 00:38:36 -07:00
Kenneth Graunke
05ddebac0a 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.
2010-05-01 00:31:35 -07:00
Kenneth Graunke
c07fdae33f Fix incorrect comments in function inliner. 2010-04-30 23:38:50 -07:00
Eric Anholt
438f38c55a ir_dead_code: Fix segfault on handling a return statement with no value. 2010-04-29 13:54:19 -07:00
Ian Romanick
a2c6df5566 Track and print user defined structure types 2010-04-28 18:22:54 -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
Ian Romanick
7d82c765a8 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.
2010-04-28 18:22:54 -07:00
Eric Anholt
35e8e461ca ir_function_inlining: Handle inlining of structure dereferences. 2010-04-28 18:22:54 -07:00
Eric Anholt
c0bfe8723e Correctly handle remapping of array dereferences if ->var is a variable. 2010-04-28 18:22:54 -07:00
Ian Romanick
c824e35dd0 Begin handling some varieties of invalid declarations 2010-04-28 18:22:54 -07:00
Ian Romanick
ab89927a91 Reject conflicting struct declarations, generate struct constructor 2010-04-28 18:22:54 -07:00
Ian Romanick
82baaf4283 glsl_type::generate_constructor_prototype now generates the function too
Also, change the name of the method to generate_constructor.
2010-04-28 18:22:54 -07:00
Ian Romanick
85ba37b97d Always return a value from ast_type_specifier::hir 2010-04-28 18:22:54 -07:00
Ian Romanick
8bec5e92e0 Support structures in glsl_type::generate_constructor_prototype 2010-04-28 18:22:54 -07:00
Ian Romanick
ae000fcb2e Implement structures and arrays in ir_dereference::is_lvalue 2010-04-28 18:22:54 -07:00
Ian Romanick
73986a7a26 Ensure that structure fields have non-NULL types 2010-04-28 18:22:54 -07:00
Ian Romanick
1d28b617ba Ensure that anonymous structures have non-NULL names 2010-04-28 18:22:54 -07:00
Ian Romanick
6efaeeea44 Convert structure field dereferences to HIR 2010-04-28 18:22:54 -07:00
Ian Romanick
7ee79fb6b7 Add ir_dereference constructor for structure field dereferences 2010-04-28 18:22:54 -07:00
Ian Romanick
8f755dcb67 Add glsl_type::field_type
Query the type of a structure field
2010-04-28 18:22:54 -07:00
Ian Romanick
3455ce6144 Begin converting structure definitions to IR 2010-04-28 18:22:53 -07:00
Ian Romanick
1f959ab4d6 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.
2010-04-28 18:22:47 -07:00