Towards Optimizing Code Generation by Domain-Sensitive Macro Expansion

Many modern code generation methods use tree pattern matching with dynamic programming. However, especially in the case of an irregular special-purpose processor architecture their lack of transparency and stability may be problematic: it is diicult to predict the exact code generation result in advance, and the eeects of a modiication in the code generation rules may be surprisingly wide. In contrast, macro expansion techniques are intuitively transparent. When global variables are disallowed, macro expansion typically has the Church-Rosser property: the nal expansion result is independent of the expansion order of the individual intermediate macro calls. Besides enabling parallel implementation, order-independence means stability: the eeects of modifying a macro deenition are guaranteed to remain local. The locality is actually the problem with macro expansion; code optimization is improved when an assembly language macro is sensitive to its context. For instance , it should know which registers are free and which ones contain useful values. A traditional mechanism for propagating contextual information is the use of global variables. But relying on global variables means that the expansion should take place strictly from left to right, so that order-independence is lost while it is still not possible to pass information in the opposite direction. In this work a novel assembly-language-level macro expansion technique with both order-independence and rather general context-sensitivity is proposed. The technique supports modular and hierarchical code libraries. Both a formal model and a code generator prototype demonstrating the technique are presented. Foreword This work has been carried out at Digital Systems Laboratory of Helsinki University of Technology. I wish to thank Professor Leo Ojala for his continuous support and guidance; in particular, I appreciate with gratitude the opportunity to concentrate on the present subject. To all my co-workers at the laboratory, I certainly owe a lot for the inspiring atmosphere. I am indebted especially to Dr. Johan Lilius and Dr. Ilkka Niemell a for their valuable suggestions on the coordination of my eeorts.

[1]  Dhananjay M. Dhamdhere,et al.  Efficient Retargetable Code Generation Using Bottom-up Tree Pattern Matching , 1990, Comput. Lang..

[2]  A. W. M. van den Enden,et al.  Discrete Time Signal Processing , 1989 .

[3]  Irwin D. Greenwald A technique for handling macro instructions , 1959, CACM.

[4]  S. M. Kafka An assembly source level global compacter for digital signal processors , 1990, International Conference on Acoustics, Speech, and Signal Processing.

[5]  장훈,et al.  [서평]「Computer Organization and Design, The Hardware/Software Interface」 , 1997 .

[6]  Sharad Malik,et al.  Challenges in code generation for embedded processors , 1994, Code Generation for Embedded Processors.

[7]  John R. Metzner,et al.  A graded bibliography on macro systems and extensible languages , 1979, SIGP.

[8]  David E. Ferguson Evolution of the meta-assembly program , 1966, CACM.

[9]  Christopher W. Fraser A language for writing code generators , 1989, PLDI '89.

[10]  Charlie Bass,et al.  Microsystems PLZ: A Family of System Programming Languages for Microprocessors , 1978, Computer.

[11]  Stanley L. Hurst Custom VLSI microelectronics , 1992 .

[12]  Doug Arnold,et al.  Machine Translation: An Introductory Guide , 1994 .

[13]  S LamMonica,et al.  Efficient context-sensitive pointer analysis for C programs , 1995 .

[14]  Eero Lassila A macro expansion approach to embedded processor code generation , 1996, Proceedings of EUROMICRO 96. 22nd Euromicro Conference. Beyond 2000: Hardware and Software Design Strategies.

[15]  William A. Wulf,et al.  BLISS: a language for systems programming , 1971, CACM.

[16]  Martin Campbell-Kelly An introduction to macros , 1973 .

[17]  Stan Y. Liao,et al.  Code generation and optimization for embedded digital signal processors , 1996 .

[18]  E.A. Lee Programmable DSP architectures. I , 1988, IEEE ASSP Magazine.

[19]  J A Fisher,et al.  Instruction-Level Parallel Processing , 1991, Science.

[20]  Edsger W. Dijkstra,et al.  Go To Statement Considered Harmful , 2022, Software Pioneers.

[21]  Peter J. Brown,et al.  Macroprocessors and Techniques for Portable Software , 1974 .

[22]  Mary Shaw,et al.  Toward relaxing assumptions in languages and their implementations , 1980, SIGP.

[23]  J. Roger Hindley,et al.  Introduction to combinators and λ-calculus , 1986, Acta Applicandae Mathematicae.

[24]  Thomas B. Steel,et al.  UNCOL: The myth and the fact , 1961 .

[25]  Christopher W. Fraser,et al.  Engineering a simple, efficient code-generator generator , 1992, LOPL.

[26]  N Solntseff,et al.  A survey of extensible programming languages , 1974 .

[27]  Owen R. Mock,et al.  The problem of programming communication with changing machines: a proposed solution , 1958, CACM.

[28]  Christopher W. Fraser,et al.  Code selection through object code optimization , 1984, TOPL.

[29]  Harold L. Somers,et al.  An introduction to machine translation , 1992 .

[30]  Kurt Keutzer,et al.  Code Optimization Techniques for Embedded DSP Microprocessors , 1995, 32nd Design Automation Conference.

[31]  C. Geschke,et al.  Reflections on a systems programming language , 1971 .

[32]  James R. Larus Assemblers, Linkers, and the SPIM Simulator , 1993 .

[33]  James L. Reuss Macro Implementation of a Structured Assembly Language , 1982, IEEE Transactions on Software Engineering.

[34]  M. Douglas McIlroy Macro instruction extensions of compiler languages , 1960, CACM.

[35]  Donald E. Knuth,et al.  The Early Development of Programming Languages. , 1977 .

[36]  Matthew S. Hecht,et al.  Flow Analysis of Computer Programs , 1977 .

