src/compiler/translator/UnfoldShortCircuitToIf.cpp


Log

Author Commit Date CI Message
Olli Etuaho d0bad2c7 2016-09-09T18:01:16 Split ternary node class from TIntermSelection Ternary operator nodes are typed parts of expressions, they always have two children and the children are also guaranteed to be TIntermTyped. "If" selection nodes can't be a part of an expression, they can have either one or two children and the children are code blocks. Due to all of these differences it makes sense to store these using two different AST node classes. BUG=angleproject:1490 TEST=angle_unittests Change-Id: I913ab1d806e3cdb5c21106f078cc9c0b6c72ac54 Reviewed-on: https://chromium-review.googlesource.com/384512 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Olli Etuaho a223430c 2016-08-31T12:05:39 Promote unary nodes automatically Unary nodes now get their type set automatically based on the operation and operand. The operand should only be changed to another of the same type after the node is constructed. The operation can't be changed on unary and binary nodes after they've been constructed. BUG=angleproject:1490 TEST=angle_unittests Change-Id: Ib1ea3dcb1162261966c02d5f03d8091cf647fac1 Reviewed-on: https://chromium-review.googlesource.com/378935 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 3cbb27a1 2016-07-14T11:55:48 Simplify loop conditions so that they won't generate statements Introduce an AST traverser that can move the evaluation of certain types of loop conditions and loop expressions inside the loop. This way subsequent AST transformations don't have to worry about cases where they have to insert new statements to implement a loop condition or expression. This includes the revert of "Unfold short-circuiting operators in loop conditions correctly". The new traverser covers the loop cases that used to be handled in UnfoldShortCircuitToIf. BUG=angleproject:1465 TEST=WebGL conformance tests, dEQP-GLES2.functional.shaders.*select_iteration_count* Change-Id: I88e50e007e924d5884a217117690ac7fa2f96d38 Reviewed-on: https://chromium-review.googlesource.com/362570 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Jamie Madill 03d863c8 2016-07-27T18:15:53 translator: Refactor node replacement APIs. BUG=angleproject:851 Change-Id: I50c3b3a4f00b27fed85f09509738513a441c7b5b Reviewed-on: https://chromium-review.googlesource.com/363990 Reviewed-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Zhenyao Mo <zmo@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Olli Etuaho 00f6fbbe 2016-07-20T16:32:29 Add IntermNodePatternMatcher helper class This will enable sharing code between different AST traversers that apply transformations on similar node structures. This will make the code more maintainable. For now the helper class is used in UnfoldShortCircuitToIf and SeparateExpressionsReturningArrays. BUG=angleproject:1341 TEST=angle_end2end_tests, WebGL 2 conformance tests Change-Id: Ib1e0d5a84fd05bcca983b34f18d47c53e86dc227 Reviewed-on: https://chromium-review.googlesource.com/361693 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 3fed4306 2015-11-02T12:26:02 Unfold short-circuiting operators in loop conditions correctly Sometimes short-circuiting operators need to be unfolded to if statements. If the unfolded operator is inside a loop condition or expression, it needs to be evaluated repeatedly inside the loop. Add logic to UnfoldShortCircuitToIf that can move or copy the unfolded part of loop conditions or expressions to inside the loop. The exact changes that need to be done depend on the type of the loop. For loops may require also moving the initializer to outside the loop. The unfolded expression inside a loop condition or expression is moved or copied to inside the loop on the first traversal of the loop node, and unfolding to if is deferred until a second traversal. This keeps the code relatively simple. BUG=angleproject:1167 TEST=WebGL 2 conformance tests, dEQP-GLES2.functional.shaders.*select_iteration_count* Change-Id: Ieffc0ea858186054378d387dca9aa64a5fa95137 Reviewed-on: https://chromium-review.googlesource.com/310230 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 3d0d9a48 2015-06-01T12:16:36 Clean up TIntermTraverser usage Remove default parameters from TIntermTraverser. Also clean up a few dead function declarations in traversers. TEST=angle_unittests, angle_end2end_tests BUG=angleproject:1037 Change-Id: I8d126c6c2d5b53e8b14e23e3d102f204a59323b3 Reviewed-on: https://chromium-review.googlesource.com/275184 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho d4f303ee 2015-05-20T17:09:06 Refactoring: Make creating temporary symbols in AST traversal reusable Temporary symbols will also be needed to store temporary arrays when complex array expressions are unfolded. Also clear tree update related structures at the end of updateTree(), so that the traverser can be reused for several rounds of replacement more easily, and remove unnecessary InVisit step from UnfoldShortCircuitToIf. BUG=angleproject:971 TEST=angle_end2end_tests, WebGL conformance tests Change-Id: Iecdd3008d43f01b02fe344ccde8614f70e6c0c65 Reviewed-on: https://chromium-review.googlesource.com/272121 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 56eea884 2015-05-18T12:41:03 Refactoring: make tracking parent block position in AST traversal reusable Add a helper function to make it easier for traverser classes to insert statements, and use it in UnfoldShortCircuitToIf. BUG=angleproject:971 TEST=angle_end2end_tests, WebGL conformance tests Change-Id: I141bdd8abf4b01988581e6cb27c2320bf38370ac Reviewed-on: https://chromium-review.googlesource.com/272140 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 0ea959f4 2015-05-13T14:51:59 Unfold sequence operator when operations inside need unfolding Unfolding the sequence operator ensures correct evaluation order when parts of the expression need to get hoisted out of the expression to the surrounding scope. BUG=angleproject:1001 TEST=WebGL conformance tests Change-Id: Ifd3093c9fb63d3e9842ebb4b9531b2f46875ad8a Reviewed-on: https://chromium-review.googlesource.com/270660 Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho a6f22096 2015-05-08T18:31:10 Make UnfoldShortCircuit to change AST instead of writing output This is needed to make way for further AST transformations to handle array expressions that need to work correctly together with unfolding short- circuiting operators. This also improves the maintainability of HLSL output by isolating the unfolding into a separate compilation step. The new version of UnfoldShortCircuit traverser will traverse the tree until an expression that needs to be unfolded is encountered. It then unfolds it and gets reset. The traverser will be run repeatedly until no more operations to unfold are found. This helps with keeping the traverser's design relatively simple. All declarations are separated to single declarations before short-circuit unfolding is run. Previously OutputHLSL already output every declaration separately. BUG=angleproject:960 TEST=WebGL conformance tests, angle_unittests, angle_end2end_tests Change-Id: Id769be396adbd4c0223e418980dc464dd855f019 Reviewed-on: https://chromium-review.googlesource.com/270460 Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>