30 SmallVectorImpl<Value> &output);
41 SmallVectorImpl<Value> &output) {
46 auto getOperandIndexIfPred =
49 branch.getSuccessorRegions(predIndex, successors);
51 if (successor.getSuccessor() != region)
54 ValueRange inputs = successor.getSuccessorInputs();
56 output.push_back(inputValue);
59 unsigned firstInputIndex, lastInputIndex;
61 firstInputIndex = inputs[0].cast<
BlockArgument>().getArgNumber();
62 lastInputIndex = inputs.back().cast<
BlockArgument>().getArgNumber();
64 firstInputIndex = inputs[0].cast<
OpResult>().getResultNumber();
65 lastInputIndex = inputs.back().cast<
OpResult>().getResultNumber();
67 if (firstInputIndex > inputIndex || lastInputIndex < inputIndex) {
68 output.push_back(inputValue);
71 return inputIndex - firstInputIndex;
83 getOperandIndexIfPred(llvm::None)) {
85 branch.getSuccessorEntryOperands(regionIndex)[*operandIndex], maxDepth,
90 for (
int i = 0, e = op->getNumRegions(); i != e; ++i) {
92 for (
Block &block : op->getRegion(i)) {
96 auto successorOperands =
98 if (successorOperands) {
100 maxDepth, visited, output);
104 output.push_back(inputValue);
115 SmallVectorImpl<Value> &output) {
119 if (ViewLikeOpInterface view = dyn_cast<ViewLikeOpInterface>(op))
123 if (
auto branch = dyn_cast<RegionBranchOpInterface>(op)) {
129 output.push_back(result);
136 SmallVectorImpl<Value> &output) {
143 auto branch = dyn_cast<BranchOpInterface>((*it)->getTerminator());
146 output.push_back(arg);
151 unsigned index = it.getSuccessorIndex();
152 Value operand = branch.getSuccessorOperands(index)[argNumber];
155 output.push_back(arg);
166 if (
auto branch = dyn_cast<RegionBranchOpInterface>(op)) {
168 maxDepth, visited, output);
172 output.push_back(arg);
178 SmallVectorImpl<Value> &output) {
180 if (!visited.insert(value).second)
183 output.push_back(value);
196 SmallVectorImpl<Value> &output) {
221 MemoryEffectOpInterface
interface = dyn_cast<MemoryEffectOpInterface>(op);
232 if (llvm::isa<SideEffects::AutomaticAllocationScopeResource>(
233 effect->getResource())) {
250 Operation *lhsAllocScope =
nullptr, *rhsAllocScope =
nullptr;
281 if (lhsHasAlloc == rhsHasAlloc) {
293 lhsAllocScope = rhsAllocScope;
305 if (rhsParentOp == lhsAllocScope) {
329 if (lhsValues.empty() || rhsValues.empty())
334 for (
Value lhsVal : lhsValues) {
335 for (
Value rhsVal : rhsValues) {
337 result = result ? result->merge(nextResult) : nextResult;
361 MemoryEffectOpInterface
interface = dyn_cast<MemoryEffectOpInterface>(op);
368 interface.getEffects(effects);
372 if (isa<MemoryEffects::Allocate, MemoryEffects::Free>(effect.getEffect()))
378 if (
Value effectValue = effect.getValue())
379 aliasResult =
alias(effectValue, location);
382 if (aliasResult.
isNo())
386 if (isa<MemoryEffects::Read>(effect.getEffect())) {
389 assert(isa<MemoryEffects::Write>(effect.getEffect()));
Include the generated interface declarations.
This class contains a list of basic blocks and a link to the parent operation it is attached to...
static ModRefResult getRef()
Return a new result that indicates that the memory access may reference the value stored in memory...
Optional< OperandRange > getRegionBranchSuccessorOperands(Operation *operation, Optional< unsigned > regionIndex)
Returns the read only operands that are passed to the region with the given regionIndex.
Operation is a basic unit of execution within MLIR.
This is a value defined by a result of an operation.
The possible results of an alias query.
Block represents an ordered list of Operations.
A trait of region holding operations that define a new scope for automatic allocations, i.e., allocations that are freed when control is transferred back from the operation's region.
static void collectUnderlyingAddressValues(Value value, unsigned maxDepth, DenseSet< Value > &visited, SmallVectorImpl< Value > &output)
Given a value, collect all of the underlying values being addressed.
Operation * getParentWithTrait()
Returns the closest surrounding parent operation with trait Trait.
bool succeeded(LogicalResult result)
Utility function that returns true if the provided LogicalResult corresponds to a success value...
The two locations precisely alias each other.
unsigned getNumSuccessors()
This trait indicates that the side effects of an operation includes the effects of operations nested ...
The possible results of whether a memory access modifies or references a memory location.
unsigned getArgNumber() const
Returns the number of this argument.
OpTy getParentOfType()
Return the closest surrounding parent operation that is of type 'OpTy'.
Region * getParent() const
Provide a 'getParent' method for ilist_node_with_parent methods.
static constexpr const bool value
ModRefResult getModRef(Operation *op, Value location)
Return the modify-reference behavior of op on location.
Operation * getOwner() const
Returns the operation that owns this result.
Block * getOwner() const
Returns the block that owns this argument.
LogicalResult success(bool isSuccess=true)
Utility function to generate a LogicalResult.
This class represents an efficient way to signal success or failure.
LogicalResult failure(bool isFailure=true)
Utility function to generate a LogicalResult.
static LogicalResult getAllocEffectFor(Value value, Optional< MemoryEffects::EffectInstance > &effect, Operation *&allocScopeOp)
Given a value, try to get an allocation effect attached to it.
unsigned getRegionNumber()
Return the number of this region in the parent operation.
Region * getParentRegion()
Return the Region in which this Value is defined.
Attributes are known-constant values of operations.
bool hasTrait()
Returns true if the operation was registered with a particular trait, e.g.
Operation * getParentOp()
Returns the closest surrounding operation that contains this operation or nullptr if this is a top-le...
unsigned getResultNumber() const
Returns the number of this result.
Block * getParentBlock()
Return the Block in which this Value is defined.
static constexpr unsigned maxUnderlyingValueSearchDepth
The maximum depth that will be searched when trying to find an underlying value.
bool isEntryBlock()
Return if this block is the entry block in the parent region.
static AliasResult aliasImpl(Value lhs, Value rhs)
Given the two values, return their aliasing behavior.
detail::constant_op_matcher m_Constant()
Matches a constant foldable operation.
This class represents an argument of a Block.
This class represents a specific instance of an effect.
bool isNo() const
Returns if this result indicates no possibility of aliasing.
Operation * getParentOp()
Return the parent operation this region is attached to.
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
The two locations do not alias at all.
This class represents a successor of a region.
static ModRefResult getMod()
Return a new result that indicates that the memory access may modify the value stored in memory...
bool matchPattern(Value value, const Pattern &pattern)
Entry point for matching a pattern over a Value.
static ModRefResult getNoModRef()
Return a new result that indicates that the memory access neither references nor modifies the value s...
bool isModAndRef() const
Returns if this result modifies and references memory.
ModRefResult merge(const ModRefResult &other)
Merge this ModRef result with other and return the result.
The two locations may or may not alias.
AliasResult alias(Value lhs, Value rhs)
Given two values, return their aliasing behavior.
This class provides an abstraction over the different types of ranges over Values.
The following effect indicates that the operation allocates from some resource.
bool isProperAncestor(Operation *other)
Return true if this operation is a proper ancestor of the other operation.
static ModRefResult getModAndRef()
Return a new result that indicates that the memory access may reference and may modify the value stor...
pred_iterator pred_begin()