public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Arguments in registers
@ 2006-09-25 15:07 Ravishankar S
  2006-09-25 17:05 ` Ian Lance Taylor
  0 siblings, 1 reply; 3+ messages in thread
From: Ravishankar S @ 2006-09-25 15:07 UTC (permalink / raw)
  To: gcc-help

Greetings,

This may probably be the wrong mailing list to ask this question. But
due to many compiler experts in this list,
I hope to get this clarified. 

The issue is about passing arguments in registers: Most of the RISC
architecture's I presume, pass function arguments in registers, as its
faster. For example in PowerPC arguments are passed in r3-r7 and return
value is in r3 (for 32 bit return values). The same registers are used
for passing arguments and for return values. It is the same case with
ARM. I also think that it's the same case with other RISC architectures.


But TriCore's EABI specifies separate registers for passing arguments
and returning values. D2-D3 for returning values and D4-D7 for passing
arguments. 

My question is : Will it make a difference from a compiler writer's
point for this type of calling convention. From experience, will it make
for a differnce in performance.

On the surface, it seems like it does, as there most of functions do not
return values and most anyway don't return 64 bit values. So reusing the
registers as PowerPC does may be better. 

Any insigths ?

Best Regards,
Ravishankar

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Arguments in registers
  2006-09-25 15:07 Arguments in registers Ravishankar S
@ 2006-09-25 17:05 ` Ian Lance Taylor
  2006-09-27 15:31   ` Ravishankar S
  0 siblings, 1 reply; 3+ messages in thread
From: Ian Lance Taylor @ 2006-09-25 17:05 UTC (permalink / raw)
  To: Ravishankar S; +Cc: gcc-help

Ravishankar S <ravishankar.s@hathway.com> writes:

> But TriCore's EABI specifies separate registers for passing arguments
> and returning values. D2-D3 for returning values and D4-D7 for passing
> arguments. 
> 
> My question is : Will it make a difference from a compiler writer's
> point for this type of calling convention. From experience, will it make
> for a differnce in performance.

It won't make much difference.  There are other architectures with
similar characteristics.  For example, on MIPS arguments are passed in
$4 through $7 or $11 (depending on the ABI), but values are returned
in $2 and $3.

> On the surface, it seems like it does, as there most of functions do not
> return values and most anyway don't return 64 bit values. So reusing the
> registers as PowerPC does may be better. 

The return registers are essentially just caller-saved scratch
registers.

I suppose if you are short on registers you might prefer to have more
callee-saved registers.  But if you have enough registers, it doesn't
matter much either way.

Ian

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: Arguments in registers
  2006-09-25 17:05 ` Ian Lance Taylor
@ 2006-09-27 15:31   ` Ravishankar S
  0 siblings, 0 replies; 3+ messages in thread
From: Ravishankar S @ 2006-09-27 15:31 UTC (permalink / raw)
  To: 'Ian Lance Taylor'; +Cc: gcc-help

Thanks Ian,

I see now: for functions with many arguments (and I have seen ones with
25 args in our software!) it could be a bit more efficient have more
registers to pass arguments. 

While Im in this discussion, I might present some other issues that I
current face. 

We use a MPC5xx variant. Our software uses only SDA addressing for all
vars and consts. This by far the most efficient , runtime and code-size
wise for a RISC processor. 

Sutability of ARM for a load/store intensive application:
===========================================================
-> If im right, ARM though RISC, does not have SDA addressing. For
constants it uses PC relative addressing (which means thet constants
must be embedded within text section ?). How does variable addressing
happen ? Does it use two instructions (like lis and ori in PPC) to form
the 32 bit address ? 

-> For a RISC ARM has lesser number of registers. I presume, if we have
lesser registers then there will be more load/store operations. (And
probably the stack is also bigger ?). Is there any way in which one can
predict the number of extra load/stores due to reduced number of
registers (other than compiling and measuring!) ?

Misc:
=======
-> Is there any open source tool which counts only executable lines of
code. Is it possible to do this with gcc ?

-> Is there an open source GNU C grammer. What intermediate
representations (tree etc ?) can be used for the source ?
Is it possible to make this persistent ?


Many Thanks and

Best Regards,
Ravishankar



-----Original Message-----
From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org] On
Behalf Of Ian Lance Taylor
Sent: Monday, September 25, 2006 10:35 PM
To: Ravishankar S
Cc: gcc-help@gcc.gnu.org
Subject: Re: Arguments in registers


Ravishankar S <ravishankar.s@hathway.com> writes:

> But TriCore's EABI specifies separate registers for passing arguments 
> and returning values. D2-D3 for returning values and D4-D7 for passing

> arguments.
> 
> My question is : Will it make a difference from a compiler writer's 
> point for this type of calling convention. From experience, will it 
> make for a differnce in performance.

It won't make much difference.  There are other architectures with
similar characteristics.  For example, on MIPS arguments are passed in
$4 through $7 or $11 (depending on the ABI), but values are returned in
$2 and $3.

> On the surface, it seems like it does, as there most of functions do 
> not return values and most anyway don't return 64 bit values. So 
> reusing the registers as PowerPC does may be better.

The return registers are essentially just caller-saved scratch
registers.

I suppose if you are short on registers you might prefer to have more
callee-saved registers.  But if you have enough registers, it doesn't
matter much either way.

Ian

__________ NOD32 1.1454 (20060321) Information __________

This message was checked by NOD32 antivirus system. http://www.eset.com


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-09-27 15:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-09-25 15:07 Arguments in registers Ravishankar S
2006-09-25 17:05 ` Ian Lance Taylor
2006-09-27 15:31   ` Ravishankar S

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).