Re: [RFC PATCH v2 3/3] Add -ftarget-clones-table option support

2025-07-01 Thread Yangyu Chen
> On 30 Jun 2025, at 17:55, Alfie Richards wrote: > > On 29/06/2025 19:57, Yangyu Chen wrote: >> This patch adds support for target_clones table option. The >> target_clones table option allows users to specify multiple versions >> of a function and select the vers

[RFC PATCH v2 1/3] Fortran: Do not make_decl_rtl in trans_function_start

2025-06-29 Thread Yangyu Chen
pool. This patch removes the make_decl_rtl call in trans_function_start, and it will finally be called in all my testcases since we will check it whenever using the DECL_RTL macro. Signed-off-by: Yangyu Chen gcc/fortran/ChangeLog: * trans-decl.cc (trans_function_start): Remove call

[RFC PATCH v2 3/3] Add -ftarget-clones-table option support

2025-06-29 Thread Yangyu Chen
able=ror32.target_clones -S ror32.c to compile the source code. This will generate 3 versions and its IFUNC resolver for the ror32 function which is "arch=+zvbb,+zbb" and "arch=+zbb" and the default version. Signed-off-by: Yangyu Chen gcc/ChangeLog: * Makefile.in: Add

[RFC PATCH v2 2/3] json: add iterate method to object class

2025-06-29 Thread Yangyu Chen
Currently, the object class in json.h does not provide a way to iterate over its keys. This commit adds an `iterate` method to the object class, allowing users to iterate over the keys of a JSON object. Signed-off-by: Yangyu Chen gcc/ChangeLog: * json.h (class object): Add iterate

[RFC PATCH v2 0/3] Add -ftarget-clones-table option support

2025-06-29 Thread Yangyu Chen
. 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_7e345ef1390b9a68a738cee15ec510864...@qq.com/ Yangyu Chen (3): Fortran: Do not make_decl_rtl in trans_funct

Re: [RFC] RISC-V: Change the default branch cost.

2025-06-17 Thread Yangyu Chen
On 18/6/2025 09:07, Kito Cheng wrote: Maybe it's a good time to create a -mtune=generic and copy-and-modify from rocket? Indeed, it appears to be the most suitable solution. Thanks, Yangyu Chen On Wed, Jun 18, 2025 at 6:59 AM Jeff Law wrote: On 6/17/25 10:51 AM, Yangyu Chen

Re: [RFC] RISC-V: Change the default branch cost.

2025-06-17 Thread Yangyu Chen
sprediction on large OoO cores usually incurs a penalty of about 10 cycles. Thanks, Yangyu Chen WRT a followup from Yangyu which touches on the BPI.  My son is currently putting together a tuning and scheduler model for the spacemit x60 chip in that system under my guidance.  I expect we'll

Re: [RFC] RISC-V: Change the default branch cost.

2025-06-17 Thread Yangyu Chen
On 17/6/2025 12:08, Dongyan Chen wrote: Hi, I've come across a question regarding the branch cost of gcc. In the link https://gcc.godbolt.org/z/hnddevd5h, gcc fails to recognize the optimization branch judgment, while llvm does. I eventually discovered that the value of the branch cost was to

Re: [RFC] RISC-V: Support -mcpu for XiangShan Kunminghu cpu.

2025-06-04 Thread Yangyu Chen
_zknh_zksed_zksh_zkt_zvbb_zvfh_" >> + "zvfhmin_zvkt_zvl128b_zvl32b_zvl64b", > > IIUC zvl128b implies zvl32b and zvl64b, then should we explicitly give > zvl32b and zvl64b here? I think not. Other existing cores in GCC are also not giving implied zvl* here. The implied ISAs will be handled automatically by GCC, thus we don't need to specify them. Thanks, Yangyu Chen > >> + "xiangshan-kunminghu") > > -- > Xi Ruoyao > School of Aerospace Science and Technology, Xidian University

Re: [PATCH 0/3] Redirect to specific target based on TARGET_VERSION_COMPATIBLE

2025-05-27 Thread Yangyu Chen
> On 27 May 2025, at 20:59, Jeff Law wrote: > So if it's OK with you I'd like to temporarily shift focus over to Alfie's > patch to get that moved forward, then come back to the RISC-V specific stuff? > Sure. Thanks, Yangyu Chen > Jeff >

Re: [PATCH 0/3] Redirect to specific target based on TARGET_VERSION_COMPATIBLE

2025-05-22 Thread Yangyu Chen
would > still be relevant if we incorporated Alfie's work? > I agree with Alfie's approach. We are addressing the same issue. His patch is more structured and includes test cases. His patch lacks a target hook for RISC-V, while mine does. However, I think it's OK if we get his patch accepted, and I will write that for RISC-V. Thanks, Yangyu Chen

Re: [RFC PATCH 0/2] Add target_clones profile option support

2025-05-15 Thread Yangyu Chen
> On 15 May 2025, at 14:01, Alice Carlotti wrote: > > On Thu, May 08, 2025 at 09:41:08PM +0800, Yangyu Chen wrote: >> >> >>> On 8 May 2025, at 18:36, Richard Sandiford >>> wrote: >>> >>> Yangyu Chen writes: >>>>> On

Re: [PATCH] RISC-V: Add missing insn types for XiangShan Nanhu scheduler model

2025-05-15 Thread Yangyu Chen
We should also back-port this commit to GCC-14. Thanks, Yangyu Chen On 6/9/2024 07:07, Zhao Dingyi wrote: This patch aims to add the missing instruction types to the XiangShan-Nanhu scheduler model. The current XiangShan -Nanhu model lacks the trap, atomic trap, fcvt_i2f, and fcvt_f2i

