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

--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tamar Christina <[email protected]>:

https://gcc.gnu.org/g:2f5aec31ea4a730e7041465f9d38f120cfcc071c

commit r17-6830-g2f5aec31ea4a730e7041465f9d38f120cfcc071c
Author: Tamar Christina <[email protected]>
Date:   Mon Nov 30 08:19:42 2026 +0000

    aarch64: route print operands through a shared lookup table [PR122716]

    The previous patch gives the middle end a way to pass named output
modifiers to
    targets.  This patch teaches AArch64 to use that mechanism without changing
the
    meaning of the existing one-letter modifiers.

    AArch64 used to dispatch print operands directly from the raw character in
a
    large switch.  That made sense when the modifier could only be a single
letter,
    but it does not give us a natural place to say that a named modifier is
    internal-only or to attach small pieces of data to a modifier.

    This patch moves the AArch64 print operand selection into a small lookup
table.
    The existing public modifiers, such as %w0, %x0 and %c0, are registered
under
    their current names and continue to work for user asm and machine
descriptions.
    The table also records whether a modifier is available to user asm, and has
an
    extra field that later patches use for small constants such as a lane
count.
    The names and their print codes are defined in aarch64-print-operands.def,
which
    is shared by the enum and the table setup.

    So for the old form:

      %w0

    the hook still ends up selecting the existing W-register printing
behaviour.
    For the new form:

      %[SOME_TARGET_NAME:0]

    the new modifier hook looks up the bracketed name and returns its code. 
The
    print hook then uses that code to select the same table entry.  Unknown
names,
    or internal-only names used from user asm, are rejected with the normal
output
    operand diagnostic.  Public names can also use the new spelling, such as
%[w:0].

    The tests cover symbolic operand names, numeric operand lists, and invalid
names
    in user asm, including asm that would be optimized away.

    There should be no intended assembly output change from this patch by
itself.
    It is the AArch64 plumbing needed by the following cleanups.

    gcc/ChangeLog:

            PR target/122716
            * config/aarch64/aarch64-print-operands.def: New file.
            * config/aarch64/aarch64.cc (aarch64_print_operands): New enum.
            (aarch64_print_operands_t): New typedef.
            (aarch64_print_operand_info): New structure.
            (aarch64_print_operand_hasher): New structure.
            (aarch64_print_operand_table, operands_cache): New variables.
            (operands_cache_initializer): New structure.
            (init_operands_cache): New variable.
            (aarch64_lookup_operand): New function.
            (aarch64_print_operand_modifier): New function.
            (aarch64_print_operand): Dispatch legacy and named modifiers
through
            the shared table.  Accept constant addresses for %c and diagnose
            out-of-range NZCV operands for %k.
            (TARGET_PRINT_OPERAND_MODIFIER): Define.
            * config/aarch64/t-aarch64 (TM_H): Add aarch64-print-operands.def.

    gcc/testsuite/ChangeLog:

            PR target/122716
            * gcc.target/aarch64/asm-named-operand-constants.c: New test.
            * gcc.target/aarch64/asm-named-operand-modifier-invalid.c:
Likewise.
            * gcc.target/aarch64/asm-named-operand-modifier-multi.c: Likewise.
            * gcc.target/aarch64/asm-named-operand-modifier.c: Likewise.
            * gcc.target/aarch64/asm-named-operand-nzcv-invalid.c: Likewise.

Reply via email to