Skip to content

Commit 5a4e344

Browse files
committed
[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
1 parent 6a38c77 commit 5a4e344

File tree

4 files changed

+20
-16
lines changed

4 files changed

+20
-16
lines changed

libc/src/__support/FPUtil/aarch64/FMA.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#ifndef LLVM_LIBC_SRC_SUPPORT_FPUTIL_AARCH64_FMA_H
1010
#define LLVM_LIBC_SRC_SUPPORT_FPUTIL_AARCH64_FMA_H
1111

12+
#include "src/__support/macros/attributes.h" // LIBC_INLINE
1213
#include "src/__support/macros/properties/architectures.h"
1314
#include "src/__support/macros/properties/cpu_features.h" // LIBC_TARGET_CPU_HAS_FMA
1415

@@ -26,20 +27,20 @@ namespace __llvm_libc {
2627
namespace fputil {
2728

2829
template <typename T>
29-
cpp::enable_if_t<cpp::is_same_v<T, float>, T> fma(T x, T y, T z) {
30+
LIBC_INLINE cpp::enable_if_t<cpp::is_same_v<T, float>, T> fma(T x, T y, T z) {
3031
float result;
31-
__asm__ __volatile__("fmadd %s0, %s1, %s2, %s3\n\t"
32-
: "=w"(result)
33-
: "w"(x), "w"(y), "w"(z));
32+
LIBC_INLINE_ASM("fmadd %s0, %s1, %s2, %s3\n\t"
33+
: "=w"(result)
34+
: "w"(x), "w"(y), "w"(z));
3435
return result;
3536
}
3637

3738
template <typename T>
38-
cpp::enable_if_t<cpp::is_same_v<T, double>, T> fma(T x, T y, T z) {
39+
LIBC_INLINE cpp::enable_if_t<cpp::is_same_v<T, double>, T> fma(T x, T y, T z) {
3940
double result;
40-
__asm__ __volatile__("fmadd %d0, %d1, %d2, %d3\n\t"
41-
: "=w"(result)
42-
: "w"(x), "w"(y), "w"(z));
41+
LIBC_INLINE_ASM("fmadd %d0, %d1, %d2, %d3\n\t"
42+
: "=w"(result)
43+
: "w"(x), "w"(y), "w"(z));
4344
return result;
4445
}
4546

libc/src/__support/FPUtil/riscv64/FMA.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#ifndef LLVM_LIBC_SRC_SUPPORT_FPUTIL_RISCV64_FMA_H
1010
#define LLVM_LIBC_SRC_SUPPORT_FPUTIL_RISCV64_FMA_H
1111

12+
#include "src/__support/macros/attributes.h" // LIBC_INLINE
1213
#include "src/__support/macros/properties/architectures.h"
1314
#include "src/__support/macros/properties/cpu_features.h" // LIBC_TARGET_CPU_HAS_FMA
1415

@@ -26,20 +27,20 @@ namespace __llvm_libc {
2627
namespace fputil {
2728

2829
template <typename T>
29-
cpp::enable_if_t<cpp::is_same_v<T, float>, T> fma(T x, T y, T z) {
30+
LIBC_INLINE cpp::enable_if_t<cpp::is_same_v<T, float>, T> fma(T x, T y, T z) {
3031
float result;
31-
__asm__ __volatile__("fmadd.s %0, %1, %2, %3\n\t"
32-
: "=f"(result)
33-
: "f"(x), "f"(y), "f"(z));
32+
LIBC_INLINE_ASM("fmadd.s %0, %1, %2, %3\n\t"
33+
: "=f"(result)
34+
: "f"(x), "f"(y), "f"(z));
3435
return result;
3536
}
3637

3738
template <typename T>
38-
cpp::enable_if_t<cpp::is_same_v<T, double>, T> fma(T x, T y, T z) {
39+
LIBC_INLINE cpp::enable_if_t<cpp::is_same_v<T, double>, T> fma(T x, T y, T z) {
3940
double result;
40-
__asm__ __volatile__("fmadd.d %0, %1, %2, %3\n\t"
41-
: "=f"(result)
42-
: "f"(x), "f"(y), "f"(z));
41+
LIBC_INLINE_ASM("fmadd.d %0, %1, %2, %3\n\t"
42+
: "=f"(result)
43+
: "f"(x), "f"(y), "f"(z));
4344
return result;
4445
}
4546

libc/src/__support/FPUtil/x86_64/FMA.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#ifndef LLVM_LIBC_SRC_SUPPORT_FPUTIL_X86_64_FMA_H
1010
#define LLVM_LIBC_SRC_SUPPORT_FPUTIL_X86_64_FMA_H
1111

12+
#include "src/__support/macros/attributes.h" // LIBC_INLINE
1213
#include "src/__support/macros/properties/architectures.h"
1314
#include "src/__support/macros/properties/cpu_features.h" // LIBC_TARGET_CPU_HAS_FMA
1415

utils/bazel/llvm-project-overlay/libc/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,7 @@ libc_support_library(
697697
":__support_fputil_fenv_impl",
698698
":__support_fputil_float_properties",
699699
":__support_fputil_fp_bits",
700+
":__support_macros_attributes",
700701
":__support_macros_optimization",
701702
":__support_macros_properties_cpu_features",
702703
":__support_uint128",

0 commit comments

Comments
 (0)