fransvo@uunet.uu.net (Frans van Otten) (02/06/89)
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 fransvo@htsa.uucp [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] -- Send compilers articles to ima!compilers or, in a pinch, to Levine@YALE.EDU Plausible paths are { decvax | harvard | yale | bbn}!ima Please send responses to the originator of the message -- I cannot forward mail accidentally sent back to compilers. Meta-mail to ima!compilers-request