Changeset View
Changeset View
Standalone View
Standalone View
mlir/lib/IR/BuiltinDialect.cpp
Show First 20 Lines • Show All 247 Lines • ▼ Show 20 Lines | static LogicalResult verify(ModuleOp op) { | ||||
for (auto attr : op->getAttrs()) { | for (auto attr : op->getAttrs()) { | ||||
if (!attr.first.strref().contains('.') && | if (!attr.first.strref().contains('.') && | ||||
!llvm::is_contained( | !llvm::is_contained( | ||||
ArrayRef<StringRef>{mlir::SymbolTable::getSymbolAttrName(), | ArrayRef<StringRef>{mlir::SymbolTable::getSymbolAttrName(), | ||||
mlir::SymbolTable::getVisibilityAttrName()}, | mlir::SymbolTable::getVisibilityAttrName()}, | ||||
attr.first.strref())) | attr.first.strref())) | ||||
return op.emitOpError() << "can only contain attributes with " | return op.emitOpError() << "can only contain attributes with " | ||||
"dialect-prefixed names, found: '" | "dialect-prefixed names, found: '" | ||||
<< attr.first << "'"; | << attr.first.getValue() << "'"; | ||||
} | } | ||||
// Check that there is at most one data layout spec attribute. | // Check that there is at most one data layout spec attribute. | ||||
StringRef layoutSpecAttrName; | StringRef layoutSpecAttrName; | ||||
DataLayoutSpecInterface layoutSpec; | DataLayoutSpecInterface layoutSpec; | ||||
for (const NamedAttribute &na : op->getAttrs()) { | for (const NamedAttribute &na : op->getAttrs()) { | ||||
if (auto spec = na.second.dyn_cast<DataLayoutSpecInterface>()) { | if (auto spec = na.second.dyn_cast<DataLayoutSpecInterface>()) { | ||||
if (layoutSpec) { | if (layoutSpec) { | ||||
InFlightDiagnostic diag = | InFlightDiagnostic diag = | ||||
op.emitOpError() << "expects at most one data layout attribute"; | op.emitOpError() << "expects at most one data layout attribute"; | ||||
diag.attachNote() << "'" << layoutSpecAttrName | diag.attachNote() << "'" << layoutSpecAttrName | ||||
<< "' is a data layout attribute"; | << "' is a data layout attribute"; | ||||
diag.attachNote() << "'" << na.first << "' is a data layout attribute"; | diag.attachNote() << "'" << na.first.getValue() | ||||
<< "' is a data layout attribute"; | |||||
} | } | ||||
layoutSpecAttrName = na.first.strref(); | layoutSpecAttrName = na.first.strref(); | ||||
layoutSpec = spec; | layoutSpec = spec; | ||||
} | } | ||||
} | } | ||||
return success(); | return success(); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 45 Lines • Show Last 20 Lines |