14#ifndef MLIR_IR_OPERATIONSUPPORT_H
15#define MLIR_IR_OPERATIONSUPPORT_H
27#include "llvm/ADT/BitmaskEnum.h"
28#include "llvm/ADT/PointerUnion.h"
29#include "llvm/ADT/STLFunctionalExtras.h"
30#include "llvm/Support/ErrorHandling.h"
31#include "llvm/Support/PointerLikeTypeTraits.h"
32#include "llvm/Support/TrailingObjects.h"
62template <
typename ValueRangeT>
78 operator bool()
const {
return data !=
nullptr; }
79 template <
typename Dest>
81 static_assert(std::is_pointer_v<Dest>,
82 "PropertyRef::as<T>() requires T to be a pointer type");
83 using RawType = std::remove_cv_t<std::remove_pointer_t<Dest>>;
85 "Property type mismatch: TypeID does not match requested type");
86 return static_cast<Dest
>(data);
113 llvm::unique_function<LogicalResult(
Operation *)
const>;
115 llvm::unique_function<LogicalResult(
Operation *)
const>;
140 virtual LogicalResult
149 virtual LogicalResult
226 StringRef
name) final;
295 template <
template <
typename T>
class Trait>
304 template <
template <
typename T>
class Trait>
325 StringRef defaultDialect)
const {
362 template <
typename T>
369 template <
typename... Models>
381 template <
typename InterfaceT>
389 template <
typename T>
400 template <
typename T>
411 StringRef
name)
const {
510 const_cast<Impl *
>(
reinterpret_cast<const Impl *
>(pointer)));
549class RegisteredOperationName :
public OperationName {
553 template <
typename ConcreteOp>
556 decltype(std::declval<ConcreteOp>().getProperties())>;
564 return ConcreteOp::getFoldHookFn()(op, attrs, results);
568 ConcreteOp::getCanonicalizationPatterns(set, context);
572 return ConcreteOp::parse;
576 ConcreteOp::populateDefaultAttrs(
name, attrs);
579 StringRef
name)
final {
580 ConcreteOp::getPrintAssemblyFn()(op, printer,
name);
583 return ConcreteOp::getVerifyInvariantsFn()(op);
586 return ConcreteOp::getVerifyRegionInvariantsFn()(op);
592 StringRef
name)
final {
594 auto concreteOp = cast<ConcreteOp>(op);
595 return ConcreteOp::getInherentAttr(concreteOp->getContext(),
596 concreteOp.getProperties(),
name);
603 auto concreteOp = cast<ConcreteOp>(op);
604 return ConcreteOp::setInherentAttr(concreteOp.getProperties(),
name,
608 "Can't call setInherentAttr on operation with empty properties");
612 auto concreteOp = cast<ConcreteOp>(op);
613 ConcreteOp::populateInherentAttrs(concreteOp->getContext(),
614 concreteOp.getProperties(), attrs);
621 return ConcreteOp::verifyInherentAttrs(opName, attributes,
emitError);
626 typename ConcreteOp::template InferredProperties<ConcreteOp>,
637 typename ConcreteOp::template InferredProperties<ConcreteOp>;
643 ConcreteOp::populateDefaultProperties(opName,
652 ConcreteOp::populateDefaultProperties(opName,
662 return ConcreteOp::setPropertiesFromAttr(*p, attr,
emitError);
664 emitError() <<
"this operation has empty properties";
669 auto concreteOp = cast<ConcreteOp>(op);
670 return ConcreteOp::getPropertiesAsAttr(concreteOp->getContext(),
671 concreteOp.getProperties());
685 return ConcreteOp::computePropertiesHash(*prop.as<
Properties *>());
693 static std::optional<RegisteredOperationName> lookup(StringRef name,
698 static std::optional<RegisteredOperationName> lookup(
TypeID typeID,
704 template <
typename T>
706 insert(std::make_unique<
Model<T>>(&dialect), T::getAttributeNames());
710 static void insert(std::unique_ptr<OperationName::Impl> ownedImpl,
719 return RegisteredOperationName(
720 const_cast<Impl *
>(
reinterpret_cast<const Impl *
>(pointer)));
727 friend OperationName;
730inline std::optional<RegisteredOperationName>
733 : std::optional<RegisteredOperationName>();
745template <
typename IteratorT,
typename NameT>
748 for (
auto it = first; it != last; ++it)
749 if (it->getName() == name)
751 return {last,
false};
758template <
typename IteratorT>
761 ptrdiff_t length = std::distance(first, last);
764 ptrdiff_t half = length / 2;
765 IteratorT mid = first + half;
766 int compare = mid->getName().strref().compare(name);
769 length = length - half - 1;
770 }
else if (compare > 0) {
776 return {first,
false};
782template <
typename IteratorT>
785 constexpr unsigned kSmallAttributeList = 16;
786 if (std::distance(first, last) > kSmallAttributeList)
793template <
typename IteratorT,
typename NameT>
801template <
typename IteratorT,
typename NameT>
802std::optional<NamedAttribute>
805 return result.second ? *
result.first : std::optional<NamedAttribute>();
825 NamedAttrList(ArrayRef<NamedAttribute> attributes);
826 NamedAttrList(DictionaryAttr attributes);
827 NamedAttrList(const_iterator inStart, const_iterator inEnd);
829 template <
typename Container>
834 return !(*
this == other);
837 return attrs == other.attrs;
854 template <
typename RangeT>
856 append(std::begin(newAttributes), std::end(newAttributes));
860 template <
typename IteratorT,
861 typename = std::enable_if_t<std::is_convertible<
862 typename std::iterator_traits<IteratorT>::iterator_category,
863 std::input_iterator_tag>::value>>
864 void append(IteratorT inStart, IteratorT inEnd) {
867 dictionarySorted.setPointerAndInt(
nullptr,
false);
868 attrs.append(inStart, inEnd);
872 void assign(const_iterator inStart, const_iterator inEnd);
876 assign(range.begin(), range.end());
881 dictionarySorted.setPointerAndInt(
nullptr,
false);
884 bool empty()
const {
return attrs.empty(); }
896 std::optional<NamedAttribute> findDuplicate()
const;
900 DictionaryAttr getDictionary(
MLIRContext *context)
const;
910 std::optional<NamedAttribute> getNamed(StringRef name)
const;
911 std::optional<NamedAttribute> getNamed(StringAttr name)
const;
936 bool isSorted()
const {
return dictionarySorted.getInt(); }
939 Attribute eraseImpl(SmallVectorImpl<NamedAttribute>::iterator it);
942 template <
typename AttrListT,
typename NameT>
943 static auto findAttr(AttrListT &attrs, NameT name) {
944 return attrs.isSorted()
945 ? impl::findAttrSorted(attrs.begin(), attrs.end(), name)
946 :
impl::findAttrUnsorted(attrs.begin(), attrs.end(), name);
950 mutable SmallVector<NamedAttribute, 4> attrs;
955 mutable llvm::PointerIntPair<Attribute, 1, bool> dictionarySorted;
999 MutableArrayRef<std::unique_ptr<Region>> regions = {});
1000 OperationState(Location location, StringRef name,
ValueRange operands,
1001 TypeRange types, ArrayRef<NamedAttribute> attributes = {},
1002 BlockRange successors = {},
1003 MutableArrayRef<std::unique_ptr<Region>> regions = {});
1012 template <
typename T>
1017#if defined(__clang__)
1018#if __has_warning("-Wdangling-assignment-gsl")
1019#pragma clang diagnostic push
1021#pragma clang diagnostic ignored "-Wdangling-assignment-gsl"
1024 propertiesDeleter = [](
PropertyRef prop) {
delete prop.as<
const T *>(); };
1026 *newProp.
as<T *>() = *prop.as<
const T *>();
1028#if defined(__clang__)
1029#if __has_warning("-Wdangling-assignment-gsl")
1030#pragma clang diagnostic pop
1035 "Inconsistent properties");
1036 return *properties.as<T *>();
1051 template <
typename T>
1053 assert(!properties &&
1054 "Can't provide a properties struct when one has been allocated");
1056#if defined(__clang__)
1057#if __has_warning("-Wdangling-assignment-gsl")
1058#pragma clang diagnostic push
1060#pragma clang diagnostic ignored "-Wdangling-assignment-gsl"
1065 *newProp.
as<T *>() = *prop.as<
const T *>();
1067#if defined(__clang__)
1068#if __has_warning("-Wdangling-assignment-gsl")
1069#pragma clang diagnostic pop
1077 types.append(newTypes.begin(), newTypes.end());
1079 template <
typename RangeT>
1080 std::enable_if_t<!std::is_convertible<RangeT, ArrayRef<Type>>::value>
1082 types.append(newTypes.begin(), newTypes.end());
1093 assert(
name &&
"attribute name cannot be null");
1094 assert(attr &&
"attribute cannot be null");
1105 assert(successor &&
"successor cannot be null");
1108 void addSuccessors(
BlockRange newSuccessors);
1118 void addRegion(std::unique_ptr<Region> &®ion);
1162 unsigned size() {
return numOperands; }
1170 unsigned capacity : 31;
1173 unsigned isStorageDynamic : 1;
1175 unsigned numOperands;
1288 std::optional<int64_t> elementsAttrElementLimit;
1291 std::optional<uint64_t> resourceStringCharLimit;
1295 int64_t elementsAttrHexElementLimit = 100;
1298 bool printDebugInfoFlag : 1;
1299 bool printDebugInfoPrettyFormFlag : 1;
1302 bool printGenericOpFormFlag : 1;
1305 bool skipRegionsFlag : 1;
1308 bool assumeVerifiedFlag : 1;
1311 bool printLocalScope : 1;
1314 bool printValueUsersFlag : 1;
1317 bool printUniqueSSAIDsFlag : 1;
1320 bool useNameLocAsPrefix : 1;
1357 function_ref<llvm::hash_code(Value)> hashResults =
1358 [](Value v) {
return hash_value(v); },
1359 Flags flags = Flags::None);
1390 Flags flags = Flags::None,
1392 checkCommutativeEquivalent =
nullptr);
1399 static bool isRegionEquivalentTo(
1405 checkCommutativeEquivalent =
nullptr);
1439 return hash == other.hash;
1442 return !(*
this == other);
1446 std::array<uint8_t, 20>
hash;
1483struct PointerLikeTypeTraits<
mlir::OperationName> {
1491 PointerLikeTypeTraits<void *>::NumLowBitsAvailable;
1494struct PointerLikeTypeTraits<
mlir::RegisteredOperationName>
1495 :
public PointerLikeTypeTraits<mlir::OperationName> {
static size_t hash(const T &value)
Local helper to compute std::hash for a value.
static llvm::hash_code computeHash(SymbolOpInterface symbolOp)
Computes a hash code to represent symbolOp based on all its attributes except for the symbol name.
memberIdxs push_back(ArrayAttr::get(parser.getContext(), values))
Attributes are known-constant values of operations.
This class provides an abstraction over the different types of ranges over Blocks.
Block represents an ordered list of Operations.
Dialects are groups of MLIR operations, types and attributes, as well as behavior associated with the...
This class represents a diagnostic that is inflight and set to be reported.
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
This is the implementation of the MLIRContext class, using the pImpl idiom.
MLIRContext is the top-level object for a collection of MLIR operations.
This class represents a contiguous range of mutable operand ranges, e.g.
NamedAttrList is array of NamedAttributes that tracks whether it is sorted and does some basic work t...
void append(IteratorT inStart, IteratorT inEnd)
Add a range of named attributes.
void assign(ArrayRef< NamedAttribute > range)
Replaces the attributes with new list of attributes.
const_iterator begin() const
void assign(const_iterator inStart, const_iterator inEnd)
Replaces the attributes with new list of attributes.
NamedAttribute & reference
SmallVectorImpl< NamedAttribute >::const_iterator const_iterator
void append(NamedAttribute attr)
Append the given named attribute.
bool operator!=(const NamedAttrList &other) const
SmallVectorImpl< NamedAttribute >::iterator iterator
const_iterator end() const
NamedAttrList(const Container &vec)
void append(StringAttr name, Attribute attr)
Add an attribute with the specified name.
void pop_back()
Pop last element from list.
bool operator==(const NamedAttrList &other) const
void append(StringRef name, Attribute attr)
Add an attribute with the specified name.
void append(RangeT &&newAttributes)
Add an array of named attributes.
void reserve(size_type N)
const NamedAttribute & const_reference
NamedAttribute represents a combination of a name and an Attribute value.
The OpAsmParser has methods for interacting with the asm parser: parsing things from it,...
This is a pure-virtual base class that exposes the asmprinter hooks necessary to implement a custom p...
This class represents a single result from folding an operation.
This class represents an operand of an operation.
bool shouldElideElementsAttr(ElementsAttr attr) const
Return if the given ElementsAttr should be elided.
std::optional< int64_t > getLargeElementsAttrLimit() const
Return the size limit for printing large ElementsAttr.
bool shouldUseNameLocAsPrefix() const
Return if the printer should use NameLocs as prefixes when printing SSA IDs.
bool shouldAssumeVerified() const
Return if operation verification should be skipped.
OpPrintingFlags & printLargeElementsAttrWithHex(int64_t largeElementLimit=100)
Enables the printing of large element attributes with a hex string.
bool shouldUseLocalScope() const
Return if the printer should use local scope when dumping the IR.
bool shouldPrintDebugInfoPrettyForm() const
Return if debug information should be printed in the pretty form.
bool shouldPrintElementsAttrWithHex(ElementsAttr attr) const
Return if the given ElementsAttr should be printed as hex string.
bool shouldPrintUniqueSSAIDs() const
Return if printer should use unique SSA IDs.
bool shouldPrintValueUsers() const
Return if the printer should print users of values.
int64_t getLargeElementsAttrHexLimit() const
Return the size limit for printing large ElementsAttr as hex string.
bool shouldPrintGenericOpForm() const
Return if operations should be printed in the generic form.
OpPrintingFlags & elideLargeResourceString(int64_t largeResourceLimit=64)
Enables the elision of large resources strings by omitting them from the dialect_resources section.
bool shouldPrintDebugInfo() const
Return if debug information should be printed.
OpPrintingFlags & elideLargeElementsAttrs(int64_t largeElementLimit=16)
Enables the elision of large elements attributes by printing a lexically valid but otherwise meaningl...
OpPrintingFlags & printNameLocAsPrefix(bool enable=true)
Print SSA IDs using their NameLoc, if provided, as prefix.
OpPrintingFlags & printValueUsers(bool enable=true)
Print users of values as comments.
OpPrintingFlags & enableDebugInfo(bool enable=true, bool prettyForm=false)
Enable or disable printing of debug information (based on enable).
OpPrintingFlags()
Initialize the printing flags with default supplied by the cl::opts above.
bool shouldSkipRegions() const
Return if regions should be skipped.
OpPrintingFlags & printGenericOpForm(bool enable=true)
Always print operations in the generic form.
OpPrintingFlags & useLocalScope(bool enable=true)
Use local scope when printing the operation.
std::optional< uint64_t > getLargeResourceStringLimit() const
Return the size limit in chars for printing large resources.
OpPrintingFlags & assumeVerified(bool enable=true)
Do not verify the operation when using custom operation printers.
OpPrintingFlags & skipRegions(bool skip=true)
Skip printing regions.
OpPrintingFlags & printUniqueSSAIDs(bool enable=true)
Print unique SSA ID numbers for values, block arguments and naming conflicts across all regions.
This class represents a contiguous range of operand ranges, e.g.
This class implements the operand iterators for the Operation class.
OperationFingerPrint & operator=(const OperationFingerPrint &)=default
OperationFingerPrint(Operation *topOp, bool includeNested=true)
bool operator!=(const OperationFingerPrint &other) const
bool operator==(const OperationFingerPrint &other) const
OperationFingerPrint(const OperationFingerPrint &)=default
TypeID propertiesTypeID
The TypeID of the Properties struct for this operation.
Dialect * getDialect() const
Impl(StringAttr name, Dialect *dialect, TypeID typeID, detail::InterfaceMap interfaceMap)
ArrayRef< StringAttr > attributeNames
A list of attribute names registered to this operation in StringAttr form.
StringAttr name
The name of the operation.
TypeID typeID
The unique identifier of the derived Op class.
friend class RegisteredOperationName
TypeID getPropertiesTypeID() const
ArrayRef< StringAttr > getAttributeNames() const
Impl(StringRef, Dialect *dialect, TypeID typeID, detail::InterfaceMap interfaceMap)
Dialect * dialect
The following fields are only populated when the operation is registered.
detail::InterfaceMap interfaceMap
A map of interfaces that were registered to this operation.
bool isRegistered() const
Returns true if this is a registered operation.
StringAttr getName() const
detail::InterfaceMap & getInterfaceMap()
void populateInherentAttrs(Operation *op, NamedAttrList &attrs) const
bool operator==(const OperationName &rhs) const
void destroyOpProperties(PropertyRef properties) const
This hooks destroy the op properties.
StringRef getStringRef() const
Return the name of this operation. This always succeeds.
ArrayRef< StringAttr > getAttributeNames() const
Return the list of cached attribute names registered to this operation.
bool operator!=(const OperationName &rhs) const
StringRef stripDialect() const
Return the operation name with dialect name stripped, if it has one.
void setInherentAttr(Operation *op, StringAttr name, Attribute value) const
Attribute getOpPropertiesAsAttribute(Operation *op) const
Return the op properties converted to an Attribute.
bool hasTrait() const
Returns true if the operation was registered with a particular trait, e.g.
bool hasPromiseOrImplementsInterface() const
Returns true if InterfaceT has been promised by the dialect or implemented.
llvm::unique_function< bool(TypeID) const > HasTraitFn
StringAttr getIdentifier() const
Return the name of this operation as a StringAttr.
void getCanonicalizationPatterns(RewritePatternSet &results, MLIRContext *context) const
This hook returns any canonicalization pattern rewrites that the operation supports,...
OperationName(Impl *impl)
ParseAssemblyFn getParseAssemblyFn() const
Return the static hook for parsing this operation assembly.
void copyOpProperties(PropertyRef lhs, PropertyRef rhs) const
std::optional< Attribute > getInherentAttr(Operation *op, StringRef name) const
Lookup an inherent attribute by name, this method isn't recommended and may be removed in the future.
Dialect * getDialect() const
Return the dialect this operation is registered to if the dialect is loaded in the context,...
OperationName(StringRef name, MLIRContext *context)
StringRef getDialectNamespace() const
Return the name of the dialect this operation is registered to.
llvm::hash_code hashOpProperties(PropertyRef properties) const
std::optional< RegisteredOperationName > getRegisteredInfo() const
If this operation is registered, returns the registered information, std::nullopt otherwise.
bool mightHaveTrait() const
Returns true if the operation might have the provided trait.
llvm::unique_function< LogicalResult(Operation *) const > VerifyInvariantsFn
bool mightHaveTrait(TypeID traitID) const
bool hasInterface() const
Returns true if this operation has the given interface registered to it.
LogicalResult setOpPropertiesFromAttribute(OperationName opName, PropertyRef properties, Attribute attr, function_ref< InFlightDiagnostic()> emitError) const
Define the op properties from the provided Attribute.
LogicalResult verifyInherentAttrs(NamedAttrList &attributes, function_ref< InFlightDiagnostic()> emitError) const
This method exists for backward compatibility purpose when using properties to store inherent attribu...
void * getAsOpaquePointer() const
Represent the operation name as an opaque pointer.
llvm::unique_function< void(const OperationName &, NamedAttrList &) const > PopulateDefaultAttrsFn
llvm::unique_function< ParseResult(OpAsmParser &, OperationState &)> ParseAssemblyFn
void initOpProperties(PropertyRef storage, PropertyRef init) const
Initialize the op properties.
bool isRegistered() const
Return if this operation is registered.
bool mightHaveInterface() const
Returns true if the operation might have the provided interface.
T::Concept * getInterface() const
Returns an instance of the concept object for the given interface if it was registered to this operat...
llvm::unique_function< LogicalResult(Operation *) const > VerifyRegionInvariantsFn
LogicalResult foldHook(Operation *op, ArrayRef< Attribute > operands, SmallVectorImpl< OpFoldResult > &results) const
This hook implements a generalized folder for this operation.
bool mightHaveInterface(TypeID interfaceID) const
bool hasTrait(TypeID traitID) const
LogicalResult verifyRegionInvariants(Operation *op) const
bool compareOpProperties(PropertyRef lhs, PropertyRef rhs) const
TypeID getTypeID() const
Return the unique identifier of the derived Op class, or null if not registered.
TypeID getOpPropertiesTypeID() const
Return the TypeID of the op properties.
void populateDefaultAttrs(NamedAttrList &attrs) const
This hook implements the method to populate defaults attributes that are unset.
MLIRContext * getContext()
Return the context this operation is associated with.
llvm::unique_function< LogicalResult( Operation *, ArrayRef< Attribute >, SmallVectorImpl< OpFoldResult > &) const > FoldHookFn
void populateDefaultProperties(PropertyRef properties) const
Set the default values on the ODS attribute in the properties.
LogicalResult verifyInvariants(Operation *op) const
These hooks implement the verifiers for this operation.
int getOpPropertyByteSize() const
This hooks return the number of bytes to allocate for the op properties.
void printAssembly(Operation *op, OpAsmPrinter &p, StringRef defaultDialect) const
This hook implements the AsmPrinter for this operation.
void print(raw_ostream &os) const
bool hasInterface(TypeID interfaceID) const
static OperationName getFromOpaquePointer(const void *pointer)
llvm::unique_function< void(Operation *, OpAsmPrinter &, StringRef) const > PrintAssemblyFn
void attachInterface()
Attach the given models as implementations of the corresponding interfaces for the concrete operation...
Operation is the basic unit of execution within MLIR.
This class contains all of the data related to a pattern, but does not contain any methods or logic f...
Type-safe wrapper around a void* for passing properties, including the properties structs of operatio...
PropertyRef(TypeID typeID, void *data)
This class contains a list of basic blocks and a link to the parent operation it is attached to.
This is a "type erased" representation of a registered operation.
static void insert(Dialect &dialect)
Register a new operation in a Dialect object.
static RegisteredOperationName getFromOpaquePointer(const void *pointer)
Represent the operation name as an opaque pointer.
static void insert(std::unique_ptr< OperationName::Impl > ownedImpl, ArrayRef< StringRef > attrNames)
The use of this method is in general discouraged in favor of 'insert<CustomOp>(dialect)'.
Dialect & getDialect() const
Return the dialect this operation is registered to.
This class implements the result iterators for the Operation class.
RewritePattern is the common base class for all DAG to DAG replacements.
This class provides an efficient unique identifier for a specific C++ type.
static TypeID get()
Construct a type info object for the given type T.
This class provides an abstraction over the various different ranges of value types.
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
This class provides an abstraction over the different types of ranges over Values.
This class implements iteration on the types of a given range of values.
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
This class provides an efficient mapping between a given Interface type, and a particular implementat...
void insertModels()
Insert the given interface models.
T::Concept * lookup() const
Returns an instance of the concept object for the given interface if it was registered to this map,...
bool contains(TypeID interfaceID) const
Returns true if the interface map contains an interface for the given id.
void eraseOperands(unsigned start, unsigned length)
Erase the operands held by the storage within the given range.
MutableArrayRef< OpOperand > getOperands()
Get the operation operands held by the storage.
unsigned size()
Return the number of operands held in the storage.
void setOperands(Operation *owner, ValueRange values)
Replace the operands contained in the storage with the ones provided in 'values'.
OperandStorage(Operation *owner, OpOperand *trailingOperands, ValueRange values)
The OpAsmOpInterface, see OpAsmInterface.td for more details.
bool hasPromisedInterface(Dialect &dialect, TypeID interfaceRequestorID, TypeID interfaceID)
Checks if a promise has been made for the interface/requestor pair.
void handleAdditionOfUndefinedPromisedInterface(Dialect &dialect, TypeID interfaceRequestorID, TypeID interfaceID)
Checks if the given interface, which is attempting to be attached, is a promised interface of this di...
std::optional< NamedAttribute > getNamedAttrFromSortedRange(IteratorT first, IteratorT last, NameT name)
Get an attribute from a sorted range of named attributes.
std::pair< IteratorT, bool > findAttrSorted(IteratorT first, IteratorT last, StringRef name)
Using llvm::lower_bound requires an extra string comparison to check whether the returned iterator po...
std::pair< IteratorT, bool > findAttrUnsorted(IteratorT first, IteratorT last, NameT name)
Unsorted string search or identifier lookups are linear scans.
Attribute getAttrFromSortedRange(IteratorT first, IteratorT last, NameT name)
Get an attribute from a sorted range of named attributes.
Include the generated interface declarations.
llvm::DenseMapInfo< T, Enable > DenseMapInfo
raw_ostream & operator<<(raw_ostream &os, const AliasResult &result)
InFlightDiagnostic emitError(Location loc)
Utility method to emit an error message using this location.
auto get(MLIRContext *context, Ts &&...params)
Helper method that injects context only if needed, this helps unify some of the attribute constructio...
inline ::llvm::hash_code hash_value(AffineExpr arg)
Make AffineExpr hashable.
llvm::function_ref< Fn > function_ref
LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE()
Enable Bitmask enums for OperationEquivalence::Flags.
static mlir::OperationName getTombstoneKey()
static mlir::OperationName getEmptyKey()
static bool isEqual(mlir::OperationName lhs, mlir::OperationName rhs)
static unsigned getHashValue(mlir::OperationName val)
static mlir::RegisteredOperationName getEmptyKey()
static mlir::RegisteredOperationName getTombstoneKey()
static mlir::OperationName getFromVoidPointer(void *P)
static constexpr int NumLowBitsAvailable
static void * getAsVoidPointer(mlir::OperationName I)
static mlir::RegisteredOperationName getFromVoidPointer(void *P)
Structure used by default as a "marker" when no "Properties" are set on an Operation.
This class provides utilities for computing if two operations are equivalent.
static llvm::hash_code ignoreHashValue(Value)
Helper that can be used with computeHash above to ignore operation operands/result mapping.
static llvm::hash_code directHashValue(Value v)
Helper that can be used with computeHash to compute the hash value of operands/results directly.
static LogicalResult ignoreValueEquivalence(Value lhs, Value rhs)
Helper that can be used with isEquivalentTo above to consider ops equivalent even if their operands a...
static LogicalResult exactValueMatch(Value lhs, Value rhs)
Helper that can be used with isEquivalentTo above to consider ops equivalent only if their operands a...
This class represents a type erased version of an operation.
virtual void populateInherentAttrs(Operation *op, NamedAttrList &attrs)=0
virtual llvm::hash_code hashProperties(PropertyRef)=0
virtual void getCanonicalizationPatterns(RewritePatternSet &, MLIRContext *)=0
virtual OperationName::ParseAssemblyFn getParseAssemblyFn()=0
virtual void printAssembly(Operation *, OpAsmPrinter &, StringRef)=0
virtual void copyProperties(PropertyRef, PropertyRef)=0
virtual LogicalResult setPropertiesFromAttr(OperationName, PropertyRef, Attribute, function_ref< InFlightDiagnostic()> emitError)=0
virtual bool hasTrait(TypeID)=0
virtual LogicalResult verifyInvariants(Operation *)=0
virtual void setInherentAttr(Operation *op, StringAttr name, Attribute value)=0
virtual Attribute getPropertiesAsAttr(Operation *)=0
virtual bool compareProperties(PropertyRef, PropertyRef)=0
virtual int getOpPropertyByteSize()=0
virtual void populateDefaultProperties(OperationName opName, PropertyRef properties)=0
virtual LogicalResult foldHook(Operation *, ArrayRef< Attribute >, SmallVectorImpl< OpFoldResult > &)=0
virtual void populateDefaultAttrs(const OperationName &, NamedAttrList &)=0
virtual std::optional< Attribute > getInherentAttr(Operation *, StringRef name)=0
Implementation for properties.
virtual void initProperties(OperationName opName, PropertyRef storage, PropertyRef init)=0
virtual LogicalResult verifyInherentAttrs(OperationName opName, NamedAttrList &attributes, function_ref< InFlightDiagnostic()> emitError)=0
virtual ~InterfaceConcept()=default
virtual LogicalResult verifyRegionInvariants(Operation *)=0
virtual void deleteProperties(PropertyRef)=0
LogicalResult foldHook(Operation *, ArrayRef< Attribute >, SmallVectorImpl< OpFoldResult > &) final
llvm::hash_code hashProperties(PropertyRef) final
void initProperties(OperationName opName, PropertyRef storage, PropertyRef init) final
OperationName::ParseAssemblyFn getParseAssemblyFn() final
void deleteProperties(PropertyRef) final
void getCanonicalizationPatterns(RewritePatternSet &, MLIRContext *) final
LogicalResult setPropertiesFromAttr(OperationName, PropertyRef, Attribute, function_ref< InFlightDiagnostic()> emitError) final
UnregisteredOpModel(StringAttr name, Dialect *dialect, TypeID typeID, detail::InterfaceMap interfaceMap)
Attribute getPropertiesAsAttr(Operation *) final
bool compareProperties(PropertyRef, PropertyRef) final
void copyProperties(PropertyRef, PropertyRef) final
This represents an operation in an abstracted form, suitable for use with the builder APIs.
OperationState & operator=(const OperationState &other)=delete
SmallVector< Block *, 1 > successors
Successors of this operation and their respective operands.
T & getOrAddProperties()
Get (or create) the properties of the provided type to be set on the operation on creation.
OperationState & operator=(OperationState &&other)=default
SmallVector< Value, 4 > operands
std::enable_if_t<!std::is_convertible< RangeT, ArrayRef< Type > >::value > addTypes(RangeT &&newTypes)
void addAttributes(ArrayRef< NamedAttribute > newAttributes)
Add an array of named attributes.
void addAttribute(StringRef name, Attribute attr)
Add an attribute with the specified name.
void addAttribute(StringAttr name, Attribute attr)
Add an attribute with the specified name.
void addSuccessors(Block *successor)
Adds a successor to the operation sate. successor must not be null.
void addTypes(ArrayRef< Type > newTypes)
MLIRContext * getContext() const
Get the context held by this operation state.
OperationState(OperationState &&other)=default
OperationState(const OperationState &other)=delete
SmallVector< std::unique_ptr< Region >, 1 > regions
Regions that the op will hold.
OperationState(Location location, StringRef name)
PropertyRef getRawProperties()
void useProperties(T &newProperties)
Attribute propertiesAttr
This Attribute is used to opaquely construct the properties of the operation.
SmallVector< Type, 4 > types
Types of the results of this operation.
Implementation of the InterfaceConcept for operation APIs that forwarded to a concrete op implementat...
std::optional< Attribute > getInherentAttr(Operation *op, StringRef name) final
Implementation for "Properties".
std::remove_reference_t< decltype(std::declval< ConcreteOp >().getProperties())> Properties
LogicalResult setPropertiesFromAttr(OperationName opName, PropertyRef properties, Attribute attr, function_ref< InFlightDiagnostic()> emitError) final
bool hasTrait(TypeID id) final
void populateDefaultProperties(OperationName opName, PropertyRef properties) final
void populateDefaultAttrs(const OperationName &name, NamedAttrList &attrs) final
OperationName::ParseAssemblyFn getParseAssemblyFn() final
bool compareProperties(PropertyRef lhs, PropertyRef rhs) final
void initProperties(OperationName opName, PropertyRef storage, PropertyRef init) final
LogicalResult verifyInvariants(Operation *op) final
void getCanonicalizationPatterns(RewritePatternSet &set, MLIRContext *context) final
void copyProperties(PropertyRef lhs, PropertyRef rhs) final
LogicalResult verifyRegionInvariants(Operation *op) final
int getOpPropertyByteSize() final
void printAssembly(Operation *op, OpAsmPrinter &printer, StringRef name) final
void populateInherentAttrs(Operation *op, NamedAttrList &attrs) final
static constexpr bool hasProperties
LogicalResult foldHook(Operation *op, ArrayRef< Attribute > attrs, SmallVectorImpl< OpFoldResult > &results) final
Attribute getPropertiesAsAttr(Operation *op) final
llvm::hash_code hashProperties(PropertyRef prop) final
LogicalResult verifyInherentAttrs(OperationName opName, NamedAttrList &attributes, function_ref< InFlightDiagnostic()> emitError) final
void setInherentAttr(Operation *op, StringAttr name, Attribute value) final
void deleteProperties(PropertyRef prop) final