Re: Compiling to C (where C is used as misspelled assembly)

Will Partain <partain@dcs.gla.ac.uk>
22 May 1997 22:33:48 -0400

          From comp.compilers

Related articles
[9 earlier articles]
Re: Compiling to C (where C is used as misspelled assembly) fjh@mundook.cs.mu.OZ.AU (1997-05-17)
Re: Compiling to C (where C is used as misspelled assembly) monnier+/news/comp/compilers@tequila.cs.yale.edu (Stefan Monnier) (1997-05-17)
Re: Compiling to C (where C is used as misspelled assembly) cdg@nullstone.com (Christopher Glaeser) (1997-05-17)
Re: Compiling to C (where C is used as misspelled assembly) conway@mundook.cs.mu.OZ.AU (1997-05-22)
Re: Compiling to C (where C is used as misspelled assembly) conway@mundook.cs.mu.OZ.AU (1997-05-22)
Re: Compiling to C (where C is used as misspelled assembly) Dave@occl-cam.demon.co.uk (Dave Lloyd) (1997-05-22)
Re: Compiling to C (where C is used as misspelled assembly) partain@dcs.gla.ac.uk (Will Partain) (1997-05-22)
Re: Compiling to C (where C is used as misspelled assembly) fjh@mundook.cs.mu.OZ.AU (1997-05-25)
Re: Compiling to C (where C is used as misspelled assembly) fjh@mundook.cs.mu.OZ.AU (1997-05-25)
| List of all articles for this month |

From: Will Partain <partain@dcs.gla.ac.uk>
Newsgroups: comp.compilers
Date: 22 May 1997 22:33:48 -0400
Organization: Compilers Central
References: 97-05-183 97-05-197
Keywords: C, assembler

The Glasgow Haskell (lazy functional language) compiler, GHC, uses C
as an intermediate language. We started off with "portable" C, but
the resulting binaries were way too big/slow to be even slightly
useful, and we quickly got to GCC-only C (global variables in
registers, etc.). We started with some ideas from Eliot Miranda, who
was (is?) doing Smalltalk things at the time (1990).


GHC goes further than the other C-as-assembly efforts: it also
*post-processes* the .s file from GCC -- done by the much-feared,
much-hated "mangler" (written in Perl)! Things it tries to do: remove
function prologues and epilogues; reverse the data layout of "info
tables"; park certain code next to certain tables; create
fall-throughs to "fast entry points"; utterly remove use of register
windows (SPARC); help a little w/ register shortage on x86; one or two
other Horrible Things...


As terrible as all that sounds, the result was really great as far as
code quality was concerned: with "gcc -O" (or -O2), we got code that
was as good as we would've hoped for if we'd written a pretty serious
native-code generator ourselves.


Compiling via GCC roughly doubled our compilation times -- that's what
ended up annoying users most. We provided a cheap-and-cheerful
native-code generator to "solve" that problem. Note: we still needed
the via-GCC route, to compile certain Magical Parts of the GHC runtime
system, which is written in C.


It's open to question whether all the fiddling w/ the above
(1990-present) was really worth it; maybe we should've bitten the
bullet and gone for a full-blown native-code generator in the first
place.


Will
(ex-Glasgow Haskell)
GHC info: see http://www.dcs.gla.ac.uk/fp/software/ghc/
--


Post a followup to this message

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