@Jeff: I think my outlook accidentally tried to add an emoji to one of the previous emails in this series as I was reading through them, apologies for that.
I'd like to also note my interest in this feature, I think this is the kind of thing that would make it easier to make use of FMV. In fact, I can imagine this would facilitate a semi-automated way of adding FMV to your workload without needting to resort to source-changes. As for supporting multiple languages, I suggest we use mangled names if possible, its probably the simplest to do? Kind regards, Andre ________________________________________ From: Yangyu Chen <[email protected]> Sent: Tuesday, October 7, 2025 1:44 PM To: [email protected] Cc: Evgeny Stupachenko; Alice Carlotti; Alfie Richards; Kito Cheng; Palmer Dabbelt; Jiawei; Jeff Law; David Malcolm; Yangyu Chen Subject: [PATCH v6 0/3] fmv: Add -ftarget-clones-table option support This patch series introduces support for the target_clones table option in GCC. This option enables users to specify target_clones attributes in a separate file, allowing GCC to generate multiple versions of the function with different ISA extensions based on the specified table. This is achieved using the -ftarget-clones-table option. The primary objective of this patch series is to provide a user-friendly way to specify target_clones attributes without modifying the source code. This approach enhances the source code's cleanliness, facilitates easier maintenance, and ensures portability across different architectures and compiler versions. A example usage is shown below: Say we have a function `foo` in C source code `foo.c`. Then we have a target clones table file `target_clones.json`: ```json { "foo": { "x86_64": ["avx2", "avx512f"], "riscv64": ["arch=+v", "arch=+zba,+zbb", ...], ... // more architectures }, // more functions } ``` Then use: `gcc -O3 -ftarget-clones-table=target_clones.json -S foo.c` to compile the source code. This will generate multiple versions of the `foo` function with the specified target clones attributes for each architecture. Changes in v6: - Add doc in doc/invoke.texi v5: https://patchwork.sourceware.org/project/gcc/cover/[email protected]/ Changes in v5: - Add some detailed comments - Delete node only when !TARGET_HAS_FMV_TARGET_ATTRIBUTE and target_attr is present - Raise error if "default" present in the target clones table v4: https://patchwork.sourceware.org/project/gcc/cover/[email protected]/ Changes in v4: - Delete node only when !TARGET_HAS_FMV_TARGET_ATTRIBUTE v3: https://patchwork.sourceware.org/project/gcc/cover/[email protected]/ Changes in v3: - Rebase to the latest master branch - Skip unsupported C++ virtual functions - Merge table clones table with attributes instead of replacing them - Add a testcase v2: https://patchwork.sourceware.org/project/gcc/cover/[email protected]/ Changes in v2: - Use the name of "-ftarget-clones-table" instead of "-ftarget-profile" - Use JSON formatted table instead of a text file - Each architectures like x86_64, aarch64, riscv64, etc. Can specify multiple target clones attributes in a single JSON table, which makes it more flexible and easier to use. v1: https://patchwork.sourceware.org/project/gcc/cover/[email protected]/ Yangyu Chen (3): Fortran: Do not make_decl_rtl in trans_function_start json: add iterate method to object class fmv: Add -ftarget-clones-table option support gcc/Makefile.in | 1 + gcc/common.opt | 7 + gcc/doc/invoke.texi | 69 +++++++++- gcc/fortran/trans-decl.cc | 3 - gcc/json.h | 5 + gcc/multiple_target.cc | 158 +++++++++++++++++++++-- gcc/testsuite/gcc.target/i386/tct-0.c | 11 ++ gcc/testsuite/gcc.target/i386/tct-0.json | 5 + 8 files changed, 246 insertions(+), 13 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/tct-0.c create mode 100644 gcc/testsuite/gcc.target/i386/tct-0.json -- 2.49.0
