microsoft / qsharp-language

Official repository for design of the quantum programming language Q# and its core libraries
MIT License
233 stars 54 forks source link

QIR spec: `Range` type should not be passed by value #108

Open swernli opened 2 years ago

swernli commented 2 years ago

The QIR spec specifically calls out the Range struct as passed by value, as seen here: https://github.com/microsoft/qsharp-language/blob/9cb9b91a49341d691c4fdc7d3f464453cc8eae36/Specifications/QIR/Data-Types.md#simple-types This makes implementation difficult as other LLVM languages, notable C, C++, and Rust, do not have a mechanism to achieve that, requiring a forwarding function to written in raw LLVM that can allocate memory, copy the struct, and then pass the struct as a pointer to the underlying implementation. If this line is change to instead indicate that the struct is passed by pointer, then it will line up with the way struct passing is translated in C, C++, and Rust and make direct implementation of the QIR functions that use Range possible where today they are not.

@alan-geller @bettinaheim @kuzminrobin FYI