Skip to main content

Constraint-Based Register Allocation and Instruction Scheduling

  • Conference paper
Principles and Practice of Constraint Programming (CP 2012)

Part of the book series: Lecture Notes in Computer Science ((LNPSE,volume 7514))

Abstract

This paper introduces a constraint model and solving techniques for code generation in a compiler back-end. It contributes a new model for global register allocation that combines several advanced aspects: multiple register banks (subsuming spilling to memory), coalescing, and packing. The model is extended to include instruction scheduling and bundling. The paper introduces a decomposition scheme exploiting the underlying program structure and exhibiting robust behavior for functions with thousands of instructions. Evaluation shows that code quality is on par with LLVM, a state-of-the-art compiler infrastructure.

The paper makes important contributions to the applicability of constraint programming as well as compiler construction: essential concepts are unified in a high-level model that can be solved by readily available modern solvers. This is a significant step towards basing code generation entirely on a high-level model and by this facilitates the construction of correct, simple, flexible, robust, and high-quality code generators.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 84.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 109.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Lattner, C., Adve, V.: LLVM: A compilation framework for lifelong program analysis & transformation. In: CGO (March 2004)

    Google Scholar 

  2. Goodwin, D.W., Wilken, K.D.: Optimal and near-optimal global register allocations using 0-1 integer programming. Software – Practice and Experience 26, 929–965 (1996)

    Article  Google Scholar 

  3. Appel, A.W., George, L.: Optimal spilling for CISC machines with few registers. SIGPLAN Not. 36, 243–253 (2001)

    Article  Google Scholar 

  4. Scholz, B., Eckstein, E.: Register allocation for irregular architectures. SIGPLAN Not. 37, 139–148 (2002)

    Article  Google Scholar 

  5. Anton Ertl, M., Krall, A.: Optimal Instruction Scheduling Using Constraint Logic Programming. In: Małuszyński, J., Wirsing, M. (eds.) PLILP 1991. LNCS, vol. 528, pp. 75–86. Springer, Heidelberg (1991)

    Chapter  Google Scholar 

  6. Malik, A.M., McInnes, J., van Beek, P.: Optimal basic block instruction scheduling for multiple-issue processors using constraint programming. International Journal on Artificial Intelligence Tools 17(1), 37–54 (2008)

    Article  Google Scholar 

  7. Leupers, R., Marwedel, P.: Time-constrained code compaction for DSP’s. IEEE Transactions on Very Large Scale Integration Systems 5, 112–122 (1997)

    Article  Google Scholar 

  8. Wilken, K., Liu, J., Heffernan, M.: Optimal instruction scheduling using integer programming. SIGPLAN Not. 35, 121–133 (2000)

    Article  Google Scholar 

  9. Malik, A.M., Chase, M., Russell, T., van Beek, P.: An Application of Constraint Programming to Superblock Instruction Scheduling. In: Stuckey, P.J. (ed.) CP 2008. LNCS, vol. 5202, pp. 97–111. Springer, Heidelberg (2008)

    Chapter  Google Scholar 

  10. Winkel, S.: Exploring the performance potential of Itanium processors with ILP-based scheduling. In: CGO, pp. 189–200. IEEE (2004)

    Google Scholar 

  11. Chou, H.C., Chung, C.P.: An optimal instruction scheduler for superscalar processor. IEEE Transactions on Parallel and Distributed Systems 6, 303–313 (1995)

    Article  Google Scholar 

  12. Shobaki, G., Wilken, K.: Optimal superblock scheduling using enumeration. In: MICRO, pp. 283–293. IEEE (2004)

    Google Scholar 

  13. Gebotys, C.H., Elmasry, M.I.: Simultaneous scheduling and allocation for cost constrained optimal architectural synthesis. In: DAC, pp. 2–7. ACM (1991)

    Google Scholar 

  14. Kästner, D.: PROPAN: A Retargetable System for Postpass Optimisations and Analyses. In: Davidson, J., Min, S.L. (eds.) LCTES 2000. LNCS, vol. 1985, pp. 63–80. Springer, Heidelberg (2001)

    Chapter  Google Scholar 

  15. Kuchcinski, K.: Constraints-driven scheduling and resource assignment. ACM Trans. Des. Autom. Electron. Syst. 8, 355–383 (2003)

    Article  Google Scholar 

  16. Nagarakatte, S.G., Govindarajan, R.: Register Allocation and Optimal Spill Code Scheduling in Software Pipelined Loops Using 0-1 Integer Linear Programming Formulation. In: Adsul, B., Vetta, A. (eds.) CC 2007. LNCS, vol. 4420, pp. 126–140. Springer, Heidelberg (2007)

    Chapter  Google Scholar 

  17. Bashford, S., Leupers, R.: Phase-coupled mapping of data flow graphs to irregular data paths. Design Automation for Embedded Systems, 119–165 (1999)

    Google Scholar 

  18. Wilson, T., Grewal, G., Halley, B., Banerji, D.: An integrated approach to retargetable code generation. In: ISSS, pp. 70–75. IEEE (1994)

    Google Scholar 

  19. Eriksson, M.V., Skoog, O., Kessler, C.W.: Optimal vs. heuristic integrated code generation for clustered VLIW architectures. In: SCOPES, pp. 11–20 (2008)

    Google Scholar 

  20. Sweetman, D.: See MIPS Run, 2nd edn. Morgan Kaufmann (2006)

    Google Scholar 

  21. Cytron, R., Ferrante, J., Rosen, B.K., Wegman, M.N., Zadeck, F.K.: Efficiently computing static single assignment form and the control dependence graph. ACM TOPLAS 13(4), 451–490 (1991)

    Article  Google Scholar 

  22. Sreedhar, V.C., Ju, R.D.-C., Gillies, D.M., Santhanam, V.: Translating Out of Static Single Assignment Form. In: Cortesi, A., Filé, G. (eds.) SAS 1999. LNCS, vol. 1694, pp. 194–210. Springer, Heidelberg (1999)

    Chapter  Google Scholar 

  23. Hack, S., Grund, D., Goos, G.: Register Allocation for Programs in SSA-Form. In: Mycroft, A., Zeller, A. (eds.) CC 2006. LNCS, vol. 3923, pp. 247–262. Springer, Heidelberg (2006)

    Chapter  Google Scholar 

  24. Smith, M.D., Ramsey, N., Holloway, G.: A generalized algorithm for graph-coloring register allocation. SIGPLAN Not. 39, 277–288 (2004)

    Article  Google Scholar 

  25. Appel, A.W.: SSA is functional programming. SIGPLAN Not. 33(4), 17–20 (1998)

    Article  MathSciNet  Google Scholar 

  26. Aycock, J., Horspool, N.: Simple Generation of Static Single-Assignment Form. In: Watt, D.A. (ed.) CC 2000. LNCS, vol. 1781, pp. 110–124. Springer, Heidelberg (2000)

    Chapter  Google Scholar 

  27. Beldiceanu, N., Carlsson, M.: Sweep as a Generic Pruning Technique Applied to the Non-overlapping Rectangles Constraint. In: Walsh, T. (ed.) CP 2001. LNCS, vol. 2239, pp. 377–391. Springer, Heidelberg (2001)

    Chapter  Google Scholar 

  28. Pereira, F., Palsberg, J.: Register allocation by puzzle solving. SIGPLAN Not. 43, 216–226 (2008)

    Article  Google Scholar 

  29. Aggoun, A., Beldiceanu, N.: Extending CHIP in order to solve complex scheduling and placement problems. Mathematical and Computer Modelling 17(7), 57–73 (1993)

    Article  MathSciNet  Google Scholar 

  30. Kessler, C.W.: Compiling for VLIW DSPs. In: Handbook of Signal Processing Systems, pp. 603–638. Springer (2010)

    Google Scholar 

  31. Chaitin, G.J., Auslander, M.A., Chandra, A.K., Cocke, J., Hopkins, M.E., Markstein, P.W.: Register allocation via coloring. Computer Languages 6(1), 47–57 (1981)

    Article  Google Scholar 

  32. Boissinot, B., Hack, S., Grund, D., Dupont de Dinechin, B., Rastello, F.: Fast liveness checking for SSA-form programs. In: CGO, pp. 35–44. ACM (2008)

    Google Scholar 

  33. Gecode Team: Gecode: generic constraint development environment (2006), http://www.gecode.org

  34. Chow, F., Hennessy, J.: Register allocation by priority-based coloring. SIGPLAN Not. 19(6), 222–232 (1984)

    Article  Google Scholar 

  35. Rau, B.R., Fisher, J.A.: Instruction-level parallel processing: history, overview, and perspective. J. Supercomput. 7, 9–50 (1993)

    Article  Google Scholar 

  36. Hooker, J.N., Ottosson, G.: Logic-based Benders decomposition. Mathematical Programming 96(1), 33–60 (2003)

    MathSciNet  MATH  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2012 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Lozano, R.C., Carlsson, M., Drejhammar, F., Schulte, C. (2012). Constraint-Based Register Allocation and Instruction Scheduling. In: Milano, M. (eds) Principles and Practice of Constraint Programming. CP 2012. Lecture Notes in Computer Science, vol 7514. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-33558-7_54

Download citation

  • DOI: https://doi.org/10.1007/978-3-642-33558-7_54

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-642-33557-0

  • Online ISBN: 978-3-642-33558-7

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics