Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a test for _Float16 ABI compatibility between clang and compiler-rt #107

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@ option(ENABLE_HWASAN
${SUPPORT_HWASAN}
)

# Check for _Float16 support
if (CLANGXX_BINARY)
message(STATUS "Checking for _Float16 support in ${CLANGXX_BINARY}")
execute_process(COMMAND ${CLANGXX_BINARY} -c ${CMAKE_CURRENT_SOURCE_DIR}/tests/float16.cpp RESULT_VARIABLE FLOAT16_STATUS ERROR_QUIET OUTPUT_QUIET)
if (${FLOAT16_STATUS} EQUAL 0)
message(STATUS "_Float16 enabled.")
set(ENABLE_FLOAT16 ON)
endif()
endif()

configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/tests/lit.site.cfg.in
${CMAKE_BINARY_DIR}/tests/lit.site.cfg
Expand Down
15 changes: 15 additions & 0 deletions tests/float16.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// REQUIRES: clang, compiler-rt, float16
// RUN: %clangxx %s -o %t.float16 -rtlib=compiler-rt
// RUN: %t.float16 | grep '0.122986'

#include <iostream>
#include <algorithm>
#include <vector>

int main()
{
_Float16 one_f16 = 0.123;
float one_f32 = one_f16;
std::cout << one_f32 << std::endl;
return 0;
}
1 change: 1 addition & 0 deletions tests/lit.site.cfg.in
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,4 @@ enable_feature("libc++", "@ENABLE_LIBCXX@")
enable_feature("static-libc++", "@ENABLE_STATIC_LIBCXX@")
enable_feature("libunwind", "@ENABLE_LIBUNWIND@")
enable_feature("support_hwasan", "@ENABLE_HWASAN@")
enable_feature("float16", "@ENABLE_FLOAT16@")
Loading