Re: [PATCH 0/12] GCC _BitInt support [PR102989]
On Mon, 18 Sep 2023, Matthew Malcomson via Gcc-patches wrote: > On 8/9/23 19:14, Jakub Jelinek via Gcc-patches wrote: > > > It is enabled only on targets which have agreed on processor specific > > ABI how to lay those out or pass as function arguments/return values, > > which currently is just x86-64 I believe, would be nice if target > > maintainers > > helped to get agreement on psABI changes and GCC 14 could enable it on far > > more architectures than just one. > > > Hello, > > Do you know of any other architectures in the process of defining a psABI for > _BitInt (or for that matter having defined an ABI between then and now)? https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102989#c13 has links to all the issues I filed requesting that ABIs be defined for _BitInt. At some point all GCC architecture maintainers should probably be asked to try to agree _BitInt ABIs with any psABI maintainers that may exist, or, failing a maintained psABI, with any other implementations for the architecture, or, failing other maintained implementations that support _BitInt or might do so in future, to write down a definition of the ABI being used by GCC for _BitInt on that architecture along with enabling the support in GCC. -- Joseph S. Myers jos...@codesourcery.com
Re: [PATCH 0/12] GCC _BitInt support [PR102989]
On 8/9/23 19:14, Jakub Jelinek via Gcc-patches wrote: It is enabled only on targets which have agreed on processor specific ABI how to lay those out or pass as function arguments/return values, which currently is just x86-64 I believe, would be nice if target maintainers helped to get agreement on psABI changes and GCC 14 could enable it on far more architectures than just one. Hello, Do you know of any other architectures in the process of defining a psABI for _BitInt (or for that matter having defined an ABI between then and now)? We're currently working on completing the ABI for AArch64 and AArch32 hoping that it could unblock the enablement for those arches. We'd like to know about the potential clashes with other ABI's w.r.t. user-visible behaviour as part of the decision making. I'd not found any other defined ABI's online, but thought it worth asking in case I just missed it. Thanks, Matthew
Patch ping^2 Re: [PATCH 0/12] GCC _BitInt support [PR102989]
Hi! On Mon, Aug 21, 2023 at 05:24:02PM +0200, Jakub Jelinek via Gcc-patches wrote: > Jakub Jelinek (12): > expr: Small optimization [PR102989] > lto-streamer-in: Adjust assert [PR102989] > phiopt: Fix phiopt ICE on vops [PR102989] > Middle-end _BitInt support [PR102989] > _BitInt lowering support [PR102989] > i386: Enable _BitInt on x86-64 [PR102989] > ubsan: _BitInt -fsanitize=undefined support [PR102989] > libgcc: Generated tables for _BitInt <-> _Decimal* conversions [PR102989] > libgcc _BitInt support [PR102989] > C _BitInt support [PR102989] > testsuite part 1 for _BitInt support [PR102989] > testsuite part 2 for _BitInt support [PR102989] + C _BitInt incremental fixes [PR102989] + libgcc _BitInt helper documentation [PR102989] I'd like to ping the rest of this patch series. First 3 patches are committed, next 4 are approved with commit waiting for approval of the rest, the 2 testsuite patches are also approved if you don't have further comments on them, the 3 libgcc patches and 2 C _BitInt patches need to be reviewed. https://gcc.gnu.org/pipermail/gcc-patches/2023-August/626850.html https://gcc.gnu.org/pipermail/gcc-patches/2023-August/626851.html https://gcc.gnu.org/pipermail/gcc-patches/2023-August/626852.html https://gcc.gnu.org/pipermail/gcc-patches/2023-August/627033.html https://gcc.gnu.org/pipermail/gcc-patches/2023-August/628141.html Thanks. Jakub
Re: Patch ping Re: [PATCH 0/12] GCC _BitInt support [PR102989]
On Mon, Aug 21, 2023 at 8:25 AM Jakub Jelinek via Gcc-patches wrote: > > Hi! > > On Wed, Aug 09, 2023 at 08:14:14PM +0200, Jakub Jelinek via Gcc-patches wrote: > > Jakub Jelinek (12): > > expr: Small optimization [PR102989] > > lto-streamer-in: Adjust assert [PR102989] > > phiopt: Fix phiopt ICE on vops [PR102989] > > Middle-end _BitInt support [PR102989] > > _BitInt lowering support [PR102989] > > i386: Enable _BitInt on x86-64 [PR102989] > > ubsan: _BitInt -fsanitize=undefined support [PR102989] > > libgcc: Generated tables for _BitInt <-> _Decimal* conversions [PR102989] > > libgcc _BitInt support [PR102989] > > C _BitInt support [PR102989] > > testsuite part 1 for _BitInt support [PR102989] > > testsuite part 2 for _BitInt support [PR102989] > > + C _BitInt incremental fixes [PR102989] > > I'd like to ping this patch series. > First 3 patches are committed, the rest awaits patch review. > > Joseph, could I ask now at least for an overall design review of the > C patches (8-10,13) whether its interfaces with middle-end are ok, > so that Richi can review the middle-end parts? On a related note, does it make sense to add this as a C++ front-end as an Extension too? I noticed clang supports it for C++. Thanks, Andrew > > Thanks. > > Jakub >
Re: Patch ping Re: [PATCH 0/12] GCC _BitInt support [PR102989]
On Mon, 21 Aug 2023, Jakub Jelinek via Gcc-patches wrote: > Joseph, could I ask now at least for an overall design review of the > C patches (8-10,13) whether its interfaces with middle-end are ok, > so that Richi can review the middle-end parts? I am fine with the interface to the middle-end parts. I think the libgcc functions (i.e. those exported by libgcc, to which references are generated by the compiler) need documenting in libgcc.texi. Internal functions or macros in the libgcc patch need appropriate comments specifying their semantics; especially FP_TO_BITINT and FP_FROM_BITINT which have a lot of arguments and no comments saying what the semantics of the macros and their arguments are supposed to me. -- Joseph S. Myers jos...@codesourcery.com
Patch ping Re: [PATCH 0/12] GCC _BitInt support [PR102989]
Hi! On Wed, Aug 09, 2023 at 08:14:14PM +0200, Jakub Jelinek via Gcc-patches wrote: > Jakub Jelinek (12): > expr: Small optimization [PR102989] > lto-streamer-in: Adjust assert [PR102989] > phiopt: Fix phiopt ICE on vops [PR102989] > Middle-end _BitInt support [PR102989] > _BitInt lowering support [PR102989] > i386: Enable _BitInt on x86-64 [PR102989] > ubsan: _BitInt -fsanitize=undefined support [PR102989] > libgcc: Generated tables for _BitInt <-> _Decimal* conversions [PR102989] > libgcc _BitInt support [PR102989] > C _BitInt support [PR102989] > testsuite part 1 for _BitInt support [PR102989] > testsuite part 2 for _BitInt support [PR102989] + C _BitInt incremental fixes [PR102989] I'd like to ping this patch series. First 3 patches are committed, the rest awaits patch review. Joseph, could I ask now at least for an overall design review of the C patches (8-10,13) whether its interfaces with middle-end are ok, so that Richi can review the middle-end parts? Thanks. Jakub
Re: [PATCH 0/12] GCC _BitInt support [PR102989]
On Thu, Aug 10, 2023 at 12:13 AM Jakub Jelinek via Gcc-patches wrote: > > On Thu, Aug 10, 2023 at 06:55:05AM +, Richard Biener wrote: > > On Wed, 9 Aug 2023, Joseph Myers wrote: > > > > > On Wed, 9 Aug 2023, Jakub Jelinek via Gcc-patches wrote: > > > > > > > - _Complex _BitInt(N) isn't supported; again mainly because none of the > > > > psABIs > > > > mention how those should be passed/returned; in a limited way they are > > > > supported internally because the internal functions into which > > > > __builtin_{add,sub,mul}_overflow{,_p} is lowered return COMPLEX_TYPE > > > > as a > > > > hack to return 2 values without using references/pointers > > > > > > What happens when the usual arithmetic conversions are applied to > > > operands, one of which is a complex integer type and the other of which is > > > a wider _BitInt type? I don't see anything in the code to disallow this > > > case (which would produce an expression with a _Complex _BitInt type), or > > > any testcases for it. > > > > > > Other testcases I think should be present (along with any corresponding > > > changes needed to the code itself): > > > > > > * Verifying that the new integer constant suffix is rejected for C++. > > > > > > * Verifying appropriate pedwarn-if-pedantic for the new constant suffix > > > for versions of C before C2x (and probably for use of _BitInt type > > > specifiers before C2x as well) - along with the expected -Wc11-c2x-compat > > > handling (in C2x mode) / -pedantic -Wno-c11-c2x-compat in older modes. > > > > Can we go as far as deprecating our _Complex int extension for > > C17 and make it unavailable for C2x, side-stepping the issue? > > Or maybe at least considering that for C2x? > > I can just sorry at it for now. And now that I search through the x86-64 > psABI again, it doesn't mention complex integers at all, so we are there on > our own. And it seems we don't have anything for complex integers on the > library side and the complex lowering is before bitint lowering, so it might > just work with < 10 lines of changes in code + testsuite, but if we do > enable it, let's do it incrementally. _Complex int division also has issues which is another reason to deprecate/remove it; see PR 104937 for that and https://gcc.gnu.org/legacy-ml/gcc/2001-11/msg00790.html (which was the first time to deprecate _Complex int; https://gcc.gnu.org/legacy-ml/gcc/2001-11/msg00863.html). Thanks, Andrew > > Jakub >
Re: [PATCH 0/12] GCC _BitInt support [PR102989]
On Thu, Aug 10, 2023 at 06:55:05AM +, Richard Biener wrote: > On Wed, 9 Aug 2023, Joseph Myers wrote: > > > On Wed, 9 Aug 2023, Jakub Jelinek via Gcc-patches wrote: > > > > > - _Complex _BitInt(N) isn't supported; again mainly because none of the > > > psABIs > > > mention how those should be passed/returned; in a limited way they are > > > supported internally because the internal functions into which > > > __builtin_{add,sub,mul}_overflow{,_p} is lowered return COMPLEX_TYPE as > > > a > > > hack to return 2 values without using references/pointers > > > > What happens when the usual arithmetic conversions are applied to > > operands, one of which is a complex integer type and the other of which is > > a wider _BitInt type? I don't see anything in the code to disallow this > > case (which would produce an expression with a _Complex _BitInt type), or > > any testcases for it. > > > > Other testcases I think should be present (along with any corresponding > > changes needed to the code itself): > > > > * Verifying that the new integer constant suffix is rejected for C++. > > > > * Verifying appropriate pedwarn-if-pedantic for the new constant suffix > > for versions of C before C2x (and probably for use of _BitInt type > > specifiers before C2x as well) - along with the expected -Wc11-c2x-compat > > handling (in C2x mode) / -pedantic -Wno-c11-c2x-compat in older modes. > > Can we go as far as deprecating our _Complex int extension for > C17 and make it unavailable for C2x, side-stepping the issue? > Or maybe at least considering that for C2x? I can just sorry at it for now. And now that I search through the x86-64 psABI again, it doesn't mention complex integers at all, so we are there on our own. And it seems we don't have anything for complex integers on the library side and the complex lowering is before bitint lowering, so it might just work with < 10 lines of changes in code + testsuite, but if we do enable it, let's do it incrementally. Jakub
Re: [PATCH 0/12] GCC _BitInt support [PR102989]
On Wed, 9 Aug 2023, Joseph Myers wrote: > On Wed, 9 Aug 2023, Jakub Jelinek via Gcc-patches wrote: > > > - _Complex _BitInt(N) isn't supported; again mainly because none of the > > psABIs > > mention how those should be passed/returned; in a limited way they are > > supported internally because the internal functions into which > > __builtin_{add,sub,mul}_overflow{,_p} is lowered return COMPLEX_TYPE as a > > hack to return 2 values without using references/pointers > > What happens when the usual arithmetic conversions are applied to > operands, one of which is a complex integer type and the other of which is > a wider _BitInt type? I don't see anything in the code to disallow this > case (which would produce an expression with a _Complex _BitInt type), or > any testcases for it. > > Other testcases I think should be present (along with any corresponding > changes needed to the code itself): > > * Verifying that the new integer constant suffix is rejected for C++. > > * Verifying appropriate pedwarn-if-pedantic for the new constant suffix > for versions of C before C2x (and probably for use of _BitInt type > specifiers before C2x as well) - along with the expected -Wc11-c2x-compat > handling (in C2x mode) / -pedantic -Wno-c11-c2x-compat in older modes. Can we go as far as deprecating our _Complex int extension for C17 and make it unavailable for C2x, side-stepping the issue? Or maybe at least considering that for C2x? Richard.
Re: [PATCH 0/12] GCC _BitInt support [PR102989]
On Wed, 9 Aug 2023, Jakub Jelinek via Gcc-patches wrote: > - _Complex _BitInt(N) isn't supported; again mainly because none of the psABIs > mention how those should be passed/returned; in a limited way they are > supported internally because the internal functions into which > __builtin_{add,sub,mul}_overflow{,_p} is lowered return COMPLEX_TYPE as a > hack to return 2 values without using references/pointers What happens when the usual arithmetic conversions are applied to operands, one of which is a complex integer type and the other of which is a wider _BitInt type? I don't see anything in the code to disallow this case (which would produce an expression with a _Complex _BitInt type), or any testcases for it. Other testcases I think should be present (along with any corresponding changes needed to the code itself): * Verifying that the new integer constant suffix is rejected for C++. * Verifying appropriate pedwarn-if-pedantic for the new constant suffix for versions of C before C2x (and probably for use of _BitInt type specifiers before C2x as well) - along with the expected -Wc11-c2x-compat handling (in C2x mode) / -pedantic -Wno-c11-c2x-compat in older modes. -- Joseph S. Myers jos...@codesourcery.com
[PATCH 0/12] GCC _BitInt support [PR102989]
Hi! The following patch series introduces support for C23 bit-precise integer types. In short, they are similar to other integral types in many ways, just aren't subject for integral promotions if smaller than int and they can have even much wider precisions than ordinary integer types. This series includes and thus subsumes all so far uncommitted _BitInt related patches. Compared to the last posted series, there is bit-field _BitInt support, _Atomic/stdatomic.h support, conversions between _Decimal{32,64,128} and _BitInt and vice versa (this particular item compared to what has been posted before has a fix for the large powers of 10 computations which with the _BitInt(575) limitation can't be really seen so far, but I've tried to call the underlying routines with very large arrays of limbs, and in addition to that the generated tables header has been made more compact) and Richard's patch review feedback has been incorporated and series has been further split into more patches. It is enabled only on targets which have agreed on processor specific ABI how to lay those out or pass as function arguments/return values, which currently is just x86-64 I believe, would be nice if target maintainers helped to get agreement on psABI changes and GCC 14 could enable it on far more architectures than just one. C23 says that defines BITINT_MAXWIDTH macro and that is the largest supported precision of the _BitInt types, smallest is precision of unsigned long long (but due to lack of psABI agreement we'll violate that on architectures which don't have the support done yet). The following series uses for the time just WIDE_INT_MAX_PRECISION as that BITINT_MAXWIDTH, with the intent to increase it incrementally later on. WIDE_INT_MAX_PRECISION is 575 bits on x86_64, but will be even smaller on lots of architectures. This is the largest precision we can support without changes of wide_int/widest_int representation (to make those non-POD and allow use of some allocated buffer rather than the included fixed size one). Once that would be overcome, there is another internal enforced limit, INTEGER_CST in current layout allows at most 255 64-bit limbs, which is 16320 bits as another cap. And if that is overcome, then we have limitation of TYPE_PRECISION being 16-bit, so 65535 as maximum precision. Perhaps we could make TYPE_PRECISION dependent on BITINT_TYPE vs. others and use 32-bit precision in that case later. Latest Clang/LLVM I think supports on paper up to 8388608 bits, but is hardly usable even with much shorter precisions. Besides this hopefully temporary cap on supported precision and support only on targets which buy into it, the support has the following limitations: - _Complex _BitInt(N) isn't supported; again mainly because none of the psABIs mention how those should be passed/returned; in a limited way they are supported internally because the internal functions into which __builtin_{add,sub,mul}_overflow{,_p} is lowered return COMPLEX_TYPE as a hack to return 2 values without using references/pointers - vectors of _BitInt(N) aren't supported, both because psABIs don't specify how that works and because I'm not really sure it would be useful given lack of hw support for anything but bit-precise integers with the same bit precision as standard integer types Because the bit-precise types have different behavior both in the C FE (e.g. the lack of promotion) and do or can have different behavior in type layout and function argument passing/returning values, the patch introduces a new integral type, BITINT_TYPE, so various spots which explicitly check for INTEGER_TYPE and not say INTEGRAL_TYPE_P macro need to be adjusted. Also the assumption that all integral types have scalar integer type mode is no longer true, larger BITINT_TYPEs have BLKmode type. The patch makes 4 different categories of _BitInt depending on the target hook decisions and their precision. The x86-64 psABI says that _BitInt which fit into signed/unsigned char, short, int, long and long long are laid out and passed as those types (with padding bits undefined if they don't have mode precision). Such smallest precision bit-precise integer types are categorized as small, the target hook gives for specific precision a scalar integral mode where a single such mode contains all the bits. Such small _BitInt types are generally kept in the IL until expansion into RTL, with minor tweaks during expansion to avoid relying on the padding bit values. All larger precision _BitInt types are supposed to be handled as structure containing an array of limbs or so, where a limb has some integral mode (for libgcc purposes best if it has word-size) and the limbs have either little or big endian ordering in the array. The padding bits in the most significant limb if any are either undefined or should be always sign/zero extended (but support for this isn't in yet, we don't know if any psABI will require it). As mentioned in some