aboutsummaryrefslogtreecommitdiff
path: root/libgcc
diff options
context:
space:
mode:
authorJulian Brown <julian@codesourcery.com>2021-06-09 06:18:23 -0700
committerJulian Brown <julian@codesourcery.com>2021-06-29 08:19:56 -0700
commita8a730cd99184e62c4d026b8c775b96589a9c262 (patch)
treedbdae551485ac2725318d60267b2cb95fccf95e9 /libgcc
parent0c06e46a81d86d70d788ca1a93d27b6902bd4dc1 (diff)
downloadgcc-a8a730cd99184e62c4d026b8c775b96589a9c262.zip
gcc-a8a730cd99184e62c4d026b8c775b96589a9c262.tar.gz
gcc-a8a730cd99184e62c4d026b8c775b96589a9c262.tar.bz2
amdgcn: Enable support for TImode for AMD GCN
This patch enables support for TImode for AMD GCN, the lack of which is currently causing a number of test failures for the target and which is also needed to support "omp_depend_kind" for OpenMP 5.0, since that is implemented as a 128-bit integer. Several libgcc support routines are built by default for the "word size" of a machine, and also for "2 * word size" of the machine. The libgcc build for AMD GCN is changed so that it builds for a "word size" of 64 bits, in order to better match the (64-bit) host compiler. However it isn't really true that we have 64-bit words -- GCN has 32-bit registers, so changing UNITS_PER_WORD unconditionally would be the wrong thing to do. Changing this setting for libgcc (only) means that support routines are built for "single word" operations that are DImode (64 bits), and those for "double word" operations are built for TImode (128 bits). That leaves some gaps regarding previous operations that were built for a "single word" size of 32 bits and a "double word" size of 64 bits (generic code doesn't cover both alternatives for all operations that might be needed). Those gaps are filled in by this patch, or by the preceding patches in the series. 2021-06-18 Julian Brown <julian@codesourcery.com> gcc/ * config/gcn/gcn.c (gcn_init_libfuncs): New function. (TARGET_INIT_LIBFUNCS): Define target hook using above function. * config/gcn/gcn.h (UNITS_PER_WORD): Define to 8 for IN_LIBGCC2, 4 otherwise. (LIBGCC2_UNITS_PER_WORD, BITS_PER_WORD): Remove definitions. (MAX_FIXED_MODE_SIZE): Change to 128. libgcc/ * config/gcn/lib2-bswapti2.c: New file. * config/gcn/lib2-divmod-di.c: New file. * config/gcn/lib2-gcn.h (DItype, UDItype, TItype, UTItype): Add typedefs. (__divdi3, __moddi3, __udivdi3, __umoddi3): Add prototypes. * config/gcn/t-amdgcn (LIB2ADD): Add lib2-divmod-di.c and lib2-bswapti2.c.
Diffstat (limited to 'libgcc')
-rw-r--r--libgcc/config/gcn/lib2-bswapti2.c47
-rw-r--r--libgcc/config/gcn/lib2-divmod-di.c35
-rw-r--r--libgcc/config/gcn/lib2-gcn.h8
-rw-r--r--libgcc/config/gcn/t-amdgcn2
4 files changed, 92 insertions, 0 deletions
diff --git a/libgcc/config/gcn/lib2-bswapti2.c b/libgcc/config/gcn/lib2-bswapti2.c
new file mode 100644
index 0000000..c19b70b
--- /dev/null
+++ b/libgcc/config/gcn/lib2-bswapti2.c
@@ -0,0 +1,47 @@
+/* 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;
+}
diff --git a/libgcc/config/gcn/lib2-divmod-di.c b/libgcc/config/gcn/lib2-divmod-di.c
new file mode 100644
index 0000000..ceb3962
--- /dev/null
+++ b/libgcc/config/gcn/lib2-divmod-di.c
@@ -0,0 +1,35 @@
+/* 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"
diff --git a/libgcc/config/gcn/lib2-gcn.h b/libgcc/config/gcn/lib2-gcn.h
index 9223d73..155cf7c 100644
--- a/libgcc/config/gcn/lib2-gcn.h
+++ b/libgcc/config/gcn/lib2-gcn.h
@@ -33,9 +33,17 @@ typedef short HItype __attribute__ ((mode (HI)));
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);
diff --git a/libgcc/config/gcn/t-amdgcn b/libgcc/config/gcn/t-amdgcn
index fe7b5fa..38bde54 100644
--- a/libgcc/config/gcn/t-amdgcn
+++ b/libgcc/config/gcn/t-amdgcn
@@ -1,6 +1,8 @@
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=