This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: naked function attribute support for Mips
- From: Richard Sandiford <rdsandiford at googlemail dot com>
- To: David Brown <david at westcontrol dot com>
- Cc: Chung-Ju Wu <jasonwucj at gmail dot com>, reed kotler <rkotler at mips dot com>, <gcc at gcc dot gnu dot org>
- Date: Fri, 03 May 2013 15:03:28 +0100
- Subject: Re: naked function attribute support for Mips
- References: <5182EA47 dot 2080804 at mips dot com> <CADj25HNcL_5DXjZbWUFgqEotc_cau--+kPi87cCpW3uTKh=f1A at mail dot gmail dot com> <CADj25HOgZi8DQGRsCHwmcXsZZ_rrSzgiT0azoRqB=h6YUBRpQQ at mail dot gmail dot com> <5183A1DC dot 3010409 at westcontrol dot com>
David Brown <david@westcontrol.com> writes:
> Personally, I've used "naked" when I want to write pure assembly code
> and don't want extra stack frames or "return" codes. I don't want to
> write stand-alone assembly files (I've written mountains of them in the
> past, and hope they stay in the past). I am happier using the very nice
> flexible gcc inline assembly syntax.
The full inline asm syntax, such as:
asm ("..." : "=r" (result) : "i" (100))
is specifically forbidden in naked functions, because in general GCC can
only satisfy the constraints by building its own frame:
Use this attribute on the ARM, AVR, MCORE, RX and SPU ports to indicate that
the specified function does not need prologue/epilogue sequences generated by
the compiler. It is up to the programmer to provide these sequences. The
only statements that can be safely included in naked functions are
@code{asm} statements _that do not have operands_. All other statements,
including declarations of local variables, @code{if} statements, and so
forth, should be avoided.
(my emphasis). Naked functions must have a body of the form:
{
asm ("....");
}
i.e. an asm with just a plain string, and no other statements or
local variables. So you don't really get any more flexibility
by using inline asms over using assembly files.
Thanks,
Richard