This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Inline functiion in GCC
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: venkatu at samsung dot com
- Cc: gcc at gcc dot gnu dot org
- Date: Fri, 06 Aug 2004 12:40:19 +0100
- Subject: Re: Inline functiion in GCC
- Organization: Codesourcery LLC
- References: <41135CDA.2060700@samsung.com>
Venkatachala Upadhya wrote:
__inline__ static int add(int, int) __attribute__ ((always_inline));
__inline__ static int add(int x, int y)
{
int xs, ys;
__asm__ __volatile__
(
"mov %3, %0, lsl #16 \n;"
"mov %4, %2, lsl #16 \n;"
"qadd %3, %3, %4 \n;"
"mov %0, %3, asr #16 \n;"
: "=r" (x)
: "0" (x), "r" (y), "r" (xs), "r" (ys)
) ;
this doesn't look at all right.
* You're writing to input registers (%3, & %4).
* the insert does not appear to have any volatile side effects.
* the only compiler unknown instruction in there is possibly qadd (I'm
not sure what that does and I don't have an ARM manual infront of me).
I suspect you'd get better results by writing this as
int xs = x << 16;
int ys = y << 16;
int tmp;
__asm__ ("qadd %0, %1, %2" : "=r" (tmp) : "r" (xs), "r" (ys));
x = tmp >> 16;
you should probably turn the optimizer on, too.
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk