rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
96.7k stars 12.49k forks source link

Using types like i1, u24, or other nonstandard integer sizes. #54855

Open moonheart08 opened 5 years ago

moonheart08 commented 5 years ago

LLVM itself supports arbitrary bitlength integers, however Rust does not. This would be useful for some less common, but still fairly normal cases, like 24-bit integers for emulating CPUs like the MC68000 (Some models use 24-bit address busses instead of 32-bit), or for memory constrained systems where you need all the space you can get, and as such packed bitfields are the best for storing data.

cuviper commented 5 years ago

There's a similar discussion here: https://internals.rust-lang.org/t/pre-rfc-generic-integers-uint-n-and-int-n/7641

programmerjake commented 3 years ago

There is a postponed RFC: https://github.com/rust-lang/rfcs/pull/2581

programmerjake commented 3 years ago

C is getting generic integers: https://github.com/rust-lang/rfcs/pull/2581#issuecomment-887036118

darleybarreto commented 3 years ago

Does it make sense to make a full featured PoC crate for integers of any size (<=128) and eventually merge into the compiler? Or something like that should be built directly inside of rustc from the ground up?