31 #include "mlir/IR/BuiltinDialect.cpp.inc"
46 BuiltinOpAsmDialectInterface(
Dialect *dialect,
51 if (llvm::isa<LocationAttr>(attr)) {
53 return AliasResult::OverridableAlias;
55 if (
auto distinct = llvm::dyn_cast<DistinctAttr>(attr))
56 if (!llvm::isa<UnitAttr>(distinct.getReferencedAttr())) {
58 return AliasResult::OverridableAlias;
64 if (
auto tupleType = llvm::dyn_cast<TupleType>(type)) {
65 if (tupleType.size() > 16) {
67 return AliasResult::OverridableAlias;
79 return cast<DenseResourceElementsHandle>(handle).getKey().str();
81 FailureOr<AsmDialectResourceHandle>
82 declareResource(StringRef key)
const final {
83 return blobManager.insert(key);
86 FailureOr<AsmResourceBlob> blob = entry.
parseAsBlob();
91 blobManager.update(entry.
getKey(), std::move(*blob));
98 blobManager.buildResources(provider, referencedResources.getArrayRef());
107 void BuiltinDialect::initialize() {
109 registerAttributes();
110 registerLocationAttributes();
113 #include "mlir/IR/BuiltinOps.cpp.inc"
116 auto &blobInterface = addInterface<BuiltinBlobManagerInterface>();
117 addInterface<BuiltinOpAsmDialectInterface>(blobInterface);
126 std::optional<StringRef> name) {
127 state.addRegion()->emplaceBlock();
135 ModuleOp ModuleOp::create(
Location loc, std::optional<StringRef> name) {
137 return builder.
create<ModuleOp>(loc, name);
145 if (
auto spec = llvm::dyn_cast<DataLayoutSpecInterface>(attr.getValue()))
155 if (
auto spec = llvm::dyn_cast<TargetSystemSpecInterface>(attr.getValue()))
163 for (
auto attr : (*this)->getAttrs()) {
164 if (!attr.getName().strref().contains(
'.') &&
167 mlir::SymbolTable::getVisibilityAttrName()},
168 attr.getName().strref()))
169 return emitOpError() <<
"can only contain attributes with "
170 "dialect-prefixed names, found: '"
171 << attr.getName().getValue() <<
"'";
175 StringRef layoutSpecAttrName;
176 DataLayoutSpecInterface layoutSpec;
178 if (
auto spec = llvm::dyn_cast<DataLayoutSpecInterface>(na.getValue())) {
181 emitOpError() <<
"expects at most one data layout attribute";
182 diag.attachNote() <<
"'" << layoutSpecAttrName
183 <<
"' is a data layout attribute";
184 diag.attachNote() <<
"'" << na.getName().getValue()
185 <<
"' is a data layout attribute";
187 layoutSpecAttrName = na.getName().strref();
200 UnrealizedConversionCastOp::fold(FoldAdaptor adaptor,
206 foldResults.append(operands.begin(), operands.end());
210 if (operands.empty())
216 Value firstInput = operands.front();
217 auto inputOp = firstInput.
getDefiningOp<UnrealizedConversionCastOp>();
218 if (!inputOp || inputOp.getResults() != operands ||
219 inputOp.getOperandTypes() != results.
getTypes())
223 foldResults.append(inputOp->operand_begin(), inputOp->operand_end());
230 if (getNumResults() == 0)
231 return emitOpError() <<
"expected at least one result for cast operation";
239 #define GET_OP_CLASSES
240 #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.