qsharp-runtime
qsharp-runtime copied to clipboard
Functions in Microsoft.Quantum.Bitwise should be marked as inline and implemented via operators
The functions in Microsoft.Quantum.Bitwise are currently body intrinsic
meaning they rely on an external implementation. However, Q# supports the bitwise operators as part of the language now, so these should be marked with the inline attribute and implemented via those operators.
See https://github.com/microsoft/qsharp-runtime/blob/main/src/Simulation/QSharpFoundation/Bitwise/Bitwise.qs#L21 for example.
Do you mean an @Inline()
attribute in Q#? I don't think Q# has one of those.
Ah, I might be getting ahead of myself then. Maybe we can leave the desire to inline them as a comment in the new implementations?
I think the most common scenario for the operator functions is to use with HOFs, in which case I'm not sure that inlining would be possible - you would need some function value to pass to something expecting a function type.
@swernli @samarsha The QIR emission makes use of an Inline attribute in addition to the TargetIntrinsic attribute. We need to add both of these to the runtime in any case, so we should attach the inline attribute where it makes sense (right now the compiler has no heurtistics for determining when to inline automatically; it inlines only if the attribute is present).
I believe this was resolved by #497. @bettinaheim should we keep this issue open to track adding the Inline attribute to bitwise functions, or is it worth closing this and opening a separate issue to add Inline attributes more broadly across the runtime?