Re: [RFC PATCH 0/2] Add target_clones profile option support

2025-05-08 Thread Yangyu Chen
> On 8 May 2025, at 18:36, Richard Sandiford wrote: > > Yangyu Chen writes: >>> On 6 May 2025, at 17:49, Alfie Richards wrote: >>> >>> On 06/05/2025 09:36, Yangyu Chen wrote: >>>>> On 6 May 2025, at 16:01, Alfie Richards wrote: >

Re: [RFC PATCH 0/2] Add target_clones profile option support

2025-05-06 Thread Yangyu Chen
> On 6 May 2025, at 17:49, Alfie Richards wrote: > > On 06/05/2025 09:36, Yangyu Chen wrote: >>> On 6 May 2025, at 16:01, Alfie Richards wrote: >>> >>> Hello, >>> >>> I like this idea. I have a couple thoughts to add. >>> >

Re: [RFC PATCH 0/2] Add target_clones profile option support

2025-05-06 Thread Yangyu Chen
> On 6 May 2025, at 16:01, Alfie Richards wrote: > > Hello, > > I like this idea. I have a couple thoughts to add. > > On 05/05/2025 09:46, Yangyu Chen wrote: >>> On 5 May 2025, at 16:34, Kyrylo Tkachov wrote: >>> >>>> On 4 May 2025, a

Re: [RFC PATCH 0/2] Add target_clones profile option support

2025-05-05 Thread Yangyu Chen
> On 5 May 2025, at 16:34, Kyrylo Tkachov wrote: > > > >> On 4 May 2025, at 19:19, Yangyu Chen wrote: >> >> Hi everyone, >> >> This patch series introduces support for the target_clones profile >> option in GCC. This option enables u

[RFC PATCH 0/2] Add target_clones profile option support

2025-05-04 Thread Yangyu Chen
them. However, I would appreciate feedback on the implementation before adding them. If the implementation is deemed acceptable, I will proceed with writing the documentation and test cases. Yangyu Chen (2): Fortran: Do not make_decl_rtl in trans_function_start Add target_clones profile o

[RFC PATCH 2/2] Add target_clones profile option support

2025-05-04 Thread Yangyu Chen
the ror32 function which is "arch=+zvbb,+zbb" and "arch=+zbb" and the default version. Signed-off-by: Yangyu Chen gcc/ChangeLog: * common.opt: Add target_clones profile option. * multiple_target.cc (expand_target_clones): Add support for target_clones

[RFC PATCH 1/2] Fortran: Do not make_decl_rtl in trans_function_start

2025-05-04 Thread Yangyu Chen
pool. This patch removes the make_decl_rtl call in trans_function_start, and it will finally be called in all my testcases since we will check it whenever using the DECL_RTL macro. Signed-off-by: Yangyu Chen gcc/fortran/ChangeLog: * trans-decl.cc (trans_function_start): Remove call

Re: [PATCH 0/3] Redirect to specific target based on TARGET_VERSION_COMPATIBLE

2025-04-14 Thread Yangyu Chen
aller is > versioned. I will share this with you shortly and we can work out what we > wish to use? Sure! Thank you! Thanks, Yangyu Chen > > Kind regards, > Alfie > > On 14/04/2025 10:00, Yangyu Chen wrote: >> This patchset implements a new featu

[PATCH 1/3] Redirect to specific target based on TARGET_VERSION_COMPATIBLE

2025-04-14 Thread Yangyu Chen
with the current caller version and redirects to it. This mechanism has been discussed in a previous patch [1]. [1] https://patchwork.sourceware.org/comment/197172/ Signed-off-by: Yangyu Chen gcc/ChangeLog: * doc/tm.texi: New Target Hook TARGET_VERSION_COMPATIBLE. * doc

[PATCH 0/3] Redirect to specific target based on TARGET_VERSION_COMPATIBLE

2025-04-14 Thread Yangyu Chen
version for RISC-V architectures. [1] https://patchwork.sourceware.org/comment/197172/ Yangyu Chen (3): Redirect to specific target based on TARGET_VERSION_COMPATIBLE RISC-V: Split parse_features_for_version with cl_target_option returned RISC-V: Implement TARGET_VERSION_COMPATIBLE gcc

Re: [PATCH 1/3] Redirect to specific target based on TARGET_VERSION_COMPATIBLE

2025-04-14 Thread Yangyu Chen
On 14/4/2025 17:02, Yangyu Chen wrote: This commit introduces a new target hook, TARGET_VERSION_COMPATIBLE, enabling the redirection of specific target clones based on version compatibility. Additionally, it modifies the existing redirection mechanism to support this new hook, which

[PATCH 2/3] RISC-V: Split parse_features_for_version with cl_target_option returned

2025-04-14 Thread Yangyu Chen
-by: Yangyu Chen gcc/ChangeLog: * config/riscv/riscv.cc (parse_features_for_version): Split parse_features_for_version with cl_target_option returned. --- gcc/config/riscv/riscv.cc | 60 --- 1 file changed, 37 insertions(+), 23 deletions

[PATCH 3/3] RISC-V: Implement TARGET_VERSION_COMPATIBLE

2025-04-14 Thread Yangyu Chen
This patch implements the TARGET_VERSION_COMPATIBLE macro for RISC-V. It checks if the versioned callee is compatible with the versioned caller. Signed-off-by: Yangyu Chen gcc/ChangeLog: * config/riscv/riscv.cc (riscv_version_compatible): New function

[PATCH] RISC-V: Allow redirecting function calls to the same FMV clone

