forked from NVIDIA/cuda-quantum
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLoopNormalize.cpp
More file actions
45 lines (38 loc) · 1.57 KB
/
Copy pathLoopNormalize.cpp
File metadata and controls
45 lines (38 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*******************************************************************************
* Copyright (c) 2022 - 2026 NVIDIA Corporation & Affiliates. *
* All rights reserved. *
* *
* This source code and the accompanying materials are made available under *
* the terms of the Apache License 2.0 which accompanies this distribution. *
******************************************************************************/
#include "LoopAnalysis.h"
#include "PassDetails.h"
#include "cudaq/Optimizer/Dialect/CC/CCOps.h"
#include "cudaq/Optimizer/Transforms/Passes.h"
#include "mlir/IR/IRMapping.h"
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
#include "mlir/Transforms/Passes.h"
namespace cudaq::opt {
#define GEN_PASS_DEF_LOOPNORMALIZE
#include "cudaq/Optimizer/Transforms/Passes.h.inc"
} // namespace cudaq::opt
#define DEBUG_TYPE "cc-loop-normalize"
using namespace mlir;
#include "LoopNormalizePatterns.inc"
namespace {
class LoopNormalizePass
: public cudaq::opt::impl::LoopNormalizeBase<LoopNormalizePass> {
public:
using LoopNormalizeBase::LoopNormalizeBase;
void runOnOperation() override {
auto *op = getOperation();
auto *ctx = &getContext();
RewritePatternSet patterns(ctx);
patterns.insert<LoopPat>(ctx, allowClosedInterval, allowBreak);
if (failed(applyPatternsGreedily(op, std::move(patterns)))) {
op->emitOpError("could not normalize loop");
signalPassFailure();
}
}
};
} // namespace