public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [trans-mem] PR 68964 fallout -- bootstrap 69343+69339
@ 2016-01-20 19:02 Richard Henderson
  0 siblings, 0 replies; only message in thread
From: Richard Henderson @ 2016-01-20 19:02 UTC (permalink / raw)
  To: GCC Patches; +Cc: Jakub Jelinek

[-- Attachment #1: Type: text/plain, Size: 797 bytes --]

These two bootstrap PRs, caused by old binutils on s390x and embedded powerpc
that doesn't support altivec, could have been worked around with yet more
configure checks.

But after discussion on IRC, we decided that to revert the arm+ppc+s390 changes
entirely and keep the libitm ABI the same.  Instead of calling new functions
with vector parameters (which internally wound up calling memcpy), we will
instead let the compiler call memcpy directly.  This solves all of the
platform-specific configury wrt when vector instructions are available and
avoids a bit of indirection in the end.

The portion of the patch for 68964 that *isn't* reverted by this does solve the
original ICE by deferring otherwise unhandled types to memcpy.

(Re-)tested on x86_64, s390x, and aarch64, and committed.


r~

[-- Attachment #2: z --]
[-- Type: text/plain, Size: 11338 bytes --]

	PR bootstrap/69343
	PR bootstrap/69339
	PR tree-opt/68964

	Revert:
gcc/
	* tree.c (tm_define_builtin): New.
	(find_tm_vector_type): New.
	(build_tm_vector_builtins): New.
	(build_common_builtin_nodes): Call it.
libitm/
	* Makefile.am (libitm_la_SOURCES) [ARCH_AARCH64]: Add vect128.cc
	(libitm_la_SOURCES) [ARCH_ARM]: Add neon.cc
	(libitm_la_SOURCES) [ARCH_PPC]: Add vect128.cc
	(libitm_la_SOURCES) [ARCH_S390]: Add vect128.cc
	* configure.ac (ARCH_AARCH64): New conditional.
	(ARCH_PPC, ARCH_S390): Likewise.
	* Makefile.in, configure: Rebuild.
	* libitm.h (_ITM_TYPE_M128): Always define.
	* vect64.cc: Split ...
	* vect128.cc: ... out of...
	* config/x86/x86_sse.cc: ... here.
	* config/arm/neon.cc: New file.

 
diff --git a/gcc/tree.c b/gcc/tree.c
index 4e54a7e..8fef0d1 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -10332,143 +10332,6 @@ local_define_builtin (const char *name, tree type, enum built_in_function code,
   set_builtin_decl (code, decl, true);
 }
 
-/* A subroutine of build_tm_vector_builtins.  Define a builtin with
-   all of the appropriate attributes.  */
-static void
-tm_define_builtin (const char *name, tree type, built_in_function code,
-		   tree decl_attrs, tree type_attrs)
-{
-  tree decl = add_builtin_function (name, type, code, BUILT_IN_NORMAL,
-			            name + strlen ("__builtin_"), decl_attrs);
-  decl_attributes (&TREE_TYPE (decl), type_attrs, ATTR_FLAG_BUILT_IN);
-  set_builtin_decl (code, decl, true);
-}
-
-/* A subroutine of build_tm_vector_builtins.  Find a supported vector
-   type VECTOR_BITS wide with inner mode ELEM_MODE.  */
-static tree
-find_tm_vector_type (unsigned vector_bits, machine_mode elem_mode)
-{
-  unsigned elem_bits = GET_MODE_BITSIZE (elem_mode);
-  unsigned nunits = vector_bits / elem_bits;
-
-  gcc_assert (elem_bits * nunits == vector_bits);
-
-  machine_mode vector_mode = mode_for_vector (elem_mode, nunits);
-  if (!VECTOR_MODE_P (vector_mode)
-      || !targetm.vector_mode_supported_p (vector_mode))
-    return NULL_TREE;
-
-  tree innertype = lang_hooks.types.type_for_mode (elem_mode, 0);
-  return build_vector_type_for_mode (innertype, vector_mode);
-}
-
-/* A subroutine of build_common_builtin_nodes.  Define TM builtins for
-   vector types.  This is done after the target hook, so that the target
-   has a chance to override these.  */
-static void
-build_tm_vector_builtins (void)
-{
-  tree vtype, pvtype, ftype, decl;
-  tree attrs_load, attrs_type_load;
-  tree attrs_store, attrs_type_store;
-  tree attrs_log, attrs_type_log;
-
-  /* Do nothing if TM is turned off, either with switch or
-     not enabled in the language.  */
-  if (!flag_tm || !builtin_decl_explicit_p (BUILT_IN_TM_LOAD_1))
-    return;
-
-  /* Use whatever attributes a normal TM load has.  */
-  decl = builtin_decl_explicit (BUILT_IN_TM_LOAD_1);
-  attrs_load = DECL_ATTRIBUTES (decl);
-  attrs_type_load = TYPE_ATTRIBUTES (TREE_TYPE (decl));
-  /* Use whatever attributes a normal TM store has.  */
-  decl = builtin_decl_explicit (BUILT_IN_TM_STORE_1);
-  attrs_store = DECL_ATTRIBUTES (decl);
-  attrs_type_store = TYPE_ATTRIBUTES (TREE_TYPE (decl));
-  /* Use whatever attributes a normal TM log has.  */
-  decl = builtin_decl_explicit (BUILT_IN_TM_LOG);
-  attrs_log = DECL_ATTRIBUTES (decl);
-  attrs_type_log = TYPE_ATTRIBUTES (TREE_TYPE (decl));
-
-  /* By default, 64 bit vectors go through the long long helpers.  */
-
-  /* If a 128-bit vector is supported, declare those builtins.  */
-  if (!builtin_decl_explicit_p (BUILT_IN_TM_STORE_M128)
-      && ((vtype = find_tm_vector_type (128, SImode))
-	  || (vtype = find_tm_vector_type (128, SFmode))))
-    {
-      pvtype = build_pointer_type (vtype);
-
-      ftype = build_function_type_list (void_type_node, pvtype, vtype, NULL);
-      tm_define_builtin ("__builtin__ITM_WM128", ftype,
-			 BUILT_IN_TM_STORE_M128,
-			 attrs_store, attrs_type_store);
-      tm_define_builtin ("__builtin__ITM_WaRM128", ftype,
-			 BUILT_IN_TM_STORE_WAR_M128,
-			 attrs_store, attrs_type_store);
-      tm_define_builtin ("__builtin__ITM_WaWM128", ftype,
-			 BUILT_IN_TM_STORE_WAW_M128,
-			 attrs_store, attrs_type_store);
-
-      ftype = build_function_type_list (vtype, pvtype, NULL);
-      tm_define_builtin ("__builtin__ITM_RM128", ftype,
-			 BUILT_IN_TM_LOAD_M128,
-			 attrs_load, attrs_type_load);
-      tm_define_builtin ("__builtin__ITM_RaRM128", ftype,
-			 BUILT_IN_TM_LOAD_RAR_M128,
-			 attrs_load, attrs_type_load);
-      tm_define_builtin ("__builtin__ITM_RaWM128", ftype,
-			 BUILT_IN_TM_LOAD_RAW_M128,
-			 attrs_load, attrs_type_load);
-      tm_define_builtin ("__builtin__ITM_RfWM128", ftype,
-			 BUILT_IN_TM_LOAD_RFW_M128,
-			 attrs_load, attrs_type_load);
-
-      ftype = build_function_type_list (void_type_node, pvtype, NULL);
-      tm_define_builtin ("__builtin__ITM_LM128", ftype,
-			 BUILT_IN_TM_LOG_M128, attrs_log, attrs_type_log);
-    }
-
-  /* If a 256-bit vector is supported, declare those builtins.  */
-  if (!builtin_decl_explicit_p (BUILT_IN_TM_STORE_M256)
-      && ((vtype = find_tm_vector_type (256, SImode))
-	  || (vtype = find_tm_vector_type (256, SFmode))))
-    {
-      pvtype = build_pointer_type (vtype);
-
-      ftype = build_function_type_list (void_type_node, pvtype, vtype, NULL);
-      tm_define_builtin ("__builtin__ITM_WM256", ftype,
-			 BUILT_IN_TM_STORE_M256,
-			 attrs_store, attrs_type_store);
-      tm_define_builtin ("__builtin__ITM_WaRM256", ftype,
-			 BUILT_IN_TM_STORE_WAR_M256,
-			 attrs_store, attrs_type_store);
-      tm_define_builtin ("__builtin__ITM_WaWM256", ftype,
-			 BUILT_IN_TM_STORE_WAW_M256,
-			 attrs_store, attrs_type_store);
-
-      ftype = build_function_type_list (vtype, pvtype, NULL);
-      tm_define_builtin ("__builtin__ITM_RM256", ftype,
-			 BUILT_IN_TM_LOAD_M256,
-			 attrs_load, attrs_type_load);
-      tm_define_builtin ("__builtin__ITM_RaRM256", ftype,
-			 BUILT_IN_TM_LOAD_RAR_M256,
-			 attrs_load, attrs_type_load);
-      tm_define_builtin ("__builtin__ITM_RaWM256", ftype,
-			 BUILT_IN_TM_LOAD_RAW_M256,
-			 attrs_load, attrs_type_load);
-      tm_define_builtin ("__builtin__ITM_RfWM256", ftype,
-			 BUILT_IN_TM_LOAD_RFW_M256,
-			 attrs_load, attrs_type_load);
-
-      ftype = build_function_type_list (void_type_node, pvtype, NULL);
-      tm_define_builtin ("__builtin__ITM_LM256", ftype,
-			 BUILT_IN_TM_LOG_M256, attrs_log, attrs_type_log);
-    }
-}
-
 /* Call this function after instantiating all builtins that the language
    front end cares about.  This will build the rest of the builtins
    and internal functions that are relied upon by the tree optimizers and
@@ -10707,7 +10570,6 @@ build_common_builtin_nodes (void)
       }
   }
 
-  build_tm_vector_builtins ();
   init_internal_fns ();
 }
 
diff --git a/libitm/Makefile.am b/libitm/Makefile.am
index 6e1438d..1dce82d 100644
--- a/libitm/Makefile.am
+++ b/libitm/Makefile.am
@@ -62,26 +62,16 @@ libitm_la_SOURCES = \
 	query.cc retry.cc rwlock.cc useraction.cc util.cc \
 	sjlj.S tls.cc method-serial.cc method-gl.cc method-ml.cc
 
-if ARCH_AARCH64
-libitm_la_SOURCES += vect128.cc
-endif
 if ARCH_ARM
-libitm_la_SOURCES += hwcap.cc neon.cc
-endif
-if ARCH_PPC
-libitm_la_SOURCES += vect128.cc
-vect128.lo : override CXXFLAGS += -maltivec
-endif
-if ARCH_S390
-libitm_la_SOURCES += vect128.cc
-vect128.lo : override CXXFLAGS += -march=z13
+libitm_la_SOURCES += hwcap.cc
 endif
 if ARCH_X86
-libitm_la_SOURCES += vect64.cc vect128.cc x86_avx.cc
-vect64.lo : override CXXFLAGS += -msse
-vect128.lo : override CXXFLAGS += -msse
+libitm_la_SOURCES += x86_sse.cc x86_avx.cc
+# Make sure -msse is appended at the end.
+x86_sse.lo : override CXXFLAGS += -msse
 endif
 if ARCH_X86_AVX
+# Make sure -mavx is appended at the end.
 x86_avx.lo : override CXXFLAGS += -mavx
 endif
 
diff --git a/libitm/config/arm/neon.cc b/libitm/config/arm/neon.cc
deleted file mode 100644
index a9c3074..0000000
--- a/libitm/config/arm/neon.cc
+++ /dev/null
@@ -1,3 +0,0 @@
-#ifdef __ARM_NEON
-#include <vect128.cc>
-#endif
diff --git a/libitm/vect128.cc b/libitm/config/x86/x86_sse.cc
similarity index 90%
rename from libitm/vect128.cc
rename to libitm/config/x86/x86_sse.cc
index 18453ac..c3b7237 100644
--- a/libitm/vect128.cc
+++ b/libitm/config/x86/x86_sse.cc
@@ -27,9 +27,16 @@
 
 // ??? Use memcpy for now, until we have figured out how to best instantiate
 // these loads/stores.
+CREATE_DISPATCH_FUNCTIONS_T_MEMCPY(M64, GTM::abi_disp()->, )
 CREATE_DISPATCH_FUNCTIONS_T_MEMCPY(M128, GTM::abi_disp()->, )
 
 void ITM_REGPARM
+_ITM_LM64 (const _ITM_TYPE_M64 *ptr)
+{
+  GTM::GTM_LB (ptr, sizeof (*ptr));
+}
+
+void ITM_REGPARM
 _ITM_LM128 (const _ITM_TYPE_M128 *ptr)
 {
   GTM::GTM_LB (ptr, sizeof (*ptr));
diff --git a/libitm/configure.ac b/libitm/configure.ac
index 36e0651..3875aa0 100644
--- a/libitm/configure.ac
+++ b/libitm/configure.ac
@@ -281,10 +281,7 @@ else
 fi
 AC_SUBST(link_itm)
 
-AM_CONDITIONAL([ARCH_AARCH64], [test "$ARCH" = aarch64])
 AM_CONDITIONAL([ARCH_ARM], [test "$ARCH" = arm])
-AM_CONDITIONAL([ARCH_PPC], [test "$ARCH" = powerpc -o "$ARCH" = powerpc64])
-AM_CONDITIONAL([ARCH_S390], [test "$ARCH" = s390 -o "$ARCH" = s390x])
 AM_CONDITIONAL([ARCH_X86], [test "$ARCH" = x86])
 AM_CONDITIONAL([ARCH_X86_AVX], [test "$libitm_cv_as_avx" = yes])
 AM_CONDITIONAL([ARCH_FUTEX], [test $enable_linux_futex = yes])
diff --git a/libitm/libitm.h b/libitm/libitm.h
index 1a6738b..d7bc166 100644
--- a/libitm/libitm.h
+++ b/libitm/libitm.h
@@ -232,11 +232,7 @@ ITM_LOG(CE)
   ITM_BARRIERS(M256)
   ITM_LOG(M256)
 # endif
-#else
-  typedef int _ITM_TYPE_M128 __attribute__((vector_size(16), may_alias));
-  ITM_BARRIERS(M128)
-  ITM_LOG(M128)
-#endif
+#endif /* i386 */
 
 #undef ITM_BARRIERS
 #undef ITM_LOG
diff --git a/libitm/vect64.cc b/libitm/vect64.cc
deleted file mode 100644
index c451c58..0000000
--- a/libitm/vect64.cc
+++ /dev/null
@@ -1,36 +0,0 @@
-/* Copyright (C) 2009-2016 Free Software Foundation, Inc.
-   Contributed by Richard Henderson <rth@redhat.com>.
-
-   This file is part of the GNU Transactional Memory Library (libitm).
-
-   Libitm 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 of the License, or
-   (at your option) any later version.
-
-   Libitm 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 "libitm_i.h"
-#include "dispatch.h"
-
-// ??? Use memcpy for now, until we have figured out how to best instantiate
-// these loads/stores.
-CREATE_DISPATCH_FUNCTIONS_T_MEMCPY(M64, GTM::abi_disp()->, )
-
-void ITM_REGPARM
-_ITM_LM64 (const _ITM_TYPE_M64 *ptr)
-{
-  GTM::GTM_LB (ptr, sizeof (*ptr));
-}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-01-20 19:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-20 19:02 [trans-mem] PR 68964 fallout -- bootstrap 69343+69339 Richard Henderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).