MLIR Passes v1.0
Loading...
Searching...
No Matches
Quake.hpp
Go to the documentation of this file.
1/* This code and any associated documentation is provided "as is"
2
3Copyright 2025 Munich Quantum Software Stack Project
4
5Licensed under the Apache License, Version 2.0 with LLVM Exceptions (the
6"License"); you may not use this file except in compliance with the License.
7You may obtain a copy of the License at
8
9https://github.com/Munich-Quantum-Software-Stack/passes/blob/develop/LICENSE
10
11Unless required by applicable law or agreed to in writing, software
12distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14License for the specific language governing permissions and limitations under
15the License.
16
17SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
18********************************************************************************
19 author Martin Letras
20 date May 2025
21 version 1.0
22********************************************************************************/
34#pragma once
35
36#include "cudaq/Optimizer/Dialect/Quake/QuakeDialect.h"
37#include "cudaq/Optimizer/Dialect/Quake/QuakeOps.h"
38#include "cudaq/Support/Plugin.h"
39#include "mlir/Dialect/SCF/IR/SCF.h"
40#include "mlir/Rewrite/FrozenRewritePatternSet.h"
41#include "mlir/Transforms/DialectConversion.h"
42
43#include "llvm/Support/Casting.h"
44#include "llvm/Support/raw_ostream.h"
45
46using namespace mlir;
47
48namespace mqss::support::quakeDialect {
49
60Value createFloatValue(OpBuilder &builder, Location loc, double value);
61
62// TODO: return -1 is not good idea
70double extractDoubleArgumentValue(Operation *op);
71// TODO: return -1 is not good idea
79int64_t extractIndexFromQuakeExtractRefOp(Operation *op);
80
89int getNumberOfQubits(func::FuncOp circuit);
90
103int getNumberOfClassicalBits(func::FuncOp circuit,
104 std::map<int, int> &measurements);
105
115int getNumberOfClassicalBits(func::FuncOp circuit);
116
125std::vector<int> getIndicesOfValueRange(mlir::ValueRange array);
126
136std::vector<double> getParametersValues(mlir::ValueRange array);
137
147mlir::Operation *getPreviousOperationOnTarget(mlir::Operation *currentOp,
148 mlir::Value targetQubit);
149
159mlir::Operation *getNextOperationOnTarget(mlir::Operation *currentOp,
160 mlir::Value targetQubit);
161} // namespace mqss::support::quakeDialect
162
163namespace supportQuake = mqss::support::quakeDialect;
std::vector< double > getParametersValues(mlir::ValueRange array)
Function that get a vector of numerical values associated with a given mlir::ValueRange.
int getNumberOfClassicalBits(func::FuncOp circuit, std::map< int, int > &measurements)
Function that get the number of classical bits used by a given quantum kernel.
double extractDoubleArgumentValue(Operation *op)
Function that extracts a double numeric value from a numeric value in an MLIR module.
mlir::Operation * getNextOperationOnTarget(mlir::Operation *currentOp, mlir::Value targetQubit)
Function get the next operation on a given target qubit.
mlir::Operation * getPreviousOperationOnTarget(mlir::Operation *currentOp, mlir::Value targetQubit)
Function get the previous operation on a given target qubit.
std::vector< int > getIndicesOfValueRange(mlir::ValueRange array)
Function that get a vector of indices associated with a given mlir::ValueRange.
Value createFloatValue(OpBuilder &builder, Location loc, double value)
Function that creates an mlir::Value associated to a numeric value.
int64_t extractIndexFromQuakeExtractRefOp(Operation *op)
Function that extracts an index of a given ExtractRefOp operation.
int getNumberOfQubits(func::FuncOp circuit)
Function that get the number of qubits used by a given quantum kernel.