MLIR  19.0.0git
GenerateRuntimeVerification.cpp
Go to the documentation of this file.
1 //===- RuntimeOpVerification.cpp - Op Verification ------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
10 
11 #include "mlir/IR/Builders.h"
12 #include "mlir/IR/Operation.h"
14 
15 namespace mlir {
16 #define GEN_PASS_DEF_GENERATERUNTIMEVERIFICATION
17 #include "mlir/Transforms/Passes.h.inc"
18 } // namespace mlir
19 
20 using namespace mlir;
21 
22 namespace {
23 struct GenerateRuntimeVerificationPass
24  : public impl::GenerateRuntimeVerificationBase<
25  GenerateRuntimeVerificationPass> {
26  void runOnOperation() override;
27 };
28 } // namespace
29 
30 void GenerateRuntimeVerificationPass::runOnOperation() {
31  getOperation()->walk([&](RuntimeVerifiableOpInterface verifiableOp) {
32  OpBuilder builder(getOperation()->getContext());
33  builder.setInsertionPoint(verifiableOp);
34  verifiableOp.generateRuntimeVerification(builder, verifiableOp.getLoc());
35  });
36 }
37 
39  return std::make_unique<GenerateRuntimeVerificationPass>();
40 }
static MLIRContext * getContext(OpFoldResult val)
This class helps build Operations.
Definition: Builders.h:209
Include the generated interface declarations.
std::unique_ptr< Pass > createGenerateRuntimeVerificationPass()
Creates a pass that generates IR to verify ops at runtime.