In order to lower to OpenQASM 3, which is most representative of real hardware today, we need to guarantee that all QWERTY functions (at least excluding classical control flow) will be inlined into straightline code. While the language itself does not offer a way to construct such programs, the MLIR verifier does not reject all IR that we know that blocks inlining:
module {
qwerty.func @kernel_0[]() irrev-> !qwerty<bitbundle[1]> {
%0 = qwerty.qbprep Z<MINUS>[1] : () -> !qwerty<qbundle[1]>
%1 = qwerty.call @tweedledee_1(%0) : (!qwerty<qbundle[1]>) -> !qwerty<bitbundle[1]>
qwerty.return %1 : !qwerty<bitbundle[1]>
}
qwerty.func @tweedledee_1[](%arg0: !qwerty<qbundle[1]>) irrev-> !qwerty<bitbundle[1]> {
%0 = qwerty.call @tweedledum_2(%arg0) : (!qwerty<qbundle[1]>) -> !qwerty<bitbundle[1]>
qwerty.return %0 : !qwerty<bitbundle[1]>
}
qwerty.func @tweedledum_2[](%arg0: !qwerty<qbundle[1]>) irrev-> !qwerty<bitbundle[1]> {
%0 = qwerty.call @tweedledee_1(%arg0) : (!qwerty<qbundle[1]>) -> !qwerty<bitbundle[1]>
qwerty.return %0 : !qwerty<bitbundle[1]>
}
}
The verifier admits this IR. When run with the inline pass, both calls to tweedledee_1 are replaced with calls to tweedledum_2. Additionally, the symbol_dce pass does nothing after this despite tweedledee_1 being dead code.
In order to lower to OpenQASM 3, which is most representative of real hardware today, we need to guarantee that all QWERTY functions (at least excluding classical control flow) will be inlined into straightline code. While the language itself does not offer a way to construct such programs, the MLIR verifier does not reject all IR that we know that blocks inlining:
The verifier admits this IR. When run with the
inlinepass, both calls totweedledee_1are replaced with calls totweedledum_2. Additionally, thesymbol_dcepass does nothing after this despitetweedledee_1being dead code.