Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/cargo-oxide/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion crates/cuda-intrinsics-gen/src/render/families/packed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions crates/cuda-oxide-codegen/tests/spine_kernel_ptx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand Down
5 changes: 3 additions & 2 deletions crates/mir-importer/src/translator/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion crates/mir-importer/src/translator/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
Expand Down
8 changes: 4 additions & 4 deletions crates/mir-lower/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) |
|--------------------------|--------------------------------------------------------------------------|
Expand Down
3 changes: 2 additions & 1 deletion crates/mir-lower/src/convert/ops/arithmetic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion crates/mir-lower/src/convert/ops/memory/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion crates/mir-lower/tests/lowering_test/calls_and_values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions crates/rustc-codegen-cuda/examples/abi_hmm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion crates/rustc-codegen-cuda/examples/cast_tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions cuda-oxide-book/compiler/lowering-pipeline.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
Loading