qir-alliance / qir-spec

QIR specification defining how to represent quantum programs within the LLVM IR
Other
68 stars 19 forks source link

__quantum__rt__bigint_shift{left,right}: Consider adding details #29

Open kuzminrobin opened 2 years ago

kuzminrobin commented 2 years ago

The doc for __quantum__rt__bigint_shiftleft and __quantum__rt__bigint_shiftright says: "Returns the big integer arithmetically shifted .. by the (positive) integer amount of bits." The doc does not say what will happen if the amount of bits (the second parameter) is negative.

Consider making the second param an unsigned type (u8 can be sufficient), such that the questions, like the one above, do not arise.

Also the fragment "(positive) integer amount of bits" tells me that the amount of bits (the second parameter) can not be zero. At least in Russian-language mathematics the word "positive" means "greater than zero", and the concept of "zero or greater" is expressed with the words "non-negative". If the amount of bits (the second parameter): can be zero then consider replacing the fragment "(positive)" with "(non-negative)" or "(zero or greater)"; cannot be zero then consider replacing the fragment "(positive)" with "(greater than zero)".

swernli commented 2 years ago

Unfortunately there is no unsigned type in LLVM, since integers are just bits that are treated as signed or unsigned by the operation they are passed to. As such, there is no u8 type and instead it would be up to the documentation on the function to specify that the integer is interpreted as unsigned.