This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH 2/2] asm inline
- From: Segher Boessenkool <segher at kernel dot crashing dot org>
- To: Martin Sebor <msebor at gmail dot com>
- Cc: gcc-patches at gcc dot gnu dot org, jakub at redhat dot com
- Date: Sun, 11 Nov 2018 16:00:58 -0600
- Subject: Re: [PATCH 2/2] asm inline
- References: <cover.1540918533.git.segher@kernel.crashing.org> <e59a75e62603e73c299550dc50b2f61a668f53ca.1540918534.git.segher@kernel.crashing.org> <72103970-b2be-a641-a0a5-d08609f62f5f@gmail.com>
On Sun, Nov 11, 2018 at 02:33:34PM -0700, Martin Sebor wrote:
> On 10/30/2018 11:30 AM, Segher Boessenkool wrote:
> >The Linux kernel people want a feature that makes GCC pretend some
> >inline assembler code is tiny (while it would think it is huge), so
> >that such code will be inlined essentially always instead of
> >essentially never.
> >
> >This patch lets you say "asm inline" instead of just "asm", with the
> >result that that inline assembler is always counted as minimum cost
> >for inlining. It implements this for C and C++.
>
> Rather than overloading the inline keyword I think it would be
> more in keeping both with the design of existing features to
> control inlining in GCC and with the way the languages are
> evolving to allow the always_inline (and perhaps also noinline)
> attribute to apply to asm statements.
We already "overloaded" the volatile and goto keywords here (it's not
overloading, the contexts are completely disjoint).
always_inline is a function attribute, and you want to make it a statement
attribute (which we do not currently support except for empty statements!)
as well.
> The inline keyword is commonly understood to be just a hint to
> the compiler.
That is exactly what it is here. It hints the compiler that this asm
is cheap, whatever it may look like.
> The attributes, on the other hand, are recognized
> as binding requests to inline (if possible) or avoid inlining,
> respectively.
And that is not what this does (that would be hard to do, in fact).
> >+You can use @code{asm inline} instead of @code{asm} to have the assembler
> >+code counted as mimimum size for inlining purposes; @pxref{Size of an
> >asm}.
Segher