https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117265

--- Comment #4 from H. Peter Anvin <hpa at zytor dot com> ---
On October 22, 2024 1:19:05 PM PDT, "pinskia at gcc dot gnu.org"
<gcc-bugzi...@gcc.gnu.org> wrote:
>https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117265
>
>Andrew Pinski <pinskia at gcc dot gnu.org> changed:
>
>           What    |Removed                     |Added
>----------------------------------------------------------------------------
>           Severity|normal                      |enhancement
>           Keywords|                            |inline-asm
>

I will dig up some examples, but it mostly involves cases where the assembler
needs to apply conditionals (.if, or loops) *based on the operands given.*

Here is an artificial example, mostly to come up with something short:

   .macro emulate_instruction reg
   .ifnc \reg, %rax
   xchg %rax, \reg
   .endif
   rax_only_instruction
   .ifnc \reg, %rax
   xchg %rax, \reg
   .endif
   .endm

Using cpp + string concatenation is what we do in most cases, but it is
unnecessary painful since it generally means writing two versions, one for C
using quoted strings and one for assembly using ##.

It has also completely prevented some highly useful things like a macro to
"find a register not used by any of these operands, but don't disturb the
compiler register allocation." That macro is some 200 lines long, and
replicating it everywhere would be a nightmare.

Reply via email to