Skip to content

docs(passes): Document NormalizeReturnOrder pass#1234

Merged
Hzfengsy merged 2 commits intohw-native-sys:mainfrom
Hzfengsy:issue-1168-doc-normalize-return-order
Apr 30, 2026
Merged

docs(passes): Document NormalizeReturnOrder pass#1234
Hzfengsy merged 2 commits intohw-native-sys:mainfrom
Hzfengsy:issue-1168-doc-normalize-return-order

Conversation

@Hzfengsy
Copy link
Copy Markdown
Member

Summary

Adds the missing per-pass documentation for NormalizeReturnOrder (slot
#20 in the Default strategy) in both English and Chinese, fills in the
pass-doc-ordering.md registry, and converts existing bare mentions in
the pass-manager / LowerPipelineLoops / codegen overview docs into
links to the new file.

  • New docs/en/dev/passes/20-normalize_return_order.md (266 lines) and
    docs/zh-cn/dev/passes/20-normalize_return_order.md (246 lines)
    cover purpose & pipeline position, required/produced/invalidated
    IRProperty, the C++ ↔ Python API table, the two-phase algorithm
    (InCore rewrite via BuildReturnToParamMapping /
    ComputeReturnPermutation / ReorderReturns, then call-site
    TupleGetItemExpr remap via TupleIndexPermutationMutator), an
    end-to-end before/after example mirroring
    test_swapped_returns_reordered, and pointers to the implementation
    • tests
  • .claude/rules/pass-doc-ordering.md slot 20 row updated from
    no doc yet20-normalize_return_order.md
  • NormalizeReturnOrder mentions in
    passes/00-pass_manager.md, passes/21-lower_pipeline_loops.md,
    codegen/00-pto_codegen.md, and codegen/01-orchestration_codegen.md
    (EN + ZH) now link to the new doc

Testing

  • python tests/lint/check_english_only.py passes
  • Pre-commit hooks (header / english-only / large-files / EOF / trailing-ws / markdownlint) all pass
  • All cross-referenced filenames verified to exist (EN + ZH)
  • Cross-layer claims spot-checked against
    include/pypto/ir/transforms/passes.h:460,
    include/pypto/ir/transforms/pass_properties.h:161,
    python/bindings/modules/passes.cpp:287,
    python/pypto/pypto_core/passes.pyi:296,
    python/pypto/ir/pass_manager.py:148
  • Docs-only change — no rebuild / pytest run required

Related Issues

Fixes #1168 (parent: #1161)

Adds the missing per-pass doc for slot hw-native-sys#20 (`NormalizeReturnOrder`) in
both EN and ZH, mirroring the established structure of the surrounding
pass docs (overview, API table, properties, two-step algorithm,
constraints, before/after example, implementation pointers, related
links). Updates `pass-doc-ordering.md` to mark slot 20 as documented,
and converts existing `NormalizeReturnOrder` mentions in pass-manager,
LowerPipelineLoops, and codegen overviews into links to the new file.

Fixes hw-native-sys#1168
Copilot AI review requested due to automatic review settings April 30, 2026 05:24
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 30, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 51b93a0e-6547-40b0-bae5-457e87661434

📥 Commits

Reviewing files that changed from the base of the PR and between 1a80b85 and 9824856.

📒 Files selected for processing (3)
  • docs/en/dev/passes/20-normalize_return_order.md
  • docs/zh-cn/dev/passes/20-normalize_return_order.md
  • docs/zh-cn/dev/passes/21-lower_pipeline_loops.md
✅ Files skipped from review due to trivial changes (3)
  • docs/zh-cn/dev/passes/21-lower_pipeline_loops.md
  • docs/zh-cn/dev/passes/20-normalize_return_order.md
  • docs/en/dev/passes/20-normalize_return_order.md

📝 Walkthrough

Walkthrough

Adds a dedicated English and Chinese developer doc for the NormalizeReturnOrder pass, updates the pass-ordering registry to reference that doc, and replaces inline mentions with links to the new pass page across related documentation files.

Changes

Cohort / File(s) Summary
Pass Ordering Registry
\.claude/rules/pass-doc-ordering.md
Replace placeholder "no doc yet" with 20-normalize_return_order.md for the 20th pipeline pass.
Pass Documentation (English)
docs/en/dev/passes/20-normalize_return_order.md
Add full pass doc: purpose, algorithm (Step A/B), IR properties, no-op conditions, API names, implementation/test references, pipeline slot (#20).
Pass Documentation (Chinese)
docs/zh-cn/dev/passes/20-normalize_return_order.md
Add bilingual mirror of the English pass doc with algorithm, properties, examples, implementation and tests.
Docs Cross-References (English)
docs/en/dev/codegen/00-pto_codegen.md, docs/en/dev/codegen/01-orchestration_codegen.md, docs/en/dev/passes/00-pass_manager.md, docs/en/dev/passes/21-lower_pipeline_loops.md
Replace inline NormalizeReturnOrder mentions with clickable links to .../passes/20-normalize_return_order.md.
Docs Cross-References (Chinese)
docs/zh-cn/dev/codegen/00-pto_codegen.md, docs/zh-cn/dev/codegen/01-orchestration_codegen.md, docs/zh-cn/dev/passes/00-pass_manager.md, docs/zh-cn/dev/passes/21-lower_pipeline_loops.md
Replace inline NormalizeReturnOrder mentions with clickable links to the new Chinese pass doc and refine relative ordering text.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related issues

  • #1168: Requests dedicated documentation for the NormalizeReturnOrder pass and correct placement in the pass-ordering table — directly addressed by these changes.
  • hw-native-sys/pypto#1161: Tracks missing per-pass documentation and ordering; this PR supplies the requested doc and ordering slot.

Possibly related PRs

Suggested labels

enhancement

Suggested reviewers

  • lyfne123

Poem

🐰 I hopped through docs to set things right,
A pass now shines in both tongues bright,
Links stitched in place, the order true,
Paper carrots for reviewers — and you! 🥕📚

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'docs(passes): Document NormalizeReturnOrder pass' clearly and concisely summarizes the main change: adding documentation for a specific compiler pass.
Description check ✅ Passed The description provides comprehensive context about adding NormalizeReturnOrder pass documentation in English and Chinese, updating registries, and converting bare mentions to links—all aligned with the changeset.
Linked Issues check ✅ Passed The PR fully addresses issue #1168 requirements: new documentation files for NormalizeReturnOrder in English and Chinese covering purpose, pipeline position, IRProperty, C++/Python API, algorithm summary, before/after example, and implementation pointers.
Out of Scope Changes check ✅ Passed All changes are documentation-focused updates aligned with linked issues: new pass documentation files, registry updates, and cross-reference conversions to links—no unrelated code changes present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces comprehensive documentation for the NormalizeReturnOrder pass in both English and Chinese. It includes a new dedicated documentation file detailing the pass's algorithm, constraints, and implementation, while also updating cross-references in the codegen and pass manager documentation. The review feedback identifies technical inaccuracies in the description of the Step B remapping logic and highlights a slot number inconsistency in the pipeline position description that needs to be aligned with the project's pass registry.

Comment thread docs/en/dev/passes/20-normalize_return_order.md Outdated
Comment thread docs/en/dev/passes/21-lower_pipeline_loops.md
Comment thread docs/zh-cn/dev/passes/20-normalize_return_order.md Outdated
Comment thread docs/zh-cn/dev/passes/21-lower_pipeline_loops.md Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/zh-cn/dev/passes/21-lower_pipeline_loops.md`:
- Line 13: Update the Chinese doc's pipeline-position sentence to match the
English wording by adding that this pass is also before CanonicalizeIOOrder:
modify the line mentioning NormalizeReturnOrder and InitMemRef (slot 20.5) to
read that it is after `NormalizeReturnOrder` and before `CanonicalizeIOOrder`
and `InitMemRef` (e.g., append “并且在 `CanonicalizeIOOrder` 之前” so the sentence
references `NormalizeReturnOrder`, `CanonicalizeIOOrder`, and `InitMemRef`).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 298a6b6f-90b7-4c4c-8c2d-7cc34930cccf

📥 Commits

Reviewing files that changed from the base of the PR and between 8a72fc3 and 1a80b85.

📒 Files selected for processing (11)
  • .claude/rules/pass-doc-ordering.md
  • docs/en/dev/codegen/00-pto_codegen.md
  • docs/en/dev/codegen/01-orchestration_codegen.md
  • docs/en/dev/passes/00-pass_manager.md
  • docs/en/dev/passes/20-normalize_return_order.md
  • docs/en/dev/passes/21-lower_pipeline_loops.md
  • docs/zh-cn/dev/codegen/00-pto_codegen.md
  • docs/zh-cn/dev/codegen/01-orchestration_codegen.md
  • docs/zh-cn/dev/passes/00-pass_manager.md
  • docs/zh-cn/dev/passes/20-normalize_return_order.md
  • docs/zh-cn/dev/passes/21-lower_pipeline_loops.md

Comment thread docs/zh-cn/dev/passes/21-lower_pipeline_loops.md Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds the missing per-pass documentation for NormalizeReturnOrder and updates cross-references so related docs link to the new pass doc, keeping the pass-doc registry in sync with the pipeline.

Changes:

  • Add new per-pass docs for NormalizeReturnOrder in both English and Chinese.
  • Update .claude/rules/pass-doc-ordering.md to register the slot-20 doc filename.
  • Replace bare NormalizeReturnOrder mentions with links in pass-manager, LowerPipelineLoops, and codegen overview/orchestration docs (EN + ZH).

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
docs/en/dev/passes/20-normalize_return_order.md New detailed per-pass documentation for NormalizeReturnOrder (EN).
docs/zh-cn/dev/passes/20-normalize_return_order.md New detailed per-pass documentation for NormalizeReturnOrder (ZH).
.claude/rules/pass-doc-ordering.md Update registry to point slot 20 to the new doc file.
docs/en/dev/passes/00-pass_manager.md Link NormalizeReturnOrder mention to the new pass doc.
docs/zh-cn/dev/passes/00-pass_manager.md Link NormalizeReturnOrder mention to the new pass doc.
docs/en/dev/passes/21-lower_pipeline_loops.md Link pipeline-position reference to NormalizeReturnOrder doc.
docs/zh-cn/dev/passes/21-lower_pipeline_loops.md Link pipeline-position reference to NormalizeReturnOrder doc.
docs/en/dev/codegen/00-pto_codegen.md Link NormalizeReturnOrder reference to the new pass doc.
docs/zh-cn/dev/codegen/00-pto_codegen.md Link NormalizeReturnOrder reference to the new pass doc.
docs/en/dev/codegen/01-orchestration_codegen.md Link NormalizeReturnOrder reference to the new pass doc.
docs/zh-cn/dev/codegen/01-orchestration_codegen.md Link NormalizeReturnOrder reference to the new pass doc.

Comment thread docs/en/dev/passes/20-normalize_return_order.md Outdated
Comment thread docs/en/dev/passes/20-normalize_return_order.md Outdated
- Convert remaining British spellings (normalisation/canonicalises/
  materialises/normalised) in 20-normalize_return_order.md (EN) to
  American to match the surrounding docs (Copilot review).
- Replace the "transformed node" Constraints row in EN+ZH with a
  clearer rationale: the mutator preserves Var node identity, so the
  operand pointer stays valid as a key in `reordered_tuple_vars_`
  (Gemini review).
- ZH 21-lower_pipeline_loops.md "Pipeline position" sentence now
  mentions both `CanonicalizeIOOrder` and `InitMemRef` to match the
  EN wording (CodeRabbit review).
@Hzfengsy Hzfengsy merged commit 9b4386c into hw-native-sys:main Apr 30, 2026
8 checks passed
@Hzfengsy Hzfengsy deleted the issue-1168-doc-normalize-return-order branch April 30, 2026 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

[Docs] Document NormalizeReturnOrder pass

2 participants