Core: Add cfg `no_128bits_fmt_parse`

I'm compiling Rust code to C code using llvm-cbe and compile that C code with SDCC

Unfortunately, both llvm-cbe and SDCC do not support 128bit integer. So I'm having a trouble compiling a core (`core` compilation to C · Issue #10 · zlfn/rust-gb · GitHub)

Except in my case, I think there will be many cases where integer operations exceeding 64bits are not supported in other situations.

I propose that a new cfg option no_128bits_fmt_parse that disables the fmt, parse and iter function for i128, u128 types in core.

I know there is a already unstable no_fp_fmt_parse cfg to disable floating point fmt, and I think a similar approach could be useful for large integers.

1 Like

I think there will be many cases where integer operations exceeding 64bits are not supported in other situations.

I cannot follow here. What cases are there? 128 bit arithmetic can always be - and is on most targets - implemented via 64 bit primitives.

LLVM has some tooling for this but I do not know how to use this or how it looks like in older versions: Reland "[mlir][arith] Add wide integer emulation pass" · llvm/llvm-project@7fa1d74 · GitHub

1 Like

I agree that this feature will only be used in very specific situations. I think it will only be used at alternative backend where 128-bit optimization is not supported, or on very small platforms where 64-bit primitives are not supported. And it probably won't be used on almost all Rust's formal targets. (It might be used on some avr targets that are Tier3, but I'm not sure exactly.)

But I think it's quite simple to implement this cfg feature (probably) and I think it would be helpful overall if it could be used for a llvm alternative backend that doesn't support 128bit emulation.

LLVM has some tooling for this but I do not know how to use this or how it looks like in older versions: Reland "[mlir][arith] Add wide integer emulation pass" · llvm/llvm-project@7fa1d74 · GitHub

Can I use MLIR's arithmetic wide integer emulation pass with LLVM-IR not MLIR? Isn't 128-bit arithmetic emulation with 64 or lower bits provided from the llvm backend for each platform?