MLIR  16.0.0git
Public Types | Static Public Member Functions | List of all members
mlir::OperationEquivalence Struct Reference

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)> mapOperands, function_ref< LogicalResult(Value, Value)> mapResults, Flags flags=Flags::None)
 Compare two operations and return if they are equivalent. More...
 
static LogicalResult ignoreValueEquivalence (Value lhs, Value rhs)
 Helper that can be used with isEquivalentTo above to ignore operation operands/result mapping. More...
 
static LogicalResult exactValueMatch (Value lhs, Value rhs)
 Helper that can be used with isEquivalentTo above to ignore operation operands/result mapping. More...
 

Detailed Description

This class provides utilities for computing if two operations are equivalent.

Definition at line 843 of file OperationSupport.h.

Member Enumeration Documentation

◆ Flags

Enumerator
None 
IgnoreLocations 

Definition at line 844 of file OperationSupport.h.

Member Function Documentation

◆ computeHash()

llvm::hash_code OperationEquivalence::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 
)
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 624 of file OperationSupport.cpp.

References mlir::Value::getAsOpaquePointer(), mlir::Operation::getAttrDictionary(), mlir::Operation::getName(), mlir::Operation::getOperands(), mlir::Operation::getResults(), mlir::Operation::getResultTypes(), and mlir::Operation::hasTrait().

Referenced by mlir::runRegionDCE().

◆ directHashValue()

static llvm::hash_code mlir::OperationEquivalence::directHashValue ( Value  v)
inlinestatic

Helper that can be used with computeHash above to ignore operation operands/result mapping.

Definition at line 869 of file OperationSupport.h.

References mlir::hash_value().

◆ exactValueMatch()

static LogicalResult mlir::OperationEquivalence::exactValueMatch ( Value  lhs,
Value  rhs 
)
inlinestatic

Helper that can be used with isEquivalentTo above to ignore operation operands/result mapping.

Definition at line 889 of file OperationSupport.h.

References mlir::LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE(), and mlir::success().

◆ ignoreHashValue()

static llvm::hash_code mlir::OperationEquivalence::ignoreHashValue ( Value  )
inlinestatic

Helper that can be used with computeHash above to ignore operation operands/result mapping.

Definition at line 866 of file OperationSupport.h.

Referenced by mlir::runRegionDCE().

◆ ignoreValueEquivalence()

static LogicalResult mlir::OperationEquivalence::ignoreValueEquivalence ( Value  lhs,
Value  rhs 
)
inlinestatic

Helper that can be used with isEquivalentTo above to ignore operation operands/result mapping.

Definition at line 884 of file OperationSupport.h.

References mlir::success().

Referenced by mlir::runRegionDCE().

◆ isEquivalentTo()

bool OperationEquivalence::isEquivalentTo ( Operation lhs,
Operation rhs,
function_ref< LogicalResult(Value, Value)>  mapOperands,
function_ref< LogicalResult(Value, Value)>  mapResults,
Flags  flags = Flags::None 
)
static

Compare two operations and return if they are equivalent.

mapOperands and mapResults are optional callbacks that allows the caller to check the mapping of SSA value between the lhs and rhs operations. It is expected to return success if the mapping is valid and failure if it conflicts with a previous mapping.

Definition at line 704 of file OperationSupport.cpp.

References mlir::Value::getAsOpaquePointer(), mlir::Operation::getAttrDictionary(), mlir::Operation::getLoc(), mlir::Operation::getName(), mlir::Operation::getNumOperands(), mlir::Operation::getNumRegions(), mlir::Operation::getNumResults(), mlir::Operation::getNumSuccessors(), mlir::Operation::getOperands(), and mlir::Operation::hasTrait().

Referenced by mlir::runRegionDCE().


The documentation for this struct was generated from the following files: