[Mlir-commits] [mlir] 63b7e1e - [mlir] Remove EDSC NestedBuilder
Alex Zinenko
llvmlistbot at llvm.org
Fri Jun 19 00:38:10 PDT 2020
Author: Alex Zinenko
Date: 2020-06-19T09:37:56+02:00
New Revision: 63b7e1e4744513bd319583e920c2436a251e1127
URL: https://github.com/llvm/llvm-project/commit/63b7e1e4744513bd319583e920c2436a251e1127
DIFF: https://github.com/llvm/llvm-project/commit/63b7e1e4744513bd319583e920c2436a251e1127.diff
LOG: [mlir] Remove EDSC NestedBuilder
All class derived from `edsc::NestedBuilder` in core MLIR have been replaced
with alternatives based on OpBuilder+callbacks. The *Builder EDSC
infrastructure has been deprecated. Remove edsc::NestedBuilder.
This completes the "structured builders" refactoring.
Differential Revision: https://reviews.llvm.org/D82128
Added:
Modified:
mlir/include/mlir/EDSC/Builders.h
Removed:
################################################################################
diff --git a/mlir/include/mlir/EDSC/Builders.h b/mlir/include/mlir/EDSC/Builders.h
index 54299f0d5041..a7c5506f7ab0 100644
--- a/mlir/include/mlir/EDSC/Builders.h
+++ b/mlir/include/mlir/EDSC/Builders.h
@@ -23,8 +23,6 @@ namespace mlir {
class OperationFolder;
namespace edsc {
-class NestedBuilder;
-
/// Helper class to transparently handle builder insertion points by RAII.
/// As its name indicates, a ScopedContext is means to be used locally in a
/// scoped fashion. This abstracts away all the boilerplate related to
@@ -90,62 +88,6 @@ struct OperationBuilder {
Op op;
};
-/// A NestedBuilder is a scoping abstraction to create an idiomatic syntax
-/// embedded in C++ that serves the purpose of building nested MLIR.
-/// Nesting and compositionality is obtained by using the strict ordering that
-/// exists between object construction and method invocation on said object (in
-/// our case, the call to `operator()`).
-/// This ordering allows implementing an abstraction that decouples definition
-/// from declaration (in a PL sense) on placeholders.
-class NestedBuilder {
-protected:
- NestedBuilder() = default;
- NestedBuilder(const NestedBuilder &) = delete;
- NestedBuilder(NestedBuilder &&other) : bodyScope(other.bodyScope) {
- other.bodyScope = nullptr;
- }
-
- NestedBuilder &operator=(const NestedBuilder &) = delete;
- NestedBuilder &operator=(NestedBuilder &&other) {
- std::swap(bodyScope, other.bodyScope);
- return *this;
- }
-
- /// Enter an mlir::Block and setup a ScopedContext to insert operations at
- /// the end of it. Since we cannot use c++ language-level scoping to implement
- /// scoping itself, we use enter/exit pairs of operations.
- /// As a consequence we must allocate a new OpBuilder + ScopedContext and
- /// let the escape.
- void enter(mlir::Block *block) {
- bodyScope = new ScopedContext(ScopedContext::getBuilderRef(),
- OpBuilder::InsertPoint(block, block->end()),
- ScopedContext::getLocation());
- if (!block->empty()) {
- auto &termOp = block->back();
- if (termOp.isKnownTerminator())
- ScopedContext::getBuilderRef().setInsertionPoint(&termOp);
- }
- }
-
- /// Exit the current mlir::Block by explicitly deleting the dynamically
- /// allocated OpBuilder and ScopedContext.
- void exit() {
- delete bodyScope;
- bodyScope = nullptr;
- }
-
- /// Custom destructor does nothing because we already destroyed bodyScope
- /// manually in `exit`. Insert an assertion to defensively guard against
- /// improper usage of scoping.
- ~NestedBuilder() {
- assert(!bodyScope &&
- "Illegal use of NestedBuilder; must have called exit()");
- }
-
-private:
- ScopedContext *bodyScope = nullptr;
-};
-
/// Creates a block in the region that contains the insertion block of the
/// OpBuilder currently at the top of ScopedContext stack (appends the block to
/// the region). Be aware that this will NOT update the insertion point of the
More information about the Mlir-commits
mailing list