🤖 AI text below 🤖
Problem Statement
Classical OpenQASM def functions and array-reference parameters remain outside
the standalone array work in #2109. The existing #2429 covers only void
subroutines with quantum parameters and explicitly excludes classical parameters
and return values.
Without classical subroutines, programs cannot pass an angle table or update a
classical array through a reusable function.
Proposed Solution
Add classical subroutines and array-reference parameters as a coherent extension
of the frontend and shared function-call representation.
- Support typed scalar arguments by value, scalar return values, local scope,
and calls to defined non-recursive functions.
- Support
readonly array[...] and mutable array[...] reference parameters,
with explicit shape or the language's rank-only #dim form.
- Borrow caller-owned storage. Preserve writes through mutable references and
reject writes through readonly references. Do not copy an entire array merely
to pass it to a function.
- Validate element type, shape/rank, initialization, and the language's alias
restrictions, including overlapping mutable arguments. Include supported
array slices in the reference contract rather than silently flattening them.
- Preserve these calls through QC/QCO conversion and OpenQASM export. Define
the supported QIR/jeff mappings and diagnose unsupported signatures instead
of accepting syntax that fails later without explanation.
Acceptance tests should cover scalar calls/returns, readonly access, caller-visible
mutation, rank-only parameters, slices, nested calls, and negative type, alias,
mutability, and lifetime cases. Existing custom gates and quantum subroutines
must retain their behavior.
Parent backlog: #1733. The array-reference portion depends on #2109. Coordinate
with #2429 for shared def syntax and call handling; its quantum-only contract
does not implement this feature. Array-valued outputs are tracked separately in
#2592 and are not required for borrowed array parameters. extern, recursion,
and array-valued function returns are not part of this issue.
Language reference: OpenQASM subroutines.
🤖 AI text below 🤖
Problem Statement
Classical OpenQASM
deffunctions and array-reference parameters remain outsidethe standalone array work in #2109. The existing #2429 covers only void
subroutines with quantum parameters and explicitly excludes classical parameters
and return values.
Without classical subroutines, programs cannot pass an angle table or update a
classical array through a reusable function.
Proposed Solution
Add classical subroutines and array-reference parameters as a coherent extension
of the frontend and shared function-call representation.
and calls to defined non-recursive functions.
readonly array[...]andmutable array[...]reference parameters,with explicit shape or the language's rank-only
#dimform.reject writes through readonly references. Do not copy an entire array merely
to pass it to a function.
restrictions, including overlapping mutable arguments. Include supported
array slices in the reference contract rather than silently flattening them.
the supported QIR/jeff mappings and diagnose unsupported signatures instead
of accepting syntax that fails later without explanation.
Acceptance tests should cover scalar calls/returns, readonly access, caller-visible
mutation, rank-only parameters, slices, nested calls, and negative type, alias,
mutability, and lifetime cases. Existing custom gates and quantum subroutines
must retain their behavior.
Parent backlog: #1733. The array-reference portion depends on #2109. Coordinate
with #2429 for shared
defsyntax and call handling; its quantum-only contractdoes not implement this feature. Array-valued outputs are tracked separately in
#2592 and are not required for borrowed array parameters.
extern, recursion,and array-valued function returns are not part of this issue.
Language reference: OpenQASM subroutines.