[Bug 1320292] [NEW] ABI incompatibility between POWER and Z HTM builtins and intrinsics

Peter Bergner 1320292 at bugs.launchpad.net
Fri May 16 16:28:48 UTC 2014


Public bug reported:

The IBM XL team defined a set of HTM intrinsic functions that were supposed
to be API compatible across the XL and GCC compilers on both Power and S390.
PR61193 describes an issue where the functions that begin a transaction
are incompatible.  The Power intrinsics return non-zero on success, while
the S390 intrinsics return zero on success.

After discussing this with the XL compiler team, the S390 GCC team and
the Power GCC team, we have decided to leave the incompatibility between
Power and S390.  However, the XL and GCC compilers will be compatible
with each other when targeting the same processor target.  To mitigate
the incompatibility somewhat, we have decided to add a macro to the
powerpc*-linux's htmintrin.h file that defines what the "successful"
return status value of the __TM_simple_begin() and __TM_begin() intrinsic
function is.  This macro is already defined in the S390's htmintrin.h
header file and is used by the S390 to determine whether the transaction
was successfully started or not.  By adding the same macro on Power, we
allow users to write common code between Power and S390, even though our
successful return status values are different.

For example, the following code can be used on Power and S390, even
though the actual value returned by __TM_simple_begin() is different.

  if ((tx_state = __TM_simple_begin ()) == _HTM_TBEGIN_STARTED)
    {
      /* Transaction State Initiated.  */
      ...
    }
  else
    {
      /* Transaction State Failed.  */
      ...
    }

David approved this offline, so I'm committing this to GCC mainline as
revision 210486, as well as the 4.9 (210487) and 4.8 (210488) branches.

Peter

	PR target/61193
	* config/rs6000/htmxlintrin.h (_HTM_TBEGIN_STARTED): New define.
	(__TM_simple_begin): Use it.
	(__TM_begin): Likewise.

Index: gcc/config/rs6000/htmxlintrin.h
===================================================================
--- gcc/config/rs6000/htmxlintrin.h	(revision 210485)
+++ gcc/config/rs6000/htmxlintrin.h	(working copy)
@@ -46,12 +46,17 @@ extern "C" {

 typedef char TM_buff_type[16];

+/* Compatibility macro with s390.  This macro can be used to determine
+   whether a transaction was successfully started from the __TM_begin()
+   and __TM_simple_begin() intrinsic functions below.  */
+#define _HTM_TBEGIN_STARTED     1
+
 extern __inline long
 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
 __TM_simple_begin (void)
 {
   if (__builtin_expect (__builtin_tbegin (0), 1))
-    return 1;
+    return _HTM_TBEGIN_STARTED;
   return 0;
 }

@@ -61,7 +66,7 @@ __TM_begin (void* const TM_buff)
 {
   *_TEXASRL_PTR (TM_buff) = 0;
   if (__builtin_expect (__builtin_tbegin (0), 1))
-    return 1;
+    return _HTM_TBEGIN_STARTED;
 #ifdef __powerpc64__
   *_TEXASR_PTR (TM_buff) = __builtin_get_texasr ();
 #else

** Affects: gcc-defaults (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: api

** Patch added: "Patch to mitigate API incompatibility between Power and S390"
   https://bugs.launchpad.net/bugs/1320292/+attachment/4113990/+files/gcc-fsf-mainline-htm-compat.diff

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to gcc-defaults in Ubuntu.
https://bugs.launchpad.net/bugs/1320292

Title:
  ABI incompatibility between POWER and Z HTM builtins and intrinsics

Status in “gcc-defaults” package in Ubuntu:
  New

Bug description:
  The IBM XL team defined a set of HTM intrinsic functions that were supposed
  to be API compatible across the XL and GCC compilers on both Power and S390.
  PR61193 describes an issue where the functions that begin a transaction
  are incompatible.  The Power intrinsics return non-zero on success, while
  the S390 intrinsics return zero on success.

  After discussing this with the XL compiler team, the S390 GCC team and
  the Power GCC team, we have decided to leave the incompatibility between
  Power and S390.  However, the XL and GCC compilers will be compatible
  with each other when targeting the same processor target.  To mitigate
  the incompatibility somewhat, we have decided to add a macro to the
  powerpc*-linux's htmintrin.h file that defines what the "successful"
  return status value of the __TM_simple_begin() and __TM_begin() intrinsic
  function is.  This macro is already defined in the S390's htmintrin.h
  header file and is used by the S390 to determine whether the transaction
  was successfully started or not.  By adding the same macro on Power, we
  allow users to write common code between Power and S390, even though our
  successful return status values are different.

  For example, the following code can be used on Power and S390, even
  though the actual value returned by __TM_simple_begin() is different.

    if ((tx_state = __TM_simple_begin ()) == _HTM_TBEGIN_STARTED)
      {
        /* Transaction State Initiated.  */
        ...
      }
    else
      {
        /* Transaction State Failed.  */
        ...
      }

  David approved this offline, so I'm committing this to GCC mainline as
  revision 210486, as well as the 4.9 (210487) and 4.8 (210488)
  branches.

  Peter

  	PR target/61193
  	* config/rs6000/htmxlintrin.h (_HTM_TBEGIN_STARTED): New define.
  	(__TM_simple_begin): Use it.
  	(__TM_begin): Likewise.

  Index: gcc/config/rs6000/htmxlintrin.h
  ===================================================================
  --- gcc/config/rs6000/htmxlintrin.h	(revision 210485)
  +++ gcc/config/rs6000/htmxlintrin.h	(working copy)
  @@ -46,12 +46,17 @@ extern "C" {

   typedef char TM_buff_type[16];

  +/* Compatibility macro with s390.  This macro can be used to determine
  +   whether a transaction was successfully started from the __TM_begin()
  +   and __TM_simple_begin() intrinsic functions below.  */
  +#define _HTM_TBEGIN_STARTED     1
  +
   extern __inline long
   __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
   __TM_simple_begin (void)
   {
     if (__builtin_expect (__builtin_tbegin (0), 1))
  -    return 1;
  +    return _HTM_TBEGIN_STARTED;
     return 0;
   }

  @@ -61,7 +66,7 @@ __TM_begin (void* const TM_buff)
   {
     *_TEXASRL_PTR (TM_buff) = 0;
     if (__builtin_expect (__builtin_tbegin (0), 1))
  -    return 1;
  +    return _HTM_TBEGIN_STARTED;
   #ifdef __powerpc64__
     *_TEXASR_PTR (TM_buff) = __builtin_get_texasr ();
   #else

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gcc-defaults/+bug/1320292/+subscriptions



More information about the foundations-bugs mailing list