MLIR
18.0.0git
|
This class provides utilities for computing if two operations are equivalent. More...
#include "mlir/IR/OperationSupport.h"
Public Types | |
enum | Flags { None = 0 , IgnoreLocations = 1 } |
Static Public Member Functions | |
static llvm::hash_code | computeHash (Operation *op, function_ref< llvm::hash_code(Value)> hashOperands=[](Value v) { return hash_value(v);}, function_ref< llvm::hash_code(Value)> hashResults=[](Value v) { return hash_value(v);}, Flags flags=Flags::None) |
Compute a hash for the given operation. More... | |
static llvm::hash_code | ignoreHashValue (Value) |
Helper that can be used with computeHash above to ignore operation operands/result mapping. More... | |
static llvm::hash_code | directHashValue (Value v) |
Helper that can be used with computeHash above to ignore operation operands/result mapping. More... | |
static bool | isEquivalentTo (Operation *lhs, Operation *rhs, function_ref< LogicalResult(Value, Value)> checkEquivalent, function_ref< void(Value, Value)> markEquivalent=nullptr, Flags flags=Flags::None) |
Compare two operations (including their regions) and return if they are equivalent. More... | |
static bool | isEquivalentTo (Operation *lhs, Operation *rhs, Flags flags) |
Compare two operations and return if they are equivalent. More... | |
static bool | isRegionEquivalentTo (Region *lhs, Region *rhs, function_ref< LogicalResult(Value, Value)> checkEquivalent, function_ref< void(Value, Value)> markEquivalent, OperationEquivalence::Flags flags) |
Compare two regions (including their subregions) and return if they are equivalent. More... | |
static bool | isRegionEquivalentTo (Region *lhs, Region *rhs, OperationEquivalence::Flags flags) |
Compare two regions and return if they are equivalent. More... | |
static LogicalResult | ignoreValueEquivalence (Value lhs, Value rhs) |
Helper that can be used with isEquivalentTo above to consider ops equivalent even if their operands are not equivalent. More... | |
static LogicalResult | exactValueMatch (Value lhs, Value rhs) |
Helper that can be used with isEquivalentTo above to consider ops equivalent only if their operands are the exact same SSA values. More... | |
This class provides utilities for computing if two operations are equivalent.
Definition at line 1228 of file OperationSupport.h.
Enumerator | |
---|---|
None | |
IgnoreLocations |
Definition at line 1229 of file OperationSupport.h.
|
static |
Compute a hash for the given operation.
The hashOperands
and hashResults
callbacks are expected to return a unique hash_code for a given Value.
Definition at line 670 of file OperationSupport.cpp.
|
inlinestatic |
Helper that can be used with computeHash
above to ignore operation operands/result mapping.
Definition at line 1254 of file OperationSupport.h.
References mlir::hash_value().
|
inlinestatic |
Helper that can be used with isEquivalentTo
above to consider ops equivalent only if their operands are the exact same SSA values.
Definition at line 1298 of file OperationSupport.h.
References mlir::success().
|
inlinestatic |
Helper that can be used with computeHash
above to ignore operation operands/result mapping.
Definition at line 1251 of file OperationSupport.h.
|
inlinestatic |
Helper that can be used with isEquivalentTo
above to consider ops equivalent even if their operands are not equivalent.
Definition at line 1293 of file OperationSupport.h.
References mlir::success().
Compare two operations and return if they are equivalent.
Definition at line 832 of file OperationSupport.cpp.
References ValueEquivalenceCache::checkEquivalent(), isEquivalentTo(), and ValueEquivalenceCache::markEquivalent().
|
static |
Compare two operations (including their regions) and return if they are equivalent.
checkEquivalent
is a callback to check if two values are equivalent. For two operations to be equivalent, their operands must be the same SSA value or this callback must return success
.markEquivalent
is a callback to inform the caller that the analysis determined that two values are equivalent.Note: Additional information regarding value equivalence can be injected into the analysis via checkEquivalent
. Typically, callers may want values that were determined to be equivalent as per markEquivalent
to be reflected in checkEquivalent
, unless exactValueMatch
or a different equivalence relationship is desired.
Definition at line 779 of file OperationSupport.cpp.
References mlir::OperationName::compareOpProperties(), mlir::failed(), mlir::Operation::getDiscardableAttrDictionary(), mlir::Operation::getLoc(), mlir::Operation::getName(), mlir::Operation::getNumOperands(), mlir::Operation::getNumRegions(), mlir::Operation::getNumResults(), mlir::Operation::getNumSuccessors(), mlir::Operation::getOperands(), mlir::Operation::getPropertiesStorage(), mlir::Operation::getRegions(), mlir::Operation::getResults(), mlir::Value::getType(), IgnoreLocations, and isRegionEquivalentTo().
Referenced by isEquivalentTo(), and isRegionEquivalentTo().
|
static |
Compare two regions (including their subregions) and return if they are equivalent.
See also isEquivalentTo
for details.
Definition at line 695 of file OperationSupport.cpp.
References mlir::Block::getArguments(), mlir::Value::getLoc(), mlir::Block::getNumArguments(), mlir::Operation::getSuccessors(), mlir::Value::getType(), IgnoreLocations, and isEquivalentTo().
Referenced by isEquivalentTo(), and isRegionEquivalentTo().
|
static |
Compare two regions and return if they are equivalent.
Definition at line 765 of file OperationSupport.cpp.
References ValueEquivalenceCache::checkEquivalent(), isRegionEquivalentTo(), and ValueEquivalenceCache::markEquivalent().