On Sun, Jul 26, 2026 at 12:09:57PM -0500, Manjunath S Matti wrote: > The changes have been bootstrapped and regression tested on > powerpc64le-linux and powerpc64-linux (m64/m32).
Thanks for working on that. > This patch implements the powerpc64le/ppc64 target hook and > libgcc runtime support needed for GCC's existing C23 > _BitInt front-end/middle-end machinery to work on rs6000. > Previously TARGET_C_BITINT_TYPE_INFO was unimplemented on > this target, so _BitInt was entirely unsupported. > > For n > 128 the ABI limb mode differs from the internal limb mode > on little-endian ppc64 only: TImode 128-bit ABI chunks, matching > aarch64's. On big-endian ppc64, gimple-lower-bitint.cc does not > support abi_limb_mode != limb_mode(PR117584 comment 3), so the > ABI limb equals the internal DImode limb there, matching what > s390x (the only other big-endian _BitInt target) already does. > ppc32 uses SImode limbs throughout with no ABI/internal split. > > The extended (padding-bit) field also differs by endianness: little- > endian uses bitint_ext_undef (padding bits undefined, matching > x86_64/aarch64). Big-endian uses bitint_ext_full, because > gimple-lower-bitint.cc's __builtin_*_overflow lowering only > sign/zero-extends the top limb's padding bits when bitint_extended > is set; with bitint_ext_undef those bits are left unclean and > combine incorrectly with the big-endian storage-order translation > in that file, producing wrong overflow results for multi-limb > (> 128-bit) _BitInt. s390x uses bitint_ext_full for the same > reason, so ppc64 BE now matches it. Up to you and/or whomever will change the PowerPC psABI, but I'm not sure if it is a good idea to design the ABI for _BitInt based on current GCC limitations (the PR117584 #c2 thing) or bugs (really, if you think bitint_ext_undef is best for the architecture, it probably is best for all 3 ABIs in it, not just one and the bug should be fixed (unless it is what you've mentioned in #c11)). Note, the ABI will apply to other compilers too (LLVM, ...). If you want to support big-endian abi_limb_mode != limb_mode (most likely just limited to the case where abi_limb_mode is twice the size of limb_mode in that case), some effort will be needed in gimple-lower-bitint.cc for that, in most cases just arrange an extra fixed offset when dealing with bitint precisions which have full non-abi limb of padding, but perhaps some extra cases in the casts. I also think that first the psABI should be updated (if it is still maintained, that is) and only afterwards the patch should be applied. All of the patch is rs6000 specific code, so in the end probably should be approved by PowerPC maintainers, not me, although I can skim it too of course. So far I haven't seen anything beyond what I wrote above. > 2026-07-26 Manjunath Matti <[email protected]> > > gcc/ > PR target/117584 > * config/rs6000/rs6000-call.cc (rs6000_bitint_large_p): New > function. > (rs6000_return_in_memory): Return large _BitInt/enum-backed > _BitInt values via a hidden pointer, using > rs6000_bitint_large_p and BITINT_TYPE_P. > (rs6000_promote_function_mode): Do not promote BITINT_TYPE; > its ABI mode is fixed by rs6000_bitint_type_info and must > match rs6000_function_value. > (rs6000_function_arg_boundary): Align _BitInt arguments to > 128 bits. > (rs6000_pass_by_reference): Pass large _BitInt/enum-backed > _BitInt arguments by reference, using rs6000_bitint_large_p > and BITINT_TYPE_P. > * config/rs6000/rs6000.cc (TARGET_C_BITINT_TYPE_INFO): Define. > (rs6000_function_value): Exclude BITINT_TYPE from sub-word > integer return-value promotion. > (rs6000_bitint_type_info): New function. > > libgcc/ > * config/rs6000/float128-sed: Add __floatbitinttf/__floatbitintkf > and __fixtfbitint/__fixkfbitint substitution rules. > * config/rs6000/float128-sed-hw: Likewise. > * config/rs6000/libgcc-glibc.ver (GCC_17.0.0): New version node, > inheriting GCC_4.2.0; export __floatbitintkf, __fixkfbitint, > __floatbitinttf, __fixtfbitint, __floatbitintsf, __fixsfbitint, > __floatbitintdf, __fixdfbitint. > * config/rs6000/t-float128 (fp128_softfp_funcs): Add floatbitintkf > and fixkfbitint. > (ibm128_bitint_funcs): New. > (fp128_ppc_funcs): Add $(ibm128_bitint_funcs). > (rs6000_bitint_bin_funcs, rs6000_bitint_bin_src): New, add to > LIB2ADD_ST unconditionally. > (rs6000_bitint_dec_funcs, rs6000_bitint_dec_src): New, add to > LIB2ADD_ST when decimal_float is enabled. > (ibm128_bitint_objs, IBM128_BITINT_CFLAGS): New. > * config/rs6000/floatbitinttf-ibm128.c: New file. > * config/rs6000/fixtfbitint-ibm128.c: New file. > > gcc/testsuite/ > * gcc.target/powerpc/bitint-alignments-powerpc.c: New test. > * gcc.target/powerpc/bitint-args-powerpc.c: Likewise. > * gcc.target/powerpc/bitint-arith-powerpc.c: Likewise. > * gcc.target/powerpc/bitint-bitwise-powerpc.c: Likewise. > * gcc.target/powerpc/bitint-compare-powerpc.c: Likewise. > * gcc.target/powerpc/bitint-conversions-powerpc.c: Likewise. > * gcc.target/powerpc/bitint-endian-powerpc.c: Likewise. > * gcc.target/powerpc/bitint-sizes-powerpc.c: Likewise. Jakub
