I've added rules to parse "~" symbol in qe-qasm: https://github.com/openqasm/qe-qasm/pull/29, at the side of qe-compiler, we need to generate a MLIR op for ASTOpTypeBitNot in lib/Frontend/OpenQASM3/QUIRGenQASM3Visitor.cpp.
After searching, I find that MLIR does not have arith operations directly related to "BitNot". In the context of OQ3, I believe "~cbit" and "!cbit" are equivalent in a "if" condition? So I just simply reused the processing logic of ASTOpTypeLogicalNot, which checks whether the target is a I1Type and also works for ASTOpTypeBitNot operation. It will also create an CmpIPredicate::ne operation.
Willing to update my pr if you have better solutions
Thanks,
Yilun
Changes
Update the commit id of qe-qasm project
Reuse the processing logic of ASTOpTypeLogicalNot for ASTOpTypeBitNot.
Hi Team,
I've added rules to parse "~" symbol in qe-qasm: https://github.com/openqasm/qe-qasm/pull/29, at the side of qe-compiler, we need to generate a MLIR op for
ASTOpTypeBitNot
inlib/Frontend/OpenQASM3/QUIRGenQASM3Visitor.cpp
.After searching, I find that MLIR does not have arith operations directly related to "BitNot". In the context of OQ3, I believe "~cbit" and "!cbit" are equivalent in a "if" condition? So I just simply reused the processing logic of
ASTOpTypeLogicalNot
, which checks whether the target is aI1Type
and also works forASTOpTypeBitNot
operation. It will also create anCmpIPredicate::ne
operation.Willing to update my pr if you have better solutions
Thanks, Yilun
Changes
ASTOpTypeLogicalNot
forASTOpTypeBitNot
.Sample
Given the following source file
The compiler generates following MLIR