qir-alliance / pyqir

PyQIR is a set of APIs for generating, parsing, and evaluating Quantum Intermediate Representation (QIR).
https://qir-alliance.github.io/pyqir
MIT License
57 stars 24 forks source link

Support functions with return values #138

Closed bamarsha closed 2 years ago

bamarsha commented 2 years ago

This PR adds support for calling external functions that have a return value, and using that return value as the argument to other external functions or rotation gates. It adds a variable case to PyQIR values. Variables are untyped (type errors will be caught only by LLVM).

bamarsha commented 2 years ago

There might be some churn on some of the things added in this PR with #140 (for example, I needed to make variables typed there), but that could change depending on how the review for #140 goes.

bamarsha commented 2 years ago

I removed Valuable and added explicit constructors for constant values. ResultRef is kind of an odd case. I want to remove it and absorb it into Value, but it's not a proper value when static result allocation is turned off because of the magic mapping. So I'll defer that to another PR.