From e445955814cbafe2f8b9798974c2a94802588260 Mon Sep 17 00:00:00 2001 From: Vyncint Ng <115854244+vyncint@users.noreply.github.com> Date: Sat, 29 Aug 2026 07:23:38 +0700 Subject: [PATCH 1/2] docs: repoint the three source references the module split invalidated #1190 split several large files into module directories. Three places in the tree still point a reader at a path that no longer exists, and following any of them lands nowhere: * `cuda-oxide-codegen/tests/spine_kernel_ptx.rs` sends the reader to `mir-lower/src/convert/types.rs` for `is_kernel_func`, now `convert/types/func_abi.rs`; * `examples/ref_index_projections/README.md` and `examples/subslice_projection/README.md` both name `mir-importer/src/translator/rvalue.rs`, now the `translator/rvalue/` directory. Two of them needed more than a new path, because the sentence around the path had gone stale too: * the same doc comment cites `lowering.rs:132` for `propagate_kernel_attrs`, which is at line 336. A line number in prose rots on the next edit, so this names the function in its file instead of pinning a number. * `ref_index_projections` says the `Rvalue::Ref` arm "has five cases" in the present tense. It has two, and had five before the fix that README documents; the description is of the pre-fix code, so it now reads as past tense and points at where that arm and its address walk live today. `examples/atomics/README.md` also names `intrinsics/atomic.rs` and `ops/atomic.rs`, but those are crate-relative shorthand in a pipeline diagram and both resolve, so they are left alone. Signed-off-by: Vyncint Ng <115854244+vyncint@users.noreply.github.com> --- .../cuda-oxide-codegen/tests/spine_kernel_ptx.rs | 5 +++-- .../examples/ref_index_projections/README.md | 15 +++++++++------ .../examples/subslice_projection/README.md | 2 +- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/crates/cuda-oxide-codegen/tests/spine_kernel_ptx.rs b/crates/cuda-oxide-codegen/tests/spine_kernel_ptx.rs index b1d55ec222..105a77145a 100644 --- a/crates/cuda-oxide-codegen/tests/spine_kernel_ptx.rs +++ b/crates/cuda-oxide-codegen/tests/spine_kernel_ptx.rs @@ -18,11 +18,12 @@ //! carrying a `gpu_kernel` *attribute* on the func op. There is no calling //! convention to set by hand and no naming convention. The chain is: //! -//! 1. `mir-lower`'s `is_kernel_func` (crates/mir-lower/src/convert/types.rs) +//! 1. `mir-lower`'s `is_kernel_func` +//! (crates/mir-lower/src/convert/types/func_abi.rs) //! returns `true` iff the func op's `attributes` contain a `StringAttr` //! under the identifier `gpu_kernel`. The *value* is not inspected, only //! presence; the rest of the pipeline writes `"true"`. -//! 2. During lowering (lowering.rs:132) `propagate_kernel_attrs` copies a +//! 2. During lowering, `lowering.rs`'s `propagate_kernel_attrs` copies a //! `gpu_kernel="true"` `StringAttr` onto the produced `llvm::FuncOp` (plus //! any optional `cluster_dim_*`/`maxntid`/`minctasm` ints). //! 3. `llvm-export`'s `PtxExportConfig::emit_ptx_kernel_keyword()` is `true`, diff --git a/crates/rustc-codegen-cuda/examples/ref_index_projections/README.md b/crates/rustc-codegen-cuda/examples/ref_index_projections/README.md index e49dbada63..4a8d966b50 100644 --- a/crates/rustc-codegen-cuda/examples/ref_index_projections/README.md +++ b/crates/rustc-codegen-cuda/examples/ref_index_projections/README.md @@ -130,12 +130,15 @@ runtime `Index`. ## Root cause -In `crates/mir-importer/src/translator/rvalue.rs`, the `Rvalue::Ref` arm has -five cases. Case 2 (`[Deref, Field, …]`) emits a `MirFieldAddrOp` for the -first field, then walks the remaining projections in an inner loop that only -handles further `Field`s — every other variant hits `_ => break`. After the -loop, the function unconditionally returns the partial field address, -**silently discarding** any tail projections, including a runtime `Index`. +Before this fix, the `Rvalue::Ref` arm had five cases. Case 2 +(`[Deref, Field, …]`) emitted a `MirFieldAddrOp` for the first field, then +walked the remaining projections in an inner loop that only handled further +`Field`s — every other variant hit `_ => break`. After the loop, the function +unconditionally returned the partial field address, **silently discarding** +any tail projections, including a runtime `Index`. + +That arm lives in `crates/mir-importer/src/translator/rvalue/expr.rs`, and the +address walk it delegates to in `…/rvalue/place_addr.rs`. The fix delegates the tail walk to the existing `translate_place_addr_from_slot` helper (which is now also extended to handle diff --git a/crates/rustc-codegen-cuda/examples/subslice_projection/README.md b/crates/rustc-codegen-cuda/examples/subslice_projection/README.md index 412ae987ed..18ed75e934 100644 --- a/crates/rustc-codegen-cuda/examples/subslice_projection/README.md +++ b/crates/rustc-codegen-cuda/examples/subslice_projection/README.md @@ -7,7 +7,7 @@ Rustc emits `Subslice` for the `middle @ ..` portion of array and slice patterns - arrays use `Subslice { from, to, from_end: false }`; the result is the sized array place `[T; to - from]` starting at element `from`; - slices use `Subslice { from, to, from_end: true }`; the result keeps a data pointer advanced by `from` elements and metadata `old_len - from - to`. -Before this fix, `crates/mir-importer/src/translator/rvalue.rs` had no `Subslice` lowering. The value walker reported `Projection element ... not yet implemented in iterative mode`, while the address walker returned `Ok(None)`. Mutable borrows then failed loudly because falling back to a reference to a copy would lose write-through semantics. +Before this fix, the place walkers under `crates/mir-importer/src/translator/rvalue/` had no `Subslice` lowering. The value walker reported `Projection element ... not yet implemented in iterative mode`, while the address walker returned `Ok(None)`. Mutable borrows then failed loudly because falling back to a reference to a copy would lose write-through semantics. ## Coverage From d34393d2e2a1b0b1c01d27eff8651cc274ca0691 Mon Sep 17 00:00:00 2001 From: nihalpasham Date: Sun, 30 Aug 2026 14:32:40 +0530 Subject: [PATCH 2/2] docs: repoint the remaining 14 references the module split orphaned The #1190 module split deleted 16 monolithic files. PR #1197 repointed the three sites issue #1196 enumerated; this commit sweeps the rest, including bare-basename spellings the original sweep missed: - abi_hmm README table rows (convert/types.rs, ops/aggregate.rs) - book lowering-pipeline.md table rows (ops/memory.rs, ops/aggregate.rs) - mir-lower README (convert/generated_intrinsics.rs, now a directory) - translator/layout.rs + lowering_test/calls_and_values.rs comments (translator/rvalue.rs) - convert/ops/arithmetic.rs + ops/memory/tests/mod.rs comments (tests/lowering_test.rs, now a directory) - cargo-oxide README source tree (commands.rs, now a directory) - render/families/packed.rs comment (resolve.rs, now a directory) - translator/types.rs comment (place walker lives in rvalue/place_addr.rs) - intrinsics/indexing.rs doc (sreg dispatch lives in generated/sreg.rs) - cast_tests README pipeline diagram (rvalue.rs -> rvalue/expr.rs) Every new pointer was verified against the tree before writing it. Sweep now returns zero dangling references across full-path, crate-relative, and bare-basename spellings of all 16 deleted files. Signed-off-by: nihalpasham --- crates/cargo-oxide/README.md | 2 +- crates/cuda-intrinsics-gen/src/render/families/packed.rs | 2 +- crates/mir-importer/src/translator/layout.rs | 5 +++-- .../src/translator/terminator/intrinsics/indexing.rs | 2 +- crates/mir-importer/src/translator/types.rs | 2 +- crates/mir-lower/README.md | 8 ++++---- crates/mir-lower/src/convert/ops/arithmetic.rs | 3 ++- crates/mir-lower/src/convert/ops/memory/tests/mod.rs | 2 +- crates/mir-lower/tests/lowering_test/calls_and_values.rs | 2 +- crates/rustc-codegen-cuda/examples/abi_hmm/README.md | 4 ++-- crates/rustc-codegen-cuda/examples/cast_tests/README.md | 2 +- .../examples/ref_index_projections/README.md | 2 +- cuda-oxide-book/compiler/lowering-pipeline.md | 4 ++-- 13 files changed, 21 insertions(+), 19 deletions(-) diff --git a/crates/cargo-oxide/README.md b/crates/cargo-oxide/README.md index 3fd4eb7e70..707eef7954 100644 --- a/crates/cargo-oxide/README.md +++ b/crates/cargo-oxide/README.md @@ -443,7 +443,7 @@ crates/cargo-oxide/ ├── main.rs # CLI definitions (clap) + dispatch ├── backend.rs # Backend discovery + build logic ├── artifact_identity.rs # Embedded artifact identity/provenance - └── commands.rs # All command implementations + └── commands/ # Command implementations, one module per command group ``` ## Future Commands diff --git a/crates/cuda-intrinsics-gen/src/render/families/packed.rs b/crates/cuda-intrinsics-gen/src/render/families/packed.rs index 6815833d5a..f4977f10af 100644 --- a/crates/cuda-intrinsics-gen/src/render/families/packed.rs +++ b/crates/cuda-intrinsics-gen/src/render/families/packed.rs @@ -380,7 +380,7 @@ pub(in crate::render) fn packed_conversion_constraint(record: &CatalogIntrinsic) /// Whether the conversion lowers through a typed NVVM intrinsic call rather /// than inline PTX. Only the scalar-`f32` pair narrowed to FP8 does; see the -/// matching predicate in `resolve.rs` for why. +/// matching predicate in `resolve/families/packed_conversion.rs` for why. fn packed_conversion_uses_typed_nvvm(record: &CatalogIntrinsic) -> bool { let conversion = record .packed_conversion diff --git a/crates/mir-importer/src/translator/layout.rs b/crates/mir-importer/src/translator/layout.rs index 4cc0f4e906..8017566e15 100644 --- a/crates/mir-importer/src/translator/layout.rs +++ b/crates/mir-importer/src/translator/layout.rs @@ -5,8 +5,9 @@ //! //! Both the type importer (`translator/types.rs`, which records tag and //! field byte offsets on `MirEnumType`) and constant decoding -//! (`translator/rvalue.rs`, which slices payload bytes out of constant -//! allocations) need the same offset lookups. Keeping them here means the +//! (`translator/rvalue/const_enum.rs` and `const_alloc.rs`, which slice +//! payload bytes out of constant allocations) need the same offset +//! lookups. Keeping them here means the //! two consumers cannot drift apart on how an offset is derived. use pliron::location::Location; diff --git a/crates/mir-importer/src/translator/terminator/intrinsics/indexing.rs b/crates/mir-importer/src/translator/terminator/intrinsics/indexing.rs index 1513cbc122..2196ae60b8 100644 --- a/crates/mir-importer/src/translator/terminator/intrinsics/indexing.rs +++ b/crates/mir-importer/src/translator/terminator/intrinsics/indexing.rs @@ -275,7 +275,7 @@ mod tests { assert_eq!(block.deref(&ctx).iter(&ctx).count(), 0); } - /// The sreg reads behind `index_1d` are dispatched from `generated.rs`, + /// The sreg reads behind `index_1d` are dispatched from `generated/sreg.rs`, /// which stamps each op with a marker literal. Assert the three markers /// against the target table the backend reads back at verification time, /// so a renumbering that reached only one of the two generated artifacts diff --git a/crates/mir-importer/src/translator/types.rs b/crates/mir-importer/src/translator/types.rs index d5fed1fbc4..ee5c23b8e7 100644 --- a/crates/mir-importer/src/translator/types.rs +++ b/crates/mir-importer/src/translator/types.rs @@ -393,7 +393,7 @@ fn translate_pointer_like( // (ptr, len), `PtrMetadata` extraction, fat-value copies) all // applies unchanged. Field access through the fat pointer // extracts the data pointer (the struct's address) first; see - // the place-address walker in `rvalue.rs`. + // the place-address walker in `rvalue/place_addr.rs`. let struct_model = translate_type(ctx, pointee)?; Ok(facts::mint_slice_type(ctx, struct_model, origin).into()) } diff --git a/crates/mir-lower/README.md b/crates/mir-lower/README.md index 610efa7c9e..d09c0d6354 100644 --- a/crates/mir-lower/README.md +++ b/crates/mir-lower/README.md @@ -98,10 +98,10 @@ For each `MirFuncOp`, `convert_func` (in `lowering.rs`): ### GPU Intrinsic Converters (`convert/intrinsics/`) -Anything `intrinsics/catalog.json` describes is lowered by -`convert/generated_intrinsics.rs` -- one level up, beside `intrinsics/`, not -inside it. The modules below are the hand-written converters that sit next to -it, one row per file: +Anything `intrinsics/catalog.json` describes is lowered by the generated +`convert/generated_intrinsics/` module (one file per intrinsic family) -- +one level up, beside `intrinsics/`, not inside it. The modules below are +the hand-written converters that sit next to it, one row per file: | Module | Purpose (from each module's own doc comment) | |--------------------------|--------------------------------------------------------------------------| diff --git a/crates/mir-lower/src/convert/ops/arithmetic.rs b/crates/mir-lower/src/convert/ops/arithmetic.rs index 82c75b8213..b57f7e1d6b 100644 --- a/crates/mir-lower/src/convert/ops/arithmetic.rs +++ b/crates/mir-lower/src/convert/ops/arithmetic.rs @@ -863,7 +863,8 @@ fn emit_discriminant_const( Ok(const_op.deref(ctx).get_result(0)) } -// Conversion coverage: `tests/lowering_test.rs::test_cmp_predicate_lowering` +// Conversion coverage: `test_cmp_predicate_lowering` in +// `tests/lowering_test/calls_and_values.rs` // locks the comparison predicate table end-to-end; the two unit tests in // this module lock the contract-only fast-math flag on float arithmetic. diff --git a/crates/mir-lower/src/convert/ops/memory/tests/mod.rs b/crates/mir-lower/src/convert/ops/memory/tests/mod.rs index 616fe704f7..d8d7e6cdbf 100644 --- a/crates/mir-lower/src/convert/ops/memory/tests/mod.rs +++ b/crates/mir-lower/src/convert/ops/memory/tests/mod.rs @@ -10,7 +10,7 @@ //! driver and not constructible standalone. So each test builds a small //! MIR module, runs the full `lower_mir_to_llvm` pass on it, and asserts //! the lowered module contains the expected `dialect-llvm` shape — same -//! pattern as `tests/lowering_test.rs`. +//! pattern as the `tests/lowering_test/` integration suite. // Tests build kinded fixture types directly; production minting lives in mir-importer's facts.rs. #![allow(clippy::disallowed_methods)] diff --git a/crates/mir-lower/tests/lowering_test/calls_and_values.rs b/crates/mir-lower/tests/lowering_test/calls_and_values.rs index ba83feab64..7840c12933 100644 --- a/crates/mir-lower/tests/lowering_test/calls_and_values.rs +++ b/crates/mir-lower/tests/lowering_test/calls_and_values.rs @@ -450,7 +450,7 @@ fn test_cmp_predicate_lowering() -> Result<(), anyhow::Error> { // One comparison op per table row, in a fixed program order. The raw // `Operation::new` construction mirrors how the importer builds these - // ops (mir-importer translator/rvalue.rs BinaryOp arm). + // ops (mir-importer translator/rvalue/expr.rs, `Rvalue::BinaryOp` arm). let cmp_infos = [ // Floats: all six predicates. (mir::MirEqOp::get_concrete_op_info(), fa, fb), diff --git a/crates/rustc-codegen-cuda/examples/abi_hmm/README.md b/crates/rustc-codegen-cuda/examples/abi_hmm/README.md index a1acaa73e6..3af751888e 100644 --- a/crates/rustc-codegen-cuda/examples/abi_hmm/README.md +++ b/crates/rustc-codegen-cuda/examples/abi_hmm/README.md @@ -235,8 +235,8 @@ Rust is different: |---------------|-------------------------------------------|------------------------------------------------| | Layout query | `mir-importer/src/translator/types.rs` | Query `fields_by_offset_order()` and `offsets` | | MIR type | `dialect-mir/src/types.rs` | Store offsets in `MirStructType` | -| LLVM lowering | `mir-lower/src/convert/types.rs` | Build struct with explicit padding | -| Field access | `mir-lower/src/convert/ops/aggregate.rs` | Map declaration → memory index | +| LLVM lowering | `mir-lower/src/convert/types/struct_layout.rs` | Build struct with explicit padding | +| Field access | `mir-lower/src/convert/ops/aggregate/fields.rs` | Map declaration → memory index | ### Pipeline Output diff --git a/crates/rustc-codegen-cuda/examples/cast_tests/README.md b/crates/rustc-codegen-cuda/examples/cast_tests/README.md index 4dd264dca4..18ff667ba7 100644 --- a/crates/rustc-codegen-cuda/examples/cast_tests/README.md +++ b/crates/rustc-codegen-cuda/examples/cast_tests/README.md @@ -42,7 +42,7 @@ Rvalue::Cast ──► MirCastOp ──► Specific LL operand, ty) (semantic intent) mir-importer/ dialect-mir/ mir-lower/ -rvalue.rs ops/cast.rs convert/ops/cast.rs +rvalue/expr.rs ops/cast.rs convert/ops/cast.rs attributes.rs ``` diff --git a/crates/rustc-codegen-cuda/examples/ref_index_projections/README.md b/crates/rustc-codegen-cuda/examples/ref_index_projections/README.md index 4a8d966b50..dda607f1c1 100644 --- a/crates/rustc-codegen-cuda/examples/ref_index_projections/README.md +++ b/crates/rustc-codegen-cuda/examples/ref_index_projections/README.md @@ -133,7 +133,7 @@ runtime `Index`. Before this fix, the `Rvalue::Ref` arm had five cases. Case 2 (`[Deref, Field, …]`) emitted a `MirFieldAddrOp` for the first field, then walked the remaining projections in an inner loop that only handled further -`Field`s — every other variant hit `_ => break`. After the loop, the function +`Field`s; every other variant hit `_ => break`. After the loop, the function unconditionally returned the partial field address, **silently discarding** any tail projections, including a runtime `Index`. diff --git a/cuda-oxide-book/compiler/lowering-pipeline.md b/cuda-oxide-book/compiler/lowering-pipeline.md index 2c9aae2a82..2223eb928b 100644 --- a/cuda-oxide-book/compiler/lowering-pipeline.md +++ b/cuda-oxide-book/compiler/lowering-pipeline.md @@ -81,9 +81,9 @@ The conversion functions are organized into modules by category: | Category | Module | What It Handles | | :------------ | :---------------------------- | :--------------------------------------------------------------------------------| | Arithmetic | `convert/ops/arithmetic.rs` | `add`→`add`, `sub`→`sub`, `checked_add`→`add`+`extractvalue` | -| Memory | `convert/ops/memory.rs` | `mir.load`→`load`, `mir.store`→`store`, `shared_alloc`→global + `addrspacecast` | +| Memory | `convert/ops/memory/*.rs` | `mir.load`→`load`, `mir.store`→`store`, `shared_alloc`→global + `addrspacecast` | | Control Flow | `convert/ops/control_flow.rs` | `mir.goto`→`br`, `mir.cond_br`→`cond_br`, `mir.return`→`return` | -| Aggregate | `convert/ops/aggregate.rs` | Struct/tuple field access → GEP or `extractvalue`/`insertvalue` | +| Aggregate | `convert/ops/aggregate/*.rs` | Struct/tuple field access → GEP or `extractvalue`/`insertvalue` | | Cast | `convert/ops/cast.rs` | `IntToInt`→`zext`/`sext`/`trunc`, `FloatToFloat`→`fpext`/`fptrunc`, etc. | | Call | `convert/ops/call.rs` | `mir.call`→`call`, with argument flattening and `::` to `__` name conversion | | GPU Intrinsic | `convert/intrinsics/*.rs` | NVVM ops → LLVM intrinsic calls or inline PTX |