aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorHans-Peter Nilsson <hp@bitrange.com>2018-09-18 02:42:15 +0000
committerHans-Peter Nilsson <hp@gcc.gnu.org>2018-09-18 02:42:15 +0000
commite6bf23cce3ed63800f4545cd9a79e3500b24625c (patch)
tree9c85bb7202d16e81503188651bb329d62cd6ff69 /gcc
parent18b0a76251a256f8b26af7ade7d9a0b346958af0 (diff)
downloadgcc-e6bf23cce3ed63800f4545cd9a79e3500b24625c.zip
gcc-e6bf23cce3ed63800f4545cd9a79e3500b24625c.tar.gz
gcc-e6bf23cce3ed63800f4545cd9a79e3500b24625c.tar.bz2
Handle a library implementation of ffs calling __builtin_ffs.
* config/mmix/mmix.c (TARGET_INIT_LIBFUNCS): Override with... (mmix_init_libfuncs): New function: make __builtin_ffs expand to __ffsdi2. From-SVN: r264381
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/config/mmix/mmix.c19
2 files changed, 26 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d236d68..ce995fa 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2018-09-18 Hans-Peter Nilsson <hp@bitrange.com>
+
+ Handle a library implementation of ffs calling __builtin_ffs.
+ * config/mmix/mmix.c (TARGET_INIT_LIBFUNCS): Override with...
+ (mmix_init_libfuncs): New function: make __builtin_ffs expand
+ to __ffsdi2.
+
2018-09-17 David Malcolm <dmalcolm@redhat.com>
* diagnostic-show-locus.c (class layout_range): Add field
diff --git a/gcc/config/mmix/mmix.c b/gcc/config/mmix/mmix.c
index b8c7c84..0225f80 100644
--- a/gcc/config/mmix/mmix.c
+++ b/gcc/config/mmix/mmix.c
@@ -33,6 +33,7 @@ along with GCC; see the file COPYING3. If not see
#include "memmodel.h"
#include "tm_p.h"
#include "insn-config.h"
+#include "optabs.h"
#include "regs.h"
#include "emit-rtl.h"
#include "recog.h"
@@ -140,6 +141,7 @@ static void mmix_setup_incoming_varargs
(cumulative_args_t, machine_mode, tree, int *, int);
static void mmix_file_start (void);
static void mmix_file_end (void);
+static void mmix_init_libfuncs (void);
static bool mmix_rtx_costs (rtx, machine_mode, int, int, int *, bool);
static int mmix_register_move_cost (machine_mode,
reg_class_t, reg_class_t);
@@ -221,6 +223,9 @@ static HOST_WIDE_INT mmix_starting_frame_offset (void);
#undef TARGET_ASM_OUTPUT_SOURCE_FILENAME
#define TARGET_ASM_OUTPUT_SOURCE_FILENAME mmix_asm_output_source_filename
+#undef TARGET_INIT_LIBFUNCS
+#define TARGET_INIT_LIBFUNCS mmix_init_libfuncs
+
#undef TARGET_CONDITIONAL_REGISTER_USAGE
#define TARGET_CONDITIONAL_REGISTER_USAGE mmix_conditional_register_usage
@@ -1308,6 +1313,20 @@ mmix_asm_output_source_filename (FILE *stream, const char *name)
fprintf (stream, "\n");
}
+/* Unfortunately, by default __builtin_ffs is expanded to ffs for
+ targets where INT_TYPE_SIZE < BITS_PER_WORD. That together with
+ newlib since 2017-07-04 implementing ffs as __builtin_ffs leads to
+ (newlib) ffs recursively calling itself. But, because of argument
+ promotion, and with ffs we're counting from the least bit, the
+ libgcc equivalent for ffsl works equally well for int arguments, so
+ just use that. */
+
+static void
+mmix_init_libfuncs (void)
+{
+ set_optab_libfunc (ffs_optab, SImode, "__ffsdi2");
+}
+
/* OUTPUT_QUOTED_STRING. */
void