Reply to post: Re: Sounds like a good idea

Keen to go _ExtInt? LLVM Clang compiler adds support for custom width integers

ST Silver badge

Re: Sounds like a good idea

The domain where _ExtInt would be applicable is very narrow, and that was clearly explained in the blog entry.

This applies, and is useful to, FPGA's. It is of no use to general-purpose computers that run on CPU's that lack integer registers smaller than 32 bits.

Coincidentally, X86 and X86_64 ISA's have registers smaller than 32 bits. Which is why Intel has been pushing this for a while. RISC CPU's don't have small registers, and don't care. On RISC machines you get 32-bit integer registers or 64-bit integer registers. On RISC-V - in theory - you also get 128-bit registers. Haven't seen it yet on a real RISC-V CPU.

So, the whole theory about saving massive amounts of memory won't apply to a RISC machine. A 16-bit short will still be loaded into a 32-bit register. The concept of a C short on a RISC machine is really just the lower 16 bits of a 32-bit register, with the upper ones zero'ed out. Simply because doing the entire sequence of shift + mask to store two 16-bit shorts into a 32-bit register is much more expensive computationally than using the whole 32-bit register.

Technically, it is a very nice to have feature in clang, but it has a very narrow focus and applicability domain. No-one is going to re-write their software running on Linux X86_64 to use 4-bit integers anytime soon.

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon

Biting the hand that feeds IT © 1998–2021