2025-04-05 Thread Yangyu Chen
_target.cc (redirect_to_specific_clone): Support RISC-V FMV redirect. (ipa_target_clone): Check TARGET_FMV_REDIRECT_CLONE. Signed-off-by: Yangyu Chen --- There is a problem raised in the previous discussion [1]: This behavior will eliminate the indirection in some cases where the runtime

Re: [PATCH v3 16/19] Refactor FMV frontend hooks and logic.

2025-03-29 Thread Yangyu Chen
(parse_res == AARCH_PARSE_OK); > + parse_res = aarch64_parse_fmv_features (str2, NULL, > + &feature_mask2, NULL); > + gcc_assert (parse_res == AARCH_PARSE_OK); > > - return (aarch64_compare_version_priority (fn1, fn2) != 0); > + return feature_mask1 == feature_mask2; &g

Re: [PATCH v3 14/19] Add reject_target_clone hook and filter target_clone versions.

2025-03-29 Thread Yangyu Chen
Hi Alfie, It appears that you've duplicated patch 14/19. The only difference between them is the title, which replaces "and" with "in order to". I think the latter version is what you intended. Thanks, Yangyu Chen

Re: [PATCH v3 05/19] Update is_function_default_version to work with target_version.

2025-03-29 Thread Yangyu Chen
> On 27 Mar 2025, at 16:45, Alfie Richards wrote: > > > Notably this respects target_version semantics where an unannotated > function can be the default version. > > gcc/ChangeLog: > > * attribs.cc (is_function_default_version): Add target_version logic. > --- > gcc/attribs.cc | 27 +++

Re: [PATCH] RISC-V: Remove the priority in FMV ASM name mangling

2025-03-25 Thread Yangyu Chen
On 25/3/2025 21:23, Kito Cheng wrote: Will it only cause issues with this patch https://gcc.gnu.org/pipermail/gcc-patches/2025-March/678918.html Yes. But I think we can merge this first. Thanks, Yangyu Chen or will it cause problems with the current trunk as well? If the latter one

[PATCH] RISC-V: Remove the priority in FMV ASM name mangling

2025-03-25 Thread Yangyu Chen
name mangling. Signed-off-by: Yangyu Chen --- gcc/config/riscv/riscv.cc | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index 38f3ae7cd84..4a042878554 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/ris

Re: [PATCH] RISC-V: Allow redirecting function calls to the same FMV clone

2025-03-24 Thread Yangyu Chen
> On 24 Mar 2025, at 16:28, Alfie Richards wrote: > > On 24/03/2025 03:28, Yangyu Chen wrote: >>> On 24 Mar 2025, at 11:03, Andrew Carlotti wrote: >>> >>> Two brief comments, since I'm on holiday until 31st but happened to notice >>> this

Re: [PATCH] RISC-V: Allow redirecting function calls to the same FMV clone

2025-03-23 Thread Yangyu Chen
> On 24 Mar 2025, at 11:03, Andrew Carlotti wrote: > > Two brief comments, since I'm on holiday until 31st but happened to notice > this > patch anyway. > > On Mon, Mar 24, 2025 at 02:19:21AM +0800, Yangyu Chen wrote: >> This behavior does not ensure th

Re: [PATCH] RISC-V: Minimal support for Qualcomm uC Xqccmp extension.

2025-02-20 Thread Yangyu Chen
On 20/2/2025 16:31, Dongyan Chen wrote: This patch support Qualcomm uC Xqccmp extension[1]. To enable GCC to recognize and process xqccmp extension correctly at compile time. [1]https://github.com/quic/riscv-unified-db/releases/tag/Xqccmp_extension-0.1.0 gcc/ChangeLog: * common/con

[PATCH] RISC-V: Drop __riscv_vendor_feature_bits

2025-02-10 Thread Yangyu Chen
-off-by: Yangyu Chen gcc/ChangeLog: * config/riscv/riscv-feature-bits.h (RISCV_VENDOR_FEATURE_BITS_LENGTH): Drop. (struct riscv_vendor_feature_bits): Drop. libgcc/ChangeLog: * config/riscv/feature_bits.c (RISCV_VENDOR_FEATURE_BITS_LENGTH): Drop

Re: [PATCH] Disable a broken multiversioning optimisation

2025-01-08 Thread Yangyu Chen
---- There was a previous patch by Yangyu Chen [1] which addressed flaw 1 but overlooked flaw 2. I pointed out flaw 2 at the time; as far as I can tell, there haven't been any further patches proposed for this issue (apologies if I missed something; I've not checked the mailing lists parti

[PATCH] RISC-V: Remove svvptc from riscv-ext-bitmask.def

2024-12-16 Thread Yangyu Chen
("RISC-V: Minimal support for svvptc extension.") Signed-off-by: Yangyu Chen gcc/ChangeLog: * common/config/riscv/riscv-ext-bitmask.def (RISCV_EXT_BITMASK): Remove svvptc. --- gcc/common/config/riscv/riscv-ext-bitmask.def | 1 - 1 file changed, 1 deletion(-) diff --git a/

Re: [PATCH] RISC-V: Support for zilsd and zclsd extensions.

2024-12-16 Thread Yangyu Chen
subext, MASK_ZCLSD), >> >> RISCV_EXT_FLAG_ENTRY ("svinval", x_riscv_sv_subext, MASK_SVINVAL), >> RISCV_EXT_FLAG_ENTRY ("svnapot", x_riscv_sv_subext, MASK_SVNAPOT), >> diff --git a/gcc/common/config/riscv/riscv-ext-bitmask.def >> b/gcc/common/

Re: [PATCH v2] Fix MV clones can not redirect to specific target on some targets

