[gclist] tail-calls in C/C++

Fergus Henderson fjh@cs.mu.OZ.AU
Tue, 6 Aug 1996 18:27:11 +1000 (EST)


Greg Morrisett, you wrote:
> 
> Why hasn't someone hacked gcc to do full tail-call elimination?

Because doing so requires modifying the machine-specific configuration
files.  That makes it about 25 times more difficult than it would
be if it could be done in a machine-independent way.

> Now, gcc already does self-tail-call elimination, (if you're
> careful with the code that you emit)

Yes, because that's >25 times easier to implement.

> I've also read about other people using the first-class labels
> of gcc.  But this does not seem to work on all architectures --
> in particular, whenever you generate position independent code,
> there's often some cruft in the calling convention that's not
> covered by simply goto'ing a label.  (For instance, how do you
> load all of the argument registers properly?)

See <http://www.cs.mu.oz.au/mercury/papers/mercury_to_c.ps.gz>
for an explanation of how we do this stuff in Mercury.

-- 
Fergus Henderson <fjh@cs.mu.oz.au>   |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
PGP: finger fjh@128.250.37.3         |     -- the last words of T. S. Garp.