|
ABSTRACT
A standard approach to the analysis of program structure for the purpose of code optimization is to construct the "control flow graph" which models the possible execution paths through the program. Various graph algorithms can be applied to the control flow graph to produce data flow information, possible optimizations, etc. [A1,A2,AC,AU2,AU3,CS,HU1,HU2.HU3,Ke1,Ke2,Ke3,Ke4,Sc,U]. Studies of the form of typical control flow graphs indicate that such graphs tend to fall into a restricted subclass of general graphs. For example, empirical investigations have shown that the vast majority of program graphs have no multiple-entry loops [AC,HU2,HU3,Kn1].The recent work on "structured programming" has suggested that "good" programs fall into an even more restricted subclass. In fact, purists recommend that all programs be synthesized from three basic control structures: sequential statements, if-then-else statements, and single-entry single-exit loops [Di,Wi].Formal language theory [HoU] has given us a practical way to specify the set of strings which comprise a given language: via a grammar. It is then a natural idea to extend grammars from the strings to graphs in hopes of getting the same power of expression. Several researchers have used this approach [FKZ,J2,Ro].In this paper we study the applicability of a grammatical approach to describing the set of control flow graphs which arise from "good" programs in the sense proposed by many programming practitioners. The resulting flow graph language contains all those programs constructed according to the purists' rules and also admits programs with multiple-exit loops if such loops are constructed sensibly. The grammar we use is the "semi-structured flow graph" grammar GSSFG which was studied originally in [FKZ]. There are several appealing properties of this grammar; perhaps the most important, from the point-of-view of a compiler-writer, is the existence of a linear-time parsing algorithm which leads directly to a linear-time data flow analysis method [FKZ].In the present work we summarize the results from [FKZ] and address several new questions. First, how often do programs written by people with no knowledge of the SSFG rules fall into the language defined by GSSFG? In other words, is the language a natural one for programming? Second, once a program has been parsed according to GSSFG do benefits other than fast data flow analysis accrue?The paper is organized into three main sections. Section II introduces GSSFG and the parsing algorithm from [FKZ]. Section III is devoted to an empirical study conducted by the authors in an attempt to answer the question of naturalness, described above. Section IV discusses several applications of the graph parse in a "graph attribute grammar" framework. The summary at the end of the paper includes suggestions for further investigation.
REFERENCES
Note: OCR errors may be found in this Reference List extracted from the full text article. ACM has opted to expose the complete List rather than only correct and linked references.
| |
1
|
{ASU} Aho, A. V., Sethi, R. and Ullmann, J. D., "Code Optimization and Finite Church-Rosser Systems" in Design and Optimization of Compilers, (R. Rustin, ed.) Prentice-Hall, Englewood Cliffs, N.J., 1972.
|
| |
2
|
|
| |
3
|
|
 |
4
|
|
 |
5
|
|
| |
6
|
{A2} Allen, F. E., "A Basis for Program Optimization," Proc. IFIP Conf. 71, North-Holland Publishing Co. Amsterdam, 1971.
|
| |
7
|
{AC} Allen, F. E. and Cocke, J., "Graph Theoretic Constructs for Program Flow Analysis," IBM Research Report RC 3923, T.J. Watson Research Center, Yorktown Heights, N.Y., July 1972.
|
| |
8
|
{AM} Ashcroft, E. and Manna, Z., "The Translation of 'Goto' Programs Into 'While' Programs," Proc. IFIP Conf. 71, North Holland Publishing Co., Amsterdam, 1971.
|
| |
9
|
{Be} Beatty, J. C., "An Algorithm for Tracing Live Variables Based On A Straightened Program Graph," IBM Technical Report TR 00.2503, IBM Poughkeepsie Laboratory, December 1973.
|
 |
10
|
|
| |
11
|
{CK} Cocke, J. and Kennedy, K., "Profitability Computations on Program Flow Graphs," IBM Research Report RC 5123, T.J. Watson Research Center, Yorktown Heights, N.Y., November 1974.
|
| |
12
|
|
| |
13
|
{Di} Dijkstra, E. W., "Notes on Structured Programming," in Dahl, Dijkstra and Hoare, Structured Programming, Academic Press (1972).
|
 |
