On Tue, May 20, 2025 at 11:29:09AM +0800, Yang Yujie wrote: > Hi, > > This is a proposition of a _BitInt(N) implementation for LoongArch, > with the following psABI description: > > ``` > === Fundamental types of N-bit integers > > `_BitInt(N)` (as proposed in ISO/IEC WG14 N2763) is a family of integer types > where `N` specifies the exact number of bits used for its representation. > > * `_BitInt(N)` objects are stored in little-endian order in memory > and are signed by default.
In the later 2 paragraphs you say they are sign or zero extended depending on if it is signed or unsigned type. I hope it is the latter and not the former. > The main differences from the existing implementations (x86_64 and aarch64) > is that all partial limbs are extended for both small/middle and large/huge > _BitInts. For this purpose, some changes needs to be made to gimple lowering > and expand. Are you sure all those changes were really necessary (rather than doing them just in case)? I believe most of gimple-lower-bitint.cc already should be sign or zero extending the partial limbs when storing stuff, there can be some corner cases (I think one of the shift directions at least). In any case, I think for targets which set info->extended_p = true; we actually need testsuite coverage to verify it works properly. I'd think something like #define CHECK(x) \ do { \ if ((typeof (x)) -1 < 0) \ { \ _BitInt(sizeof (x) * __CHAR_BIT__) __x; \ __builtin_memcpy (&__x, &(x), sizeof (__x)); \ if (__x != (x)) \ __builtin_abort (); \ } \ else \ { \ unsigned _BitInt(sizeof (x) * __CHAR_BIT__) __x; \ __builtin_memcpy (&__x, &(x), sizeof (__x)); \ if (__x != (x)) \ __builtin_abort (); \ } \ } while (0) and use the macro on various _BitInt variables, arguments, return values after various arithmetic operations (and enable those tests solely on the info->extended_p targets, which would be loongarch, most likely s390x and arm 32-bit). Jakub