Complexity of intermediate code

mcvax!htsa! (Frans van Otten)
6 Feb 89 10:46:36 GMT

          From comp.compilers

Related articles
Complexity of intermediate code mcvax!htsa! (1989-02-06)
| List of all articles for this month |

From: mcvax!htsa! (Frans van Otten)
Newsgroups: comp.compilers
Keywords: machine-independent front-end, level of intermediate code
Date: 6 Feb 89 10:46:36 GMT
Organization: AHA-TMF (Technical Institute), Amsterdam, Netherlands

We are involved in building a compiler for Modula-2. This compiler consists
of two parts: the front-end module, producing intermediate code, and a back-
end module, converting the intermediate code to assembly. The basic idea is
to keep the front-end module machine independent, i.e. the intermediate code
should be easily convertible to any assembly language. We designed an
intermediate code called the H-code. This is a nice stack oriented code etc.
Now we are at the stage to produce intermediate code. We stumbled on a
problem that we didn't think of earlier. This concerns byte/word/etc boundary
requirements. For example, the 68000 wants all its data on word-boundary.
Should such requirements be extended to the intermediate code ?

Extending such requirements to the intermediate code makes that and the front-
end machine-dependent. But the back-end can be simpler, and if you would
execute (interpret) the intermediate code this would be faster. On the other
hand, we would like the front-end really independent of the machine we are
compiling to. But then the intermediate code becomes more complex.

We wonder how other people think about this issue: How complex can one
design intermediate code ? How far should one go keeping parts of the
compiler independent of the 'destination-language' ?

                                                  Frans van Otten
                                                  Algemene Hogeschool Amsterdam
Technische en Maritieme Faculteit
[Intermediate code design is a major can of worms. I have never seen a
satisfactory intermediate code design that didn't pander at least a little
to the target machine; otherwise the intermediate code ends up being little
more than a parsed version of the source program and isn't very useful for
the sorts of optimization and code generation operations that you want to do.
You could still have a machine-independent front end, but one that had flags
to tell it the alignment restrictions and such of the target. (Once you've
done all that, then consider how it works on a word-addressed machine such
as a PDP-10.) If anybody can prove me wrong and show a practical machine
independent intermediate language I'd be pleased to hear about it, but I'm
not holding my breath. -John]

Post a followup to this message

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