Skip to content

Commit 6e04e0c

Browse files
clazissartemiy-volkov
authored andcommitted
Add 32bit variant for clz, ctz, ffs, parity and popcount
1 parent 0a8afe7 commit 6e04e0c

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

gcc/config/arc64/arc64.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,13 +1114,26 @@ arc64_initialize_trampoline (rtx tramp, tree fndecl, rtx cxt)
11141114

11151115

11161116
/* Implement FUNCTION_OK_FOR_SIBCALL hook. */
1117+
11171118
static bool
11181119
arc64_function_ok_for_sibcall (tree decl ATTRIBUTE_UNUSED,
11191120
tree exp ATTRIBUTE_UNUSED)
11201121
{
11211122
return true;
11221123
}
11231124

1125+
/* Implement INIT_LIBFUNCS hook. */
1126+
1127+
static void
1128+
arc64_init_libfuncs (void)
1129+
{
1130+
set_optab_libfunc (ffs_optab, SImode, "__ffssi2");
1131+
set_optab_libfunc (clz_optab, SImode, "__clzsi2");
1132+
set_optab_libfunc (ctz_optab, SImode, "__ctzsi2");
1133+
set_optab_libfunc (popcount_optab, SImode, "__popcountsi2");
1134+
set_optab_libfunc (parity_optab, SImode, "__paritysi2");
1135+
}
1136+
11241137
/*
11251138
Global functions.
11261139
*/
@@ -1598,6 +1611,9 @@ arc64_limm_addr_p (rtx op)
15981611
#undef TARGET_FUNCTION_OK_FOR_SIBCALL
15991612
#define TARGET_FUNCTION_OK_FOR_SIBCALL arc64_function_ok_for_sibcall
16001613

1614+
#undef TARGET_INIT_LIBFUNCS
1615+
#define TARGET_INIT_LIBFUNCS arc64_init_libfuncs
1616+
16011617
struct gcc_target targetm = TARGET_INITIALIZER;
16021618

16031619
#include "gt-arc64.h"

libgcc/config/arc64/lib2funcs.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,15 @@ __umoddi3 (uint64_t a, uint64_t b)
137137
{
138138
return udivmoddi4 (a, b, 1);
139139
}
140+
141+
/* We need 32bit version for some of the functions defined in
142+
libgcc2.c. */
143+
#define LIBGCC2_UNITS_PER_WORD 4
144+
145+
#define L_clzsi2
146+
#define L_ctzsi2
147+
#define L_ffssi2
148+
#define L_paritysi2
149+
#define L_popcountsi2
150+
151+
#include "libgcc2.c"

0 commit comments

Comments
 (0)