]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
s390.c: (s390_expand_builtin): Allow -mhtm to be enabled without -march=zEC12.
authorAndreas Krebbel <Andreas.Krebbel@de.ibm.com>
Wed, 17 Jul 2013 11:15:24 +0000 (11:15 +0000)
committerAndreas Krebbel <krebbel@gcc.gnu.org>
Wed, 17 Jul 2013 11:15:24 +0000 (11:15 +0000)
2013-07-17  Andreas Krebbel  <Andreas.Krebbel@de.ibm.com>

* config/s390/s390.c: (s390_expand_builtin): Allow -mhtm to be
enabled without -march=zEC12.
* config/s390/s390.h (TARGET_HTM): Do not require EC12 machine
flags to be set.

2013-07-17  Andreas Krebbel  <Andreas.Krebbel@de.ibm.com>

* acinclude.m4: Add htm asm check for s390.
* configure.tgt: Add -mhtm and -Wa,-march=zEC12 to the options.
* configure: Regenerate.
* config/s390/target.h: Remove __HTM__ check.
(htm_available): Call getauxval to get hwcaps and check whether
HTM is available or not.

From-SVN: r201004

gcc/ChangeLog
gcc/config/s390/s390.c
gcc/config/s390/s390.h
libitm/ChangeLog
libitm/acinclude.m4
libitm/config/s390/target.h
libitm/configure
libitm/configure.tgt

index b4f628753b4d60304c34349c3048007d2dfcaac5..60c176da0a9f5f9f443a466aab5105c9064dd21c 100644 (file)
@@ -1,3 +1,10 @@
+2013-07-17  Andreas Krebbel  <Andreas.Krebbel@de.ibm.com>
+
+       * config/s390/s390.c: (s390_expand_builtin): Allow -mhtm to be
+       enabled without -march=zEC12.
+       * config/s390/s390.h (TARGET_HTM): Do not require EC12 machine
+       flags to be set.
+
 2013-07-16  Maciej W. Rozycki  <macro@codesourcery.com>
 
        * config/mips/mips.h (ISA_HAS_FP4): Correct formatting.
index 7ce0c30c8838e06e404d01e8dd67d9bdb18aa946..ab4cc8bb269e0f112bab14dfa6087ba97b0dfeee 100644 (file)
@@ -9771,11 +9771,8 @@ s390_expand_builtin (tree exp, rtx target, rtx subtarget ATTRIBUTE_UNUSED,
   if (icode == 0)
     internal_error ("bad builtin fcode");
 
-  if (!TARGET_ZEC12)
-    error ("Transactional execution builtins require zEC12 or later\n");
-
-  if (!TARGET_HTM && TARGET_ZEC12)
-    error ("Transactional execution builtins not enabled (-mtx)\n");
+  if (!TARGET_HTM)
+    error ("Transactional execution builtins not enabled (-mhtm)\n");
 
   /* Set a flag in the machine specific cfun part in order to support
      saving/restoring of FPRs.  */
index d53fed7a6f2ee6b5e0b1972bebc5f549cba7c5c5..bca18fe36f59253bdede497274e1a5898990a42b 100644 (file)
@@ -81,8 +81,7 @@ enum processor_flags
        (TARGET_ZARCH && TARGET_CPU_Z196)
 #define TARGET_ZEC12 \
        (TARGET_ZARCH && TARGET_CPU_ZEC12)
-#define TARGET_HTM \
-       (TARGET_ZARCH && TARGET_CPU_HTM && TARGET_OPT_HTM)
+#define TARGET_HTM (TARGET_OPT_HTM)
 
 
 #define TARGET_AVOID_CMP_AND_BRANCH (s390_tune == PROCESSOR_2817_Z196)
index 6b8ac0be157de4b47bd603aa5f2f8f15d06c5f14..3e9a70679792aa6d662f1f4518c68c7e65395c48 100644 (file)
@@ -1,3 +1,12 @@
+2013-07-17  Andreas Krebbel  <Andreas.Krebbel@de.ibm.com>
+
+       * acinclude.m4: Add htm asm check for s390.
+       * configure.tgt: Add -mhtm and -Wa,-march=zEC12 to the options.
+       * configure: Regenerate.
+       * config/s390/target.h: Remove __HTM__ check.
+       (htm_available): Call getauxval to get hwcaps and check whether
+       HTM is available or not.
+
 2013-07-15  Peter Bergner  <bergner@vnet.ibm.com>
 
        * acinclude.m4 (LIBITM_CHECK_AS_HTM): New.
index eacf8d4538310c70e3291b948c72619eb7026039..ca7e0a92118029e69e8746d0852e7f91312556a4 100644 (file)
@@ -135,6 +135,17 @@ powerpc*)
     AC_DEFINE(HAVE_AS_HTM, 1, [Define to 1 if the assembler supports HTM.])
   fi
   ;;
