public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* INIT_CUMULATIVE_ARGS(): bug?
@ 2003-03-25 14:18 Anders Ådland
  2003-03-25 17:52 ` Hans-Peter Nilsson
  0 siblings, 1 reply; 5+ messages in thread
From: Anders Ådland @ 2003-03-25 14:18 UTC (permalink / raw)
  To: gcc

Thanks for all the help you have given me so fare. I need some more...

I am using INIT_CUMULATIVE_ARGS(cum, fntype, libname, indirect) to
initialize the cum variable. The first register to use for passing
arguments depends on the size of the argument. A long long int is using
the register pair r11:r10 while an int is using r12. Is fntype
representing the type of the first argument? It looks like it is
representing the type of the return value:

In the function

long long int foo(int arg1, int arg2) { ... }

TREE_INT_CST_LOW(TYPE_SIZE(TREE_TYPE(fntype))) is equal to 64, but in
the function

int foo(int arg1, int arg2) { ... }

TREE_INT_CST_LOW(TYPE_SIZE(TREE_TYPE(fntype))) is equal to 32. Why?

Is this how it should be? I am using r12 as return register.

Anders

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

* Re: INIT_CUMULATIVE_ARGS(): bug?
  2003-03-25 14:18 INIT_CUMULATIVE_ARGS(): bug? Anders Ådland
@ 2003-03-25 17:52 ` Hans-Peter Nilsson
  2003-03-26 12:46   ` INIT_CUMULATIVE_ARGS() Anders Ådland
  0 siblings, 1 reply; 5+ messages in thread
From: Hans-Peter Nilsson @ 2003-03-25 17:52 UTC (permalink / raw)
  To: Anders Ådland; +Cc: gcc

On 25 Mar 2003, Anders Ådland wrote:

> Thanks for all the help you have given me so fare. I need some more...
>
> I am using INIT_CUMULATIVE_ARGS(cum, fntype, libname, indirect) to
> initialize the cum variable. The first register to use for passing
> arguments depends on the size of the argument.

These two sentences makes me think you want to look at a
function argument in INIT_CUMULATIVE_ARGS.  That's wrong; you
use FUNCTION_ARG (and FUNCTION_INCOMING_ARG) for looking at
argument types and position and deciding where the parameter is
passed and FUNCTION_ARG_ADVANCE to update the iterator you
initialized in INIT_CUMULATIVE_ARGS.

Please send patches to improve the documentation.

brgds, H-P



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

* Re: INIT_CUMULATIVE_ARGS()
  2003-03-25 17:52 ` Hans-Peter Nilsson
@ 2003-03-26 12:46   ` Anders Ådland
  2003-03-26 14:58     ` INIT_CUMULATIVE_ARGS() Hans-Peter Nilsson
  0 siblings, 1 reply; 5+ messages in thread
From: Anders Ådland @ 2003-03-26 12:46 UTC (permalink / raw)
  To: Hans-Peter Nilsson; +Cc: gcc

On Tue, 2003-03-25 at 18:16, Hans-Peter Nilsson wrote:
> On 25 Mar 2003, Anders Ådland wrote:
> 
> > Thanks for all the help you have given me so fare. I need some more...
> >
> > I am using INIT_CUMULATIVE_ARGS(cum, fntype, libname, indirect) to
> > initialize the cum variable. The first register to use for passing
> > arguments depends on the size of the argument.
> 
> These two sentences makes me think you want to look at a
> function argument in INIT_CUMULATIVE_ARGS.  That's wrong; you
> use FUNCTION_ARG (and FUNCTION_INCOMING_ARG) for looking at
> argument types and position and deciding where the parameter is
> passed and FUNCTION_ARG_ADVANCE to update the iterator you
> initialized in INIT_CUMULATIVE_ARGS.

