Commit Graph

117 Commits

Author SHA1 Message Date
Eric Anholt
8558459512 Return the rvalue of a variable decl to fix while (bool b = condition) {} 2010-04-14 15:38:52 -07:00
Eric Anholt
fbc7c0b8f2 Make function bodies rely on the parameter variable declarations.
Previously, generating inlined function bodies was going to be
difficult, as there was no mapping between the body's declaration of
variables where parameter values were supposed to live and the
parameter variables that a caller would use in paramater setup.
Presumably this also have been a problem for actual codegen.
2010-04-07 17:23:23 -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
Ian Romanick
ae4c4c0795 Use _mesa_glsl_shader_target_name 2010-04-07 16:49:25 -07:00
Ian Romanick
8c46ed2490 Generate correct IR for do-while loops
Previously the same code was generated for a while loop and a do-while
loop.  This pulls the code that generates the conditional break into a
separate method.  This method is called either at the beginning or the
end depending on the loop type.

Reported-by: Kenneth Graunke <kenneth@whitecape.org>
2010-04-07 11:42:36 -07:00
Ian Romanick
4cf20cd37c Process ast_jump_statement into ir_loop_jump
Specifically, handle 'break' and 'continue' inside loops.

This causes the following tests to pass:

    glslparsertest/shaders/break.frag
    glslparsertest/shaders/continue.frag
2010-04-07 11:42:36 -07:00
Ian Romanick
e9d0f265aa Begin tracking the nesting of loops and switch-statements 2010-04-07 11:42:36 -07:00
Ian Romanick
c0e76d8352 Use switch based on mode in ast_jump_statement::hir 2010-04-07 11:42:36 -07:00
Ian Romanick
9e7d010ee0 Process ast_iteration_statement into ir_loop
This causes the following tests to pass:
     glslparsertest/shaders/dowhile.frag
     glslparsertest/shaders/while.frag
     glslparsertest/shaders/while1.frag
     glslparsertest/shaders/while2.frag
2010-04-07 11:42:36 -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
63f394203a Set lower bound on size implied by whole-array assignment
When an unsized array is accessed with a constant extension index this
sets a lower bound on the allowable sizes.  When the unsized array
gets a size set due to a whole-array assignment, this size must be at
least as large as the implied lower bound.

This causes the following tests to pass:

    glslparsertest/glsl2/array-16.vert
2010-04-05 14:35:47 -07:00
Ian Romanick
63038e18ad Allow dereference of vectors and matrices with []
This causes the following tests to pass:
     glslparsertest/glsl2/matrix-11.vert
     glslparsertest/glsl2/matrix-12.vert
     glslparsertest/shaders/CorrectParse2.vert
     glslparsertest/shaders/CorrectSwizzle2.frag
2010-04-05 13:16:00 -07:00
Ian Romanick
0157f41e5e Propagate sizes when assigning a whole array to an unsized array 2010-04-02 17:44:39 -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
Ian Romanick
cf37c9e8da Additional void parameter checks
If there is a void parameter it must not have a name, and it must be
the only parameter.
2010-04-02 15:30:45 -07:00
Ian Romanick
45d8a70c12 Require that function formal parameters have names 2010-04-02 15:09:33 -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
3f15150932 Test that invalid quailfiers aren't used on variables in GLSL 1.10. 2010-04-02 11:22:41 -07:00
Eric Anholt
5150c567a0 Test for the type being different in parameter_lists_match.
Fixes CorrectFuncOverload.frag.
2010-04-02 11:22:41 -07:00
Eric Anholt
90b7825b0e Reject non-float varyings.
Fixes varying2.frag.
2010-04-02 11:22:41 -07:00
Eric Anholt
ebbf14b980 Fix error handling of logic operators.
They were always throwing a type error because type wasn't being set.
2010-04-02 11:22:41 -07:00
Eric Anholt
183d8c6394 Emit errors for unfinished ast_to_hir expression operations. 2010-04-02 11:22:41 -07:00
Eric Anholt
a5827fe8d0 Fix ast_logic_not handling to be unary, not binary. 2010-04-02 11:22:41 -07:00
Eric Anholt
65e1a7ac6a Add errors for type results of other expressions. 2010-04-02 11:22:41 -07:00
Eric Anholt
a13bb1490c Emit errors from failure in arithmetic_result_type.
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
2010-04-02 11:22:35 -07:00
Eric Anholt
307c71bf24 Compute the constant value of a constant initializer.
Fixes constFunc.frag.
2010-04-02 11:05:16 -07:00
Eric Anholt
ac3af37d27 Allow initializers of constant values to succeed.
This regresses constFunc.frag, but that's just unexpectedly passing
because of the FINISHME just above.
2010-04-02 11:05:16 -07:00
Eric Anholt
068c80cfe0 Don't create a parameter declaration for a (void) parameter.
Fixes segfaults in a shader consisting of just:

    void main(void) { }

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
2010-04-02 11:05:16 -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
27e3cf8c0d Begin processing ast_array_index nodes
This causes the following tests to pass:

    glslparsertest/shaders/parser3.frag
    glslparsertest/shaders/varying3.frag (also generates spurious error)
