Skip to content

✨ Support iteration over OpenQASM arrays and slices - #2590

Open
simon1hofmann wants to merge 1 commit into
codex/openqasm-runtime-sizeoffrom
codex/openqasm-array-iteration
Open

simon1hofmann wants to merge 1 commit into
codex/openqasm-runtime-sizeoffrom
codex/openqasm-array-iteration

Conversation

@simon1hofmann

@simon1hofmann simon1hofmann commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

🤖 AI text below 🤖

Description

Support for loops over one-dimensional classical arrays and slices, including
rank-one selections from multidimensional arrays and runtime slice bounds.

  • Bind each element by value in a local loop variable. Assigning the variable
    does not change the array or the next iteration value.
  • Capture slice bounds once, read elements in selection order, and preserve
    nested break/continue and empty-array behavior.
  • Reuse existing views, loop lowering, initialization checks, and scalar type
    conversions. Do not copy or unroll the iterated array.
  • Support bool, sized int/uint, float, and compatible angle loop variables.
    Retain the existing restrictions on runtime fixed-width angle conversion.

Stacked on #2585. Refs #2109; this intermediate slice does not close the issue.
Subroutines and array-reference parameters remain separate work.

Validation

  • At this PR boundary, all 213 frontend/emitter, 239 compiler, 204 native QCO, and 219 QC translation tests pass.
  • Execution checks cover QC/QCO round trips, Adaptive QIR, measurement-dependent bounds, reversed slices, nested jumps, narrow integer conversions, and by-value iteration.
  • Full-file C++ lint found no issues in this PR's changed files. Repository lint and diff-whitespace checks pass.
  • Hosted CI for the pushed commits has not been checked.

Codex assisted with implementation, tests, documentation, and this description.

Checklist

  • The pull request only contains commits that are focused and relevant to this change.
  • I have added appropriate tests that cover the new/changed functionality.
  • I have updated the documentation to reflect these changes.
  • The changes follow the project's style guidelines and introduce no new warnings.
  • The changes are fully tested and pass the CI checks.
  • I have reviewed my own code changes.

If PR contains AI-assisted content:

  • Any agent that created, edited, or submitted GitHub content was explicitly authorized for that scope, as required by our AI Usage Guidelines.
  • Every agent-authored or agent-edited public text body begins with the visible disclosure 🤖 *AI text below* 🤖 (titles are exempt).
  • I have disclosed AI assistance in the PR description.
  • I confirm that I have personally reviewed and understood all AI-generated content, and accept full responsibility for it.

@simon1hofmann simon1hofmann added feature New feature or request MLIR Anything related to MLIR labels Sep 21, 2026
@simon1hofmann
simon1hofmann added this pull request to stack #2576 September 21, 2026 08:51
@simon1hofmann simon1hofmann self-assigned this Sep 21, 2026
@codecov

codecov Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.39640% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...nclude/mqt/Target/OpenQASM/Detail/OpenQASMParser.h 89.7% 4 Missing ⚠️
...lib/Dialect/QC/Translation/OpenQASMToQCEmitter.cpp 96.6% 2 Missing ⚠️
mlir/lib/Target/OpenQASM/OpenQASMSemantics.cpp 98.3% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@simon1hofmann
simon1hofmann force-pushed the codex/openqasm-array-iteration branch from c4b75e2 to 933ed31 Compare September 24, 2026 11:23
@simon1hofmann
simon1hofmann force-pushed the codex/openqasm-array-iteration branch from 933ed31 to 151ad13 Compare September 26, 2026 10:36
@simon1hofmann
simon1hofmann force-pushed the codex/openqasm-array-iteration branch from 151ad13 to 84555ef Compare September 28, 2026 10:36
Reuse array views and existing loop lowering to preserve by-value iteration, captured slice bounds, and nested loop control without copying arrays.

Assisted-by: GPT-5 via Codex
@simon1hofmann
simon1hofmann force-pushed the codex/openqasm-array-iteration branch from 84555ef to 8076092 Compare September 29, 2026 07:12

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

feature New feature or request MLIR Anything related to MLIR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant