Re: [PATCH v6 06/13] ARC: hardware floating point support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 5/29/20 3:28 PM, Vineet Gupta via Libc-alpha wrote:
>>> +/* Macros for accessing the hardware control word.  */
>>> +#  define _FPU_GETCW(cw) __asm__ volatile ("lr %0, [0x300]" : "=r" (cw))
>>> +#  define _FPU_SETCW(cw) __asm__ volatile ("sr %0, [0x300]" : : "r" (cw))
>>> +
>>> +/*  Macros for accessing the hardware status word.
>>> +    FWE bit is special as it controls if actual status bits could be wrritten
>>> +    explicitly (other than FPU instructions). We handle it here to keep the
>>> +    callers agnostic of it:
>>> +      - clear it out when reporting status bits
>>> +      - always set it when changing status bits.  */
>>> +#  define _FPU_GETS(cw)				\
>>> +    __asm__ volatile ("lr   %0, [0x301]	\r\n" 	\
>>> +                      "bclr %0, %0, 31	\r\n" 	\
>>> +                      : "=r" (cw))
>>> +
>>> +#  define _FPU_SETS(cw)				\
>>> +    do {					\
>>> +      unsigned int __tmp = 0x80000000 | (cw);	\
>>> +      __asm__ volatile ("sr  %0, [0x301] \r\n" 	\
>>> +                        : : "r" (__tmp));	\
>>> +    } while (0)
>>> +
>> Although this code follow other architectures, I think it woudl be better
>> to move forward a macro that emulates function calls and use proper
>> static inline function instead for _FPU_* (as for get-rounding-mode.h).
> OK. do you have a preference for names, existing upper case names OK ?

Something like below ?

+# define _FPU_FPSR_FWE		0x80000000
+
-#  define _FPU_GETCW(cw) __asm__ volatile ("lr %0, [0x300]" : "=r" (cw))
-#  define _FPU_SETCW(cw) __asm__ volatile ("sr %0, [0x300]" : : "r" (cw))
+static inline unsigned int arc_fpu_getcw(void)
+{
+  unsigned int cw;
+  __asm__ volatile ("lr %0, [0x300]" : "=r" (cw));
+  return cw;
+}
+
+static inline void arc_fpu_setcw(unsigned int cw)
+{
+  __asm__ volatile ("sr %0, [0x300]" : : "r" (cw));
+}

 /*  Macros for accessing the hardware status word.
     FWE bit is special as it controls if actual status bits could be wrritten
     explicitly (other than FPU instructions). We handle it here to keep the
     callers agnostic of it:
       - clear it out when reporting status bits
-      - always set it when changing status bits.  */
-#  define _FPU_GETS(cw)				\
-    __asm__ volatile ("lr   %0, [0x301]	\r\n" 	\
-                      "bclr %0, %0, 31	\r\n" 	\
-                      : "=r" (cw))
-
-#  define _FPU_SETS(cw)				\
-    do {					\
-      unsigned int __tmp = 0x80000000 | (cw);	\
-      __asm__ volatile ("sr  %0, [0x301] \r\n" 	\
-                        : : "r" (__tmp));	\
-    } while (0)
+      - set it when intending to change status bits.  */
+static inline unsigned int arc_fpu_getsw(void)
+{
+  unsigned int sw;
+  __asm__ volatile ("lr %0, [0x301]" : "=r" (sw));
+  sw &= ~_FPU_FPSR_FWE;
+  return sw;
+}
+
+static inline void arc_fpu_setsw(unsigned int sw)
+{
+  sw |= _FPU_FPSR_FWE;
+  __asm__ volatile ("sr %0, [0x301]" : : "r" (sw));
+}
+
+# define _FPU_GETCW arc_fpu_getcw
+# define _FPU_SETCW arc_fpu_setcw
+# define _FPU_GETS  arc_fpu_getsw
+# define _FPU_SETS  arc_fpu_setsw

_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/linux-snps-arc



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux