[gcc r16-5154] LoongArch: Implement TARGET_COMPARE_VERSION_PRIORITY.
LuluCheng
chenglulu@gcc.gnu.org
Tue Nov 11 07:34:54 GMT 2025
https://gcc.gnu.org/g:8e4d9013007d160b51f6026b4b3e3b8220f2f683
commit r16-5154-g8e4d9013007d160b51f6026b4b3e3b8220f2f683
Author: Lulu Cheng <chenglulu@loongson.cn>
Date: Wed Oct 15 16:51:21 2025 +0800
LoongArch: Implement TARGET_COMPARE_VERSION_PRIORITY.
gcc/ChangeLog:
* config/loongarch/loongarch.cc
(loongarch_compare_version_priority): Returns true if DECL1
and DECL2 are versions of the same function.
(TARGET_COMPARE_VERSION_PRIORITY): Define.
Diff:
---
gcc/config/loongarch/loongarch.cc | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc
index edec88136554..a700e177dc86 100644
--- a/gcc/config/loongarch/loongarch.cc
+++ b/gcc/config/loongarch/loongarch.cc
@@ -12013,6 +12013,23 @@ loongarch_generate_version_dispatcher_body (void *node_p)
return resolver_decl;
}
+/* Compare priorities of two version decls. Return:
+ 1: decl1 has a higher priority
+ -1: decl2 has a higher priority
+ 0: decl1 and decl2 have the same priority.
+*/
+
+int
+loongarch_compare_version_priority (tree decl1, tree decl2)
+{
+ unsigned int prio1, prio2;
+ get_feature_mask_for_version (decl1, NULL, &prio1);
+ get_feature_mask_for_version (decl2, NULL, &prio2);
+
+ return prio1 == prio2 ? 0
+ : prio1 > prio2 ? 1 : -1;
+}
+
/* Initialize the GCC target structure. */
#undef TARGET_ASM_ALIGNED_HI_OP
#define TARGET_ASM_ALIGNED_HI_OP "\t.half\t"
@@ -12316,6 +12333,10 @@ loongarch_generate_version_dispatcher_body (void *node_p)
#define TARGET_GENERATE_VERSION_DISPATCHER_BODY \
loongarch_generate_version_dispatcher_body
+#undef TARGET_COMPARE_VERSION_PRIORITY
+#define TARGET_COMPARE_VERSION_PRIORITY \
+ loongarch_compare_version_priority
+
struct gcc_target targetm = TARGET_INITIALIZER;
#include "gt-loongarch.h"
More information about the Gcc-cvs
mailing list