2024-11-19 Thread Yangyu Chen
Ping again. On 11/5/24 11:37, Yangyu Chen wrote: Ping and also CC Jeff and Kito. This is also useful for RISC-V since RISC-V uses target_version, which defines TARGET_HAS_FMV_TARGET_ATTRIBUTE to zero. On 10/28/24 00:00, Yangyu Chen wrote: Following the implementation of commit b8ce8129a5

Re: [PATCH] RISC-V: Fix target-attr-norelax.c testcase

2024-11-12 Thread Yangyu Chen
Sorry for the wrong address CC to Yulong. And this should add fixes: Fixes: 4bee5252c1de ("RISC-V: Add norelax function attribute")

[PATCH] RISC-V: Fix target-attr-norelax.c testcase

2024-11-12 Thread Yangyu Chen
The target-attr-norelax.c testcase was failing due to the redundant "\t" check in the assembly output, and forgot to skip the check for lto build in the testcase. Signed-off-by: Yangyu Chen gcc/testsuite/ChangeLog: * gcc.target/riscv/target-attr-norelax.c: Fix testcase

Re: [PATCH] RISC-V: Add norelax function attribute

2024-11-07 Thread Yangyu Chen
Thanks for doing this! > On Nov 8, 2024, at 00:19, shiyul...@iscas.ac.cn wrote: > > From: yulong > > This patch adds norelax function attribute that be discussed in > riscv-c-api-doc PR#94. > URL:https://github.com/riscv-non-isa/riscv-c-api-doc/pull/94 > > gcc/ChangeLog: > >* config/

Re: [PATCH v2] Fix MV clones can not redirect to specific target on some targets

