From 5a4e344bd9ec3a9e01f5aee0c5bc8bde1586cfa3 Mon Sep 17 00:00:00 2001 From: Tue Ly Date: Fri, 2 Jun 2023 16:13:19 -0400 Subject: [PATCH] [libc][NFC] Add LIBC_INLINE and attribute.h header includes to targets' FMA.h. Targets' FMA.h headers are missing LIBC_INLINE and attributes.h header. Reviewed By: brooksmoses Differential Revision: https://reviews.llvm.org/D152024 --- libc/src/__support/FPUtil/aarch64/FMA.h | 17 +++++++++-------- libc/src/__support/FPUtil/riscv64/FMA.h | 17 +++++++++-------- libc/src/__support/FPUtil/x86_64/FMA.h | 1 + utils/bazel/llvm-project-overlay/libc/BUILD.bazel | 1 + 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/libc/src/__support/FPUtil/aarch64/FMA.h b/libc/src/__support/FPUtil/aarch64/FMA.h index 5f80ed7..bcc4c70 100644 --- a/libc/src/__support/FPUtil/aarch64/FMA.h +++ b/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 __llvm_libc { namespace fputil { template -cpp::enable_if_t, T> fma(T x, T y, T z) { +LIBC_INLINE cpp::enable_if_t, 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 -cpp::enable_if_t, T> fma(T x, T y, T z) { +LIBC_INLINE cpp::enable_if_t, 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; } diff --git a/libc/src/__support/FPUtil/riscv64/FMA.h b/libc/src/__support/FPUtil/riscv64/FMA.h index 9b003f1..8f19665 100644 --- a/libc/src/__support/FPUtil/riscv64/FMA.h +++ b/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 __llvm_libc { namespace fputil { template -cpp::enable_if_t, T> fma(T x, T y, T z) { +LIBC_INLINE cpp::enable_if_t, 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 -cpp::enable_if_t, T> fma(T x, T y, T z) { +LIBC_INLINE cpp::enable_if_t, 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; } diff --git a/libc/src/__support/FPUtil/x86_64/FMA.h b/libc/src/__support/FPUtil/x86_64/FMA.h index 31494bd..9953e83 100644 --- a/libc/src/__support/FPUtil/x86_64/FMA.h +++ b/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 diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel index 5a3879d..0df29f5 100644 --- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel @@ -697,6 +697,7 @@ libc_support_library( ":__support_fputil_fenv_impl", ":__support_fputil_float_properties", ":__support_fputil_fp_bits", + ":__support_macros_attributes", ":__support_macros_optimization", ":__support_macros_properties_cpu_features", ":__support_uint128", -- 2.7.4