Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QoL] Change ValueRange to ResultRange in gate_op's result getters #1192

Closed
paul0403 opened this issue Oct 8, 2024 · 2 comments
Closed

[QoL] Change ValueRange to ResultRange in gate_op's result getters #1192

paul0403 opened this issue Oct 8, 2024 · 2 comments
Assignees
Labels
compiler Pull requests that update the compiler enhancement New feature or request

Comments

@paul0403
Copy link
Contributor

paul0403 commented Oct 8, 2024

We have some convenience result/operand getters for gate operations, and currently they all return ValueRange.

Nothing is inherently wrong with this, but ResultRange has the replace methods built-in, and ValueRange does not.

To avoid manually casting or looping, we can change the result getters to return ResultRange directly, or provide an overloaded result getter.

@paul0403 paul0403 added enhancement New feature or request compiler Pull requests that update the compiler labels Oct 8, 2024
@dime10
Copy link
Contributor

dime10 commented Jan 6, 2025

The location the link is pointing to doesn't really make sense to me, but that might be because it's not a permalink. This (among other methods seems more sensible to me):

mlir::ValueRange getNonCtrlQubitResults() {

@paul0403
Copy link
Contributor Author

paul0403 commented Jan 7, 2025

Hi @sengthai , we can chat more when I get back, but just quickly, here is an example of a place where I needed to do a manual loop to replace uses of a[i] with b[i] for all i for two ValueRanges a, b.

Ideally, with ResultRange's built-in replacement methods, only the one-line a.replaceAllUsesWith(b) will be necessary!

sengthai added a commit that referenced this issue Jan 10, 2025
…1426)

**Context:**
This PR updates `gate_op` by replacing `ValueRange` with `ResultRange`
and `Value` with `OpResult` to better align with the semantics of
`**QubitResult()` functions like `getNonCtrlQubitResults()`. This change
ensures clearer intent and usage.

**Related GitHub Issues:**
#1192
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler Pull requests that update the compiler enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants