1212
1313#include " ir/Definitions.hpp"
1414#include " ir/operations/OpType.hpp"
15- #include " mlir/Dialect/MQTOpt /IR/MQTOptDialect .h"
15+ #include " mlir/Dialect/QCO /IR/QCODialect .h"
1616
1717#include < Eigen/Core> // NOLINT(misc-include-cleaner)
1818#include < Eigen/Eigenvalues> // NOLINT(misc-include-cleaner)
3030#include < string>
3131#include < unsupported/Eigen/KroneckerProduct> // TODO: unstable, NOLINT(misc-include-cleaner)
3232
33- namespace mqt ::ir::opt {
33+ namespace mlir ::qco {
3434using fp = qc::fp;
3535using qfp = std::complex <fp>;
3636// NOLINTBEGIN(misc-include-cleaner)
@@ -47,9 +47,9 @@ constexpr qfp C_M_ONE{-1., 0.};
4747constexpr qfp IM {0 ., 1 .};
4848constexpr qfp M_IM {0 ., -1 .};
4949
50- } // namespace mqt::ir::opt
50+ } // namespace mlir::qco
5151
52- namespace mqt ::ir::opt ::helpers {
52+ namespace mlir ::qco ::helpers {
5353
5454std::optional<fp> mlirValueToFp (mlir::Value value);
5555
@@ -136,17 +136,17 @@ template <typename T, typename Func>
136136}
137137
138138[[nodiscard]] inline llvm::SmallVector<fp, 3 >
139- getParameters (UnitaryInterface op) {
139+ getParameters (UnitaryOpInterface op) {
140140 llvm::SmallVector<fp, 3 > parameters;
141- for (auto && param : op.getParams () ) {
142- if (auto value = helpers::mlirValueToFp (param )) {
141+ for (std:: size_t i = 0 ; i < op.getNumParams (); ++i ) {
142+ if (auto value = helpers::mlirValueToFp (op. getParameter (i) )) {
143143 parameters.push_back (*value);
144144 }
145145 }
146146 return parameters;
147147}
148148
149- [[nodiscard]] inline qc::OpType getQcType (UnitaryInterface op) {
149+ [[nodiscard]] inline qc::OpType getQcType (UnitaryOpInterface op) {
150150 try {
151151 const std::string type = op->getName ().stripDialect ().str ();
152152 return qc::opTypeFromString (type);
@@ -155,27 +155,12 @@ getParameters(UnitaryInterface op) {
155155 }
156156}
157157
158- [[nodiscard]] inline bool isSingleQubitOperation (UnitaryInterface op) {
159- auto && inQubits = op.getInQubits ();
160- auto && outQubits = op.getOutQubits ();
161- const bool isSingleQubitOp =
162- inQubits.size () == 1 && outQubits.size () == 1 && !op.isControlled ();
163- return isSingleQubitOp;
158+ [[nodiscard]] inline bool isSingleQubitOperation (UnitaryOpInterface op) {
159+ return op.isSingleQubit ();
164160}
165161
166- [[nodiscard]] inline bool isTwoQubitOperation (UnitaryInterface op) {
167- auto && inQubits = op.getInQubits ();
168- auto && inPosCtrlQubits = op.getPosCtrlInQubits ();
169- auto && inNegCtrlQubits = op.getNegCtrlInQubits ();
170- auto inQubitSize =
171- inQubits.size () + inPosCtrlQubits.size () + inNegCtrlQubits.size ();
172- auto && outQubits = op.getOutQubits ();
173- auto && outPosCtrlQubits = op.getPosCtrlOutQubits ();
174- auto && outNegCtrlQubits = op.getNegCtrlOutQubits ();
175- auto outQubitSize =
176- outQubits.size () + outPosCtrlQubits.size () + outNegCtrlQubits.size ();
177- const bool isTwoQubitOp = inQubitSize == 2 && outQubitSize == 2 ;
178- return isTwoQubitOp;
162+ [[nodiscard]] inline bool isTwoQubitOperation (UnitaryOpInterface op) {
163+ return op.isTwoQubit ();
179164}
180165
181166// NOLINTBEGIN(misc-include-cleaner)
@@ -235,4 +220,4 @@ template <typename T, int N, int M>
235220 return 1 ;
236221}
237222
238- } // namespace mqt::ir::opt ::helpers
223+ } // namespace mlir::qco ::helpers
0 commit comments