2010-04-01 18:34:56 -07:00
Ian Romanick
a4f308f066 Allow unsized arrays to be redeclared with a size
Test glslparsertest/shaders/array11.frag now passes for the right reason.
2010-04-01 17:25:11 -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
e29a585989 Use ir_variable::clone to copy parameters to the function body
Several other code movements were also done.  This partitions this
function into two halves.  The first half processes the prototype
part, and the second have processes the actual function definition.
The coming patch series will parition ast_function_definition::hir
into (at least) two separate functions.
2010-03-31 17:54:26 -07:00
Ian Romanick
25711a85c2 Minor cleanups in ast_function_definition::hir 2010-03-31 17:43:33 -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
d612a127cc Move type_specifier_to_glsl_type to ast_type_specifier::glsl_type
This make is easily accessible from other modules.
2010-03-31 16:22:06 -07:00
Eric Anholt
0ed6125725 Test that const declarations include initializers.
Fixes dataType6.frag, and also array2.frag for an unexpected but valid
reason.
2010-03-31 13:17:23 -07:00
Ian Romanick
e0800062da Reject declarations with 'in' or 'out' qualifiers
'in' and 'out' can only be used in function parameter lists or at
global scope (1.30 and later).  This change enforces this.
2010-03-31 13:15:23 -07:00
Ian Romanick
d8065d86e8 Fix comment bug and printf bug in previous commit 2010-03-31 13:03:56 -07:00
Ian Romanick
b168e53452 Require that 'uniform' and 'varying' variables be declared at global scope
This causes the following tests to pass:

    glslparsertest/shaders/uniform.frag
    glslparsertest/shaders/varying.frag
2010-03-31 12:31:18 -07:00
Ian Romanick
e1c1a3f3bd Slightly refector checks for declarations that must be at global scope 2010-03-31 12:26:03 -07:00
Eric Anholt
b82c0c31ae Implement logical operators.
Fixes parser9.frag.
2010-03-31 09:17:39 -10:00
Eric Anholt
b97ee2e260 Test that variable names don't use the reserved gl_ prefix.
Fixes identifier2.frag.
2010-03-31 09:17:35 -10:00
Eric Anholt
b980207707 Test that discard only appears in the fragment shader.
Fixes fragmentOnly4.vert.
2010-03-30 23:40:14 -10:00
Eric Anholt
174cc03edc Test that main doesn't take any parameters.
Fixes main2.vert.
2010-03-30 23:37:51 -10:00
Eric Anholt
aad7c77937 Test that a non-void function returns a value. 2010-03-30 23:30:11 -10:00
Eric Anholt
ab79d4ec6e Test that a void function doesn't return a value.
Fixes function1.frag.
2010-03-30 23:28:17 -10:00
Eric Anholt
794ea61006 Fix unused variable warning. 2010-03-30 18:31:32 -10:00
Ian Romanick
a80cbd6d82 Forbid array comparisons in GLSL 1.10
This causes the following tests to pass:

    glslparsertest/shaders/array3.frag
2010-03-30 17:04:48 -07:00