Skip to content

✨ Support runtime OpenQASM array size queries - #2585

Open
simon1hofmann wants to merge 1 commit into
codex/openqasm-array-concatenationfrom
codex/openqasm-runtime-sizeof
Open

simon1hofmann wants to merge 1 commit into
codex/openqasm-array-concatenationfrom
codex/openqasm-runtime-sizeof

Conversation

@simon1hofmann

@simon1hofmann simon1hofmann commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

🤖 AI text below 🤖

Description

Support sizeof on runtime-sized classical array slices, such as sizeof(a[start:step:stop]). The result is a runtime uint; queries with known extents still fold to constants, including zero-length dimensions and fixed dimensions beside runtime-sized ones.

  • Reuse the existing inclusive range calculation and runtime bounds/step preconditions.
  • Do not read array elements or create array copies or subviews. The queried array need not be initialized.
  • Support nested queries and use in arithmetic, conditions, gate parameters, and loop bodies/bounds. Keep the queried dimension a compile-time integer.
  • Diagnose runtime size queries in constant-only contexts, including const initializers and fixed array/type widths.

Stacked on #2584. No new dependencies or dialect operations. Refs #2109; this is an intermediate slice and does not close the issue.

Validation

  • At this PR boundary, all 210 frontend/emitter, 239 compiler, 204 native QCO, and 219 QC translation tests pass, including QC/QCO round trips and Adaptive QIR execution.
  • 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 18, 2026
@simon1hofmann
simon1hofmann added this pull request to stack #2576 September 18, 2026 12:58
@simon1hofmann simon1hofmann self-assigned this Sep 18, 2026
@codecov

codecov Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.01961% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
mlir/lib/Target/OpenQASM/OpenQASMSemantics.cpp 98.5% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@simon1hofmann
simon1hofmann force-pushed the codex/openqasm-runtime-sizeof branch from 5b8b54a to fe78552 Compare September 21, 2026 08:16
@simon1hofmann
simon1hofmann force-pushed the codex/openqasm-runtime-sizeof branch from fe78552 to 8c0e4af Compare September 24, 2026 11:21
@simon1hofmann
simon1hofmann force-pushed the codex/openqasm-runtime-sizeof branch from 8c0e4af to 7706abc Compare September 26, 2026 10:29
@simon1hofmann
simon1hofmann force-pushed the codex/openqasm-runtime-sizeof branch from 7706abc to 19e8438 Compare September 28, 2026 10:35
Reuse range arithmetic for sizeof on runtime-sized slices without reading or copying array elements. Preserve constant folding for known extents and diagnose runtime queries in constant-only contexts.

Refs #2109

Assisted-by: GPT-5 via Codex
@simon1hofmann
simon1hofmann force-pushed the codex/openqasm-runtime-sizeof branch from 19e8438 to 7b75d2c 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