Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions mlir/test/mlir-tblgen/op-decl-and-defs.td
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ def NS_AOp : NS_Op<"a_op", [IsolatedFromAbove, IsolatedFromAbove]> {
// CHECK: ::llvm::LogicalResult verifyInvariants();
// CHECK: static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context);
// CHECK: ::llvm::LogicalResult fold(FoldAdaptor adaptor, ::llvm::SmallVectorImpl<::mlir::OpFoldResult> &results);
// CHECK: static ::llvm::LogicalResult setPropertiesFromParsedAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError);
// CHECK: // Display a graph for debugging purposes.
// CHECK: void displayGraph();
// CHECK: };
Expand Down
18 changes: 12 additions & 6 deletions mlir/tools/mlir-tblgen/OpFormatGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1302,8 +1302,8 @@ if (!dict) {
}
// keep track of used keys in the input dictionary to be able to error out
// if there are some unknown ones.
DenseSet<StringAttr> usedKeys;
MLIRContext *ctx = dict.getContext();
::mlir::DenseSet<::mlir::StringAttr> usedKeys;
::mlir::MLIRContext *ctx = dict.getContext();
(void)ctx;
)decl";

Expand All @@ -1315,7 +1315,7 @@ auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr,
::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::mlir::LogicalResult {{
{0};
};
auto {1}AttrName = StringAttr::get(ctx, "{1}");
auto {1}AttrName = ::mlir::StringAttr::get(ctx, "{1}");
usedKeys.insert({1}AttrName);
auto attr = dict.get({1}AttrName);
if (!attr && {2}) {{
Expand Down Expand Up @@ -1363,7 +1363,7 @@ if (attr && ::mlir::failed(setFromAttr(prop.{1}, attr, emitError)))
bool isRequired = !attr.isOptional() && !attr.hasDefaultValue();
body << formatv(R"decl(
auto &propStorage = prop.{0};
auto {0}AttrName = StringAttr::get(ctx, "{0}");
auto {0}AttrName = ::mlir::StringAttr::get(ctx, "{0}");
auto attr = dict.get({0}AttrName);
usedKeys.insert({0}AttrName);
if (attr || /*isRequired=*/{1}) {{
Expand All @@ -1384,7 +1384,7 @@ if (attr || /*isRequired=*/{1}) {{
namedAttr.name, isRequired);
}
body << R"decl(
for (NamedAttribute attr : dict) {
for (::mlir::NamedAttribute attr : dict) {
if (!usedKeys.contains(attr.getName()))
return emitError() << "unknown key '" << attr.getName() <<
"' when parsing properties dictionary";
Expand Down Expand Up @@ -3848,8 +3848,14 @@ void mlir::tblgen::generateOpFormat(const Operator &constOp, OpClass &opClass,
// TODO: Operator doesn't expose all necessary functionality via
// the const interface.
Operator &op = const_cast<Operator &>(constOp);
if (!op.hasAssemblyFormat())
if (!op.hasAssemblyFormat()) {
// We still need to generate the parsed attribute properties setter for
// allowing it to be reused in custom assembly implementations.
OperationFormat format(op, hasProperties);
format.hasPropDict = true;
genParsedAttrPropertiesSetter(format, op, opClass);
return;
}

// Parse the format description.
llvm::SourceMgr mgr;
Expand Down