31 #include "mlir/IR/BuiltinDialect.cpp.inc"
46 BuiltinOpAsmDialectInterface(
Dialect *dialect,
51 if (llvm::isa<AffineMapAttr>(attr)) {
53 return AliasResult::OverridableAlias;
55 if (llvm::isa<IntegerSetAttr>(attr)) {
57 return AliasResult::OverridableAlias;
59 if (llvm::isa<LocationAttr>(attr)) {
61 return AliasResult::OverridableAlias;
63 if (
auto distinct = llvm::dyn_cast<DistinctAttr>(attr))
64 if (!llvm::isa<UnitAttr>(distinct.getReferencedAttr())) {
66 return AliasResult::OverridableAlias;
72 if (
auto tupleType = llvm::dyn_cast<TupleType>(type)) {
73 if (tupleType.size() > 16) {
75 return AliasResult::OverridableAlias;
87 return cast<DenseResourceElementsHandle>(handle).getKey().str();
89 FailureOr<AsmDialectResourceHandle>
90 declareResource(StringRef key)
const final {
91 return blobManager.insert(key);
94 FailureOr<AsmResourceBlob> blob = entry.
parseAsBlob();
99 blobManager.update(entry.
getKey(), std::move(*blob));
106 blobManager.buildResources(provider, referencedResources.getArrayRef());
115 void BuiltinDialect::initialize() {
117 registerAttributes();
118 registerLocationAttributes();
121 #include "mlir/IR/BuiltinOps.cpp.inc"
124 auto &blobInterface = addInterface<BuiltinBlobManagerInterface>();
125 addInterface<BuiltinOpAsmDialectInterface>(blobInterface);
134 std::optional<StringRef> name) {
135 state.addRegion()->emplaceBlock();
143 ModuleOp ModuleOp::create(
Location loc, std::optional<StringRef> name) {
145 return builder.
create<ModuleOp>(loc, name);
153 if (
auto spec = llvm::dyn_cast<DataLayoutSpecInterface>(attr.getValue()))
163 if (
auto spec = llvm::dyn_cast<TargetSystemSpecInterface>(attr.getValue()))
171 for (
auto attr : (*this)->getAttrs()) {
172 if (!attr.getName().strref().contains(
'.') &&
175 mlir::SymbolTable::getVisibilityAttrName()},
176 attr.getName().strref()))
177 return emitOpError() <<
"can only contain attributes with "
178 "dialect-prefixed names, found: '"
179 << attr.getName().getValue() <<
"'";
183 StringRef layoutSpecAttrName;
184 DataLayoutSpecInterface layoutSpec;
186 if (
auto spec = llvm::dyn_cast<DataLayoutSpecInterface>(na.getValue())) {
189 emitOpError() <<
"expects at most one data layout attribute";
190 diag.attachNote() <<
"'" << layoutSpecAttrName
191 <<
"' is a data layout attribute";
192 diag.attachNote() <<
"'" << na.getName().getValue()
193 <<
"' is a data layout attribute";
195 layoutSpecAttrName = na.getName().strref();
208 UnrealizedConversionCastOp::fold(FoldAdaptor adaptor,
214 foldResults.append(operands.begin(), operands.end());
218 if (operands.empty())
224 Value firstInput = operands.front();
225 auto inputOp = firstInput.
getDefiningOp<UnrealizedConversionCastOp>();
226 if (!inputOp || inputOp.getResults() != operands ||
227 inputOp.getOperandTypes() != results.
getTypes())
231 foldResults.append(inputOp->operand_begin(), inputOp->operand_end());
238 if (getNumResults() == 0)
239 return emitOpError() <<
"expected at least one result for cast operation";
247 #define GET_OP_CLASSES
248 #include "mlir/IR/BuiltinOps.cpp.inc"
static TargetSystemSpecInterface getTargetSystemSpec(Operation *operation)
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 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...
NamedAttribute represents a combination of a name and an Attribute value.
This class helps build Operations.
Operation * create(const OperationState &state)
Creates an operation given the fields represented as an OperationState.
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.
DataLayoutSpecInterface getDataLayoutSpec(Operation *op)
Include the generated interface declarations.
LogicalResult verify(Operation *op, bool verifyRecursively=true)
Perform (potentially expensive) checks of invariants, used to detect compiler bugs,...
This represents an operation in an abstracted form, suitable for use with the builder APIs.