Related articles |
---|
[12 earlier articles] |
Re: C as assembly language felixundduni@freenet.de (felix) (2001-04-14) |
Re: C as assembly language fjh@cs.mu.OZ.AU (2001-04-14) |
Re: C as assembly language rhyde@transdimension.com (Randall Hyde) (2001-04-14) |
Re: C as assembly language vbdis@aol.com (2001-04-15) |
Re: C as assembly language jim.granville@designtools.co.nz (Jim Granville) (2001-04-18) |
Re: C as assembly language joachim_d@gmx.de (Joachim Durchholz) (2001-05-03) |
Re: C as assembly language joachim_d@gmx.de (Joachim Durchholz) (2001-05-07) |
Re: C as assembly language Hans_Boehm@hp.com (Hans Boehm) (2001-05-07) |
Re: C as assembly language jthorn@galileo.thp.univie.ac.at (2001-05-13) |
Re: C as assembly language david.thompson1@worldnet.att.net (David Thompson) (2001-05-15) |
Re: C as assembly language thp@cs.ucr.edu (2002-03-31) |
From: | "Joachim Durchholz" <joachim_d@gmx.de> |
Newsgroups: | comp.compilers |
Date: | 7 May 2001 23:16:15 -0400 |
Organization: | Compilers Central |
References: | 01-03-006 01-03-046 01-03-130 01-04-027 01-04-052 |
Keywords: | C |
Posted-Date: | 07 May 2001 23:16:15 EDT |
Morrisett <jmorris2@twcny.rr.com> wrote:
> "Joachim Durchholz" <joachim_d@gmx.de> wrote in message
> > 5) It cannot return multiple values in registers
>
> I don't understand this -- what's to prevent a (small) struct
> from being returned in registers?
Nothing. But putting the results into a struct comes with its own set of
problems:
1) The HLL compiler can't force the C compiler to do that. I'm pretty
sure that several brain-damaged C compiler can't do that.
2) What's more important: The HLL compiler has no way to decide how many
results should go into the result struct. If it puts too few results
into the struct, it wastes register space. If it puts too many results
into the struct, no results at all will be passed in registers.
3) What should the caller do with a struct from a result? You can't
assign it to another struct in C. You can't even take its address. All
you can do with it is (a) select a member from it (which essentially
means you're back at a single result) and (b) pass it to another
function (which will result in unlimited stack growth unless you're
*very* careful *and* have a C compiler that can do tail call
elimination).
Regards,
Joachim
--
This is not an official statement from my employer.
Return to the
comp.compilers page.
Search the
comp.compilers archives again.