[37]  David A. Patterson,et al.  Reduced instruction set computers , 1985, CACM.

[38]  Charles N. Fischer,et al.  Retargetable Compiler Code Generation , 1982, CSUR.

[39]  Jack G. Ganssle,et al.  The Art of Programming Embedded Systems , 1991 .

[40]  Donald E. Knuth,et al.  The TeXbook , 1984 .

[41]  Susan L. Graham,et al.  A new method for compiler code generation , 1978, POPL '78.

[42]  Peter D. Lawrence,et al.  Real-time microcomputer system design - an introduction , 1987, McGraw-Hill series in electrical engineering.

[43]  Simon L. Peyton Jones,et al.  The Implementation of Functional Programming Languages , 1987 .

[44]  GhiyaRakesh,et al.  Context-sensitive interprocedural points-to analysis in the presence of function pointers , 1994 .

[45]  Susan L. Graham,et al.  Table-Driven Code Generation , 1980, Computer.

[46]  J. W. Backus,et al.  The FORTRAN automatic coding system , 1899, IRE-AIEE-ACM '57 (Western).

[47]  D. L. Parnas,et al.  On the criteria to be used in decomposing systems into modules , 1972, Software Pioneers.

[48]  Richard L. Sites,et al.  Machine-independent PASCAL code optimization , 1979, SIGPLAN '79.

[49]  J. S. Wholey IEEE Transactions on Electronic Computers , 1963 .

[50]  Joseph A. Fisher,et al.  Trace Scheduling: A Technique for Global Microcode Compaction , 1981, IEEE Transactions on Computers.

[51]  David F. Bacon,et al.  Compiler transformations for high-performance computing , 1994, CSUR.

[52]  B. N. Dickman ETC: an extendible macro-based compiler , 1971, AFIPS '71 (Spring).

[53]  Thomas Richard Wilcox Generating machine code for high-level programming languages , 1971 .

[54]  Niklaus Wirth,et al.  PL360, a Programming Language for the 360 Computers , 1968, JACM.

[55]  Pierre G. Paulin,et al.  DSP design tool requirements for embedded systems: A telecommunications industrial perspective , 1995, J. VLSI Signal Process..

[56]  Laurie J. Hendren,et al.  Context-sensitive interprocedural points-to analysis in the presence of function pointers , 1994, PLDI '94.

[57]  Brian W. Kernighan,et al.  The C Programming Language, Second Edition , 1988 .

[58]  William Kent Assembler-Language Macroprogramming: A Tutorial Oriented Toward the IBM 360 , 1969, CSUR.

[59]  Eero Lassila ReFlExAn Experimental Tool for Special-Purpose Processor Code Generation , 1996 .

[60]  Emmanuel Skordalakis Meta-assemblers , 1983, IEEE Micro.

[61]  Jim Welch Structured programming in macro assembly languages , 1978, Softw. Pract. Exp..

[62]  D. Farber A survey of the systematic use of macros in systems building , 1971, SIGPLAN Symposium on Languages for System Implementation.

[63]  Robert R Henry Graham-Glanville Code Generators , 1999 .

[64]  Thomas E. Cheatham,et al.  The introduction of definitional facilities into higher level programming languages , 1966, AFIPS '66 (Fall).

[65]  Peter Lee,et al.  Optimizing ML with run-time code generation , 1996, PLDI '96.

[66]  John L. Hennessy,et al.  The priority-based coloring approach to register allocation , 1990, TOPL.

[67]  Erin Farquhar,et al.  The MIPS Programmer's Handbook , 1994 .

[68]  William A. Wulf Compilers and Computer Architecture , 1981, Computer.

[69]  John McCarthy,et al.  Mathematical Theory of Computation , 1991 .

[70]  Philip A. Nelson,et al.  A comparison of PASCAL intermediate languages , 1979, SIGPLAN '79.

[71]  Mark I. Halpern Programming Languages: Toward a general processor for programming languages , 1968, CACM.

[72]  William H. Harrison A New Strategy for Code Generation - the General-Purpose Optimizing Compiler , 1979, IEEE Trans. Software Eng..

[73]  Manuel E. Benitez,et al.  The Advantages of Machine-Dependent Global Optimization , 1994, Programming Languages and System Architectures.

[74]  Kurt Keutzer,et al.  Storage assignment to decrease code size , 1996, TOPL.

[75]  Charles N. Fischer,et al.  Crafting a Compiler , 1988 .

[76]  Peter J. Brown,et al.  A survey of macro processors , 1969 .

[77]  Eduardo Pelegrí-Llopart,et al.  Optimal code generation for expression trees: an application BURS theory , 1988, POPL '88.

[78]  Bjarne Stroustrup,et al.  C++ Programming Language , 1986, IEEE Softw..

[79]  Alfred V. Aho,et al.  Compilers: Principles, Techniques, and Tools , 1986, Addison-Wesley series in computer science / World student series edition.

[80]  David Salomon,et al.  Assemblers and loaders , 1992, Ellis Horwood series in computers and their applications.

[81]  Alfred V. Aho,et al.  Code generation using tree matching and dynamic programming , 1989, ACM Trans. Program. Lang. Syst..

[82]  Mark Elson,et al.  Code-Generation Technique for Large-Language Compilers , 1970, IBM Syst. J..

[83]  Robert Steven Glanville,et al.  A Machine Independent Algorithm for Code Generation and Its Use in Retargetable Compilers , 1977 .

[84]  Henk Barendregt,et al.  The Lambda Calculus: Its Syntax and Semantics , 1985 .

[85]  Steven W. K. Tjiang,et al.  SUIF: an infrastructure for research on parallelizing and optimizing compilers , 1994, SIGP.