This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Structure members in asm using one register only
- From: Falk Hueffner <falk at debian dot org>
- To: Maurizio Monge <maurizio dot monge at gmail dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Sat, 07 May 2005 01:09:44 +0200
- Subject: Re: Structure members in asm using one register only
- References: <e4c5193505050505423d508d3d@mail.gmail.com>
Maurizio Monge <maurizio.monge@gmail.com> writes:
> Hi, i am trying to make gcc access the members of a class
> using only one register (for the class address).
> If i do:
> [member1] "m" (this->member1),
> [member2] "m" (this->member2),
> etc.
> gcc will put the address of this->member1 in one register,
> address of this->member2 in another one, etc...
>
> i know that i can do
> [thiz] "r" (this)
> and access the members as xyz([this]) with the right xyz,
gcc already does this automatically:
falk@juist:/tmp% cat test.c
struct s { int a, b; };
void f(struct s *s) {
asm("frob %0 %1" : :"m"(s->a), "m"(s->b));
}
falk@juist:/tmp% gcc -O3 -S test.c && grep frob test.s
frob 0($16) 4($16)
--
Falk