This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC] asm goto


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]