29#include "mlir/IR/BuiltinDialect.cpp.inc"
44 BuiltinOpAsmDialectInterface(
Dialect *dialect,
49 if (llvm::isa<LocationAttr>(attr)) {
51 return AliasResult::OverridableAlias;
53 if (
auto distinct = llvm::dyn_cast<DistinctAttr>(attr))
54 if (!llvm::isa<UnitAttr>(distinct.getReferencedAttr())) {
56 return AliasResult::OverridableAlias;
62 if (
auto tupleType = llvm::dyn_cast<TupleType>(type)) {
63 if (tupleType.size() > 16) {
65 return AliasResult::OverridableAlias;
77 return cast<DenseResourceElementsHandle>(handle).getKey().str();
79 FailureOr<AsmDialectResourceHandle>
80 declareResource(StringRef key)
const final {
81 return blobManager.insert(key);
84 FailureOr<AsmResourceBlob> blob = entry.
parseAsBlob();
89 blobManager.update(entry.
getKey(), std::move(*blob));
96 blobManager.buildResources(provider, referencedResources.getArrayRef());
105void BuiltinDialect::initialize() {
107 registerAttributes();
108 registerLocationAttributes();
111#include "mlir/IR/BuiltinOps.cpp.inc"
114 auto &blobInterface = addInterface<BuiltinBlobManagerInterface>();
115 addInterface<BuiltinOpAsmDialectInterface>(blobInterface);
124 std::optional<StringRef> name) {
133ModuleOp ModuleOp::create(
Location loc, std::optional<StringRef> name) {
135 return ModuleOp::create(builder, loc, name);
138DataLayoutSpecInterface ModuleOp::getDataLayoutSpec() {
142 for (NamedAttribute attr : getOperation()->getAttrs())
143 if (
auto spec = llvm::dyn_cast<DataLayoutSpecInterface>(attr.getValue()))
148TargetSystemSpecInterface ModuleOp::getTargetSystemSpec() {
152 for (NamedAttribute attr : getOperation()->getAttrs())
153 if (
auto spec = llvm::dyn_cast<TargetSystemSpecInterface>(attr.getValue()))
158LogicalResult ModuleOp::verify() {
161 for (
auto attr : (*this)->getAttrs()) {
162 if (!attr.getName().strref().contains(
'.') &&
164 ArrayRef<StringRef>{mlir::SymbolTable::getSymbolAttrName(),
165 mlir::SymbolTable::getVisibilityAttrName()},
166 attr.getName().strref()))
167 return emitOpError() <<
"can only contain attributes with "
168 "dialect-prefixed names, found: '"
169 << attr.getName().getValue() <<
"'";
173 StringRef layoutSpecAttrName;
174 DataLayoutSpecInterface layoutSpec;
175 for (
const NamedAttribute &na : (*this)->getAttrs()) {
176 if (
auto spec = llvm::dyn_cast<DataLayoutSpecInterface>(na.getValue())) {
178 InFlightDiagnostic
diag =
179 emitOpError() <<
"expects at most one data layout attribute";
180 diag.attachNote() <<
"'" << layoutSpecAttrName
181 <<
"' is a data layout attribute";
182 diag.attachNote() <<
"'" << na.getName().getValue()
183 <<
"' is a data layout attribute";
185 layoutSpecAttrName = na.getName().strref();
198UnrealizedConversionCastOp::fold(FoldAdaptor adaptor,
204 foldResults.append(operands.begin(), operands.end());
208 if (operands.empty())
214 Value firstInput = operands.front();
215 auto inputOp = firstInput.
getDefiningOp<UnrealizedConversionCastOp>();
216 if (!inputOp || inputOp.getResults() != operands ||
217 inputOp.getOperandTypes() != results.
getTypes())
221 foldResults.append(inputOp->operand_begin(), inputOp->operand_end());
225LogicalResult UnrealizedConversionCastOp::verify() {
228 if (getNumResults() == 0)
229 return emitOpError() <<
"expected at least one result for cast operation";
237#define GET_OP_CLASSES
238#include "mlir/IR/BuiltinOps.cpp.inc"
p<< " : "<< getMemRefType()<< ", "<< getType();}static LogicalResult verifyVectorMemoryOp(Operation *op, MemRefType memrefType, VectorType vectorType) { if(memrefType.getElementType() !=vectorType.getElementType()) return op-> emitOpError("requires memref and vector types of the same elemental type")
Given a list of lists of parsed operands, populates uniqueOperands with unique operands.
ResourceBlobManagerDialectInterfaceBase< DenseResourceElementsHandle > BuiltinBlobManagerInterface
static std::string diag(const llvm::Value &value)
The possible results of an alias query.
@ NoAlias
The two locations do not alias at all.
This class represents an opaque handle to a dialect resource entry.
This class represents a single parsed resource entry.
virtual FailureOr< AsmResourceBlob > parseAsBlob(BlobAllocatorFn allocator) const =0
Parse the resource entry represented by a binary blob.
virtual StringRef getKey() const =0
Return the key of the resource entry.
This class is used to build resource entries for use by the printer.
Attributes are known-constant values of operations.
MLIRContext * getContext() const
Return the context this attribute belongs to.
StringAttr getStringAttr(const Twine &bytes)
NamedAttribute getNamedAttr(StringRef name, Attribute val)
Dialects are groups of MLIR operations, types and attributes, as well as behavior associated with the...
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
void push_back(NamedAttribute newAttribute)
Add an attribute with the specified name.
This class helps build Operations.
This class implements the operand iterators for the Operation class.
type_range getType() const
Operation is the basic unit of execution within MLIR.
This class provides a base class for dialects implementing the resource blob interface.
This class implements the result iterators for the Operation class.
type_range getTypes() const
type_range getType() const
static StringRef getSymbolAttrName()
Return the name of the attribute used for symbol names.
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Operation * getDefiningOp() const
If this value is the result of an operation, return the operation that defines it.
void addBytecodeInterface(BuiltinDialect *dialect)
Add the interfaces necessary for encoding the builtin dialect components in bytecode.
Include the generated interface declarations.
llvm::SetVector< T, Vector, Set, N > SetVector
This represents an operation in an abstracted form, suitable for use with the builder APIs.
Region * addRegion()
Create a region that should be attached to the operation.