diff options
Diffstat (limited to 'mlir/lib/IR')
| -rw-r--r-- | mlir/lib/IR/Builders.cpp | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/mlir/lib/IR/Builders.cpp b/mlir/lib/IR/Builders.cpp index 4d6cd3550ca..8c54df4d55b 100644 --- a/mlir/lib/IR/Builders.cpp +++ b/mlir/lib/IR/Builders.cpp @@ -306,6 +306,13 @@ AffineMap Builder::getShiftedAffineMap(AffineMap map, int64_t shift) { OpBuilder::~OpBuilder() {} +/// Insert the given operation at the current insertion point and return it. +Operation *OpBuilder::insert(Operation *op) { + if (block) + block->getOperations().insert(insertPoint, op); + return op; +} + /// Add new block and set the insertion point to the end of it. The block is /// inserted at the provided insertion point of 'parent'. Block *OpBuilder::createBlock(Region *parent, Region::iterator insertPt) { @@ -328,10 +335,7 @@ Block *OpBuilder::createBlock(Block *insertBefore) { /// Create an operation given the fields represented as an OperationState. Operation *OpBuilder::createOperation(const OperationState &state) { - assert(block && "createOperation() called without setting builder's block"); - auto *op = Operation::create(state); - insert(op); - return op; + return insert(Operation::create(state)); } /// Attempts to fold the given operation and places new results within @@ -359,9 +363,3 @@ void OpBuilder::tryFold(Operation *op, SmallVectorImpl<Value *> &results) { [](OpFoldResult result) { return result.get<Value *>(); }); op->erase(); } - -/// Insert the given operation at the current insertion point. -void OpBuilder::insert(Operation *op) { - if (block) - block->getOperations().insert(insertPoint, op); -} |