2024-11-04 Thread Yangyu Chen
Ping and also CC Jeff and Kito. This is also useful for RISC-V since RISC-V uses target_version, which defines TARGET_HAS_FMV_TARGET_ATTRIBUTE to zero. On 10/28/24 00:00, Yangyu Chen wrote: Following the implementation of commit b8ce8129a5 ("Redirect call within specific target attr

[PATCH v5 5/8] RISC-V: Implement TARGET_COMPARE_VERSION_PRIORITY and TARGET_OPTION_FUNCTION_VERSIONS

2024-11-04 Thread Yangyu Chen
reuses the code in TARGET_COMPARE_VERSION_PRIORITY and check it returns 0, which means the equal priority. Co-Developed-by: Hank Chang Signed-off-by: Yangyu Chen gcc/ChangeLog: * config/riscv/riscv.cc (parse_features_for_version): New function. (compare_fmv_features

[PATCH v5 7/8] RISC-V: Implement TARGET_GENERATE_VERSION_DISPATCHER_BODY and TARGET_GET_FUNCTION_VERSIONS_DISPATCHER

2024-11-04 Thread Yangyu Chen
ent in the dispatcher function. Signed-off-by: Yangyu Chen gcc/ChangeLog: * config/riscv/riscv.cc (add_condition_to_bb): New function. (dispatch_function_versions): New function. (get_suffixed_assembler_name): New function. (make_resolver_func): Ne

[PATCH v5 4/8] RISC-V: Implement TARGET_OPTION_VALID_VERSION_ATTRIBUTE_P

2024-11-04 Thread Yangyu Chen
et_version" for function versioning. Co-Developed-by: Hank Chang Signed-off-by: Yangyu Chen gcc/ChangeLog: * config/riscv/riscv-protos.h (riscv_process_target_attr): Remove as it is not used. (riscv_option_valid_version_attribute_p): Declare. (riscv_process

[PATCH v5 8/8] RISC-V: Add Multi-Versioning Test Cases

2024-11-04 Thread Yangyu Chen
This patch adds test cases for the Function Multi-Versioning (FMV) feature for RISC-V, which reuses the existing test cases from the aarch64 and ported them to RISC-V. Signed-off-by: Yangyu Chen gcc/testsuite/ChangeLog: * g++.target/riscv/mv-symbols1.C: New test. * g++.target

[PATCH v5 6/8] RISC-V: Implement TARGET_MANGLE_DECL_ASSEMBLER_NAME

2024-11-04 Thread Yangyu Chen
This patch implements the TARGET_MANGLE_DECL_ASSEMBLER_NAME for RISC-V. This is used to add function multiversioning suffixes to the assembler name. Signed-off-by: Yangyu Chen gcc/ChangeLog: * config/riscv/riscv.cc (riscv_mangle_decl_assembler_name): New function

[PATCH v5 2/8] RISC-V: Implement Priority syntax parser for Function Multi-Versioning

2024-11-04 Thread Yangyu Chen
/85 Signed-off-by: Yangyu Chen gcc/ChangeLog: * config/riscv/riscv-target-attr.cc (riscv_target_attr_parser::handle_priority): New function. (riscv_target_attr_parser::update_settings): Update priority attribute. * config/riscv/riscv.opt: Add TargetVariable

[PATCH v5 3/8] RISC-V: Implement riscv_minimal_hwprobe_feature_bits

2024-11-04 Thread Yangyu Chen
g to allow the FMV dispatcher to work correctly on older kernels. Signed-off-by: Yangyu Chen gcc/ChangeLog: * common/config/riscv/riscv-common.cc (RISCV_EXT_BITMASK): New macro. (struct riscv_ext_bitmask_table_t): New struct. (riscv_minimal_hwprobe_feature_bits): Ne

[PATCH v5 1/8] Introduce TARGET_CLONES_ATTR_SEPARATOR for RISC-V

2024-11-04 Thread Yangyu Chen
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 gcc/ChangeLog: * defaults.

[PATCH v5 0/8] RISC-V: Add Function Multi-Versioning support

2024-11-04 Thread Yangyu Chen
3cRNDuSNp58Tgpt=pzm4dg...@mail.gmail.com/ [5] https://inbox.sourceware.org/gcc-patches/tencent_fd68a30bdf936092b6a663146e634c76c...@qq.com/ [6] https://inbox.sourceware.org/gcc-patches/tencent_a646c713dc9218dd10ca460ebe074153e...@qq.com/ [7] https://patchwork.sourceware.org/project/gcc/patch/tencent_

[PATCH v4 8/8] RISC-V: Add Multi-Versioning Test Cases

2024-11-01 Thread Yangyu Chen
This patch adds test cases for the Function Multi-Versioning (FMV) feature for RISC-V, which reuses the existing test cases from the aarch64 and ported them to RISC-V. Signed-off-by: Yangyu Chen gcc/testsuite/ChangeLog: * g++.target/riscv/mv-symbols1.C: New test. * g++.target

[PATCH v4 6/8] RISC-V: Implement TARGET_MANGLE_DECL_ASSEMBLER_NAME

2024-11-01 Thread Yangyu Chen
This patch implements the TARGET_MANGLE_DECL_ASSEMBLER_NAME for RISC-V. This is used to add function multiversioning suffixes to the assembler name. Signed-off-by: Yangyu Chen gcc/ChangeLog: * config/riscv/riscv.cc (riscv_mangle_decl_assembler_name): New function

[PATCH v4 5/8] RISC-V: Implement TARGET_COMPARE_VERSION_PRIORITY and TARGET_OPTION_FUNCTION_VERSIONS

2024-11-01 Thread Yangyu Chen
reuses the code in TARGET_COMPARE_VERSION_PRIORITY and check it returns 0, which means the equal priority. Co-Developed-by: Hank Chang Signed-off-by: Yangyu Chen gcc/ChangeLog: * config/riscv/riscv.cc (parse_features_for_version): New function. (compare_fmv_features

[PATCH v4 7/8] RISC-V: Implement TARGET_GENERATE_VERSION_DISPATCHER_BODY and TARGET_GET_FUNCTION_VERSIONS_DISPATCHER

2024-11-01 Thread Yangyu Chen
ent in the dispatcher function. Signed-off-by: Yangyu Chen gcc/ChangeLog: * config/riscv/riscv.cc (add_condition_to_bb): New function. (dispatch_function_versions): New function. (get_suffixed_assembler_name): New function. (make_resolver_func): Ne

[PATCH v4 4/8] RISC-V: Implement TARGET_OPTION_VALID_VERSION_ATTRIBUTE_P

2024-11-01 Thread Yangyu Chen
et_version" for function versioning. Co-Developed-by: Hank Chang Signed-off-by: Yangyu Chen gcc/ChangeLog: * config/riscv/riscv-protos.h (riscv_process_target_attr): Remove as it is not used. (riscv_option_valid_version_attribute_p): Declare. (riscv_process

[PATCH v4 3/8] RISC-V: Implement riscv_minimal_hwprobe_feature_bits

2024-11-01 Thread Yangyu Chen
g to allow the FMV dispatcher to work correctly on older kernels. Signed-off-by: Yangyu Chen gcc/ChangeLog: * common/config/riscv/riscv-common.cc (RISCV_EXT_BITMASK): New macro. (struct riscv_ext_bitmask_table_t): New struct. (riscv_minimal_hwprobe_feature_bits): Ne

[PATCH v4 2/8] RISC-V: Implement Priority syntax parser for Function Multi-Versioning

2024-11-01 Thread Yangyu Chen
/85 Signed-off-by: Yangyu Chen gcc/ChangeLog: * config/riscv/riscv-target-attr.cc (riscv_target_attr_parser::handle_priority): New function. (riscv_target_attr_parser::update_settings): Update priority attribute. * config/riscv/riscv.opt: Add TargetVariable

[PATCH v4 1/8] Introduce TARGET_CLONES_ATTR_SEPARATOR for RISC-V

2024-11-01 Thread Yangyu Chen
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 gcc/ChangeLog: * defaults.

[PATCH v4 0/8] RISC-V: Add Function Multi-Versioning support

2024-11-01 Thread Yangyu Chen
m/ [6] https://inbox.sourceware.org/gcc-patches/tencent_a646c713dc9218dd10ca460ebe074153e...@qq.com/ [7] https://patchwork.sourceware.org/project/gcc/patch/tencent_f08be088f6b1e3152e508c63c870e31cd...@qq.com/ Yangyu Chen (8): Introduce TARGET_CLONES_ATTR_SEPARATOR for RISC-V RISC-V: Implement Priority synt

Re: [PATCH v3 05/11] RISC-V: Implement TARGET_COMPARE_VERSION_PRIORITY and TARGET_OPTION_FUNCTION_VERSIONS

2024-11-01 Thread Yangyu Chen
On 10/31/24 21:26, Kito Cheng wrote: On Thu, Oct 31, 2024 at 6:59 PM Yangyu Chen wrote: On Oct 31, 2024, at 18:14, Kito Cheng wrote: diff --git a/gcc/config/riscv/riscv-target-attr.cc b/gcc/config/riscv/riscv-target-attr.cc index 087fbae77b0..4c85ad60b72 100644 --- a/gcc/config/riscv

Re: [PATCH v3 09/11] RISC-V: Reapply target_version attribute after target attribute

2024-11-01 Thread Yangyu Chen
after checking all the callers for target_option,valid_attribute_p, I see that this case is already being handled, so it dropped. On Thu, Oct 24, 2024 at 3:15 PM Yangyu Chen wrote: To ensure that the target_version attribute is applied after target attributes. gcc/ChangeLog

Re: [PATCH v3 10/11] RISC-V: Implement TARGET_GENERATE_VERSION_DISPATCHER_BODY and TARGET_GET_FUNCTION_VERSIONS_DISPATCHER

2024-11-01 Thread Yangyu Chen
discussion, a possible solution might be to refuse the relax for the IFUNC resolvers and its callees. Thus, we don’t require gp to access global variables like __riscv_feature_bits. I came up with a solution that adds an attribute like __attribute__((norelax)) to functional like -mno-relax for a specific function to both the FMV resolver gimple function and the libgcc source code which will be called from FMV resolver. Would this solution be acceptable? Thanks, Yangyu Chen

Re: [PATCH v3 05/11] RISC-V: Implement TARGET_COMPARE_VERSION_PRIORITY and TARGET_OPTION_FUNCTION_VERSIONS

2024-10-31 Thread Yangyu Chen
> On Oct 31, 2024, at 18:14, Kito Cheng wrote: > >> diff --git a/gcc/config/riscv/riscv-target-attr.cc >> b/gcc/config/riscv/riscv-target-attr.cc >> index 087fbae77b0..4c85ad60b72 100644 >> --- a/gcc/config/riscv/riscv-target-attr.cc >> +++ b/gcc/config/riscv/riscv-target-attr.cc >> @@ -239,1

Re: [PATCH v3 03/11] RISC-V: Implement Priority syntax parser for Function Multi-Versioning

2024-10-31 Thread Yangyu Chen
NC resolver. > so I guess we need to make riscv_target_attr_parser able to > distinguish target and target_version? maybe add an extra argument to > riscv_target_attr_parser? I think so if it really needed. > > On Thu, Oct 24, 2024 at 3:12 PM Yangyu Chen wrote: >> >&

[PATCH v2] RISC-V: allow -fno-plt to disable PLT

2024-10-31 Thread Yangyu Chen
: Yangyu Chen gcc/ChangeLog: * config/riscv/predicates.md: Use flag_plt instead of TARGET_PLT. * config/riscv/riscv.opt: alias common option fplt to mplt. --- gcc/config/riscv/predicates.md | 2 +- gcc/config/riscv/riscv.opt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions

[PATCH] RISC-V: allow -fno-plt to disable PLT

2024-10-30 Thread Yangyu Chen
x27;s safe to use logical and to combine them. Co-Developed-by: Liao Shihua Signed-off-by: Yangyu Chen gcc/ChangeLog: * config/riscv/predicates.md: deprecates mplt option. * config/riscv/riscv.opt: allow -fno-plt to disable PLT. --- gcc/config/riscv/predicates.md | 3 ++- gcc/c

Re: [PATCH v3] [aarch64] Fix function multiversioning dispatcher link error with LTO

2024-10-30 Thread Yangyu Chen
> On Oct 30, 2024, at 19:59, Richard Sandiford > wrote: > > Yangyu Chen writes: >> We forgot to apply DECL_EXTERNAL to __init_cpu_features_resolver decl. When >> building with LTO, the linker cannot find the >> __init_cpu_features_resolver.lto_priv*

[PATCH v4] [aarch64] Fix function multiversioning dispatcher link error with LTO

2024-10-30 Thread Yangyu Chen
: 0cfde688e213 ("[aarch64] Add function multiversioning support") Signed-off-by: Yangyu Chen gcc/ChangeLog: * config/aarch64/aarch64.cc (dispatch_function_versions): Adding DECL_EXTERNAL, TREE_PUBLIC and hidden DECL_VISIBILITY to __init_cpu_features_resolver and

[PATCH v3] [aarch64] Fix function multiversioning dispatcher link error with LTO

2024-10-29 Thread Yangyu Chen
We forgot to apply DECL_EXTERNAL to __init_cpu_features_resolver decl. When building with LTO, the linker cannot find the __init_cpu_features_resolver.lto_priv* symbol, causing the link error. This patch gets this fixed by adding DECL_EXTERNAL to the decl. To avoid used but never defined warning f

[PATCH v2] Fix MV clones can not redirect to specific target on some targets

2024-10-27 Thread Yangyu Chen
Following the implementation of commit b8ce8129a5 ("Redirect call within specific target attribute among MV clones (PR ipa/82625)"), we can now optimize calls by invoking a versioned function callee from a caller that shares the same target attribute. However, on targets that define TARGET_HAS_FMV_

[PATCH] Fix MV clones can not redirect to specific target on some targets

2024-10-27 Thread Yangyu Chen
Following the implementation of commit b8ce8129a5 ("Redirect call within specific target attribute among MV clones (PR ipa/82625)"), we can now optimize calls by invoking a versioned function callee from a caller that shares the same target attribute. However, on targets that define TARGET_HAS_FMV_

[PATCH v2] [aarch64] Fix function multiversioning dispatcher link error with LTO

2024-10-27 Thread Yangyu Chen
We forgot to apply DECL_EXTERNAL to __init_cpu_features_resolver decl. When building with LTO, the linker cannot find the __init_cpu_features_resolver.lto_priv* symbol, causing the link error. This patch get this fixed by adding DECL_EXTERNAL to the decl. To avoid used but never defined warning fo

Re: [PATCH v3 10/11] RISC-V: Implement TARGET_GENERATE_VERSION_DISPATCHER_BODY and TARGET_GET_FUNCTION_VERSIONS_DISPATCHER

2024-10-26 Thread Yangyu Chen
On 2024/10/24 15:13, Yangyu Chen wrote: This patch implements the TARGET_GENERATE_VERSION_DISPATCHER_BODY and TARGET_GET_FUNCTION_VERSIONS_DISPATCHER for RISC-V. This is used to generate the dispatcher function and get the dispatcher function for function multiversioning. This patch copies

[PATCH] [aarch64] Fix function multiversioning dispatcher link error with LTO

2024-10-26 Thread Yangyu Chen
We forgot to apply DECL_EXTERNAL to __init_cpu_features_resolver decl. When building with LTO, the linker cannot find the __init_cpu_features_resolver.lto_priv* symbol, causing the link error. This patch get this fixed by adding DECL_EXTERNAL to the decl. Minimal steps to reproduce the bug: echo

Re: [PATCH] RISC-V: Add function multiversioning support

2024-10-24 Thread Yangyu Chen
re. I’ve also been testing these patches recently since one of my research works relies on this. FYI, there is a v3 version now. Link: https://patchwork.sourceware.org/project/gcc/list/?series=39863&state=* Thanks, Yangyu Chen > On Mon, Oct 21, 2024 at 11:57 AM Yangyu Chen wrote: >>

[PATCH v3 10/11] RISC-V: Implement TARGET_GENERATE_VERSION_DISPATCHER_BODY and TARGET_GET_FUNCTION_VERSIONS_DISPATCHER

2024-10-24 Thread Yangyu Chen
This patch implements the TARGET_GENERATE_VERSION_DISPATCHER_BODY and TARGET_GET_FUNCTION_VERSIONS_DISPATCHER for RISC-V. This is used to generate the dispatcher function and get the dispatcher function for function multiversioning. This patch copies many codes from commit 0cfde688e213 ("[aarch64]

[PATCH v3 08/11] RISC-V: Do not inline when callee is versioned but caller is not

2024-10-24 Thread Yangyu Chen
When the callee is versioned but the caller is not, we should not inline the callee into the caller, to prevent the default version of the callee from being inlined into a not versioned caller. gcc/ChangeLog: * config/riscv/riscv.cc (riscv_can_inline_p): Refuse to inline when call

[PATCH v3 11/11] RISC-V: Add Multi-Versioning Test Cases

2024-10-24 Thread Yangyu Chen
This patch adds test cases for the Function Multi-Versioning (FMV) feature for RISC-V, which reuses the existing test cases from the aarch64 and ported them to RISC-V. gcc/testsuite/ChangeLog: * g++.target/riscv/mv-symbols1.C: New test. * g++.target/riscv/mv-symbols2.C: New test.

[PATCH v3 09/11] RISC-V: Reapply target_version attribute after target attribute

2024-10-24 Thread Yangyu Chen
To ensure that the target_version attribute is applied after target attributes. gcc/ChangeLog: * config/riscv/riscv-target-attr.cc (riscv_option_valid_attribute_p): Reapply target_version attribute after target attribute --- gcc/config/riscv/riscv-target-attr.cc | 13

[PATCH v3 05/11] RISC-V: Implement TARGET_COMPARE_VERSION_PRIORITY and TARGET_OPTION_FUNCTION_VERSIONS

2024-10-24 Thread Yangyu Chen
This patch implements TARGET_COMPARE_VERSION_PRIORITY and TARGET_OPTION_FUNCTION_VERSIONS for RISC-V. The TARGET_COMPARE_VERSION_PRIORITY is implemented to compare the priority of two function versions based on the rules defined in the RISC-V C-API Doc PR #85: https://github.com/riscv-non-isa/ris

[PATCH v3 07/11] RISC-V: Implement TARGET_MANGLE_DECL_ASSEMBLER_NAME

2024-10-24 Thread Yangyu Chen
This patch implements the TARGET_MANGLE_DECL_ASSEMBLER_NAME for RISC-V. This is used to add function multiversioning suffixes to the assembler name. gcc/ChangeLog: * config/riscv/riscv.cc (riscv_mangle_decl_assembler_name): New function. (TARGET_MANGLE_DECL_ASSEMBLER_NAME)

[PATCH v3 06/11] RISC-V: Implement TARGET_OPTION_VALID_VERSION_ATTRIBUTE_P

2024-10-24 Thread Yangyu Chen
This patch implements the TARGET_OPTION_VALID_VERSION_ATTRIBUTE_P for RISC-V. This hook is used to process attribute ((target_version ("..."))). Co-Developed-by: Hank Chang gcc/ChangeLog: * config/riscv/riscv-protos.h (riscv_option_valid_version_attribute_p): Declare. (r

[PATCH v3 04/11] RISC-V: Implement riscv_minimal_hwprobe_feature_bits

2024-10-24 Thread Yangyu Chen
v-ext-bitmask.def @@ -0,0 +1,83 @@ +/* RISC-V Extension Bitmask Definitions, corresponding to Extension Bitmask + Definitions in RISC-V C API Specification. + Copyright (C) 2024 Free Software Foundation, Inc. + Contributed by Yangyu Chen (c...@cyyself.name). + +This file is part of GCC. + +

[PATCH v3 03/11] RISC-V: Implement Priority syntax parser for Function Multi-Versioning

2024-10-24 Thread Yangyu Chen
This patch adds the priority syntax parser to support the Function Multi-Versioning (FMV) feature in RISC-V. This feature allows users to specify the priority of the function version in the attribute syntax. Chnages based on RISC-V C-API PR: https://github.com/riscv-non-isa/riscv-c-api-doc/pull/85

[PATCH v3 02/11] RISC-V: Split riscv_process_target_attr with const char *args argument

2024-10-24 Thread Yangyu Chen
This patch splits static bool riscv_process_target_attr (tree args, location_t loc) into two functions: - bool riscv_process_target_attr (const char *args, location_t loc) - static bool riscv_process_target_attr (tree args, location_t loc) Thus, we can call `riscv_process_target_attr` with a `con

[PATCH v3 01/11] Introduce TARGET_CLONES_ATTR_SEPARATOR for RISC-V

2024-10-24 Thread Yangyu Chen
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

[PATCH v3 00/11] RISC-V: Add Function Multi-Versioning support

2024-10-24 Thread Yangyu Chen
iscv-c-api-doc/pull/85 [3] https://patchwork.sourceware.org/project/glibc/patch/tencent_71d182fbda6e8e57b80731dd218d8d5c7...@qq.com/ Yangyu Chen (11): Introduce TARGET_CLONES_ATTR_SEPARATOR for RISC-V RISC-V: Split riscv_process_target_attr with const char *args argument RISC-V: Implement P

[PATCH v2 06/11] RISC-V: Implement TARGET_OPTION_VALID_VERSION_ATTRIBUTE_P

2024-10-21 Thread Yangyu Chen
This patch implements the TARGET_OPTION_VALID_VERSION_ATTRIBUTE_P for RISC-V. This hook is used to process attribute ((target_version ("..."))). Co-Developed-by: Hank Chang gcc/ChangeLog: * config/riscv/riscv-protos.h (riscv_option_valid_version_attribute_p): Declare. (r

Re: [PATCH] RISC-V: Add function multiversioning support

2024-10-21 Thread Yangyu Chen
> On Oct 21, 2024, at 10:41, Kito Cheng wrote: > > Could you add testcases? Also, could you splitted that into smaller > patches to make it easier to review? > Done! Link: https://patchwork.sourceware.org/project/gcc/list/?series=39772

[PATCH v2 11/11] RISC-V: Add Multi-Versioning Test Cases

2024-10-21 Thread Yangyu Chen
This patch adds test cases for the Function Multi-Versioning (FMV) feature for RISC-V, which reuses the existing test cases from the aarch64 and ported them to RISC-V. gcc/testsuite/ChangeLog: * g++.target/riscv/mv-symbols1.C: New test. * g++.target/riscv/mv-symbols2.C: New test.

[PATCH v2 10/11] RISC-V: Implement TARGET_GENERATE_VERSION_DISPATCHER_BODY and TARGET_GET_FUNCTION_VERSIONS_DISPATCHER

2024-10-21 Thread Yangyu Chen
This patch implements the TARGET_GENERATE_VERSION_DISPATCHER_BODY and TARGET_GET_FUNCTION_VERSIONS_DISPATCHER for RISC-V. This is used to generate the dispatcher function and get the dispatcher function for function multiversioning. This patch copies many codes from commit 0cfde688e213 ("[aarch64]

[PATCH v2 09/11] RISC-V: Reapply target_version attribute after target attribute

2024-10-21 Thread Yangyu Chen
To ensure that the target_version attribute is applied after target attributes. gcc/ChangeLog: * config/riscv/riscv-target-attr.cc (riscv_option_valid_attribute_p): Reapply target_version attribute after target attribute --- gcc/config/riscv/riscv-target-attr.cc | 13

[PATCH v2 08/11] RISC-V: Do not inline when callee is versioned but caller is not

2024-10-21 Thread Yangyu Chen
When the callee is versioned but the caller is not, we should not inline the callee into the caller, to prevent the default version of the callee from being inlined into a not versioned caller. gcc/ChangeLog: * config/riscv/riscv.cc (riscv_can_inline_p): Refuse to inline when call

[PATCH v2 07/11] RISC-V: Implement TARGET_MANGLE_DECL_ASSEMBLER_NAME

2024-10-21 Thread Yangyu Chen
This patch implements the TARGET_MANGLE_DECL_ASSEMBLER_NAME for RISC-V. This is used to add function multiversioning suffixes to the assembler name. gcc/ChangeLog: * config/riscv/riscv.cc (riscv_mangle_decl_assembler_name): New function. (TARGET_MANGLE_DECL_ASSEMBLER_NAME)

[PATCH v2 03/11] RISC-V: Implement Priority syntax parser for Function Multi-Versioning

2024-10-21 Thread Yangyu Chen
This patch adds the priority syntax parser to support the Function Multi-Versioning (FMV) feature in RISC-V. This feature allows users to specify the priority of the function version in the attribute syntax. Chnages based on RISC-V C-API PR: https://github.com/riscv-non-isa/riscv-c-api-doc/pull/85

[PATCH v2 05/11] RISC-V: Implement TARGET_COMPARE_VERSION_PRIORITY and TARGET_OPTION_FUNCTION_VERSIONS

2024-10-21 Thread Yangyu Chen
This patch implements TARGET_COMPARE_VERSION_PRIORITY and TARGET_OPTION_FUNCTION_VERSIONS for RISC-V. The TARGET_COMPARE_VERSION_PRIORITY is implemented to compare the priority of two function versions based on the rules defined in the RISC-V C-API Doc PR #85: https://github.com/riscv-non-isa/ris

[PATCH v2 04/11] RISC-V: Implement riscv_minimal_hwprobe_feature_bits

2024-10-21 Thread Yangyu Chen
This patch implements the riscv_minimal_hwprobe_feature_bits feature for the RISC-V target. The feature bits are defined in the previous patch [1] to provide bitmasks of ISA extensions that defined in RISC-V C-API. Thus, we need a function to generate the feature bits for IFUNC resolver to dispatch

  1   2   >