Deutsch   English   Français   Italiano  
<fce2bc7116c6e905e624819e7c8bdf8d@www.novabbs.org>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!weretis.net!feeder9.news.weretis.net!news.nk.ca!rocksolid2!i2pn2.org!.POSTED!not-for-mail
From: mitchalsup@aol.com (MitchAlsup1)
Newsgroups: comp.arch
Subject: Re: Calling conventions (particularly 32-bit ARM)
Date: Wed, 8 Jan 2025 20:19:40 +0000
Organization: Rocksolid Light
Message-ID: <fce2bc7116c6e905e624819e7c8bdf8d@www.novabbs.org>
References: <vlgngv$1ks4a$1@dont-email.me> <4903307dfcce354508c9fc016a4c1ea1@www.novabbs.org> <jwv34htql17.fsf-monnier+comp.arch@gnu.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: i2pn2.org;
	logging-data="2663117"; mail-complaints-to="usenet@i2pn2.org";
	posting-account="o5SwNDfMfYu6Mv4wwLiW6e/jbA93UAdzFodw5PEa6eU";
User-Agent: Rocksolid Light
X-Rslight-Posting-User: cb29269328a20fe5719ed6a1c397e21f651bda71
X-Spam-Checker-Version: SpamAssassin 4.0.0
X-Rslight-Site: $2y$10$sZRZSF7vWID0yu14tT.//OkOgjydkuhPGc5O/NxpjCjRfFrUrwvum
Bytes: 3006
Lines: 43

On Wed, 8 Jan 2025 17:34:30 +0000, Stefan Monnier wrote:

>> I looked high and low for codes using more than 8 arguments and
>> returning aggregates larger than 8 double words, and about the
>> only things I found were a handful of []print[]() calls.
>
> For languages where the type systems ensures that the max number of
> arguments is known (and the same) when compiling the function and when
> compiling the calls to it, you could adjust the number of caller-saved
> argument registers according to the actual number of arguments of the
> function, thus making it "cheap" to allow, say, 13 argument registers
> for those functions that take 13 arguments, since it doesn't impact the
> other functions.

The counter argument is that there are too few subroutines wanting
this amount of register argument passing. So, even if you allowed
for this, it probably does not show up on the bottom line.

> But in any case, I suspect there are also diminishing returns at some
> point: how much faster is it in practice to pass/return 13 values in
> registers instead of 8 of them in registers and the remaining 5 on
> the stack?  I expect a 13-arg function to perform an amount
> of work that will dwarf the extra work of going through the stack.

Then there is the issue of what is IN the structure passed in
registers??

If it is a series of bytes, then it is better passed by reference
so the bytes can be LDed (1 instruction) rather than extracted
(2 instructions in most ISAs); or STed (1 instruction) rather
than insertion (3 instruction most ISAs).

If, instead, the structure is comprised of bit-fields, then it is
almost always wise to pass in registers--since extraction and
insertion are always reg->reg.

Also note: If the structure is written deep with the subroutine,
many (many) instructions before return, Then it is often wiser
to perform this stuff into a memory area, and reload just prior
to return.

>
>
>         Stefan