Repository navigation
feat(topic28): extend RISC-V instruction selection and f64 support - #85
ForsakenDelusion wants to merge 12 commits into
Conversation
🤖 AI Code Review
📁
|
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
The design contains unresolved type-validation and floating-point spill/reload issues, plus configuration and ordering ambiguities.
Review effort: Lite
Findings: None
What changed in this PR
Adds a technical design for Topic 28 instruction selection and links it from the topic page.
Changes:
- Defines typed IR, integer/F/D floating-point lowering, register allocation, ABI, and constant folding.
- Adds CLI integration, testing, acceptance criteria, and phased implementation planning.
- Links the new design document from the topic page.
| File | Summary |
|---|---|
docs/topics/28-扩展指令选择/28-扩展指令选择.md |
Adds the design document link. |
docs/topics/28-扩展指令选择/28-扩展指令选择-设计文档.md |
Adds the comprehensive instruction-selection design. Findings: unknown ONNX types must fail instead of silently becoming FLOAT32 (critical, 1 vote); FPR spill/reload needs value-width/type propagation (moderate, 1 vote); rounding_mode requires validation (moderate, 1 vote); candidate priority direction should be defined (nit, 1 vote). |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
@copilot code review |
Add independent-function regressions and expand LLVM integer input rejection tests, recording before/after validation in the review report.
Decode constant storage bits consistently at load and operand boundaries, preserving instruction-only encodings within each function. Add bit-level regression tests and document before/after validation.
Explain the findings and fixes in plain language, mark all four issues as resolved, and retain reproduction examples and validation results.
Use minimum-version annotations and standard-library APIs, preserve frozen scheduler construction, and align Python support documentation. Add real Python 3.8 coverage to the existing CI test job and keep ONNX test fixtures consistent across supported NumPy and ONNX versions.
Summary
增加除法、余数、平方根、min/max、符号操作、访存及比较分支,提供四个 DSL 示例、支持列表和使用说明。R1–R4 的 LLVM 失败处理、函数内部重名、常量编码和分配器复用问题已修复。后续 R5 也已修复:ONNX 浮点 Min/Max 在任意输入为 NaN 时返回 NaN,IR 执行器同步处理,DSL 保持既有规则。
最低 Python 版本保留为 3.8:替换不兼容注解和标准库方法,保留调度器构造行为,统一版本说明,并在现有测试任务中增加独立的 3.8 兼容检查。
Review 报告与修复记录
2026-10-14 工程复审报告:新增 R7(P1)和 R6(P2),目前尚未修复;两项规范/维护建议为 P3。
Evidence
37516a7再跑完整回归:3826 passed,0 failed,0 skipped。独立探针仍确认 9 个 LLVM 常量错误场景和 36 个 ONNX 符号零结果差异,已有测试尚未覆盖或采用了目标预期。77bef84的生产代码上,新 NaN 专项测试为 156 失败、60 通过;加上纠正 ONNX 预期后的 96 项既有编码测试,共 216 失败、96 通过。After: 新增 216 项专项测试通过,既有编码测试继续检查位模式、ABI 和异常标志;R5 修复后的 Python 3.12 完整回归为 3826 passed,0 failed,0 skipped。
e061861的生产代码和真实 Python 3.8 下全部失败,导入阶段报错。After: 6 项全部通过;Python 兼容性修复时最低版本 CI 入口的 145 项测试通过,包含原始课题验收 99 项和真实 RISC-V 执行。
git diff --check通过。远端 Actions 结果以实际运行记录为准。Merge Danger
Door: two-way
代码和配置可通过回退提交恢复。
Blast Radius: 编译管线
影响共享前端、IR 优化、RISC-V 选择与分配、栈布局及部分基准工具。范围为 RV32 标量和硬件 F/D;内部 encoder/emulator 仍仅支持 RV32IM。
ONNX Min/Max 的 NaN 传播问题已修复。本轮复审仍有两项待处理:R7(P1),共享 typed const 输入进入 LLVM 后,普通 f32 小数可产生无法解析的文本,f64 常量可能丢精度或负零符号;R6(P2),ONNX 正负零经 Min/Max 后接 Div 的结果与官方参考实现和 ONNX Runtime 符号相反。R6 是已复现的兼容差异,公开 ONNX 算子说明没有明文规定符号零相等时的选择规则。范围仍为 RV32 标量与硬件 F/D。