2019-03-11 06:44:47 +08:00
|
|
|
//===- PassDetail.h - MLIR Pass details -------------------------*- C++ -*-===//
|
|
|
|
//
|
2020-01-26 11:58:30 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
2019-12-24 01:35:36 +08:00
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2019-03-11 06:44:47 +08:00
|
|
|
//
|
2019-12-24 01:35:36 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2019-03-11 06:44:47 +08:00
|
|
|
#ifndef MLIR_PASS_PASSDETAIL_H_
|
|
|
|
#define MLIR_PASS_PASSDETAIL_H_
|
|
|
|
|
|
|
|
#include "mlir/Pass/Pass.h"
|
2019-09-10 00:51:59 +08:00
|
|
|
#include "mlir/Pass/PassManager.h"
|
2019-03-11 06:44:47 +08:00
|
|
|
|
|
|
|
namespace mlir {
|
|
|
|
namespace detail {
|
|
|
|
|
2019-07-13 02:20:09 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2019-09-03 10:24:47 +08:00
|
|
|
// Verifier Pass
|
2019-07-13 02:20:09 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2019-09-03 10:24:47 +08:00
|
|
|
/// Pass to verify an operation and signal failure if necessary.
|
2020-04-08 04:56:16 +08:00
|
|
|
class VerifierPass : public PassWrapper<VerifierPass, OperationPass<>> {
|
2019-09-03 10:24:47 +08:00
|
|
|
void runOnOperation() override;
|
2019-07-13 02:20:09 +08:00
|
|
|
};
|
|
|
|
|
2019-03-11 06:44:47 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2019-09-03 10:24:47 +08:00
|
|
|
// OpToOpPassAdaptor
|
2019-03-11 06:44:47 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2020-04-30 06:08:05 +08:00
|
|
|
/// An adaptor pass used to run operation passes over nested operations.
|
2020-04-08 04:56:16 +08:00
|
|
|
class OpToOpPassAdaptor
|
2020-04-30 06:08:05 +08:00
|
|
|
: public PassWrapper<OpToOpPassAdaptor, OperationPass<>> {
|
2019-03-11 06:44:47 +08:00
|
|
|
public:
|
2019-09-10 00:51:59 +08:00
|
|
|
OpToOpPassAdaptor(OpPassManager &&mgr);
|
2020-04-30 06:08:05 +08:00
|
|
|
OpToOpPassAdaptor(const OpToOpPassAdaptor &rhs) = default;
|
2019-03-11 06:44:47 +08:00
|
|
|
|
2019-09-03 10:24:47 +08:00
|
|
|
/// Run the held pipeline over all operations.
|
|
|
|
void runOnOperation() override;
|
2019-03-11 06:44:47 +08:00
|
|
|
|
2020-04-30 06:08:05 +08:00
|
|
|
/// Merge the current pass adaptor into given 'rhs'.
|
|
|
|
void mergeInto(OpToOpPassAdaptor &rhs);
|
2019-03-27 12:15:54 +08:00
|
|
|
|
2020-04-30 06:08:05 +08:00
|
|
|
/// Returns the pass managers held by this adaptor.
|
|
|
|
MutableArrayRef<OpPassManager> getPassManagers() { return mgrs; }
|
2019-03-11 06:44:47 +08:00
|
|
|
|
2019-12-06 03:52:58 +08:00
|
|
|
/// Return the async pass managers held by this parallel adaptor.
|
|
|
|
MutableArrayRef<SmallVector<OpPassManager, 1>> getParallelPassManagers() {
|
|
|
|
return asyncExecutors;
|
|
|
|
}
|
|
|
|
|
2020-04-30 06:08:05 +08:00
|
|
|
/// Returns the adaptor pass name.
|
|
|
|
std::string getAdaptorName();
|
|
|
|
|
2019-03-11 06:44:47 +08:00
|
|
|
private:
|
2020-04-30 06:08:05 +08:00
|
|
|
/// Run this pass adaptor synchronously.
|
|
|
|
void runOnOperationImpl();
|
|
|
|
|
|
|
|
/// Run this pass adaptor asynchronously.
|
|
|
|
void runOnOperationAsyncImpl();
|
2019-03-11 06:44:47 +08:00
|
|
|
|
2020-04-30 06:08:05 +08:00
|
|
|
/// A set of adaptors to run.
|
|
|
|
SmallVector<OpPassManager, 1> mgrs;
|
2019-09-10 00:51:59 +08:00
|
|
|
|
2020-04-30 06:08:05 +08:00
|
|
|
/// A set of executors, cloned from the main executor, that run asynchronously
|
|
|
|
/// on different threads. This is used when threading is enabled.
|
|
|
|
SmallVector<SmallVector<OpPassManager, 1>, 8> asyncExecutors;
|
|
|
|
};
|
2019-03-27 12:15:54 +08:00
|
|
|
|
2019-03-11 06:44:47 +08:00
|
|
|
} // end namespace detail
|
|
|
|
} // end namespace mlir
|
|
|
|
#endif // MLIR_PASS_PASSDETAIL_H_
|