-
Notifications
You must be signed in to change notification settings - Fork 12.9k
/
Copy pathInterpreterPass.cpp
51 lines (43 loc) · 1.72 KB
/
InterpreterPass.cpp
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
46
47
48
49
50
51
//===- InterpreterPass.cpp - Transform dialect interpreter pass -----------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "mlir/Dialect/Transform/IR/TransformDialect.h"
#include "mlir/Dialect/Transform/Transforms/Passes.h"
#include "mlir/Dialect/Transform/Transforms/TransformInterpreterUtils.h"
using namespace mlir;
namespace mlir {
namespace transform {
#define GEN_PASS_DEF_INTERPRETERPASS
#include "mlir/Dialect/Transform/Transforms/Passes.h.inc"
} // namespace transform
} // namespace mlir
namespace {
class InterpreterPass
: public transform::impl::InterpreterPassBase<InterpreterPass> {
public:
using Base::Base;
LogicalResult initialize(MLIRContext *context) override {
// TODO: investigate using a resource blob if some ownership mode allows it.
transformModule = transform::detail::getPreloadedTransformModule(context);
return success();
}
void runOnOperation() override {
if (failed(transform::applyTransformNamedSequence(
getOperation(), transformModule,
options.enableExpensiveChecks(true), entryPoint)))
return signalPassFailure();
}
private:
/// Transform interpreter options.
transform::TransformOptions options;
/// The separate transform module to be used for transformations, shared
/// across multiple instances of the pass if it is applied in parallel to
/// avoid potentially expensive cloning. MUST NOT be modified after the pass
/// has been initialized.
ModuleOp transformModule;
};
} // namespace