-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[libc][stdbit] implement stdc_trailing_zeros (C23) #80344
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
995f36d
[libc][stdbit] implement stdc_trailing_zeros (C23)
nickdesaulniers 984693d
format
nickdesaulniers 68d1f7f
refactor cmake; getting tired of writing these already
nickdesaulniers ccc4daa
s/LLONG_WIDTH/ULLONG_WIDTH/
nickdesaulniers 4cdccb5
update stdc.td
nickdesaulniers 282a079
update macros in spect.td
nickdesaulniers 5d94dd3
prefer set to list APPEND
nickdesaulniers File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,99 +1,19 @@ | ||
add_entrypoint_object( | ||
stdc_leading_zeros_uc | ||
SRCS | ||
stdc_leading_zeros_uc.cpp | ||
HDRS | ||
stdc_leading_zeros_uc.h | ||
DEPENDS | ||
libc.src.__support.CPP.bit | ||
) | ||
|
||
add_entrypoint_object( | ||
stdc_leading_zeros_us | ||
SRCS | ||
stdc_leading_zeros_us.cpp | ||
HDRS | ||
stdc_leading_zeros_us.h | ||
DEPENDS | ||
libc.src.__support.CPP.bit | ||
) | ||
|
||
add_entrypoint_object( | ||
stdc_leading_zeros_ui | ||
SRCS | ||
stdc_leading_zeros_ui.cpp | ||
HDRS | ||
stdc_leading_zeros_ui.h | ||
DEPENDS | ||
libc.src.__support.CPP.bit | ||
) | ||
|
||
add_entrypoint_object( | ||
stdc_leading_zeros_ul | ||
SRCS | ||
stdc_leading_zeros_ul.cpp | ||
HDRS | ||
stdc_leading_zeros_ul.h | ||
DEPENDS | ||
libc.src.__support.CPP.bit | ||
) | ||
|
||
add_entrypoint_object( | ||
stdc_leading_zeros_ull | ||
SRCS | ||
stdc_leading_zeros_ull.cpp | ||
HDRS | ||
stdc_leading_zeros_ull.h | ||
DEPENDS | ||
libc.src.__support.CPP.bit | ||
) | ||
|
||
add_entrypoint_object( | ||
stdc_leading_ones_uc | ||
SRCS | ||
stdc_leading_ones_uc.cpp | ||
HDRS | ||
stdc_leading_ones_uc.h | ||
DEPENDS | ||
libc.src.__support.CPP.bit | ||
) | ||
|
||
add_entrypoint_object( | ||
stdc_leading_ones_us | ||
SRCS | ||
stdc_leading_ones_us.cpp | ||
HDRS | ||
stdc_leading_ones_us.h | ||
DEPENDS | ||
libc.src.__support.CPP.bit | ||
) | ||
|
||
add_entrypoint_object( | ||
stdc_leading_ones_ui | ||
SRCS | ||
stdc_leading_ones_ui.cpp | ||
HDRS | ||
stdc_leading_ones_ui.h | ||
DEPENDS | ||
libc.src.__support.CPP.bit | ||
) | ||
|
||
add_entrypoint_object( | ||
stdc_leading_ones_ul | ||
SRCS | ||
stdc_leading_ones_ul.cpp | ||
HDRS | ||
stdc_leading_ones_ul.h | ||
DEPENDS | ||
libc.src.__support.CPP.bit | ||
) | ||
|
||
add_entrypoint_object( | ||
stdc_leading_ones_ull | ||
SRCS | ||
stdc_leading_ones_ull.cpp | ||
HDRS | ||
stdc_leading_ones_ull.h | ||
DEPENDS | ||
libc.src.__support.CPP.bit | ||
) | ||
set(prefixes | ||
leading_zeros | ||
leading_ones | ||
trailing_zeros | ||
) | ||
set(suffixes c s i l ll) | ||
foreach(prefix IN LISTS prefixes) | ||
foreach(suffix IN LISTS suffixes) | ||
add_entrypoint_object( | ||
stdc_${prefix}_u${suffix} | ||
SRCS | ||
stdc_${prefix}_u${suffix}.cpp | ||
HDRS | ||
stdc_${prefix}_u${suffix}.h | ||
DEPENDS | ||
libc.src.__support.CPP.bit | ||
) | ||
endforeach() | ||
endforeach() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
//===-- Implementation of stdc_trailing_zeros_uc --------------------------===// | ||
// | ||
// 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 "src/stdbit/stdc_trailing_zeros_uc.h" | ||
|
||
#include "src/__support/CPP/bit.h" | ||
#include "src/__support/common.h" | ||
|
||
namespace LIBC_NAMESPACE { | ||
|
||
LLVM_LIBC_FUNCTION(unsigned, stdc_trailing_zeros_uc, (unsigned char value)) { | ||
return static_cast<unsigned>(cpp::countr_zero(value)); | ||
} | ||
|
||
} // namespace LIBC_NAMESPACE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
//===-- Implementation header for stdc_trailing_zeros_uc --------*- C++ -*-===// | ||
// | ||
// 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_LIBC_SRC_STDBIT_STDC_TRAILING_ZEROS_UC_H | ||
#define LLVM_LIBC_SRC_STDBIT_STDC_TRAILING_ZEROS_UC_H | ||
|
||
namespace LIBC_NAMESPACE { | ||
|
||
unsigned stdc_trailing_zeros_uc(unsigned char value); | ||
|
||
} // namespace LIBC_NAMESPACE | ||
|
||
#endif // LLVM_LIBC_SRC_STDBIT_STDC_TRAILING_ZEROS_UC_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
//===-- Implementation of stdc_trailing_zeros_ui --------------------------===// | ||
// | ||
// 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 "src/stdbit/stdc_trailing_zeros_ui.h" | ||
|
||
#include "src/__support/CPP/bit.h" | ||
#include "src/__support/common.h" | ||
|
||
namespace LIBC_NAMESPACE { | ||
|
||
LLVM_LIBC_FUNCTION(unsigned, stdc_trailing_zeros_ui, (unsigned value)) { | ||
return static_cast<unsigned>(cpp::countr_zero(value)); | ||
} | ||
|
||
} // namespace LIBC_NAMESPACE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
//===-- Implementation header for stdc_trailing_zeros_ui --------*- C++ -*-===// | ||
// | ||
// 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_LIBC_SRC_STDBIT_STDC_TRAILING_ZEROS_UI_H | ||
#define LLVM_LIBC_SRC_STDBIT_STDC_TRAILING_ZEROS_UI_H | ||
|
||
namespace LIBC_NAMESPACE { | ||
|
||
unsigned stdc_trailing_zeros_ui(unsigned value); | ||
|
||
} // namespace LIBC_NAMESPACE | ||
|
||
#endif // LLVM_LIBC_SRC_STDBIT_STDC_TRAILING_ZEROS_UI_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
//===-- Implementation of stdc_trailing_zeros_ul --------------------------===// | ||
// | ||
// 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 "src/stdbit/stdc_trailing_zeros_ul.h" | ||
|
||
#include "src/__support/CPP/bit.h" | ||
#include "src/__support/common.h" | ||
|
||
namespace LIBC_NAMESPACE { | ||
|
||
LLVM_LIBC_FUNCTION(unsigned, stdc_trailing_zeros_ul, (unsigned long value)) { | ||
return static_cast<unsigned>(cpp::countr_zero(value)); | ||
} | ||
|
||
} // namespace LIBC_NAMESPACE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
//===-- Implementation header for stdc_trailing_zeros_ul --------*- C++ -*-===// | ||
// | ||
// 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_LIBC_SRC_STDBIT_STDC_TRAILING_ZEROS_UL_H | ||
#define LLVM_LIBC_SRC_STDBIT_STDC_TRAILING_ZEROS_UL_H | ||
|
||
namespace LIBC_NAMESPACE { | ||
|
||
unsigned stdc_trailing_zeros_ul(unsigned long value); | ||
|
||
} // namespace LIBC_NAMESPACE | ||
|
||
#endif // LLVM_LIBC_SRC_STDBIT_STDC_TRAILING_ZEROS_UL_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//===-- Implementation of stdc_trailing_zeros_ull -------------------------===// | ||
// | ||
// 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 "src/stdbit/stdc_trailing_zeros_ull.h" | ||
|
||
#include "src/__support/CPP/bit.h" | ||
#include "src/__support/common.h" | ||
|
||
namespace LIBC_NAMESPACE { | ||
|
||
LLVM_LIBC_FUNCTION(unsigned, stdc_trailing_zeros_ull, | ||
(unsigned long long value)) { | ||
return static_cast<unsigned>(cpp::countr_zero(value)); | ||
} | ||
|
||
} // namespace LIBC_NAMESPACE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
//===-- Implementation header for stdc_trailing_zeros_ull -------*- C++ -*-===// | ||
// | ||
// 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_LIBC_SRC_STDBIT_STDC_TRAILING_ZEROS_ULL_H | ||
#define LLVM_LIBC_SRC_STDBIT_STDC_TRAILING_ZEROS_ULL_H | ||
|
||
namespace LIBC_NAMESPACE { | ||
|
||
unsigned stdc_trailing_zeros_ull(unsigned long long value); | ||
|
||
} // namespace LIBC_NAMESPACE | ||
|
||
#endif // LLVM_LIBC_SRC_STDBIT_STDC_TRAILING_ZEROS_ULL_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
//===-- Implementation of stdc_trailing_zeros_us --------------------------===// | ||
// | ||
// 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 "src/stdbit/stdc_trailing_zeros_us.h" | ||
|
||
#include "src/__support/CPP/bit.h" | ||
#include "src/__support/common.h" | ||
|
||
namespace LIBC_NAMESPACE { | ||
|
||
LLVM_LIBC_FUNCTION(unsigned, stdc_trailing_zeros_us, (unsigned short value)) { | ||
return static_cast<unsigned>(cpp::countr_zero(value)); | ||
} | ||
|
||
} // namespace LIBC_NAMESPACE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
//===-- Implementation header for stdc_trailing_zeros_us --------*- C++ -*-===// | ||
// | ||
// 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_LIBC_SRC_STDBIT_STDC_TRAILING_ZEROS_US_H | ||
#define LLVM_LIBC_SRC_STDBIT_STDC_TRAILING_ZEROS_US_H | ||
|
||
namespace LIBC_NAMESPACE { | ||
|
||
unsigned stdc_trailing_zeros_us(unsigned short value); | ||
|
||
} // namespace LIBC_NAMESPACE | ||
|
||
#endif // LLVM_LIBC_SRC_STDBIT_STDC_TRAILING_ZEROS_US_H |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.