Skip to content

Commit

Permalink
[libc][NFC] Add LIBC_INLINE and attribute.h header includes to target…
Browse files Browse the repository at this point in the history
…s' FMA.h.

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

Reviewed By: brooksmoses

Differential Revision: https://reviews.llvm.org/D152024
  • Loading branch information
lntue committed Jun 3, 2023
1 parent 6a38c77 commit 5a4e344
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
17 changes: 9 additions & 8 deletions libc/src/__support/FPUtil/aarch64/FMA.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -26,20 +27,20 @@ namespace __llvm_libc {
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;
}

Expand Down
17 changes: 9 additions & 8 deletions libc/src/__support/FPUtil/riscv64/FMA.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -26,20 +27,20 @@ namespace __llvm_libc {
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;
}

Expand Down
1 change: 1 addition & 0 deletions libc/src/__support/FPUtil/x86_64/FMA.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions utils/bazel/llvm-project-overlay/libc/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 5a4e344

Please sign in to comment.