Commit graph

55 commits

Author SHA1 Message Date
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
Ian Romanick
95cd6cc195 Add ir_function::iterator to iterate over function signatures 2010-03-31 16:40:26 -07:00
Ian Romanick
6a15d5b514 Use ir_function::add_signature to create link between function and signature
ir_function_signature now has a pointer back to the ir_function that owns it.
2010-03-31 16:37:10 -07:00
Ian Romanick
1cf43a4331 Initial bits of constant expression evaluator
Currently only works for constants.  The rest will be added later.
2010-03-30 16:56:50 -07:00
Ian Romanick
3c6fea3048 Implement ir_if (for if-statments) and conversion from AST
The following tests now pass:

    glslparsertest/shaders/if1.frag
    glslparsertest/shaders/if2.frag

The following tests that used to pass now fail.  It appears that most
of these fail because ast_nequal and ast_equal are not converted to HIR.

    shaders/glsl-unused-varying.frag
    shaders/glsl-fs-sqrt-branch.frag
2010-03-29 15:17:11 -07:00
Ian Romanick
521c2983b4 Trivial code cleanup in ir_dereference::is_lvalue 2010-03-29 12:52:00 -07:00
Eric Anholt
a9fafc6504 Don't let swizzles with duplicated components be considered as lvalues.
Fixes swizzle2.frag.
2010-03-29 12:48:45 -07:00
Eric Anholt
01665262e5 Implement exp2() and log2(), and make ir_unop_exp and ir_unop_log be base e.
Making the base e functions IR operations is not a clear win.  i965
doesn't support it, it doesn't look like r600 supports it, but r500
does. It should be easily supportable as a lowering pass, though.
2010-03-29 12:48:45 -07:00
Eric Anholt
44d68fd06f Add sqrt() builtin as an IR operation.
Following a discussion in #dri-devel, I think this makes more sense
than implementing it as RSQ RCP CMP as Mesa did.  The i965 has a
hardware sqrt that should work, and AMD is suppposed to be able to
implement it as RSQ RCP with an alternate floating point mode so that
the 0.0 case is handled like we want.
2010-03-29 12:48:45 -07:00
Eric Anholt
c22c40015d Implement the first builtin function: exp(). 2010-03-29 12:48:45 -07:00
Eric Anholt
c4f86d3b80 Make read-only variables not be considered lvalues.
This should fix tests trying to assign to builtin "in" variables, and
will also be relied on for post_inc/dec handling.
2010-03-26 17:51:41 -07:00
Eric Anholt
3c36b2df7c Add constructors for immediate hir constants.
This will make ast_to_hir for inc/dec easier.
2010-03-26 17:51:41 -07:00
Eric Anholt
e65e12fdbc IR print visitor: Print out something for the operator. 2010-03-26 17:51:40 -07:00
Ian Romanick
93614bc4b9 Add hack ir_call::callee_name to get the name of the called function 2010-03-26 17:29:29 -07:00
Ian Romanick
9878c6518f Add ir_call::iterator to iterate over actual parameters 2010-03-26 17:20:31 -07:00
Ian Romanick
6c86ea8adc Add unary operator to convert unsigned integer to float 2010-03-26 16:11:48 -07:00
Kenneth Graunke
affc1413ac Move swizzles out of ir_dereference and into their own class.
Also turn generate_swizzle into a static "create" method of the new
class; we'll want to use it for the IR reader as well.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
2010-03-26 14:00:59 -07:00
Kenneth Graunke
fb9fb5f51d Add new abstract ir_rvalue class; rework accordingly.
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
2010-03-26 13:58:48 -07:00
Kenneth Graunke
44e1dfa2df Replace "mode" type tag with virtual as_foo() downcasting functions.
These should work well even in a non-flat IR hierarchy.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
2010-03-26 12:50:40 -07:00
Ian Romanick
9546997736 Add dereference constructor for array element dereferences
This should have gone in before the previous commit.
2010-03-25 17:01:15 -07:00
Kenneth Graunke
f25a5ad939 Widen num_components to handle vec4 correctly. 2010-03-25 11:22:42 -07:00
Kenneth Graunke
904872372e Typo fixes: de/re/ference. 2010-03-25 10:18:40 -07:00
Ian Romanick
2f4240fb02 Add method to set the swizzle of an ir_dereference 2010-03-24 15:12:21 -07:00
Ian Romanick
882dad7540 ir_function constructor now takes the function name as a parameter 2010-03-23 17:42:04 -07:00
Ian Romanick
9e7c34b865 Set the type of a function call to be the return type of the callee 2010-03-23 12:21:18 -07:00
Ian Romanick
e39cc69fa3 Set, and require, a return type for function signatures 2010-03-23 12:19:13 -07:00
Ian Romanick
9578c87ce2 Implement IR return instructions 2010-03-19 16:44:52 -07:00
Ian Romanick
e309a6051d Add multiple include protection to ir.h 2010-03-15 15:20:15 -07:00
Ian Romanick
471471f834 Initial pass at resolving function calls
The code is still really rough and *REALLY* incomplete.  This at least
passes the first few trivially simple test cases.
2010-03-11 14:57:26 -08:00
Ian Romanick
ed45ec6a51 Add ir_call call to represent function calls. 2010-03-11 14:35:37 -08:00
Ian Romanick
d27ec2461b Fix broken constructor of ir_instruction base class
Make the constructor inline-able, and don't try to initialize it as a
simple_node.  It hasn't been derived from simple_node in a long time.
2010-03-11 14:23:41 -08:00