Skip to content

Implement i128 lowering for backends without stable i128 support  #45676

Closed
@est31

Description

@est31

While {i128, u128} support works greatly on many backends (x86 32 bit and 64 bit versions for example), emscripten and other smaller backends have a shaky support story for i128 integers. Often a backend gets written with support for C/C++ in mind, and those languages don't mandate i128 integer support, so those backends don't implement it. You are getting assertions or worse if presenting the backend with IR that uses i128. While we offer intrinsics for many i128 related operations in the compiler_builtins crate (offering the i128 operation implementations beyond the limited set of targets that C written comiler-rt supports), a backend still needs to implement sret support and other features. So for these backends, i128 is disabled right now.

Having spotty support for i128 means that even if we stabilize i128, many users of the language will avoid using the native i128 types, and instead adopt crates that do that lowering manually, which in turn leads to fragmentation of the ecosystem and prevents them from having a native i128 experience which includes support for proper literals. This is not what we have a native i128 support for!

Therefore, rustc should implement lowering of i128 that backends which don't have support for i128 can opt into.

One way to expose this feature could be as a member i128_lowering to the TargetOptions struct, which is enabled for the targets in question.

cc tracking issue #35118.

cc @alexcrichton @nagisa @sfackler

@scottmcm is doing awesome work on the issue:

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-codegenArea: Code generationC-enhancementCategory: An issue proposing an enhancement or a PR with one.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions