You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
And give the constant the same semantics except that it can't be assigned to. Even if adding an operation declare_constant is the right approach, some kind of refactoring rather than copying 50 lines verbatim should be done.
The text was updated successfully, but these errors were encountered:
I think extending the DeclareVariableOp to indicate whether a variable is a constant is cleaner than introducing a separate op for constant variables. In addition to the operation itself, we would also introduce (mostly) duplicate code in all scenarios that reference variables (be they constant or not).
Operations for variable assignment should have their MLIR verifier check that the target variable is not constant constant
The AST to MLIR generation step should check as well and provide an actionable diagnostic message.
QUIR should support
const
in statements like:const int[64] x = 2
.The QASM code
uint x = 1;
andconst uint x = 1;
emit the same mlir. Furthermore, in both cases,x
may be mutated.Suggestions
The information is available in the AST via
node->IsConst()
. So you would discrimination when processing the variable -declaration node herehttps://github.com/Qiskit/qss-compiler/blob/7180bf9a96b6109c0ff9491c15f8330f5a4ff7ef/lib/Frontend/OpenQASM3/QUIRVariableBuilder.cpp#L34-L36
by including another parameter
bool isConst
. And select eitherhttps://github.com/Qiskit/qss-compiler/blob/7180bf9a96b6109c0ff9491c15f8330f5a4ff7ef/lib/Frontend/OpenQASM3/QUIRVariableBuilder.cpp#L49
as now or
declareOp = builder.create<mlir::quir::DeclareConstantOp>
.Then copy/paste this
https://github.com/Qiskit/qss-compiler/blob/7180bf9a96b6109c0ff9491c15f8330f5a4ff7ef/include/Dialect/QUIR/IR/QUIROps.td#L137-L138
like this:
And give the constant the same semantics except that it can't be assigned to. Even if adding an operation
declare_constant
is the right approach, some kind of refactoring rather than copying 50 lines verbatim should be done.The text was updated successfully, but these errors were encountered: