MLIR
20.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, function_ref< LogicalResult(ValueRange, ValueRange)> checkCommutativeEquivalent=nullptr) |
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, function_ref< LogicalResult(ValueRange, ValueRange)> checkCommutativeEquivalent=nullptr) |
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 1272 of file OperationSupport.h.
Enumerator | |
---|---|
None | |
IgnoreLocations |
Definition at line 1273 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 675 of file OperationSupport.cpp.
References mlir::Operation::getLoc(), mlir::Operation::getName(), mlir::Operation::getNumOperands(), mlir::Operation::getOperand(), mlir::Operation::getOperands(), mlir::Operation::getRawDictionaryAttrs(), mlir::Operation::getResults(), mlir::Operation::getResultTypes(), mlir::Operation::hashProperties(), and mlir::Operation::hasTrait().
|
inlinestatic |
Helper that can be used with computeHash
above to ignore operation operands/result mapping.
Definition at line 1298 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 1350 of file OperationSupport.h.
|
inlinestatic |
Helper that can be used with computeHash
above to ignore operation operands/result mapping.
Definition at line 1295 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 1345 of file OperationSupport.h.
Compare two operations and return if they are equivalent.
Definition at line 891 of file OperationSupport.cpp.
References ValueEquivalenceCache::checkCommutativeEquivalent(), 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.checkCommutativeEquivalent
is an optional callback to check for equivalence across two ranges for a commutative operation. If not passed in, then equivalence is checked pairwise. This callback is needed to be able to query the optional equivalence classes.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 828 of file OperationSupport.cpp.
References mlir::OperationName::compareOpProperties(), 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::getRawDictionaryAttrs(), mlir::Operation::getRegions(), mlir::Operation::getResults(), mlir::Value::getType(), mlir::Operation::hasTrait(), 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 708 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 811 of file OperationSupport.cpp.
References ValueEquivalenceCache::checkCommutativeEquivalent(), ValueEquivalenceCache::checkEquivalent(), isRegionEquivalentTo(), and ValueEquivalenceCache::markEquivalent().