Integer polyfills
还没有人认领这个 Issue。
- 主要语言
- Rust
- 星标
- 3.4k
- 派生
- 126
- PR 合并指标
- 30 天内没有已合并 PR
描述
We should have polyfills to downlevel u64 and u128 to many u32 instructions, enabling the use of these types without concern for hardware capabilities on eg. mobile ARM platforms. Also consider polyfill for u8 and u16, which could enable things like using enum Ordering from std, see https://github.com/Rust-GPU/rust-gpu/issues/147.
libm only handles float math, no integer downlevel.
Discussed in https://github.com/Rust-GPU/rust-gpu/discussions/301
Originally posted by nazar-pc June 27, 2025
I faced a small challenge: my CPU code I'm trying to run on a GPU naturally maps onto u64 and u128, but even u64 apparently requires OpCapability Int64, let alone u128.
Now writing polyfills that work around that feels like a job that compiler should do for me, though I appreciate that it at least tells me that there isn't a native way to run that and I should think about what to do with it.
I'm wondering it it'd be possible to either have a compilation flag that automatically inserts polyfills for such types. It will be an explicit opt-in feature, but otherwise require the least amount of effort for those who do need it. I believe LLVM is capable of this.
I'm really not looking forward to writing polyfills for u128 using a bunch of u32s.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
先从 issue 描述和链接的讨论 301 开始,然后查看相关 issue 147,了解针对整数提出的使用场景和约束。定义哪些整数宽度和目标指令属于范围,opt-in polyfilling 应如何工作,以及在开始实现之前哪些测试可以证明支持情况。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- rust
- 领域
- compilers
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 25/100