A High-Level IR Transformation System
The development and implementation of source-to-source code transformations based on high-level intermediate representations (IRs) is a labor-intensive, error-prone task. It tends to result in large code bases which are hard to read and maintain. Although not encountered within widely used source-to-source compiler infrastructures, transformation systems tackle this issue by utilizing declarative descriptions of unification-based term rewriting rules. However, unification lacks the ability of (arbitrarily) deep term inspection and is limited to tree nodes exhibiting a fixed arity – a property not generally satisfied by high-level IRs or programming languages.
In this paper we present a declarative tree transformation system which exceeds the expressiveness of conventional unification based systems by operating on arbitrary tree structures.We define its formal foundation, describe its implementation within the Insieme compiler project and provide real-world code examples. The latter demonstrate the expressive power, usability and intuitiveness of our solution.
KeywordsCompiler Program Transformation Term Rewriting Pattern Matching Regular Expressions
Unable to display preview. Download preview PDF.
- 1.clang: a C language family frontend for LLVM (2012), http://clang.llvm.org/ (Online May 30, 2013)
- 3.Insieme Compiler and Runtime Infrastructure. University of Innsbruck, http://insieme-compiler.org
- 4.Jordan, H., et al.: INSPIRE: The Insieme Parallel Intermediate Representation. In: PACT. ACM (2013) (to be published)Google Scholar
- 5.Merrill, J.: Generic and gimple: A new tree representation for entire functions. In: GCC Developers Summit, pp. 171–179 (2003)Google Scholar
- 7.Quinlan, D.: ROSE: Compiler support for object-oriented frameworks. Parallel Processing Letters 10(02-03), 215–226 (2000)Google Scholar
- 8.The Program Transformation Wiki (2013), http://program-transformation.org/ (May 30, 2013)
- 10.Visser, E.: A survey of rewriting strategies in program transformation systems. ENTCS 57, 109–143 (2001)Google Scholar