Rewriting Strategies for Instruction Selection
Instruction selection (mapping IR trees to machine instructions) can be expressed by means of rewrite rules. Typically, such sets of rewrite rules are highly ambiguous. Therefore, standard rewriting engines based on fixed, exhaustive strategies are not appropriate for the execution of instruction selection. Code generator generators use special purpose implementations employing dynamic programming. In this paper we show how rewriting strategies for instruction selection can be encoded concisely in Stratego, a language for program transformation based on the paradigm of programmable rewriting strategies. This embedding obviates the need for a language dedicated to code generation, and makes it easy to combine code generation with other optimizations.
KeywordsDynamic Programming Instruction Tree Purpose Implementation Program Transformation Intermediate Representation
Unable to display preview. Download preview PDF.
- 1.A. V. Aho, M. Ganapathi, and S. W. K. Tjiang. Code generation using tree pattern matching and dynamic programming. ACM Transactions on Programming Languages and Systems, 11(4):491–516, October 1989.Google Scholar
- 3.A. W. Appel. Modern Compiler Implementation in ML. Cambridge University Press, 1998.Google Scholar
- 5.H. Emmelmann, F.-W. Schroer, and R. Landwehr. BEG-a generator for efficient back ends. In ACM SIGPLAN 1989 Conference on Programming Language Design and Implementation (PLDI’89), pages 227–237. ACM, July 1989.Google Scholar
- 6.C. H. Hoffmann and M. J. O’Donnell. Pattern matching in trees. Journal of the ACM, 29(1):68–95, January 1982.Google Scholar
- 7.P. Johann and E. Visser. Fusing logic and control with local transformations: An example optimization. In B. Gramlich and S. Lucas, editors, Workshop on Reduction Strategies in Rewriting and Programming (WRS’01), volume 57 of Electronic Notes in Theoretical Computer Science, Utrecht, The Netherlands, May 2001. El-sevier Science Publishers.Google Scholar
- 8.T. A. Proebsting. BURS automata generation. ACM Transactions on Programming Languages and Systems, 17(3):461–486, May 1995.Google Scholar
- 9.E. Visser. Scoped dynamic rewrite rules. In M. van den Brand and R. Verma, editors, Rule Based Programming (RULE’01), volume 59/4 of Electronic Notes in Theoretical Computer Science. Elsevier Science Publishers, September 2001.Google Scholar
- 10.E. Visser. Stratego: A language for program transformation based on rewriting strategies. System description of Stratego 0.5. In A. Middeldorp, editor, Rewriting Techniques and Applications (RTA’ 01), volume 2051 of Lecture Notes in Computer Science, pages 357–361. Springer-Verlag, May 2001.CrossRefGoogle Scholar
- 11.E. Visser, Z.-e.-A. Benaissa, and A. Tolmach. Building program optimizers with rewriting strategies. In Proceedings of the third ACM SIGPLAN International Conference on Functional Programming (ICFP’98), pages 13–26. ACM Press, September 1998.Google Scholar