[libc-commits] [PATCH] D152024: [libc][NFC] Add LIBC_INLINE and attribute.h header includes to targets' FMA.h.

Tue Ly via Phabricator via libc-commits libc-commits at lists.llvm.org
Fri Jun 2 13:14:55 PDT 2023


lntue created this revision.
lntue added reviewers: michaelrj, sivachandra.
Herald added subscribers: luke, frasercrmck, luismarques, apazos, sameer.abuasal, tschuett, s.egerton, Jim, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, johnrusso, rbar, asb.
Herald added projects: libc-project, All.
lntue requested review of this revision.
Herald added a subscriber: pcwang-thead.

Targets' FMA.h headers are missing LIBC_INLINE and attributes.h header.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152024

Files:
  libc/src/__support/FPUtil/aarch64/FMA.h
  libc/src/__support/FPUtil/riscv64/FMA.h
  libc/src/__support/FPUtil/x86_64/FMA.h


Index: libc/src/__support/FPUtil/x86_64/FMA.h
===================================================================
--- libc/src/__support/FPUtil/x86_64/FMA.h
+++ libc/src/__support/FPUtil/x86_64/FMA.h
@@ -9,6 +9,7 @@
 #ifndef LLVM_LIBC_SRC_SUPPORT_FPUTIL_X86_64_FMA_H
 #define LLVM_LIBC_SRC_SUPPORT_FPUTIL_X86_64_FMA_H
 
+#include "src/__support/macros/attributes.h" // LIBC_INLINE
 #include "src/__support/macros/properties/architectures.h"
 #include "src/__support/macros/properties/cpu_features.h" // LIBC_TARGET_CPU_HAS_FMA
 
Index: libc/src/__support/FPUtil/riscv64/FMA.h
===================================================================
--- libc/src/__support/FPUtil/riscv64/FMA.h
+++ libc/src/__support/FPUtil/riscv64/FMA.h
@@ -9,6 +9,7 @@
 #ifndef LLVM_LIBC_SRC_SUPPORT_FPUTIL_RISCV64_FMA_H
 #define LLVM_LIBC_SRC_SUPPORT_FPUTIL_RISCV64_FMA_H
 
+#include "src/__support/macros/attributes.h" // LIBC_INLINE
 #include "src/__support/macros/properties/architectures.h"
 #include "src/__support/macros/properties/cpu_features.h" // LIBC_TARGET_CPU_HAS_FMA
 
@@ -26,20 +27,20 @@
 namespace fputil {
 
 template <typename T>
-cpp::enable_if_t<cpp::is_same_v<T, float>, T> fma(T x, T y, T z) {
+LIBC_INLINE cpp::enable_if_t<cpp::is_same_v<T, float>, T> fma(T x, T y, T z) {
   float result;
-  __asm__ __volatile__("fmadd.s %0, %1, %2, %3\n\t"
-                       : "=f"(result)
-                       : "f"(x), "f"(y), "f"(z));
+  LIBC_INLINE_ASM("fmadd.s %0, %1, %2, %3\n\t"
+                  : "=f"(result)
+                  : "f"(x), "f"(y), "f"(z));
   return result;
 }
 
 template <typename T>
-cpp::enable_if_t<cpp::is_same_v<T, double>, T> fma(T x, T y, T z) {
+LIBC_INLINE cpp::enable_if_t<cpp::is_same_v<T, double>, T> fma(T x, T y, T z) {
   double result;
-  __asm__ __volatile__("fmadd.d %0, %1, %2, %3\n\t"
-                       : "=f"(result)
-                       : "f"(x), "f"(y), "f"(z));
+  LIBC_INLINE_ASM("fmadd.d %0, %1, %2, %3\n\t"
+                  : "=f"(result)
+                  : "f"(x), "f"(y), "f"(z));
   return result;
 }
 
Index: libc/src/__support/FPUtil/aarch64/FMA.h
===================================================================
--- libc/src/__support/FPUtil/aarch64/FMA.h
+++ libc/src/__support/FPUtil/aarch64/FMA.h
@@ -9,6 +9,7 @@
 #ifndef LLVM_LIBC_SRC_SUPPORT_FPUTIL_AARCH64_FMA_H
 #define LLVM_LIBC_SRC_SUPPORT_FPUTIL_AARCH64_FMA_H
 
+#include "src/__support/macros/attributes.h" // LIBC_INLINE
 #include "src/__support/macros/properties/architectures.h"
 #include "src/__support/macros/properties/cpu_features.h" // LIBC_TARGET_CPU_HAS_FMA
 
@@ -26,20 +27,20 @@
 namespace fputil {
 
 template <typename T>
-cpp::enable_if_t<cpp::is_same_v<T, float>, T> fma(T x, T y, T z) {
+LIBC_INLINE cpp::enable_if_t<cpp::is_same_v<T, float>, T> fma(T x, T y, T z) {
   float result;
-  __asm__ __volatile__("fmadd %s0, %s1, %s2, %s3\n\t"
-                       : "=w"(result)
-                       : "w"(x), "w"(y), "w"(z));
+  LIBC_INLINE_ASM("fmadd %s0, %s1, %s2, %s3\n\t"
+                  : "=w"(result)
+                  : "w"(x), "w"(y), "w"(z));
   return result;
 }
 
 template <typename T>
-cpp::enable_if_t<cpp::is_same_v<T, double>, T> fma(T x, T y, T z) {
+LIBC_INLINE cpp::enable_if_t<cpp::is_same_v<T, double>, T> fma(T x, T y, T z) {
   double result;
-  __asm__ __volatile__("fmadd %d0, %d1, %d2, %d3\n\t"
-                       : "=w"(result)
-                       : "w"(x), "w"(y), "w"(z));
+  LIBC_INLINE_ASM("fmadd %d0, %d1, %d2, %d3\n\t"
+                  : "=w"(result)
+                  : "w"(x), "w"(y), "w"(z));
   return result;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152024.527940.patch
Type: text/x-patch
Size: 3623 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230602/ae1054be/attachment-0001.bin>


More information about the libc-commits mailing list