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();
90 declareResource(StringRef key)
const final {
91 return blobManager.insert(key);
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()))
161 for (
auto attr : (*this)->getAttrs()) {
162 if (!attr.getName().strref().contains(
'.') &&
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;
176 if (
auto spec = llvm::dyn_cast<DataLayoutSpecInterface>(na.getValue())) {
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();
198 UnrealizedConversionCastOp::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());
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"
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 provides support for representing a failure result, or a valid value of type T.
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 failure(bool isFailure=true)
Utility function to generate a LogicalResult.
LogicalResult success(bool isSuccess=true)
Utility function to generate a LogicalResult.
LogicalResult verify(Operation *op, bool verifyRecursively=true)
Perform (potentially expensive) checks of invariants, used to detect compiler bugs,...
bool failed(LogicalResult result)
Utility function that returns true if the provided LogicalResult corresponds to a failure value.
This class represents an efficient way to signal success or failure.
This represents an operation in an abstracted form, suitable for use with the builder APIs.