Commit Graph

85 Commits

Author SHA1 Message Date
Kenneth Graunke 56d3f6ad78 Set the type of ir_texture properly; infer it from the sampler type. 2010-06-09 11:14:57 -07:00
Kenneth Graunke 26d74cd1d1 Add stub visitor support for ir_texture. 2010-06-09 11:14:57 -07:00
Kenneth Graunke c30f6e5dea Add mappings between ir_texture_opcode and strings. 2010-06-09 11:14:57 -07:00
Ian Romanick 81377c012c Define IR instruction for texture look-ups 2010-06-09 11:14:57 -07:00
Ian Romanick 35159b542c There is no class ir_label, so there's no need for ir_instruction::as_label 2010-06-02 13:39:45 -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 fd55da2147 ir_dereference::mode is no longer used, kill with fire 2010-05-26 15:23:25 -07:00
Ian Romanick b067db2e25 Refactor whole-variable assigment checking into member function 2010-05-26 15:23:25 -07:00
Ian Romanick 36ea28646c Refactor ir_dereference data fields to subclasses 2010-05-26 15:23:25 -07:00
Ian Romanick c7b1046a9f Refactor ir_dereference support for ir_visitor
Move the accept method for visitors from ir_dereference to the derived
classes.
2010-05-26 15:23:25 -07:00
Ian Romanick f3a002b503 Refactor ir_dereference support for ir_hierarchical_visitor
Move the accept method for hierarchical visitors from ir_dereference
to the derived classes.  This was mostly straight-forward, but I
suspect that ir_dead_code_local may be broken now.
2010-05-26 15:23:25 -07:00
Ian Romanick 70fe8b6663 Begin refactoring ir_dereference
Create separate subclasses of ir_dereference for variable, array, and
record dereferences.  As a side effect, array and record dereferences
no longer point to ir_variable objects directly.  Instead they each
point to an ir_dereference_variable object.

This is the first of several steps in the refactoring process.  The
intention is that ir_dereference will eventually become an abstract
base class.
2010-05-26 15:23:19 -07:00
Ian Romanick 8895bae55b Add ir_hierarchical_visitor base class and associated infrastructure
This type of visitor should eventually replace all or almost all
current uses of ir_visitor.
2010-05-17 12:03:13 -07:00
Ian Romanick 2b3c476fa0 Add ir_rvalue::variable_referenced 2010-05-14 17:35:42 -07:00
Kenneth Graunke 57e7da173e Implement "sin" and "cos" builtins via new expression operators. 2010-05-14 16:34:46 -07:00
Kenneth Graunke a4b7b5a654 Implement "sign" builtin via a new expression operator. 2010-05-14 16:34:46 -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
Ian Romanick 7ee79fb6b7 Add ir_dereference constructor for structure field dereferences 2010-04-28 18:22:54 -07:00
Kenneth Graunke 3b96996b7e Move array of operator strings out of ir_print_visitor.cpp.
Also implement a reverse-lookup function for use in the IR reader.
2010-04-28 15:42:07 -07:00
Kenneth Graunke bff6013d46 Factor out parameter list replacement for later reuse. 2010-04-28 15:34:52 -07:00
Kenneth Graunke 0d605cb97c 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.
2010-04-28 15:34:52 -07:00
Kenneth Graunke abd40b1521 Factor out qualifier checking code for later reuse. 2010-04-28 15:34:52 -07:00
Kenneth Graunke 7dd6adbe2e 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).
2010-04-28 15:34:52 -07:00
Kenneth Graunke 6202cbfe36 Fix ir_dead_code for function refactoring. 2010-04-21 16:02:15 -07:00
Kenneth Graunke 3289886688 Remove ir_label since it is no longer used. 2010-04-21 15:37:10 -07:00
Kenneth Graunke 9fa99f3b6c 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.
2010-04-21 15:36:36 -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 71df19f5ef 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.
2010-04-19 11:13:20 -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 cad9766118 Inline functions consisting of a return of an expression. 2010-04-08 11:24:06 -07:00
Ian Romanick b427c917ce Remove extraneous base-class constructor calls 2010-04-07 18:03:50 -07:00
Eric Anholt 894ea972a4 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).
2010-04-07 17:23:23 -07:00
Eric Anholt f1ddca9f21 Clarify the types of various exec_list in ir.h 2010-04-07 17:23:23 -07:00
Ian Romanick c178c74c27 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.
2010-04-07 16:53:54 -07:00
Ian Romanick 01f8de4a87 Add dynamic cast for ir_loop 2010-04-07 11:42:36 -07:00
Ian Romanick f8e31e00b1 Add ir_loop_jump to represent 'break' and 'continue' in loops 2010-04-07 11:42:30 -07:00
Ian Romanick fad607a9be 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.
2010-04-07 11:41:50 -07:00
Eric Anholt 70b74928a2 Make constant folding descend into if statements. 2010-04-06 11:52:09 -07:00
Eric Anholt 326c676236 Handle constant expressions using derefs of const values.
Fixes CorrectParse1.frag and makes for a ton of folding in
CorrectParse2.frag.
2010-04-06 11:42:34 -07:00
Ian Romanick 9d975377ca Track whether whole-arrays are assignable
In GLSL 1.10 this was not allowed, but in GLSL 1.20 and later it is.

This causes the following tests to pass:

    glslparsertest/glsl2/array-09.vert
    glslparsertest/glsl2/array-13.vert
2010-04-02 17:17:47 -07:00
Eric Anholt c2cb84e17b Add bool/int conversion as IR operations.
Fixes constructor-09.glsl and CorrectParse2.frag.
2010-04-02 11:22:41 -07:00
Eric Anholt dc58b3f8cc Add conversion of bool to float as an IR operation to match int to float. 2010-04-02 11:22:41 -07:00
Eric Anholt c7da28b4be Allow array dereferences to be considered as lvalues.
Fixes glsl-vs-arrays.vert and glsl-vs-mov-after-deref.vert.
Regresses parser3.frag which was failing for the wrong reason.
2010-04-02 11:22:41 -07:00
Eric Anholt 160d092507 Simplify ir_constant_expression.cpp by factoring operand computation out. 2010-04-02 11:22:41 -07:00
Eric Anholt aeab105342 Remove fake ir_binop_logic_not. I think you meant ir_unop_logic_not. 2010-04-02 11:22:41 -07:00
Ian Romanick b8a21cc6df Track max accessed array element, reject additional out-of-bounds accesses
For unsized arrays, we can't flag out-of-bounds accesses until the
array is redeclared with a size.  Track the maximum accessed element
and generate an error if the declaration specifies a size that would
cause that access to be out-of-bounds.

This causes the following tests to pass:

    glslparsertest/shaders/array10.frag
2010-04-01 18:35:08 -07:00
Ian Romanick 2d394d4877 Add ir_variable::clone 2010-03-31 17:52:44 -07:00
Ian Romanick 0f0ea58264 Add ir_function_signature::function_name 2010-03-31 16:44:12 -07:00
Ian Romanick a4775823b0 Make ir_function::signatures private 2010-03-31 16:40:58 -07:00