#endif
}
+/* Implement TARGET_INIT_LIBFUNCS. */
+
+static void
+gcn_init_libfuncs (void)
+{
+ /* BITS_PER_UNIT * 2 is 64 bits, which causes
+ optabs-libfuncs.c:gen_int_libfunc to omit TImode (i.e 128 bits)
+ libcalls that we need to support operations for that type. Initialise
+ them here instead. */
+ set_optab_libfunc (udiv_optab, TImode, "__udivti3");
+ set_optab_libfunc (umod_optab, TImode, "__umodti3");
+ set_optab_libfunc (sdiv_optab, TImode, "__divti3");
+ set_optab_libfunc (smod_optab, TImode, "__modti3");
+ set_optab_libfunc (smul_optab, TImode, "__multi3");
+ set_optab_libfunc (addv_optab, TImode, "__addvti3");
+ set_optab_libfunc (subv_optab, TImode, "__subvti3");
+ set_optab_libfunc (negv_optab, TImode, "__negvti2");
+ set_optab_libfunc (absv_optab, TImode, "__absvti2");
+ set_optab_libfunc (smulv_optab, TImode, "__mulvti3");
+ set_optab_libfunc (ffs_optab, TImode, "__ffsti2");
+ set_optab_libfunc (clz_optab, TImode, "__clzti2");
+ set_optab_libfunc (ctz_optab, TImode, "__ctzti2");
+ set_optab_libfunc (clrsb_optab, TImode, "__clrsbti2");
+ set_optab_libfunc (popcount_optab, TImode, "__popcountti2");
+ set_optab_libfunc (parity_optab, TImode, "__parityti2");
+ set_optab_libfunc (bswap_optab, TImode, "__bswapti2");
+}
+
/* Expand the CMP_SWAP GCN builtins. We have our own versions that do
not require taking the address of any object, other than the memory
cell being operated on.
#define TARGET_HAVE_SPECULATION_SAFE_VALUE speculation_safe_value_not_needed
#undef TARGET_INIT_BUILTINS
#define TARGET_INIT_BUILTINS gcn_init_builtins
+#undef TARGET_INIT_LIBFUNCS
+#define TARGET_INIT_LIBFUNCS gcn_init_libfuncs
#undef TARGET_IRA_CHANGE_PSEUDO_ALLOCNO_CLASS
#define TARGET_IRA_CHANGE_PSEUDO_ALLOCNO_CLASS \
gcn_ira_change_pseudo_allocno_class
#define BYTES_BIG_ENDIAN 0
#define WORDS_BIG_ENDIAN 0
-#define BITS_PER_WORD 32
-#define UNITS_PER_WORD (BITS_PER_WORD/BITS_PER_UNIT)
-#define LIBGCC2_UNITS_PER_WORD 4
+#ifdef IN_LIBGCC2
+/* We want DImode and TImode helpers. */
+#define UNITS_PER_WORD 8
+#else
+#define UNITS_PER_WORD 4
+#endif
#define POINTER_SIZE 64
#define PARM_BOUNDARY 64
#define FUNCTION_BOUNDARY 32
#define BIGGEST_ALIGNMENT 64
#define EMPTY_FIELD_BOUNDARY 32
-#define MAX_FIXED_MODE_SIZE 64
+#define MAX_FIXED_MODE_SIZE 128
#define MAX_REGS_PER_ADDRESS 2
#define STACK_SIZE_MODE DImode
#define Pmode DImode
--- /dev/null
+/* Copyright (C) 2021 Free Software Foundation, Inc.
+
+This file is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 3, or (at your option) any
+later version.
+
+This file is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+<http://www.gnu.org/licenses/>. */
+
+#include "lib2-gcn.h"
+
+UTItype
+__bswapti2 (UTItype x)
+{
+ UDItype lo, hi, outlo, outhi;
+ lo = (UDItype) x;
+ hi = (UDItype) (x >> 64);
+ outhi = (lo >> 56) & 0xff;
+ outhi |= ((lo >> 48) & 0xff) << 8;
+ outhi |= ((lo >> 40) & 0xff) << 16;
+ outhi |= ((lo >> 32) & 0xff) << 24;
+ outhi |= ((lo >> 24) & 0xff) << 32;
+ outhi |= ((lo >> 16) & 0xff) << 40;
+ outhi |= ((lo >> 8) & 0xff) << 48;
+ outhi |= (lo & 0xff) << 56;
+ outlo = (hi >> 56) & 0xff;
+ outlo |= ((hi >> 48) & 0xff) << 8;
+ outlo |= ((hi >> 40) & 0xff) << 16;
+ outlo |= ((hi >> 32) & 0xff) << 24;
+ outlo |= ((hi >> 24) & 0xff) << 32;
+ outlo |= ((hi >> 16) & 0xff) << 40;
+ outlo |= ((hi >> 8) & 0xff) << 48;
+ outlo |= (hi & 0xff) << 56;
+ return ((UTItype) outhi << 64) | outlo;
+}
--- /dev/null
+/* Copyright (C) 2021 Free Software Foundation, Inc.
+ Contributed by Mentor Graphics, Inc.
+
+This file is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 3, or (at your option) any
+later version.
+
+This file is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+<http://www.gnu.org/licenses/>. */
+
+#include "lib2-gcn.h"
+
+/* We really want DImode here: override LIBGCC2_UNITS_PER_WORD. */
+#define LIBGCC2_UNITS_PER_WORD 4
+#define TARGET_HAS_NO_HW_DIVIDE
+
+#define L_divmoddi4
+#define L_divdi3
+#define L_moddi3
+#define L_udivdi3
+#define L_umoddi3
+
+#include "libgcc2.c"
typedef unsigned short UHItype __attribute__ ((mode (HI)));
typedef int SItype __attribute__ ((mode (SI)));
typedef unsigned int USItype __attribute__ ((mode (SI)));
+typedef int DItype __attribute__ ((mode (DI)));
+typedef unsigned int UDItype __attribute__ ((mode (DI)));
+typedef int TItype __attribute__ ((mode (TI)));
+typedef unsigned int UTItype __attribute__ ((mode (TI)));
typedef int word_type __attribute__ ((mode (__word__)));
/* Exported functions. */
+extern DItype __divdi3 (DItype, DItype);
+extern DItype __moddi3 (DItype, DItype);
+extern UDItype __udivdi3 (UDItype, UDItype);
+extern UDItype __umoddi3 (UDItype, UDItype);
extern SItype __divsi3 (SItype, SItype);
extern SItype __modsi3 (SItype, SItype);
extern USItype __udivsi3 (USItype, USItype);
LIB2ADD += $(srcdir)/config/gcn/atomic.c \
$(srcdir)/config/gcn/lib2-divmod.c \
$(srcdir)/config/gcn/lib2-divmod-hi.c \
+ $(srcdir)/config/gcn/lib2-divmod-di.c \
+ $(srcdir)/config/gcn/lib2-bswapti2.c \
$(srcdir)/config/gcn/unwind-gcn.c
LIB2ADDEH=