On 11/1/24 2:58 PM, Yangyu Chen wrote:
Some architectures may use ',' in the attribute string, but it is not
used as the separator for different targets. To avoid conflict, we
introduce a new macro TARGET_CLONES_ATTR_SEPARATOR to separate different
clones.

As an example, according to RISC-V C-API Specification [1], RISC-V allows
',' in the attribute string in the "arch=" option to specify one more
ISA extensions in the same target function, which conflict with the
default separator to separate different clones. This patch introduces
TARGET_CLONES_ATTR_SEPARATOR for RISC-V and choose '#' as the separator,
since '#' is not allowed in the target_clones option string.

[1] 
https://github.com/riscv-non-isa/riscv-c-api-doc/blob/c6c5d6d9cf96b342293315a5dff3d25e96ef8191/src/c-api.adoc#__attribute__targetattr-string

Signed-off-by: Yangyu Chen <c...@cyyself.name>

gcc/ChangeLog:

        * defaults.h (TARGET_CLONES_ATTR_SEPARATOR): Define new macro.
        * multiple_target.cc (get_attr_str): Use
          TARGET_CLONES_ATTR_SEPARATOR to separate attributes.
        (separate_attrs): Likewise.
        * attribs.cc (attr_strcmp): Likewise.
        (sorted_attr_string): Likewise.
        * tree.cc (get_target_clone_attr_len): Likewise.
        * config/riscv/riscv.h (TARGET_CLONES_ATTR_SEPARATOR): Define
          TARGET_CLONES_ATTR_SEPARATOR for RISC-V.
Basically OK. But it does need a documentation update for TARGET_CLONES_ATTR_SEPARATOR.

Look in doc/tm.texi for guidance on the doc stuff.

Jeff

Reply via email to