14
|
|
| |
15
|
{FKZ} Farrow, R., Kennedy, K., and Zucconi, L., "Graph Grammars and Global Program Data Flow Analysis," to appear in Proceedings of the Seventeenth Annual IEEE Symposium on the Foundations of Computer Science, October 1976.
|
 |
16
|
|
 |
17
|
|
 |
18
|
|
| |
19
|
{HU2} Hecht, M. S., and Ullman, J. D., "Flow Graph Reducibility," SIAM J. Computing, Vol. 1, No. 2, pp. 188-202, June 1972.
|
 |
20
|
|
| |
21
|
|
| |
22
|
{J2} Jazayeri, M., "Live Variable Analysis, Attribute Grammars, and Program Optimization," draft, Dept. of Computer Science, University of North Carolina, Chapel Hill, N.C. March 1975.
|
 |
23
|
|
| |
24
|
{Ke1} Kennedy, K., "A Global Flow Analysis Algorithm," International J. Computer Math., Section A, Vol. 3, pp. 5-15, Dec. 1971.
|
| |
25
|
{Ke2} Kennedy, K., "A Comparison of Algorithms for Global Flow Analysis," Technical Report 476-093-1, Dept. of Mathematical Sciences, Rice University, Houston, Texas, Feb. 1974.
|
 |
26
|
|
| |
27
|
{Ke4} Kennedy, K., "Use-definition Chains with Applications," Rice Technical Report 476-093-9, Dept. of Mathematical Sciences, Rice University, Houston, Texas, April 1975.
|
| |
28
|
{KR} Kennedy, K. and Ramanathan, J., "A Deterministic Attribute Grammar Evaluator Based on Dynamic Sequencing," Technical Report 476-093-12, Dept. of Mathematical Sciences, Rice University, Houston, Texas, Oct. 1975.
|
 |
29
|
|
| |
30
|
|
 |
31
|
|
 |
32
|
|
| |
33
|
{Kn1} Knuth, Donald E., "An Empirical Study of Fortran Programs," Software Practice and Experience, Vol. 1, No. 2, 1971, pp. 105-134.
|
 |
34
|
|
| |
35
|
{Kn3} Knuth, Donald E., "Semantics of Context-Free Languages," Math. Systems Theory J. 2, pp. 127-145 (1968).
|
| |
36
|
{Kn4} Knuth, Donald E., "Semantics of Context-Free Languages: Correction," Math Systems Theory J 5, p. 95 (1971).
|
 |
37
|
|
| |
38
|
{MT} Markowsky, G. and Tarjan, R. E., "Lower Bounds on the Lengths of Node Sequences in Directed Graphs," IBM Research Report RC 5477, T.J. Watson Research Center, Yorktown Heights, N.Y., July 1975.
|
 |
39
|
|
 |
40
|
|
 |
41
|
|
| |
42
|
|
 |
43
|
|
 |
44
|
|
| |
45
|
{T} Tarjan, R. E., "Depth-First Search and Linear Graph Algorithms," SIAM J. Computing, Vol. 1, No. 2, June 1972.
|
| |
46
|
{U} Ullman, J. D., "Fast Algorithms for the Elimination of Common Subexpressions," Acta Informatica, Vol. 2, pp. 191-213, 1973.
|
 |
47
|
|
 |
48
|
|
 |
49
|
|
 |
50
|
|
| |
51
|
{Z} Zahn, C. T., "Structured Control in Programming Languages," Proceedings of the 1975 NCC, AFIPS Conference Proceedings, Vol. 44, AFIPS Press (1975).
|
CITED BY 8
|
|
Karen A. Lemone , Mary Ann A. O'Connor , Jeffrey J. McConnell , Joc Wisnewski, Implementing semantics of object oriented languages using attribute grammars, Proceedings of the 19th annual conference on Computer Science, p.190-202, April 1991, San Antonio, Texas, United States
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|