This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: 128-bit integer - nonsensical documentation?
- From: David Brown <david at westcontrol dot com>
- To: Kostas Savvidis <ksavvidis at gmail dot com>, Jonathan Wakely <jwakely dot gcc at gmail dot com>
- Cc: gcc-help <gcc-help at gcc dot gnu dot org>
- Date: Wed, 26 Aug 2015 14:47:39 +0200
- Subject: Re: 128-bit integer - nonsensical documentation?
- Authentication-results: sourceware.org; auth=none
- References: <1B1111BE-E274-4C80-8189-22B78D77647A at gmail dot com> <CAH6eHdTumersYZtRi62uGVhjW+nxmCkXRC__bN1En2Q6shRa3w at mail dot gmail dot com> <93EE7806-1082-4A59-B5FB-6758E0532049 at gmail dot com>
On 26/08/15 14:32, Kostas Savvidis wrote:
> I sense there is a consensus that
> 1) the 128bit integer is emulated emulated on 64-bit platforms, not
> available on 32-bit platforms, and is not native anywhere
As far as I know, 128-bit integers are supported natively on the RISC-V
architecture, which has a gcc port. I've never used such a device, so I
don't know the details - but perhaps it has 128-bit long long's. The
point is, there is nothing to stop an architecture having native 128-bit
integers.
And there is also nothing to stop 32-bit (or smaller) targets supporting
__int128. I use gcc on an 8-bit device, and it has full support for
64-bit long long's (emulated by software and library routines, of
course). If people find 128-bit integers useful and convenient, then it
seems likely that support will be added to more targets - perhaps using
SIMD or floating point registers where these are more efficient than
general purpose registers. But I'd imagine that they are only useful in
a few specialised algorithms (such as in cryptography), and then only if
they are noticeably faster than using 64-bit integers.
> 2) the long long int is 64-bits everywhere so you can *NEVER* do what
> the document seems to suggest one *MIGHT* be able to do â input a
> 128-bit constant
Again, there is nothing in the C standards saying that a "long long" is
limited to 64-bit - only that it is /at least/ 64-bit. Some targets may
have longer long long's.
>
> To me, this would justify rewriting the documentation.
The fact that you are asking these questions suggests that the
documentation is not as clear as it could be.
>
> My personal lament is that i still cannot find out anywhere if it is
> available on all 64-bit platforms or on intel only.
There are a fair number of places where the documentation mentions
features that are available or unavailable on some targets, without
being explicit. I am sure the gcc developers would be happy with
volunteers who can fill in the details :-)
David
>
> KS
>
>> On Aug 26, 2015, at 3:22 PM, Jonathan Wakely
>> <jwakely.gcc@gmail.com> wrote:
>>
>> On 26 August 2015 at 12:04, Kostas Savvidis wrote:
>>> The online documentation contains the attached passage as part of
>>> the "C-Extensionsâ chapter. There are no actual machines which
>>> have an " integer mode wide enough to hold 128 bitsâ as the
>>> document puts it.
>>
>> It's not talking about machine integers, it's talking about GCC
>> integer modes. Several targets support that.
>>
>>> This would be a harmless confusion if it didnât go on to say ââ
>>> long long integer less than 128 bits wideâ (???!!!) Whereas in
>>> reality "long long intâ is 64 bits everywhere i have seen.
>>
>>
>> Read it more carefully, it says you can't express an integer
>> constant of type __int128 on such platforms.
>>
>> So you can't write __int128 i =
>> 999999999999999999999999999999999999999999999999999999999999;
>
>