Skip to content

codegen: ask the type for the extents of a copied row and of a vector - #4620

Open
hiraditya wants to merge 1 commit into
mainfrom
codegen-typed-stmt-extents
Open

hiraditya wants to merge 1 commit into
mainfrom
codegen-typed-stmt-extents

Conversation

@hiraditya

Copy link
Copy Markdown
Collaborator

The next step of #388, after #4613. #4613 said that stmt.rs had no text tests on MLIR types left after it. Two were still there, and this PR changes them:

  • copy_into_new_buffer split the text after memref< at each x to find the ? extents. It now asks the memref type for its extents.
  • store_vector_in_a_new_buffer made memref<...> from the text of vector<...> and parsed it. It now builds the memref type from the vector's extents and element type.

vector_shape is a new helper in generator.rs. melior has no vector type, so it uses the MLIR C API.

Checks

  • The vxc from main ea0d9e8 and the vxc from this branch emitted MLIR for all 1,823 programs under tests/*/pass/, with each code generator.
    • 3,644 of the 3,646 outputs are the same.
    • 2 differ in an error message from the borrow check, before code generation. std_nn_kernels_run_on_the_apple_gpu.vx without its --machine flag reports Cannot borrow 'k' or 'v' at random.
  • return_a_row_from_a_function.vx and a_let_holds_an_operation_on_two_rows.vx reach the two changed functions with the AST code generator.
  • cargo test --workspace --no-fail-fast in a debug build passed.

Issue: #388. #4617 lists the remaining work.

Generated With Claude Code

Two functions in `stmt.rs` still read extents from the printed type:

- `copy_into_new_buffer` split the text after `memref<` at each `x` to
  find the `?` extents. It now asks the memref type for its extents.
- `store_vector_in_a_new_buffer` made `memref<...>` from the text of
  `vector<...>` and parsed it. It now builds the memref type from the
  vector's extents and element type.

`vector_shape` is a new helper in `generator.rs`. melior has no vector
type, so it uses the MLIR C API.

Issue: #388

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant