src/compiler/translator/UnfoldShortCircuitToIf.cpp


Log

Author Commit Date CI Message
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>