Formal Aspects of Computing

, Volume 6, Issue 6, pp 643–658 | Cite as

Specification, Verification and Prototyping of an Optimized Compiler

Formal Aspects of Computing

Abstract

This paper generalizes an algebraic method for the design of a correct compiler to tackle specification and verification of an optimized compiler. The main optimization issues of concern here include the use of existing contents of registers where possible and the identification of common expressions. A register table is introduced in the compiling specification predicates to map each register to an expression whose value is held by it. We define different kinds of predicates to specify compilation of programs, expressions and Boolean tests. A set of theorems relating to these predicates, acting as a correct compiling specification, are presented and an example proof within the refinement algebra of the programming language is given. Based on these theorems, a prototype compiler in Prolog is produced.

Keywords

Program compilation Code optimization Formal verification Refinement algebra Logic programming 

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. [ASU86]
    Aho, A. V., Sethi, R. and Ullman, J. D.: Compilers: Principles, Techniques and Tools. Addison-Wesley, Series in Computer Science, 1986.Google Scholar
  2. [BJø92]
    Bjørner, D.: Trusted Computing Systems: The ProCoS Experience. Proc. ICSE ’14, North-Holland, Melbourne, Australia, 11–14 May 1992.CrossRefGoogle Scholar
  3. [Bow92]
    Bowen, J. P.: From Programs to Object Code using Logic and Logic Programming. In [GiG92], pp. 173–192.Google Scholar
  4. [Bow93a]
    Bowen, J. P.: From Programs to Object Code and back again using Logic Programming: Compilation and Decompilation. Journal of Software Maintenance: Research and Practice, 5, 205–234 (December 1993).CrossRefGoogle Scholar
  5. [Bow93b]
    Bowen, J. P. et al.: A ProCoS II Project Description: ESPRIT Basic Research Project 7071. Bulletin of the European Association for Theoretical Computer Science (EATCS), 50, 128–137 (June 1993).MATHGoogle Scholar
  6. [Bow94]
    Bowen, J. P. (ed.): Towards Verified Systems. Elsevier, Real-Time Safety-Critical Systems series, 1994.Google Scholar
  7. [BoB92]
    Bowen, J. P. and Breuer, P. T: Occam’s Razor: The Cutting Edge of Parser Technology. Proc. TOULOUSE’92: Fifth International Conference on Software Engineering and its Applications, Toulouse, France, 7–11 December 1992.Google Scholar
  8. [BoB93]
    Bowen, J. P. and Breuer, P. T.: Decompilation. In van Zuylen, H. (ed.), The REDO Compendium: Reverse Engineering for Software Maintenance, chapter 10, John Wiley & Sons, pp. 131–138, 1993.Google Scholar
  9. [BFO93]
    Bowen, J. P., Fränzle, M., Olderog, E.-R. and Ravn, A.P.: Developing Correct Systems. Proc. 5th Euromicro Workshop on Real-Time Systems, IEEE Computer Society Press, pp. 176–187, 1993.Google Scholar
  10. [BHP90]
    Bowen, J. P., He Jifeng and Pandya, P. K.: An Approach to Verifiable Compiling Specification and Prototyping. In Deransart, P. and Małuszyński, J. (eds.), Programming Language Implementation and Logic Programming, Springer-Verlag, LNCS 456, pp. 45–59, 1990.Google Scholar
  11. [BoS93]
    Bowen, J. P. and Stavridou, V.: Safety-Critical Systems, Formal Methods and Standards. IEE/BCS Software Engineering Journal, 8(4), 189–209 (July 1993).CrossRefGoogle Scholar
  12. [BrB92]
    Breuer, P. T. and Bowen, J. P.: Decompilation is the Efficient Enumeration of Types. In Billaud, M. et al. (eds.), Journées de Travail WSA’92 Analyse Statique, BIGRE 81-82, IRISA-Campus de Beaulieu, F-35042 Rennes cedex, France, pp. 255–273, 1992.Google Scholar
  13. [BSW90]
    Bundy, A., Smaill, A. and Wiggins G.: The Synthesis of Logic Programs from Inductive Proofs. In Lloyd, J. W (ed.) Computational Logic. pringer-Verlag, Basic research series, pp. 135–149, 1990.CrossRefGoogle Scholar
  14. [Bun82]
    Bunimova, E. O.: A Method of Language Mappings Describing. Doctoral dissertation, Moscow University, Russia, 1982. (In Russian.)Google Scholar
  15. [BBF92]
    Buth, B., Buth, K.-H., Fränzle, M., von Karger, B., Lakhneche, Y., Langmaack, H. and Müller-Olm, M.: Provably Correct Compiler Implementation. In Karstens, U. and Pfahler, P. (eds.), Compiler Construction, Springer-Verlag, LNCS 641, pp. 141–155, 1992.CrossRefGoogle Scholar
  16. [ClL92]
    Clement, T. P. and Lau, K.-K.: Logic Program Synthesis and Transformation. Springer-Verlag, Workshops in Computing, 1992.CrossRefGoogle Scholar
  17. [ClM87]
    Clocksin, W. F., and Mellish, C. S.: Programming in Prolog. 3rd edition, Springer-Verlag, 1987.CrossRefMATHGoogle Scholar
  18. [Coh90]
    Cohen, J.: Constraint Logic Programming Languages. Communications of the ACM, 33(7), 52–68 (1990).CrossRefGoogle Scholar
  19. [Cur93]
    Curzon, P.: Deriving Correctness Properties of Compiled Code. Formal Methods in System Design, 3, 83–115 (1993).CrossRefMATHGoogle Scholar
  20. [Gie92]
    Giegerich, R.: Considerate Code Selection. In [GiG92], pp. 51–65.Google Scholar
  21. [GiG92]
    Giegerich, R. and Graham, S. L. (eds.): Code Generation — Concepts, Tools, Techniques. Springer-Verlag, Workshops in Computing, 1992.Google Scholar
  22. [HeB92]
    He Jifeng and Bowen, J. P.: Time Interval Semantics and Implementation of a Real-Time Programming Language. Proc. Fourth Euromicro Workshop on Real-Time Systems, IEEE Computer Society Press, pp. 110–115, 1992.Google Scholar
  23. [HPB93]
    He Jifeng, Page, I. and Bowen, J. P.: Towards a provably correct hardware implementation of Occam. In Milne, G. J. and Pierre, L. (eds.) Correct Hardware Design and Verification Methods, Springer-Verlag, LNCS 683, pp. 214–225, 1993.CrossRefMathSciNetGoogle Scholar
  24. [Hoa91]
    Hoare, C. A. R.: Refinement Algebra Proves Correctness of Compiling Specifications. In Morgan, C. C. and Woodcock, J. C. P. (eds.), 3rd Refinement Workshop, Springer-Verlag, Workshops in Computing, pp. 33–48, 1991.Google Scholar
  25. [HoH92]
    Hoare, C. A. R. and He Jifeng: Refinement Algebra Proves Correctness of a Compiler. In Broy, M. (ed.), Programming and Mathematical Method, Springer-Verlag, NATO ASI Series F: Computer and Systems Sciences, vol. 88, pp. 245–269, 1992.CrossRefGoogle Scholar
  26. [HHB90]
    Hoare, C. A. R., He Jifeng, Bowen, J. P. and Pandya, P. K.: An Algebraic Approach to Verifiable Compiling Specification and Prototyping of the ProCoS Level 0 Programming Language. ESPRIT ’90 Conference Proceedings, Kluwer Academic Publishers, pp. 804–818, 1990.Google Scholar
  27. [HHS93]
    Hoare C. A. R., He Jifeng and Sampaio, A.: Normal Form Approach to Compiler Design. Acta Informatica, 30, 701–739 (1993).CrossRefMATHMathSciNetGoogle Scholar
  28. [KPS93]
    Krishna Rao, M. R. K., Pandya, P. K. and Shyamasundar, R. K.: Verification Tools in the Development of Provably Correct Compilers. In Woodcock, J. C. P. and Larsen, P. G. (eds.), FME ’93: Industrial-Stength Formal Methods, Springer-Verlag, LNCS 670, pp. 442–461, 1993.Google Scholar
  29. [Lev92]
    Levin, V.: Algebraically Provable Specification of Optimized Compilations. In Bjørner, D., Broy, M. and Pottosin, I.V. (eds.), Formal Methods in Programming and Their Applications, Springer-Verlag, LNCS 735, 1993.Google Scholar
  30. [Llo87]
    Lloyd, J. W: Foundations of Logic Programming. 2nd edition, Springer-Verlag, 1987.CrossRefMATHGoogle Scholar
  31. [Rus92]
    Russinoff, D. M.: A Verified Prolog Compiler for the Warren Abstract Machine. Journal of Logic Programming, 13, 367–412 (1992).CrossRefMATHMathSciNetGoogle Scholar
  32. [Ste93]
    Stepney, S.: High Integrity Compilation: A Case Study. Prentice Hall, 1993.MATHGoogle Scholar
  33. [SWC91]
    Stepney, S., Whitley, D., Cooper, D. and Grant, C.: A Demonstrably Correct Compiler. Formal Aspects of Computing, 3(1), 58–101 (January–March 1991).CrossRefMATHGoogle Scholar

Copyright information

© BCS 1994

Authors and Affiliations

  1. 1.Oxford University Computing LaboratoryProgramming Research GroupOxfordUK

Personalised recommendations