MLIR 22.0.0git
PassDetail.cpp
Go to the documentation of this file.
1//===- PassDetail.cpp - Async Pass class details ----------------*- C++ -*-===//
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-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "PassDetail.h"
10#include "mlir/IR/Builders.h"
12
13using namespace mlir;
14
16 OpBuilder builder(&region);
17 cloneConstantsIntoTheRegion(region, builder);
18}
19
21 OpBuilder &builder) {
22 // Values implicitly captured by the region.
24 getUsedValuesDefinedAbove(region, region, captures);
25
26 OpBuilder::InsertionGuard guard(builder);
27 builder.setInsertionPointToStart(&region.front());
28
29 // Clone ConstantLike operations into the region.
30 for (Value capture : captures) {
31 Operation *op = capture.getDefiningOp();
32 if (!op || !op->hasTrait<OpTrait::ConstantLike>())
33 continue;
34
35 Operation *cloned = builder.clone(*op);
36
37 for (auto tuple : llvm::zip(op->getResults(), cloned->getResults())) {
38 Value orig = std::get<0>(tuple);
39 Value replacement = std::get<1>(tuple);
41 }
42 }
43}
*if copies could not be generated due to yet unimplemented cases *copyInPlacementStart and copyOutPlacementStart in copyPlacementBlock *specify the insertion points where the incoming copies and outgoing should be the output argument nBegin is set to its * replacement(set to `begin` if no invalidation happens). Since outgoing *copies could have been inserted at `end`
RAII guard to reset the insertion point of the builder when destroyed.
Definition Builders.h:348
This class helps build Operations.
Definition Builders.h:207
Operation * clone(Operation &op, IRMapping &mapper)
Creates a deep copy of the specified operation, remapping any operands that use values outside of the...
Definition Builders.cpp:562
void setInsertionPointToStart(Block *block)
Sets the insertion point to the start of the specified block.
Definition Builders.h:431
This class provides the API for a sub-set of ops that are known to be constant-like.
Operation is the basic unit of execution within MLIR.
Definition Operation.h:88
bool hasTrait()
Returns true if the operation was registered with a particular trait, e.g.
Definition Operation.h:749
result_range getResults()
Definition Operation.h:415
This class contains a list of basic blocks and a link to the parent operation it is attached to.
Definition Region.h:26
Block & front()
Definition Region.h:65
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Definition Value.h:96
void cloneConstantsIntoTheRegion(Region &region)
Clone ConstantLike operations that are defined above the given region and have users in the region in...
Include the generated interface declarations.
void replaceAllUsesInRegionWith(Value orig, Value replacement, Region &region)
Replace all uses of orig within the given region with replacement.
void getUsedValuesDefinedAbove(Region &region, Region &limit, SetVector< Value > &values)
Fill values with a list of values defined at the ancestors of the limit region and used within region...