Re: Source to source compiling

rgg@tidos.tid.es (Raul Garcia Garcia)
Mon, 19 Sep 1994 10:33:50 GMT

          From comp.compilers

Related articles
[3 earlier articles]
Re: Source to source compiling mabp@bga.com (1994-09-13)
Re: Source to source compiling f1rederc@iia.org (1994-09-13)
Re: source to source compiling ghiya@vani.cs.mcgill.ca (1994-09-18)
Re: Source to source compiling bernecky@eecg.toronto.edu (Robert Bernecky) (1994-09-18)
Re: Source to source compiling toconnor@vcd.hp.com (1994-09-18)
Re: Source to source compiling pjj@cs.man.ac.uk (1994-09-16)
Re: Source to source compiling rgg@tidos.tid.es (1994-09-19)
Re: Source to source compiling lexa@adam.botik.yaroslavl.su (1994-09-22)
Re: Source to source compiling md@pact.srf.ac.uk (1994-09-22)
| List of all articles for this month |
Newsgroups: comp.compilers
From: rgg@tidos.tid.es (Raul Garcia Garcia)
Keywords: translator, optimize
Organization: Telefonica I+D
References: 94-09-031 94-09-080
Date: Mon, 19 Sep 1994 10:33:50 GMT

Casper Gripenberg <casper@snakemail.hut.fi> wrote:
> Now the problem is that I don't know how to convert these conditional goto
> statements in the source language to while/if-then-else constructs in the
> destination language.


Robert Bernecky (bernecky@eecg.toronto.edu) said:
> Another well-written, clear article is:
>
> Taming Control Flow: A Structured Approach to Eliminating GOTO
> Statements.
> Ana M. Erosa and Laurie J. Hendren
> ACAPS Technical Memo 76
> McGill University
> ... the method is both efficient and effective.


Certainly. I used this method in my engineer's degree required project,
a C to occam2 translator.


Since occam2 lacks of goto statement, I had to map all C flow-control
constructions into occam2 IF and WHILE statements. This article (and
others, also at McGill and related to their McCAT compiler project)
allowed an implementation of a powerful, yet straightforward, algorithm
which made the desired translation. The algorithm operates function by
function, and consists of two phases:


1. All C control-flow constructs (do, while, for, if, switch, break,
      continue, return and goto) are converted to the most general one -- goto.


2. The entire function code, whose flow of control is expressed now only
      using goto statemets, is normalized into the desired control-flow
      paradigm -- in this case the occam2 one (IF and WHILE statements only).


The method purposed in the article allows the design of a second phase
which map the code into other control-flow paradigms distinct of the
occam2 one.


Check wally.cs.mcgill.ca [132.206.3.30] for more details. There are
some technical memos (in /pub/doc/memos) and even a thesis (Maryam
Emami Master's thesis, in /pub/doc/thesis/emami) related to the
McCAT compiler, last time I checked (about 3 months ago).




Raul Garcia


Raul Garcia Garcia
    Telefonica I+D
E-mail: rgg@tid.es
Phone: +34 1 337 4341
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.