Is this what happends?
- INIT_CUMULATIVE_ARGS is called to initialize iterator.
- FUNCTION_ARG is called one or more times and returns where the first
argument is passed.
- FUNCTION_ARG_ADVANCE is called to update iterator.
- FUNCTION_ARG is called one or more times and returns where the second
argument is passed.
- FUNCTION_ARG_ADVANCE is called to update iterator.
...

Anders

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

* Re: INIT_CUMULATIVE_ARGS()
  2003-03-26 12:46   ` INIT_CUMULATIVE_ARGS() Anders Ådland
@ 2003-03-26 14:58     ` Hans-Peter Nilsson
  0 siblings, 0 replies; 5+ messages in thread
From: Hans-Peter Nilsson @ 2003-03-26 14:58 UTC (permalink / raw)
  To: Anders Ådland; +Cc: gcc

On 26 Mar 2003, Anders Ådland wrote:
> Is this what happends?
> - INIT_CUMULATIVE_ARGS is called to initialize iterator.
> - FUNCTION_ARG is called one or more times and returns where the first
> argument is passed.
> - FUNCTION_ARG_ADVANCE is called to update iterator.
> - FUNCTION_ARG is called one or more times and returns where the second
> argument is passed.
> - FUNCTION_ARG_ADVANCE is called to update iterator.

I recommend that you single-step through that code in gdb.
Break on occurrences of INIT_CUMULATIVE_ARGS and single-step
from there.  It will give you the answer and useful insight that
will help you when you trace down bugs in your port and in
"core" gcc.  (It *will* happen.  AFAIK all ports have uncovered
one or more bugs in "core" gcc.)

If you find that something in the documentation is lacking,
please help improve it.  I just looked -- the answer is there
too, but maybe that kind of overview of the macros would help.

brgds, H-P
PS.  Oops.

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

* RE: INIT_CUMULATIVE_ARGS(): bug?
@ 2003-03-25 15:32 Martin York
  0 siblings, 0 replies; 5+ messages in thread
From: Martin York @ 2003-03-25 15:32 UTC (permalink / raw)
  To: 'Anders Ådland', gcc



If fnType is a type node representing a function
(ie TREE_CODE(fntype) == FUNCTION_TYPE)

Assuming you used 'build_function_type()' then:

	TREE_CODE(fntype) is the type node representing the return type.

So the output below seems reasonable.
long long int:  64 bit
int             32 bit

				


-----Original Message-----
From: Anders Ådland [mailto:adland@stud.ntnu.no]
Sent: 25 March 2003 08:46
To: gcc@gcc.gnu.org
Subject: INIT_CUMULATIVE_ARGS(): bug?


Thanks for all the help you have given me so fare. I need some more...

I am using INIT_CUMULATIVE_ARGS(cum, fntype, libname, indirect) to
initialize the cum variable. The first register to use for passing
arguments depends on the size of the argument. A long long int is using
the register pair r11:r10 while an int is using r12. Is fntype
representing the type of the first argument? It looks like it is
representing the type of the return value:

In the function

long long int foo(int arg1, int arg2) { ... }

TREE_INT_CST_LOW(TYPE_SIZE(TREE_TYPE(fntype))) is equal to 64, but in
the function

int foo(int arg1, int arg2) { ... }

TREE_INT_CST_LOW(TYPE_SIZE(TREE_TYPE(fntype))) is equal to 32. Why?

Is this how it should be? I am using r12 as return register.

Anders

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

end of thread, other threads:[~2003-03-26 12:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-25 14:18 INIT_CUMULATIVE_ARGS(): bug? Anders Ådland
2003-03-25 17:52 ` Hans-Peter Nilsson
2003-03-26 12:46   ` INIT_CUMULATIVE_ARGS() Anders Ådland
2003-03-26 14:58     ` INIT_CUMULATIVE_ARGS() Hans-Peter Nilsson
2003-03-25 15:32 INIT_CUMULATIVE_ARGS(): bug? Martin York

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).