Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libc/shared/builtins.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include "libc_common.h"

#include "builtins/adddf3.h"
#include "builtins/addtf3.h"
#include "builtins/divtf3.h"
#include "builtins/multf3.h"
Expand Down
29 changes: 29 additions & 0 deletions libc/shared/builtins/adddf3.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
///
/// \file
/// This header exposes LLVM-libc's __adddf3 implementation as shared::adddf3 so
/// that it can be reused by compiler-rt's builtins.
///
//===----------------------------------------------------------------------===//

#ifndef LLVM_LIBC_SHARED_BUILTINS_ADDDF3_H
#define LLVM_LIBC_SHARED_BUILTINS_ADDDF3_H

#include "shared/libc_common.h"
#include "src/__support/builtins/adddf3.h"

namespace LIBC_NAMESPACE_DECL {
namespace shared {

using builtins::adddf3;

} // namespace shared
} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SHARED_BUILTINS_ADDDF3_H
9 changes: 9 additions & 0 deletions libc/src/__support/builtins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,12 @@ add_header_library(
libc.src.__support.FPUtil.generic.div
libc.src.__support.macros.config
)

add_header_library(
adddf3
HDRS
adddf3.h
DEPENDS
libc.src.__support.FPUtil.generic.add_sub
libc.src.__support.macros.config
)
32 changes: 32 additions & 0 deletions libc/src/__support/builtins/adddf3.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
///
/// \file
/// This header exposes LLVM-libc's __adddf3 implementation as builtins::adddf3
/// so that it can be reused by compiler-rt's builtins.
///
//===----------------------------------------------------------------------===//

#ifndef LLVM_LIBC_SRC___SUPPORT_BUILTINS_ADDDF3_H
#define LLVM_LIBC_SRC___SUPPORT_BUILTINS_ADDDF3_H

#include "src/__support/FPUtil/generic/add_sub.h"
#include "src/__support/macros/config.h"

namespace LIBC_NAMESPACE_DECL {
namespace builtins {

// Addition at double precision; mirrors compiler-rt's __adddf3.
LIBC_INLINE double adddf3(double x, double y) {
return fputil::generic::add<double>(x, y);
}

} // namespace builtins
} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC___SUPPORT_BUILTINS_ADDDF3_H
1 change: 1 addition & 0 deletions libc/test/shared/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,7 @@ add_fp_unittest(
SRCS
shared_builtins_test.cpp
DEPENDS
libc.src.__support.builtins.adddf3
libc.src.__support.builtins.addtf3
libc.src.__support.builtins.divtf3
libc.src.__support.builtins.multf3
Expand Down
2 changes: 1 addition & 1 deletion libc/test/shared/shared_builtins_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ TEST(LlvmLibcSharedBuiltinsTest, AllFloat) {
}

TEST(LlvmLibcSharedBuiltinsTest, AllDouble) {
// TODO: assertions for shared::*df3 builtins.
EXPECT_FP_EQ(3.0, LIBC_NAMESPACE::shared::adddf3(1.0, 2.0));
}

#ifdef LIBC_TYPES_HAS_FLOAT128
Expand Down
Loading