Commit Graph

104 Commits

Author SHA1 Message Date
Carl Worth a22426dc4c Fix typos of "variable" as "varaible"
One of these was just in a comment. But ther other was in an enum
tag, (which is apparently not being used anywhere yet).
2010-06-23 16:12:53 -07:00
Eric Anholt 4b6fd39c89 Add a virtual clone() method to ir_instruction.
This will be used by function inlining, the linker, and avoiding double
usage of the LHS deref chains in ++, *=, and similar operations.
2010-06-23 15:20:29 -07:00
Ian Romanick 8b80e9f9e3 ir_variable: Add query to get number of slots used by a variable 2010-06-23 10:56:04 -07:00
Ian Romanick 69a079aee8 ir_variable: Track the location of uniforms, varings, attributes, etc. 2010-06-23 10:56:03 -07:00
Ian Romanick 950ceb2bd6 ir_variable: Add method to get string representing interpolation qualifier 2010-06-23 10:56:03 -07:00
Ian Romanick 1e8b7a714e ir_constant: Add method to determine if two constants have the same value 2010-06-23 10:56:03 -07:00
Eric Anholt 53cdb7e51d ir_validate: New pass for checking our invariants. 2010-06-22 18:18:30 -07:00
Eric Anholt e46a454305 ir: Give ir_instruction a print visitor helper.
This avoids spamming each file with includes of ir_print_visitor.h
because someone was doing debugging at some point, and is less typing
when doing debugging.
2010-06-22 18:18:30 -07:00
Eric Anholt ac95f2f8c8 Include stdio.h and stdlib.h everywhere, and don't cook our own #define NULL. 2010-06-22 12:30:55 -07:00
Ian Romanick 824b659d91 ir_constant: Eliminate 'void *' constructor
All of the places that had been using the (glsl_type *, void *)
constructor were actually passing an ir_constant_data for the
'void *'.  The code can be greatly simplified by replacing this
constructor with a (glsl_type *, ir_constant_data *) constructor.
This should also help prevent one class of invalid uses of the old
constructor.
2010-06-11 17:12:40 -07:00
Ian Romanick be1d2bfdea Matrix and vector constructors with a single constant scalar are constant 2010-06-11 15:48:26 -07:00
Ian Romanick b94c29a47b ir_constant: Add get_record_field query 2010-06-11 15:36:05 -07:00
Ian Romanick 710919fd7c ir_constant: Support constant structures in clone 2010-06-11 13:51:42 -07:00
Ian Romanick 7f1ab834d7 ir_constant: Add storage for multiple constants for arrays and records 2010-06-11 13:51:42 -07:00
Ian Romanick 756a3fac4f Construct an ir_constant from a list of ir_constant values 2010-06-11 13:51:09 -07:00
Ian Romanick 31881908eb Add methods to ir_constant to get scalar components in a particular type 2010-06-11 13:51:09 -07:00
Ian Romanick 989cfc432e Construct an ir_constant from a scalar component of another ir_constant 2010-06-11 13:51:09 -07:00
Kenneth Graunke b843c7a20c Implement dFdx, dFdy, and fwidth via new expression opcodes. 2010-06-09 14:44:39 -07:00
Kenneth Graunke b97efa5db5 ir_function_cloning_visitor: Add support for ir_texture. 2010-06-09 11:14:58 -07:00
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