forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[libc][stdbit] implement stdc_trailing_zeros (C23) (llvm#80344)
- Loading branch information
1 parent
62c352e
commit d5a3de4
Showing
21 changed files
with
384 additions
and
211 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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 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 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 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 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 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.