[clang] [docs] Add some undocumented C2y stdbit.h intrinsics (PR #247017)
Jan Schultke via cfe-commits
cfe-commits at lists.llvm.org
Sun Nov 29 22:49:45 PST 2026
https://github.com/eisenwave updated https://github.com/llvm/llvm-project/pull/247017
>From 7dee34481a18b16040c3fa6587bdf2075fd4bfe2 Mon Sep 17 00:00:00 2001
From: Eisenwave <me at eisenwave.net>
Date: Sun, 29 Nov 2026 23:00:46 +0100
Subject: [PATCH 1/3] [docs] Add some undocumented C2y stdbit.h intrinsics
---
clang/docs/LanguageExtensions.md | 3 +++
1 file changed, 3 insertions(+)
diff --git a/clang/docs/LanguageExtensions.md b/clang/docs/LanguageExtensions.md
index f53d4f636b4640..a2cbedab5c35b8 100644
--- a/clang/docs/LanguageExtensions.md
+++ b/clang/docs/LanguageExtensions.md
@@ -3880,6 +3880,9 @@ bool __builtin_stdc_has_single_bit(T value);
unsigned int __builtin_stdc_bit_width(T value);
T __builtin_stdc_bit_floor(T value);
T __builtin_stdc_bit_ceil(T value);
+T __builtin_stdc_rotate_left(T value, unsigned int count);
+T __builtin_stdc_rotate_right(T value, unsigned int count);
+void __builtin_stdc_memreverse8(size_t n, unsigned char *ptr);
```
where `T` is any unsigned integer type except `bool` and enumeration types,
>From 4abfb0b74c4bd5df7cac1109084c1f0774cc7999 Mon Sep 17 00:00:00 2001
From: Eisenwave <me at eisenwave.net>
Date: Mon, 30 Nov 2026 07:44:39 +0100
Subject: [PATCH 2/3] Remove redundant documentation for rotations
---
clang/docs/LanguageExtensions.md | 2 --
1 file changed, 2 deletions(-)
diff --git a/clang/docs/LanguageExtensions.md b/clang/docs/LanguageExtensions.md
index a2cbedab5c35b8..3d9bf0d083a600 100644
--- a/clang/docs/LanguageExtensions.md
+++ b/clang/docs/LanguageExtensions.md
@@ -3880,8 +3880,6 @@ bool __builtin_stdc_has_single_bit(T value);
unsigned int __builtin_stdc_bit_width(T value);
T __builtin_stdc_bit_floor(T value);
T __builtin_stdc_bit_ceil(T value);
-T __builtin_stdc_rotate_left(T value, unsigned int count);
-T __builtin_stdc_rotate_right(T value, unsigned int count);
void __builtin_stdc_memreverse8(size_t n, unsigned char *ptr);
```
>From c87aaa95e917f9cb89c0dfb92cba60b5749cdbb6 Mon Sep 17 00:00:00 2001
From: Eisenwave <me at eisenwave.net>
Date: Mon, 30 Nov 2026 07:49:30 +0100
Subject: [PATCH 3/3] Reference both C23 and C2y, not just C23
---
clang/docs/LanguageExtensions.md | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/clang/docs/LanguageExtensions.md b/clang/docs/LanguageExtensions.md
index 3d9bf0d083a600..c943065a046e3b 100644
--- a/clang/docs/LanguageExtensions.md
+++ b/clang/docs/LanguageExtensions.md
@@ -3888,20 +3888,20 @@ including `_BitInt` types.
**Description**:
-These builtins implement the C23 `<stdbit.h>` operations. Following the C23
-standard, `unsigned int` is used as the `generic_return_type` for count and
+These builtins implement the C23 and C2y `<stdbit.h>` operations. Following the
+C standard, `unsigned int` is used as the `generic_return_type` for count and
position queries (`leading_zeros`, `leading_ones`, `trailing_zeros`,
`trailing_ones`, `first_leading_zero`, `first_leading_one`,
`first_trailing_zero`, `first_trailing_one`, `count_zeros`,
`count_ones`, `bit_width`); `has_single_bit` returns `bool`; and
`bit_floor`/`bit_ceil` return the same type as the operand. Zero and
-all-ones cases follow the C23 definitions. All are usable in constant
+all-ones cases follow the C definitions. All are usable in constant
expressions.
-`bool` and enumeration types are rejected as arguments because C23 does not
+`bool` and enumeration types are rejected as arguments because C does not
permit them for these functions.
-As a Clang extension, `_BitInt` types of arbitrary widths are supported. C23
+As a Clang extension, `_BitInt` types of arbitrary widths are supported. C
only requires support for bit-precise integers whose width matches a standard
or extended integer type.
More information about the cfe-commits
mailing list