| Message ID | tencent_E30926688F388EE02AC74486E835BAF0390A@qq.com |
|---|---|
| Headers |
Return-Path: <gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DFB533858C24 for <patchwork@sourceware.org>; Tue, 7 Oct 2025 12:47:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DFB533858C24 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=qq.com header.i=@qq.com header.a=rsa-sha256 header.s=s201512 header.b=UaQWx27U X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from out203-205-221-210.mail.qq.com (out203-205-221-210.mail.qq.com [203.205.221.210]) by sourceware.org (Postfix) with UTF8SMTPS id C376B3858C50 for <gcc-patches@gcc.gnu.org>; Tue, 7 Oct 2025 12:44:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C376B3858C50 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=cyyself.name Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=cyyself.name ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C376B3858C50 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=203.205.221.210 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1759841072; cv=none; b=uhB5g20KA54tadZYfbyM77gHzER5oADXbmPPjN/nXy89KunyzbANC7e2RMTW6Gm8QfbJVVQChAGjzL/wXz8FgjzSNYt2HlhX0MT5pfw+m+zhEIqMUfelY9huRpTm++/PnJixqC5jQbmZWacm6DKeXIvPjFJMhO8iFvEdZvqf/v8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1759841072; c=relaxed/simple; bh=wyxxxFZJYl+qyj7bQRH5oU2sI9CPfdVaRKuIK5ZhgfI=; h=DKIM-Signature:Message-ID:From:To:Subject:Date:MIME-Version; b=Ijs6irFud+WE/Qx6OyzPqT6Ay+vb25QFMDWW+ImUgboM4d9ObqiSFp69Nolm5FWn78uSaeI1D3zH91KHJX/SEVuTvRS2SOGWyN/JRyKfP0AUr4DRo730GRkB2+Ln3a+qE6oPLntFbOXk2eF+n1FMI935YUM0HtzTvQUjQ5xKGhY= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C376B3858C50 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s201512; t=1759841067; bh=20bjqF1tKfKR32fUqaFTPIxRFnfIxXq48jeAh+EJFjI=; h=From:To:Cc:Subject:Date; b=UaQWx27UDBtPx200K94t6d92XbHbtOZHFEi3Nliiubdun1diZmlRl/fbWUp9pjs++ 3aSUPE6euKJHRukidhiBsqlPg63DDQ+xfmpzAiI/mOZ4Mwd3sILFCdFN5EGycYj6Df CxMxSmtizutQv943IXDIv4K61H9fq3xQE4J9u62E= Received: from cyy-pc.lan ([240e:379:2266:a000:785f:fad1:3646:61bf]) by newxmesmtplogicsvrsza29-0.qq.com (NewEsmtp) with SMTP id B1912EE8; Tue, 07 Oct 2025 20:44:25 +0800 X-QQ-mid: xmsmtpt1759841065tj2j8e27z Message-ID: <tencent_E30926688F388EE02AC74486E835BAF0390A@qq.com> X-QQ-XMAILINFO: MFA3rFz8fXqrTkJXxGqvnUgqo5gRM/gCa/qfW32euhCQ3ZjfzndZBgXrGPzLIR 4ctdiZgiODKfgOMtRX9IEpQvFCfSPzVGzef1OinytnRJ39dxTI7SPT3iqXm1BxFOUhuqj3+UsXMd NKbDD0Z4RRXTJY9M3/KilBXoEpl2tmT9NJMZoumzK/caNXINFbkke+MAnFo96eqqcayG4eUl5Fuh fRJZLMljpOcSVDU9Lbprnik9m7qYoG9r0uB5m/hVQNz8dHs+RTOGy3AlA4PFzmanqEnx2GYnxyIj v9NyN9gu3BHKsRN4ScFFgy5MmiQuBA2JZLdSMqc9gsxJtC5X5Hr+jJeISv1GfBs4jjFJdnqh2ePv RxfSYT2Rd/lmaCZv1yt9O4PfmdgmB84MIE8IPt7LiKMUe80nB0a5LrpDgieKQTmGjuoZnff0CaSy 6yzTUQrW8e3aNYJMvEn1zzYpEintbJhWQwz9nz2PJJqpah4VEuDFW07yYaPtRTODeMHE1TN1NHyp rhNZIprJ9s36yIVRAgM/D2OaLcgQQ2ZY761pGT91h6rHkfAGmyCJBlNpZMwNBKIdpoab6gCw+zyB Vx2qTiMCU58n3Qkt491EEKaQ9hGsKYN2m4r7SYSE+Cdw0JBUPY5NWWI/hQA3WNuktdjeuCIegkvx NNkEHkCuMCU7rJGPUH6omOiScUUdaJ9rPrMpLFzh2JYWEs/O+q3xKQx0RIGmLFR8y1L4qHfST8lx Fp04BhE91IRgTIW2SajaCh3oRq6rv6xcnX96w0ISe6K8iTaehPjCz8+0CXApCPUqnrI2VqFC2Cs2 0QKv6kc1mhWyziSQ6PxjTqi84n5cJ2xgNcMPSE0h3lZ90JZgW/noYI0UOo8o7Zw40ttFtMau88Xq P6XT7INXxA04Mq4vIb02gxf0OmAzGujZMGQ+EKwYQsM5PBN5Zw1hHZp3fAwlrPShUYA5CN92bqrD QwvVAybjXVimUm0AXji8jnMBeXk+VlxnoQxf9/OXsB5Hr0BjuVblssg4qFTn8UxQcZayEcBo2moG YS+257xQ64F+UKyojs+AsiimlcoAcrm27VKFTM/5rBZYvSc29872cYqPQdcdQKxqBApWY9YQ== X-QQ-XMRINFO: NS+P29fieYNw95Bth2bWPxk= From: Yangyu Chen <cyy@cyyself.name> To: gcc-patches@gcc.gnu.org Cc: Evgeny Stupachenko <evstupac@gmail.com>, Andrew Carlotti <andrew.carlotti@arm.com>, Alfie Richards <alfie.richards@arm.com>, Kito Cheng <kito.cheng@gmail.com>, Palmer Dabbelt <palmer@dabbelt.com>, Jiawei <jiawei@iscas.ac.cn>, Jeff Law <jeffreyalaw@gmail.com>, David Malcolm <dmalcolm@redhat.com>, Yangyu Chen <cyy@cyyself.name> Subject: [PATCH v6 0/3] fmv: Add -ftarget-clones-table option support Date: Tue, 7 Oct 2025 20:44:18 +0800 X-OQ-MSGID: <20251007124418.2983920-1-cyy@cyyself.name> X-Mailer: git-send-email 2.49.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, HELO_DYNAMIC_IPADDR, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED, RDNS_DYNAMIC, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org |
| Series |
fmv: Add -ftarget-clones-table option support
|
|
Message
Yangyu Chen
Oct. 7, 2025, 12:44 p.m. UTC
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/tencent_3DBE4676BE12C123ED71C72D5CD098A39007@qq.com/
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/tencent_07C73CDC8318F910F2C6003E00C11BED0607@qq.com/
Changes in v4:
- Delete node only when !TARGET_HAS_FMV_TARGET_ATTRIBUTE
v3: https://patchwork.sourceware.org/project/gcc/cover/tencent_7B3F04A7F18A6F457051DBC4110FF72A8605@qq.com/
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/tencent_815F8860AE36BFA3102E4ECC77C843231606@qq.com/
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/tencent_7E345EF1390B9A68A738CEE15EC510864C0A@qq.com/
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