This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [RFC] asm goto
- From: Michael Matz <matz at suse dot de>
- To: Richard Henderson <rth at redhat dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, jbaron at redhat dot com
- Date: Tue, 28 Jul 2009 14:41:29 +0200 (CEST)
- Subject: Re: [RFC] asm goto
- References: <4A6E1BE6.8060504@redhat.com>
Hi,
On Mon, 27 Jul 2009, Richard Henderson wrote:
> +#define TRACE1(NUM) \
> + do { \
> + asm goto ("0: nop;" \
> + ".pushsection trace_table;" \
> + ".long 0b, %l0;" \
> + ".popsection" \
> + : : : : trace#NUM); \
> + if (0) { trace#NUM: trace(); } \
> + } while (0)
> +#define TRACE TRACE1(__COUNTER__)
>
> So. Comments?
I'm not thrilled by the reuse of the reserved keyword "goto" here, and not
by both being separate words. If the special marking of such asms seems
worthwhile enough (I don't think so) then it should at least be only _one_
new word, perhaps asm_goto or __asm_goto or something. I'd rather go with
just __asm, though.
In the initial thread(s) about this problem there was some alternate
syntax modelled after __builtin_expect, ala:
if (__builtin_newname(ID))
{ do tracing stuff }
[else
{ do non-tracing stuff } ]
{ do common stuff }
where internally that __builtin_newname would do essentially the above
asm magic. It would be nice if something like this syntax could be
implemented with asm gotos but I don't immediately see how, due to the
need of the artificial label.
Ciao,
Michael.