+s390*)
+  AC_CACHE_CHECK([if the assembler supports HTM], libitm_cv_as_htm, [
+    save_CFLAGS="$CFLAGS"
+    CFLAGS="$CFLAGS -march=zEC12"
+    AC_TRY_COMPILE([], [asm("tbegin 0,0; tend");],
+                  [libitm_cv_as_htm=yes], [libitm_cv_as_htm=no])
+    CFLAGS="$save_CFLAGS"])
+  if test x$libitm_cv_as_htm = xyes; then
+    AC_DEFINE(HAVE_AS_HTM, 1, [Define to 1 if the assembler supports HTM.])
+  fi
+  ;;
 esac])
 
 sinclude(../libtool.m4)
index 580606f0270a361a00d36be80126cc5d673d7db1..17228f844dd702cacc11534de03eb5207dc4e340 100644 (file)
    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-
-#include <htmintrin.h>
-
-/* Number of retries for transient failures.  */
-#define _HTM_ITM_RETRIES 10
+#ifdef HAVE_SYS_AUXV_H
+#include <sys/auxv.h>
+#endif
 
 namespace GTM HIDDEN {
 
@@ -58,13 +56,24 @@ cpu_relax (void)
   __asm volatile ("" : : : "memory");
 }
 
-#ifdef __HTM__
+
+// Use HTM if it is supported by the system.
+// See gtm_thread::begin_transaction for how these functions are used.
+#if defined (__linux__) \
+    && defined (HAVE_AS_HTM) \
+    && defined (HAVE_GETAUXVAL) \
+    && defined (HWCAP_S390_TE)
+
+#include <htmintrin.h>
+
+/* Number of retries for transient failures.  */
+#define _HTM_ITM_RETRIES 10
 #define USE_HTM_FASTPATH
 
 static inline bool
 htm_available ()
 {
-  return true;
+  return (getauxval (AT_HWCAP) & HWCAP_S390_TE) ? true : false;
 }
 
 static inline uint32_t
index 7b3c0692e8f77d5d4f2e1c16ada32cb6859f7658..21361b031ad65c25818ebc7430f78876359ac483 100644 (file)
 $as_echo "$libitm_cv_as_htm" >&6; }
   if test x$libitm_cv_as_htm = xyes; then
 
+$as_echo "#define HAVE_AS_HTM 1" >>confdefs.h
+
+  fi
+  ;;
+s390*)
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the assembler supports HTM" >&5
+$as_echo_n "checking if the assembler supports HTM... " >&6; }
+if test "${libitm_cv_as_htm+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+    save_CFLAGS="$CFLAGS"
+    CFLAGS="$CFLAGS -march=zEC12"
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+asm("tbegin 0,0; tend");
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  libitm_cv_as_htm=yes
+else
+  libitm_cv_as_htm=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+    CFLAGS="$save_CFLAGS"
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libitm_cv_as_htm" >&5
+$as_echo "$libitm_cv_as_htm" >&6; }
+  if test x$libitm_cv_as_htm = xyes; then
+
 $as_echo "#define HAVE_AS_HTM 1" >>confdefs.h
 
   fi
index d8f3ca52876a15be7f7ac03a4561dedef70a2587..4dc2807cfe52e36f9430c0acd67fd0e78b91ec04 100644 (file)
@@ -109,8 +109,8 @@ case "${target_cpu}" in
        ARCH=x86
        ;;
   s390|s390x)
+       XCFLAGS="${XCFLAGS} -mzarch -mhtm -Wa,-march=zEC12"
        ARCH=s390
-       XCFLAGS="${XCFLAGS} -mzarch"
        ;;
 
   *)