You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: flang/docs/FortranIR.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,9 @@
1
-
<!--===- docs/FortranIR.md
2
-
1
+
<!--===- docs/FortranIR.md
2
+
3
3
Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
4
See https://llvm.org/LICENSE.txt for license information.
5
5
SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
-
6
+
7
7
-->
8
8
9
9
# Design: Fortran IR
@@ -95,7 +95,7 @@ The CFG can be directly constructed by traversing the parse tree, threading cont
95
95
96
96
* Pro: Straightforward implementation when control-flow is well-structured as the contextual state parallels the syntax of the language closely.
97
97
* Con: The contextual state needed can become large and difficult to manage in the presence of unstructured control-flow. For example, not every labeled statement in Fortran may be a control-flow destination.
98
-
* Con: The contextual state must deal with the recursive nature of the parse tree.
98
+
* Con: The contextual state must deal with the recursive nature of the parse tree.
99
99
* Con: Complexity. Since structured constructs cohabitate with unstructured constructs, the context needs to carry information about all combinations until the basic blocks and relations are fully elaborated.
100
100
101
101
#### Alternative: linearized approach (decomposing the problem)
@@ -104,7 +104,7 @@ Instead of constructing the CFG directly from a parse tree traversal, an interme
104
104
105
105
While each control-flow source statement is explicit in the traversal, it can be the case that not all of the targets have been traversed yet (references to forward basic blocks), and those basic blocks will not yet have been created. These relations can be captured at the time the source is traversed, added to a to do list, and then completed when all the basic blocks for the procedure have been created. Specifically, at the point when we create a terminator all information is known to create the FIR terminator, however all basic blocks that may be referenced may not have been created. Those are resolved in one final "clean up" pass over a list of closures.
106
106
107
-
* Con: An extra representation must be defined and constructed.
107
+
* Con: An extra representation must be defined and constructed.
108
108
* Pro: This representation reifies all the information that is referred to as contextual state in the direct approach.
109
109
* Pro: Constructing the linearized form can be done with a simple traversal of the parse tree.
110
110
* Pro: Once composed the linearized form can be traversed and a CFG directly constructed. This greatly reduces bookkeeping of contextual state.
0 commit comments