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).
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
Similar content being viewed by others
References
Andersen, L.O.: Program Analysis and Specialization for the C programming Language. PhD thesis, DIKU, University of Copenhagen, Denmark (May 1994)
Appel, A.W.: SSA is functional programming. ACM SIGPLAN Notices 33(4), 17–20 (1998)
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)
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)
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)
Gallagher, J., Bruynooghe, M.: The derivation of an algorithm for program specialisation. New Generation Computing 9(3 & 4), 305–333 (1991)
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)
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)
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)
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)
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)
Jaffar, J., Maher, M.J.: Constraint logic programming: A survey. The Journal of Logic Programming 19(20), 503–581 (1994)
Jones, N.D., Gomard, C.K., Sestoft, P.: Partial Evaluation and Automatic Program Generation. Prentice-Hall International Series (1993)
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)
Kleinrubatscher, P., Kriegshaber, A., Zöling, R., Glück, R.: Fortran program specialization. SIGPLAN Notices 30(4), 61–70 (1995)
Lafave, L.: A Constraint-based Partial Evaluator for Functional Logic Programs and its Application. PhD thesis, University of Bristol, UK (1999)
Lloyd, J.W., Shepherdson, J.C.: Partial evaluation in logic programming. The Journal of Logic Programming 11(3 & 4), 217–242 (1991)
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)
Muchnick, S.S.: Advanced Compiler Design and Implementation. Morgan Kaufman, San Francisco (1997)
Nielson, H.R., Nielson, F.: Semantics with Applications. John Wiley and Sons, Chichester (1992)
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)
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)
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)
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)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights 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