brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · 1273414 Raw
58 lines · cpp
1//===- TestTransformDialectInterpreter.cpp --------------------------------===//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 defines a test pass that interprets Transform dialect operations in10// the module.11//12//===----------------------------------------------------------------------===//13 14#include "mlir/Dialect/Transform/Interfaces/TransformInterfaces.h"15#include "mlir/IR/BuiltinOps.h"16#include "mlir/Pass/Pass.h"17 18using namespace mlir;19 20namespace {21template <typename Derived>22class OpPassWrapper : public PassWrapper<Derived, OperationPass<>> {};23 24struct TestTransformDialectEraseSchedulePass25    : public PassWrapper<TestTransformDialectEraseSchedulePass,26                         OperationPass<ModuleOp>> {27  MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(28      TestTransformDialectEraseSchedulePass)29 30  StringRef getArgument() const final {31    return "test-transform-dialect-erase-schedule";32  }33 34  StringRef getDescription() const final {35    return "erase transform dialect schedule from the IR";36  }37 38  void runOnOperation() override {39    getOperation()->walk<WalkOrder::PreOrder>([&](Operation *nestedOp) {40      if (isa<transform::TransformOpInterface>(nestedOp)) {41        nestedOp->erase();42        return WalkResult::skip();43      }44      return WalkResult::advance();45    });46  }47};48} // namespace49 50namespace mlir {51namespace test {52/// Registers the test pass for erasing transform dialect ops.53void registerTestTransformDialectEraseSchedulePass() {54  PassRegistration<TestTransformDialectEraseSchedulePass> reg;55}56} // namespace test57} // namespace mlir58