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

[libc] support for _BitInt in stdbit.h #80509

Open
nickdesaulniers opened this issue Feb 2, 2024 · 7 comments
Open

[libc] support for _BitInt in stdbit.h #80509

nickdesaulniers opened this issue Feb 2, 2024 · 7 comments

Comments

@nickdesaulniers
Copy link
Member

This was pointed out in #80459 (comment) , that C23 added support for _BitInt types. It would be nice if our type generic macros in stdbit.h would resolve for these types.

I wonder if the support of _BitInt was related to why GCC added a few builtins to help implement c23 stdbit.h?

@llvmbot
Copy link
Collaborator

llvmbot commented Feb 2, 2024

@llvm/issue-subscribers-libc

Author: Nick Desaulniers (nickdesaulniers)

This was pointed out in https://github.com//pull/80459#discussion_r1476478451 , that C23 added support for `_BitInt` types. It would be nice if our type generic macros in stdbit.h would resolve for these types.

I wonder if the support of _BitInt was related to why GCC added a few builtins to help implement c23 stdbit.h?

@pinskia
Copy link

pinskia commented Feb 3, 2024

I wonder if the support of _BitInt was related to why #79630 (comment) to help implement c23 stdbit.h?

It is.

@SchrodingerZhu
Copy link
Contributor

Those builtins are type generic?

@pinskia
Copy link

pinskia commented Feb 3, 2024

Those builtins are type generic?

Yes the g builtins are type generic and documented that way.
see starting at https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html#index-_005f_005fbuiltin_005fffsg .
"Similar to __builtin_ffs, except the argument is type-generic signed integer (standard, extended or bit-precise)."

@nickdesaulniers
Copy link
Member Author

nickdesaulniers commented Mar 13, 2024

Some issues I'm running into:

  • -std=c23 is nice for the tests, but only is supported in clang-18+ and gcc trunk (to be 14). Can stick with -std=c2x for now.
  • UWB suffixes on literals a nice for tests, but only supported in clang-15+ and gcc trunk (to be 14). I guess I might be able to stick to casts for now?

@Flandini
Copy link
Contributor

@nickdesaulniers, is there some ongoing work on this? I would be interested in helping with this while my math issues and PRs are on hold.

@nickdesaulniers
Copy link
Member Author

No, please feel free to send a patch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants