brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.0 KiB · 5ca2d1a Raw
80 lines · cpp
1//===------ TestRemarkPipeline.cpp --- dynamic pipeline test pass --------===//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-exception6//7//===----------------------------------------------------------------------===//8//9// This file implements a pass to test the dynamic pipeline feature.10//11//===----------------------------------------------------------------------===//12 13#include "mlir/IR/BuiltinOps.h"14#include "mlir/IR/Location.h"15#include "mlir/IR/Remarks.h"16#include "mlir/Pass/Pass.h"17#include "mlir/Pass/PassManager.h"18#include "mlir/Support/WalkResult.h"19 20using namespace mlir;21 22namespace {23 24class TestRemarkPass : public PassWrapper<TestRemarkPass, OperationPass<>> {25public:26  MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestRemarkPass)27 28  StringRef getArgument() const final { return "test-remark"; }29  StringRef getDescription() const final {30    return "Tests the remark pipeline feature";31  }32 33  TestRemarkPass() = default;34 35  void runOnOperation() override {36 37    getOperation()->walk([](Operation *op) {38      if (isa<ModuleOp>(op))39        return WalkResult::advance();40      Location loc = op->getLoc();41      mlir::remark::missed(loc, remark::RemarkOpts::name("test-remark")42                                    .category("a-category-1-missed"))43          << remark::add("This is a test missed remark")44          << remark::reason("because we are testing the remark pipeline")45          << remark::suggest("try using the remark pipeline feature");46      mlir::remark::passed(47          loc,48          remark::RemarkOpts::name("test-remark").category("category-1-passed"))49          << remark::add("This is a test passed remark (should be dropped)")50          << remark::reason("because we are testing the remark pipeline")51          << remark::suggest("try using the remark pipeline feature");52      mlir::remark::passed(53          loc,54          remark::RemarkOpts::name("test-remark").category("category-1-passed"))55          << remark::add("This is a test passed remark")56          << remark::reason("because we are testing the remark pipeline")57          << remark::suggest("try using the remark pipeline feature");58 59      mlir::remark::failed(60          loc,61          remark::RemarkOpts::name("test-remark").category("category-2-failed"))62          << remark::add("This is a test failed remark")63          << remark::reason("because we are testing the remark pipeline")64          << remark::suggest("try using the remark pipeline feature");65 66      mlir::remark::analysis(loc, remark::RemarkOpts::name("test-remark")67                                      .category("category-2-analysis"))68          << remark::add("This is a test analysis remark");69      return WalkResult::advance();70    });71  }72};73} // namespace74 75namespace mlir {76namespace test {77void registerTestRemarkPass() { PassRegistration<TestRemarkPass>(); }78} // namespace test79} // namespace mlir80