-
Notifications
You must be signed in to change notification settings - Fork 13k
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
[libc][stdfix] Implement countlsfx
functions
#114318
Changes from all commits
cc87a9a
1d0488a
e73b2a2
81148c2
371f0fc
e80e108
04db3f7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ set( | |
"float16_conversion" | ||
"float128" | ||
"fixed_point" | ||
"padding_on_unsigned_fixed_point" | ||
) | ||
|
||
# Making sure ALL_COMPILER_FEATURES is sorted. | ||
|
@@ -62,6 +63,8 @@ foreach(feature IN LISTS ALL_COMPILER_FEATURES) | |
set(link_options "") | ||
if(${feature} STREQUAL "fixed_point") | ||
list(APPEND compile_options "-ffixed-point") | ||
elseif(${feature} STREQUAL "padding_on_unsigned_fixed_point") | ||
list(APPEND compile_options "-Xclang=-fpadding-on-unsigned-fixed-point") | ||
elseif(${feature} MATCHES "^builtin_" OR | ||
${feature} STREQUAL "float16_conversion") | ||
set(compile_options ${LIBC_COMPILE_OPTIONS_DEFAULT}) | ||
|
@@ -110,6 +113,8 @@ foreach(feature IN LISTS ALL_COMPILER_FEATURES) | |
set(LIBC_TYPES_HAS_FLOAT128 TRUE) | ||
elseif(${feature} STREQUAL "fixed_point") | ||
set(LIBC_COMPILER_HAS_FIXED_POINT TRUE) | ||
elseif(${feature} STREQUAL "padding_on_unsigned_fixed_point") | ||
set(LIBC_COMPILER_HAS_PADDING_ON_UNSIGNED_FIXED_POINT TRUE) | ||
elseif(${feature} STREQUAL "builtin_ceil_floor_rint_trunc") | ||
set(LIBC_COMPILER_HAS_BUILTIN_CEIL_FLOOR_RINT_TRUNC TRUE) | ||
elseif(${feature} STREQUAL "builtin_fmax_fmin") | ||
|
@@ -140,3 +145,4 @@ check_cxx_compiler_flag("-nostdlib++" LIBC_CC_SUPPORTS_NOSTDLIBPP) | |
|
||
# clang-3.0+ | ||
check_cxx_compiler_flag("-nostdlibinc" LIBC_CC_SUPPORTS_NOSTDLIBINC) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: looks like you added an extra space here |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "include/llvm-libc-macros/stdfix-macros.h" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this file supposed to have more? Maybe an |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,34 @@ foreach(suffix IN ITEMS hr r lr hk k lk uhr ur ulr uhk uk ulk) | |
DEPENDS | ||
libc.src.__support.fixed_point.fx_bits | ||
) | ||
|
||
add_entrypoint_object( | ||
countls${suffix} | ||
HDRS | ||
countls${suffix}.h | ||
SRCS | ||
countls${suffix}.cpp | ||
COMPILE_OPTIONS | ||
-O3 | ||
DEPENDS | ||
libc.src.__support.fixed_point.fx_bits | ||
) | ||
|
||
if(LIBC_COMPILER_HAS_PADDING_ON_UNSIGNED_FIXED_POINT) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need these extra entry points built with this flag? Are they supposed to be on or off by default? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah this flag should just be used for tests. This flag isn't on by default in clang but if users want it then they can add it when building llvm-libc from source. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, the idea is to run all countlsfx tests twice. Once with Are there any other places in the codebase where we run the same test set twice but differ the flags? If so, I can mirror what is done there. |
||
add_entrypoint_object( | ||
countls${suffix}_padding_on_unsigned_fixed_point | ||
HDRS | ||
countls${suffix}.h | ||
SRCS | ||
countls${suffix}.cpp | ||
COMPILE_OPTIONS | ||
-O3 | ||
-Xclang=-fpadding-on-unsigned-fixed-point | ||
DEPENDS | ||
libc.src.__support.fixed_point.fx_bits | ||
) | ||
endif() | ||
|
||
endforeach() | ||
|
||
add_entrypoint_object( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "countlshk.h" | ||
#include "src/__support/common.h" | ||
#include "src/__support/fixed_point/fx_bits.h" | ||
#include "src/__support/macros/config.h" | ||
|
||
namespace LIBC_NAMESPACE_DECL { | ||
|
||
LLVM_LIBC_FUNCTION(int, countlshk, (short accum x)) { | ||
return fixed_point::countls(x); | ||
} | ||
|
||
} // namespace LIBC_NAMESPACE_DECL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you also need to add
-ffixed-point
here.