Skip to main content

Imperative Program Specialisation: An Approach Using CLP

  • Conference paper

Part of the book series: Lecture Notes in Computer Science ((LNCS,volume 1817))

Abstract

The semantics of an imperative programming language can be expressed as a program in a declarative constraint language. Not only does this render the semantics executable, but it opens up the possibility of applying to imperative languages the advances made in program analysis and transformation of declarative languages.

We propose a method for carrying out partial evaluation of imperative programs, using partial evaluation in a declarative language, but returning the results in the syntax of the imperative program which is to be partially evaluated. The approach uses a special form of the semantics and program points to aid partial evaluation. The partially evaluated semantics program is represented as a labelled directed graph. An algorithm for reconstructing an imperative program from the graph and the residual program is presented. Constraints provide a means through which information is propagated inside both branches of a conditional, the body of a loop, and along def-use chains in the program.

The method provides a framework for constructing a partial evaluator for any imperative programming language, by writing down its semantics as a declarative program (a constraint logic program, in the approach shown here).

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

Buying options

Chapter
USD   29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD   39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD   54.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

Learn about institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Andersen, L.O.: Program Analysis and Specialization for the C programming Language. PhD thesis, DIKU, University of Copenhagen, Denmark (May 1994)

    Google Scholar 

  2. Appel, A.W.: SSA is functional programming. ACM SIGPLAN Notices 33(4), 17–20 (1998)

    Article  MathSciNet  Google Scholar 

  3. Blazy, S., Facon, P.: An automatic interprocedural analysis for the understanding of scientific application programs. In: Danvy, O., Thiemann, P., Glück, R. (eds.) Dagstuhl Seminar 1996. LNCS, vol. 1110, pp. 1–16. Springer, Heidelberg (1996)

    Google Scholar 

  4. Coen-Porisini, A., De Paoli, F., Ghezzi, C., Mandrioli, D.: Software specialization via symbolic execution. IEEE Transactions on Software Engineering 17(9), 884–899 (1991)

    Article  Google Scholar 

  5. Consel, C., Danvy, O.: Static and dymanic semantic processing. In: ACM Press, editor, Conference Record of the Eighteenth Annual ACM Symposium on Principles of Programming Languages, Orlando, Florida, pp. 14–24 (1991)

    Google Scholar 

  6. Gallagher, J., Bruynooghe, M.: The derivation of an algorithm for program specialisation. New Generation Computing 9(3 & 4), 305–333 (1991)

    Article  Google Scholar 

  7. Gallagher, J.P.: Tutorial on specialisation of logic programs. In: Proceedings of the ACM SIGPLAN Symposium on Partial Evaluation and Semantics-Based Program Manipulation, Copenhagen, Denmark, pp. 88–98. ACM Press, New York (1993)

    Google Scholar 

  8. Gallagher, J.P., Lafave, L.: Regular approximation of computation paths in logic and functional languages. In: Danvy, O., Thiemann, P., Glück, R. (eds.) Dagstuhl Seminar 1996. LNCS, vol. 1110, pp. 115–136. Springer, Heidelberg (1996)

    Google Scholar 

  9. Gallagher, J.P., Peralta, J.C.: Using regular approximations for generalisation during partial evaluation. In: Workshop on Partial Evaluation and Program Manipulation, pp. 44–51. ACM Press, New York (2000)

    Google Scholar 

  10. Glenstrup, A.J., Makholm, H., Secher, J.P.: C-mix: Specialization of C programs. Notes from the Partial Evaluation Summer School held at DIKU Copenhagen, Denmark (1998)

    Google Scholar 

  11. Hornof, L., Noyé, J., Consel, C.: Consel Effiective specialization of realistic programs via use sensitivity. In: Van Hentenryck, P. (ed.) SAS 1997. LNCS, vol. 1302, pp. 293–318. Springer, Heidelberg (1997)

    Chapter  Google Scholar 

  12. Jaffar, J., Maher, M.J.: Constraint logic programming: A survey. The Journal of Logic Programming 19(20), 503–581 (1994)

    Article  MathSciNet  Google Scholar 

  13. Jones, N.D., Gomard, C.K., Sestoft, P.: Partial Evaluation and Automatic Program Generation. Prentice-Hall International Series (1993)

    Google Scholar 

  14. Jones, N.D., Muchnick, S.S.: A flexible approach to interprocedural data flow analysis and programs with recursive data structures. In: ACM Press (ed.), Conference Record of the Ninth Symposium on Principles of Programming Languages, pp. 66–74 (1982)

    Google Scholar 

  15. Kleinrubatscher, P., Kriegshaber, A., Zöling, R., Glück, R.: Fortran program specialization. SIGPLAN Notices 30(4), 61–70 (1995)

    Article  Google Scholar 

  16. Lafave, L.: A Constraint-based Partial Evaluator for Functional Logic Programs and its Application. PhD thesis, University of Bristol, UK (1999)

    Google Scholar 

  17. Lloyd, J.W., Shepherdson, J.C.: Partial evaluation in logic programming. The Journal of Logic Programming 11(3 & 4), 217–242 (1991)

    Article  MATH  MathSciNet  Google Scholar 

  18. Meyer, U.: Techniques for partial evaluation of imperative programs. In: Proceedings of the Symposium on Partial Evaluation and Semantics-Based Program Manipulation, New Haven, Conneticut, pp. 94–115. ACM Press, New York (1991)

    Google Scholar 

  19. Muchnick, S.S.: Advanced Compiler Design and Implementation. Morgan Kaufman, San Francisco (1997)

    Google Scholar 

  20. Nielson, H.R., Nielson, F.: Semantics with Applications. John Wiley and Sons, Chichester (1992)

    MATH  Google Scholar 

  21. Peralta, J.C., Gallagher, J.P., Sağlam, H.: Analysis of imperative programs through analysis of constraint logic programs. In: Levi, G. (ed.) SAS 1998. LNCS, vol. 1503, pp. 246–261. Springer, Heidelberg (1998)

    Chapter  Google Scholar 

  22. Reps, T.: Program analysis via graph reachability. Technical Report TR-1386, Computer Sciences Department, University of Wisconsin, Extended version of invited paper in Proceedings of ILPS97 (August 1998)

    Google Scholar 

  23. Ross, B.J.: The partial evaluation of imperative programs using Prolog. In: Abramson, H., Rogers, M.H. (eds.) Meta-Programming in Logic Programming, pp. 341–363. MIT Press, Cambridge (1989)

    Google Scholar 

  24. Sağlam, H., Gallagher, J.P.: Constrained regular approximation of logic programs. In: Fuchs, N.E. (ed.) LOPSTR 1997. LNCS, vol. 1463, pp. 282–299. Springer, Heidelberg (1998)

    Chapter  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2000 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Peralta, J.C., Gallagher, J.P. (2000). Imperative Program Specialisation: An Approach Using CLP. In: Bossi, A. (eds) Logic-Based Program Synthesis and Transformation. LOPSTR 1999. Lecture Notes in Computer Science, vol 1817. Springer, Berlin, Heidelberg. https://doi.org/10.1007/10720327_7

Download citation

  • DOI: https://doi.org/10.1007/10720327_7

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-67628-7

  • Online ISBN: 978-3-540-45148-8

  • eBook Packages: Springer Book Archive

Publish with us

Policies and ethics