"gcc" (which is really Apple LLVM) on my M1 Mac does __int128 ok. No such thing as int128_t though :-(
(...)
But it's not supported for riscv32 :-(
Yes, as quoted from gcc's docs, __int128/__uint128 is a purely gcc extension (likely supported by LLVM and other compilers) that is only supported on targets that have native 128-bit operations...
NONE of the ISAs I showed code for -- amd64, arm64, and riscv64 -- have native 128-bit operations.
All of them implement __int128 by doing multiple operations with 64 bit ints.
Oh, I know. I was just deriving the point from gcc's docs (that I linked). Admittedly, the paragraph on 128-bit integers is not crystal clear.
So just some guesses here - since I don't know exactly what led to those decisions:
- Regarding amd64: strictly speaking you're right, but actual x86_64 processors (Intel, AMD) have had some 128-bit registers for a pretty long time now (through extensions mainly), so my guess it that gcc first added 128-bit integer support for those targets, hence the "explanation" made in the linked paragraph;
- Then probably many people using other 64-bit targets (or plain amd64 without extensions) asked for support of 128-bit integers too, and not adding that support for those would have looked like unacceptable bias towards specific targets (albeit very common ones) - so they added this using software emulation;
- For the record, as I remember, 128-bit integers were also supported as an extension in MSVC a "long" time ago, so that may have also been part of the trigger regarding x86_64 targets;
- For 32-bit targets, as I said, there was probably very little demand in comparison, so they just didn't bother;
- Also as I mentioned, since widths > 64 bits are not *required* to be implemented (from the std), there is no incentive for generalizing this implementation for all targets.
Again, just guesses here, but the most "reasonable" I can come up with, given the information I have about this.
Maybe the real rationale is a bit different and more "political" than this, or due to a number of constraints in the compiler design, I dunno.