This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH, rs6000] Allow libitm to use HTM on newer hw and kernels


On 12/12/18 2:52 PM, Segher Boessenkool wrote:
>> +/* This is a fairly new feature bit, so handle it not being defined.  */
>> +#ifndef PPC_FEATURE2_HTM_NO_SUSPEND
>> +# define PPC_FEATURE2_HTM_NO_SUSPEND 0
>> +#endif
> 
> Doing it this way can be pretty surprising for users not aware you defined
> it to 0.  Since there are no other users yet it's no big deal.

Would you instead prefer something along the lines of the following?

Peter


 static inline bool
 htm_available (void)
 {
-  return (getauxval (AT_HWCAP2) & PPC_FEATURE2_HAS_HTM) ? true : false;
+#ifdef __BUILTIN_CPU_SUPPORTS__
+  if (__builtin_cpu_supports ("htm-no-suspend")
+      || __builtin_cpu_supports ("htm"))
+    return true;
+#else
+#ifdef PPC_FEATURE2_HTM_NO_SUSPEND
+  unsigned long htm_flags = PPC_FEATURE2_HAS_HTM | PPC_FEATURE2_HTM_NO_SUSPEND;
+#else
+  unsigned long htm_flags = PPC_FEATURE2_HAS_HTM;
+#endif
+  if (getauxval (AT_HWCAP2) & htm_flags)
+    return true;
+#endif
+  return false;
 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]