2020-05-07 09:41:54 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// 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 "npcomp/Conversion/TCFToTCP/TCFToTCP.h"
|
|
|
|
|
|
|
|
#include "../PassDetail.h"
|
|
|
|
#include "mlir/Dialect/Shape/IR/Shape.h"
|
2020-09-18 09:56:01 +08:00
|
|
|
#include "mlir/Dialect/StandardOps/IR/Ops.h"
|
2020-05-07 09:41:54 +08:00
|
|
|
#include "mlir/Dialect/Traits.h"
|
|
|
|
#include "mlir/Transforms/DialectConversion.h"
|
2020-10-30 06:25:55 +08:00
|
|
|
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
|
2020-05-07 09:41:54 +08:00
|
|
|
#include "npcomp/Dialect/TCF/IR/TCFOps.h"
|
2020-09-09 23:12:52 +08:00
|
|
|
#include "npcomp/Dialect/TCP/IR/TCPDialect.h"
|
2020-05-07 09:41:54 +08:00
|
|
|
#include "npcomp/Dialect/TCP/IR/TCPOps.h"
|
|
|
|
|
|
|
|
using namespace mlir;
|
|
|
|
using namespace mlir::NPCOMP;
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
class ConvertTCFToTCP : public ConvertTCFToTCPBase<ConvertTCFToTCP> {
|
|
|
|
public:
|
2020-09-09 23:12:52 +08:00
|
|
|
void getDependentDialects(DialectRegistry ®istry) const override {
|
2020-09-16 08:54:58 +08:00
|
|
|
registry.insert<shape::ShapeDialect, tcp::TCPDialect>();
|
2020-09-09 23:12:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void runOnOperation() override {
|
2020-11-14 07:34:24 +08:00
|
|
|
(void)applyPatternsAndFoldGreedily(getOperation(), getPatterns());
|
2020-10-30 06:25:55 +08:00
|
|
|
}
|
2020-05-07 09:41:54 +08:00
|
|
|
|
2021-04-28 04:05:06 +08:00
|
|
|
FrozenRewritePatternSet getPatterns() {
|
2020-11-10 07:49:22 +08:00
|
|
|
// NOTE: We are keeping this pass around, even though it currently does
|
|
|
|
// nothing, in order to avoid having to reintroduce the same
|
|
|
|
// boilerplate.
|
2021-03-24 05:16:23 +08:00
|
|
|
RewritePatternSet patterns(getOperation().getContext());
|
2020-10-30 06:25:55 +08:00
|
|
|
return std::move(patterns);
|
2020-05-07 09:41:54 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
} // namespace
|
|
|
|
|
2020-11-14 07:34:24 +08:00
|
|
|
std::unique_ptr<OperationPass<FuncOp>>
|
2020-05-07 09:41:54 +08:00
|
|
|
mlir::NPCOMP::createConvertTCFToTCPPass() {
|
|
|
|
return std::make_unique<ConvertTCFToTCP>();
|
|
|
|
}
|