Fast and flexible instruction selection with constraints

Tree-parsing instruction selection as used in, e.g., lcc, uses dynamic costs to gain flexibility and handle situations (such as read-modify-write instructions) that do not fit into the basic tree-parsing model. The disadvantage of dynamic costs is that we can no longer turn the tree grammar into a tree automaton (as is done by burg) for fast instruction selection for JIT compilers. In this paper we introduce constraints that say whether a tree-grammar rule is applicable or not. While theoretically less powerful than dynamic costs, constraints cover the practical uses of dynamic costs; more importantly, they allow turning the tree grammar with constraints into a tree automaton (with instruction-selection-time checks), resulting in faster instruction selection than with pure instruction-selection-time dynamic programming. We integrate constraints in an instruction selector that matches DAGs with tree rules. We evaluate this concept in lcc and the CACAO JavaVM JIT compiler, and see instruction selector speedups by a factor 1.33--1.89.

[1]  Albrecht Kadlec,et al.  Generalized instruction selection using SSA-graphs , 2008, LCTES '08.

[2]  FrankeBjörn,et al.  Generalized just-in-time trace compilation using a parallel task farm in a dynamic binary translator , 2011 .

[3]  Ian Rogers,et al.  Proceedings of the 4th workshop on the Implementation, Compilation, Optimization of Object-Oriented Languages and Programming Systems , 2009, ECOOP 2009.

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

[5]  Helmut Emmelmann,et al.  BEG: a generator for efficient back ends , 1989, PLDI '89.

[6]  David Ryan Koes,et al.  Near-optimal instruction selection on dags , 2008, CGO '08.

[7]  Andreas Krall,et al.  Efficient JavaVM just-in-time compilation , 1998, Proceedings. 1998 International Conference on Parallel Architectures and Compilation Techniques (Cat. No.98EX192).

[8]  Christopher W. Fraser,et al.  A Retargetable C Compiler: Design and Implementation , 1995 .

[9]  M. Anton Ertl Optimal code selection in DAGs , 1999, POPL '99.

[10]  Christopher W. Fraser,et al.  BURG: fast optimal instruction selection and tree parsing , 1992, SIGP.

[11]  Todd A. Proebsting BURS automata generation , 1995, TOPL.

[12]  Igor Böhm,et al.  Generalized just-in-time trace compilation using a parallel task farm in a dynamic binary translator , 2011, PLDI '11.

[13]  Reinhard Wilhelm,et al.  Tree automata for code selection , 1994, Acta Informatica.

[14]  Carl Friedrich Bolz,et al.  Tracing the meta-level: PyPy's tracing JIT compiler , 2009, ICOOOLPS@ECOOP.

[15]  Gabriel Hjort Blindell Instruction Selection , 2016, Springer International Publishing.

[16]  Vikram S. Adve,et al.  LLVM: a compilation framework for lifelong program analysis & transformation , 2004, International Symposium on Code Generation and Optimization, 2004. CGO 2004..

[17]  David Gregg,et al.  Fast and flexible instruction selection with on-demand tree-parsing automata , 2006, PLDI '06.

[18]  Andreas Krall,et al.  Adaptive inlining and on-stack replacement in the CACAO virtual machine , 2007, PPPJ.

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

[20]  Hanspeter Mössenböck,et al.  An intermediate representation for speculative optimizations in a dynamic compiler , 2013, VMIL '13.

[21]  Christopher W. Fraser,et al.  Hard‐coding bottom‐up code generation tables to save time and space , 1990, Softw. Pract. Exp..

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

[23]  Cliff Click,et al.  The java hotspot TM server compiler , 2001 .