[Mlir-commits] [mlir] fix: use LLVM result types in mlir-tblgen (PR #237375)
Alex Trotta
llvmlistbot at llvm.org
Fri Oct 30 13:54:06 PDT 2026
https://github.com/Ahajha updated https://github.com/llvm/llvm-project/pull/237375
>From a443f483bb678056d107c22000a21311568ca831 Mon Sep 17 00:00:00 2001
From: Alex Trotta <ahajha at gmail.com>
Date: Fri, 30 Oct 2026 16:25:53 -0400
Subject: [PATCH 1/2] fix: use LLVM result types in mlir-tblgen
mlir/Support/LogicalResult.h notes that it's a temporary header to ease the migration of uses. When migrating that use in our stack, we hit this case, where mlir-tblgen still assumes that the types are pulled from that header.
This patch fully qualifies the names to come from the proper namespace.
---
mlir/tools/mlir-tblgen/EnumsGen.cpp | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/mlir/tools/mlir-tblgen/EnumsGen.cpp b/mlir/tools/mlir-tblgen/EnumsGen.cpp
index c83ed3cf42fcd7..93f0aa00960c08 100644
--- a/mlir/tools/mlir-tblgen/EnumsGen.cpp
+++ b/mlir/tools/mlir-tblgen/EnumsGen.cpp
@@ -89,7 +89,7 @@ static void emitFieldParserDecls(const EnumInfo &enumInfo, StringRef qualName,
namespace mlir {
template<>
struct FieldParser<{0}, {0}> {{{1}
- static FailureOr<{0}> parse(AsmParser &parser);
+ static ::llvm::FailureOr<{0}> parse(AsmParser &parser);
};
/// Support for std::optional, useful in attribute/type definition where the enum is
@@ -100,7 +100,7 @@ template<>
struct FieldParser<std::optional<{0}>, std::optional<{0}>> {{
static constexpr bool isKeyValueCompositional = false;
- static FailureOr<std::optional<{0}>> parse(AsmParser &parser);
+ static ::llvm::FailureOr<std::optional<{0}>> parse(AsmParser &parser);
};
} // namespace mlir
)";
@@ -147,11 +147,11 @@ static void emitFieldParserDefs(const EnumInfo &enumInfo, raw_ostream &os) {
// Generate the parser for the enum, excluding non-quoted bit enums.
const char *const fieldParserDefs = R"(
namespace mlir {
-FailureOr<{0}> FieldParser<{0}, {0}>::parse(AsmParser &parser) {{
+::llvm::FailureOr<{0}> FieldParser<{0}, {0}>::parse(AsmParser &parser) {{
// Parse the keyword/string containing the enum.
std::string enumKeyword;
auto loc = parser.getCurrentLocation();
- if (failed(parser.parseOptionalKeywordOrString(&enumKeyword)))
+ if (::llvm::failed(parser.parseOptionalKeywordOrString(&enumKeyword)))
return parser.emitError(loc, "expected keyword for {2}");
// Symbolize the keyword.
@@ -160,12 +160,12 @@ FailureOr<{0}> FieldParser<{0}, {0}>::parse(AsmParser &parser) {{
return parser.emitError(loc, "expected one of {3} for {2}, got: ") << enumKeyword;
}
-FailureOr<std::optional<{0}>>
+::llvm::FailureOr<std::optional<{0}>>
FieldParser<std::optional<{0}>, std::optional<{0}>>::parse(AsmParser &parser) {{
// Parse the keyword/string containing the enum.
std::string enumKeyword;
auto loc = parser.getCurrentLocation();
- if (failed(parser.parseOptionalKeywordOrString(&enumKeyword, {4})))
+ if (::llvm::failed(parser.parseOptionalKeywordOrString(&enumKeyword, {4})))
return std::optional<{0}>{{};
// Symbolize the keyword.
@@ -178,13 +178,13 @@ FieldParser<std::optional<{0}>, std::optional<{0}>>::parse(AsmParser &parser) {{
const char *const fieldParserDefsUnquotedBitEnum = R"(
namespace mlir {
-FailureOr<{0}> FieldParser<{0}, {0}>::parse(AsmParser &parser) {{
+::llvm::FailureOr<{0}> FieldParser<{0}, {0}>::parse(AsmParser &parser) {{
{0} flags = {{};
do {{
// Parse the keyword containing a part of the enum.
::llvm::StringRef enumKeyword;
auto loc = parser.getCurrentLocation();
- if (failed(parser.parseOptionalKeyword(&enumKeyword))) {{
+ if (::llvm::failed(parser.parseOptionalKeyword(&enumKeyword))) {{
return parser.emitError(loc, "expected keyword for {2}");
}
@@ -194,11 +194,11 @@ FailureOr<{0}> FieldParser<{0}, {0}>::parse(AsmParser &parser) {{
} else {{
return parser.emitError(loc, "expected one of {3} for {2}, got: ") << enumKeyword;
}
- } while (::mlir::succeeded(parser.{5}()));
+ } while (::llvm::succeeded(parser.{5}()));
return flags;
}
-FailureOr<std::optional<{0}>>
+::llvm::FailureOr<std::optional<{0}>>
FieldParser<std::optional<{0}>, std::optional<{0}>>::parse(AsmParser &parser) {{
{0} flags = {{};
bool firstIter = true;
@@ -206,7 +206,7 @@ FieldParser<std::optional<{0}>, std::optional<{0}>>::parse(AsmParser &parser) {{
// Parse the keyword containing a part of the enum.
::llvm::StringRef enumKeyword;
auto loc = parser.getCurrentLocation();
- if (failed(parser.parseOptionalKeyword(&enumKeyword, {6}))) {{
+ if (::llvm::failed(parser.parseOptionalKeyword(&enumKeyword, {6}))) {{
if (firstIter)
return std::optional<{0}>{{};
return parser.emitError(loc, "expected keyword for {2} after '{4}'");
@@ -219,7 +219,7 @@ FieldParser<std::optional<{0}>, std::optional<{0}>>::parse(AsmParser &parser) {{
} else {{
return parser.emitError(loc, "expected one of {3} for {2}, got: ") << enumKeyword;
}
- } while(::mlir::succeeded(parser.{5}()));
+ } while(::llvm::succeeded(parser.{5}()));
return std::optional<{0}>{{flags};
}
} // namespace mlir
>From e5efe12f3c5ebde06c23ae7e7fb431351bd1bed4 Mon Sep 17 00:00:00 2001
From: Alex Trotta <ahajha at gmail.com>
Date: Fri, 30 Oct 2026 16:53:53 -0400
Subject: [PATCH 2/2] migrate a bunch more
---
mlir/test/mlir-tblgen/attr-or-type-format.td | 112 ++++++-------
mlir/test/mlir-tblgen/attrdefs.td | 4 +-
mlir/test/mlir-tblgen/constraint-unique.td | 40 ++---
.../default-type-attr-print-parser.td | 4 +-
mlir/test/mlir-tblgen/enums-gen.td | 2 +-
mlir/test/mlir-tblgen/op-decl-and-defs.td | 4 +-
mlir/test/mlir-tblgen/op-format.td | 18 +-
.../mlir-tblgen/op-properties-predicates.td | 20 +--
mlir/test/mlir-tblgen/op-result.td | 8 +-
mlir/test/mlir-tblgen/predicate.td | 4 +-
.../mlir-tblgen/rewriter-static-matcher.td | 16 +-
mlir/test/mlir-tblgen/typedefs.td | 4 +-
mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp | 30 ++--
.../tools/mlir-tblgen/AttrOrTypeFormatGen.cpp | 29 ++--
mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp | 104 ++++++------
mlir/tools/mlir-tblgen/OpFormatGen.cpp | 155 +++++++++---------
mlir/tools/mlir-tblgen/RewriterGen.cpp | 30 ++--
17 files changed, 289 insertions(+), 295 deletions(-)
diff --git a/mlir/test/mlir-tblgen/attr-or-type-format.td b/mlir/test/mlir-tblgen/attr-or-type-format.td
index d908a2a4793bc7..2e18cbaf226196 100644
--- a/mlir/test/mlir-tblgen/attr-or-type-format.td
+++ b/mlir/test/mlir-tblgen/attr-or-type-format.td
@@ -49,12 +49,12 @@ def TypeParamB : TypeParameter<"TestParamD", "a type param D"> {
// ATTR: if (odsParser.parseEqual())
// ATTR: return {};
// ATTR: _result_value = ::mlir::FieldParser<IntegerAttr>::parse(odsParser);
-// ATTR: if (::mlir::failed(_result_value))
+// ATTR: if (::llvm::failed(_result_value))
// ATTR: return {};
// ATTR: if (odsParser.parseComma())
// ATTR: return {};
// ATTR: _result_complex = ::parseAttrParamA(odsParser, odsType);
-// ATTR: if (::mlir::failed(_result_complex))
+// ATTR: if (::llvm::failed(_result_complex))
// ATTR: return {};
// ATTR: if (odsParser.parseRParen())
// ATTR: return {};
@@ -96,13 +96,13 @@ def AttrA : TestAttr<"TestA"> {
// ATTR: if (!_seen_v0 && _paramKey == "v0") {
// ATTR: _seen_v0 = true;
// ATTR: _result_v0 = ::parseAttrParamA(odsParser, odsType);
-// ATTR: if (::mlir::failed(_result_v0))
+// ATTR: if (::llvm::failed(_result_v0))
// ATTR: return {};
// ATTR: } else if (!_seen_v1 && _paramKey == "v1") {
// ATTR: _seen_v1 = true;
// ATTR: _result_v1 = odsType ? ::parseAttrWithType(odsParser, odsType) :
// ATTR-SAME: ::parseAttrWithout(odsParser);
-// ATTR: if (::mlir::failed(_result_v1))
+// ATTR: if (::llvm::failed(_result_v1))
// ATTR: return {};
// ATTR: } else {
// ATTR: return {};
@@ -144,15 +144,15 @@ def AttrB : TestAttr<"TestB"> {
// ATTR: ::mlir::Attribute TestFAttr::parse(::mlir::AsmParser &odsParser,
// ATTR: ::mlir::Type odsType) {
-// ATTR: ::mlir::FailureOr<int> _result_v0;
-// ATTR: ::mlir::FailureOr<int> _result_v1;
+// ATTR: ::llvm::FailureOr<int> _result_v0;
+// ATTR: ::llvm::FailureOr<int> _result_v1;
// ATTR: _result_v0 = ::mlir::FieldParser<int>::parse(odsParser);
-// ATTR: if (::mlir::failed(_result_v0))
+// ATTR: if (::llvm::failed(_result_v0))
// ATTR: return {};
// ATTR: if (odsParser.parseComma())
// ATTR: return {};
// ATTR: _result_v1 = ::mlir::FieldParser<int>::parse(odsParser);
-// ATTR: if (::mlir::failed(_result_v1))
+// ATTR: if (::llvm::failed(_result_v1))
// ATTR: return {};
// ATTR: return TestFAttr::get(odsParser.getContext(),
// ATTR: int((*_result_v0)),
@@ -241,7 +241,7 @@ def EnumAttrC : EnumAttr<Test_Dialect, TestStructEnum, "EnumAttrC">;
// EnumAttr parameters in a struct use the underlying enum syntax rather than
// the EnumAttr's assembly format.
// ATTR-LABEL: AttrWithEnumAttrStructAttr::parse
-// ATTR: _result_required = [&]() -> ::mlir::FailureOr<::TestStructEnumAttr> {
+// ATTR: _result_required = [&]() -> ::llvm::FailureOr<::TestStructEnumAttr> {
// ATTR-NEXT: auto odsEnumValue = ::mlir::FieldParser<::TestStructEnum>::parse(odsParser);
// ATTR: return ::TestStructEnumAttr::get(odsParser.getContext(), *odsEnumValue);
// ATTR-LABEL: AttrWithEnumAttrStructAttr::print
@@ -302,14 +302,14 @@ def AttrWithBitEnumAttrStruct : TestAttr<"AttrWithBitEnumAttrStruct"> {
// TYPE: if (odsParser.parseKeyword("bar"))
// TYPE: return {};
// TYPE: _result_value = ::mlir::FieldParser<IntegerAttr>::parse(odsParser);
-// TYPE: if (::mlir::failed(_result_value))
+// TYPE: if (::llvm::failed(_result_value))
// TYPE: return {};
// TYPE: bool _seen_complex = false;
// TYPE: const auto _loop_body = [&](::llvm::StringRef _paramKey) -> bool {
// TYPE: if (!_seen_complex && _paramKey == "complex") {
// TYPE: _seen_complex = true;
// TYPE: _result_complex = ::parseTypeParamC(odsParser);
-// TYPE: if (::mlir::failed(_result_complex))
+// TYPE: if (::llvm::failed(_result_complex))
// TYPE: return {};
// TYPE: } else {
// TYPE: return {};
@@ -356,7 +356,7 @@ def TypeA : TestType<"TestC"> {
// TYPE: ::mlir::Type TestDType::parse(::mlir::AsmParser &odsParser) {
// TYPE: _result_v0 = ::parseTypeParamC(odsParser);
-// TYPE: if (::mlir::failed(_result_v0))
+// TYPE: if (::llvm::failed(_result_v0))
// TYPE: return {};
// TYPE: bool _seen_v1 = false;
// TYPE: bool _seen_v2 = false;
@@ -366,12 +366,12 @@ def TypeA : TestType<"TestC"> {
// TYPE: if (!_seen_v1 && _paramKey == "v1") {
// TYPE: _seen_v1 = true;
// TYPE: _result_v1 = someFcnCall();
-// TYPE: if (::mlir::failed(_result_v1))
+// TYPE: if (::llvm::failed(_result_v1))
// TYPE: return {};
// TYPE: } else if (!_seen_v2 && _paramKey == "v2") {
// TYPE: _seen_v2 = true;
// TYPE: _result_v2 = ::parseTypeParamC(odsParser);
-// TYPE: if (::mlir::failed(_result_v2))
+// TYPE: if (::llvm::failed(_result_v2))
// TYPE: return {};
// TYPE: } else {
// TYPE: return {};
@@ -387,7 +387,7 @@ def TypeA : TestType<"TestC"> {
// TYPE: return {};
// TYPE: }
// TYPE: _result_v3 = someFcnCall();
-// TYPE: if (::mlir::failed(_result_v3))
+// TYPE: if (::llvm::failed(_result_v3))
// TYPE: return {};
// TYPE: return TestDType::get(odsParser.getContext(),
// TYPE: TestParamC((*_result_v0)),
@@ -432,12 +432,12 @@ def TypeB : TestType<"TestD"> {
// TYPE: if (!_seen_v0 && _paramKey == "v0") {
// TYPE: _seen_v0 = true;
// TYPE: _result_v0 = ::mlir::FieldParser<IntegerAttr>::parse(odsParser);
-// TYPE: if (::mlir::failed(_result_v0))
+// TYPE: if (::llvm::failed(_result_v0))
// TYPE: return {};
// TYPE: } else if (!_seen_v2 && _paramKey == "v2") {
// TYPE: _seen_v2 = true;
// TYPE: _result_v2 = ::mlir::FieldParser<IntegerAttr>::parse(odsParser);
-// TYPE: if (::mlir::failed(_result_v2))
+// TYPE: if (::llvm::failed(_result_v2))
// TYPE: return {};
// TYPE: } else {
// TYPE: return {};
@@ -460,12 +460,12 @@ def TypeB : TestType<"TestD"> {
// TYPE: if (!_seen_v1 && _paramKey == "v1") {
// TYPE: _seen_v1 = true;
// TYPE: _result_v1 = ::mlir::FieldParser<IntegerAttr>::parse(odsParser);
-// TYPE: if (::mlir::failed(_result_v1))
+// TYPE: if (::llvm::failed(_result_v1))
// TYPE: return {};
// TYPE: } else if (!_seen_v3 && _paramKey == "v3") {
// TYPE: _seen_v3 = true;
// TYPE: _result_v3 = ::mlir::FieldParser<IntegerAttr>::parse(odsParser);
-// TYPE: if (::mlir::failed(_result_v3))
+// TYPE: if (::llvm::failed(_result_v3))
// TYPE: return {};
// TYPE: } else {
// TYPE: return {};
@@ -526,9 +526,9 @@ def TypeD : TestType<"TestF"> {
}
// TYPE: ::mlir::Type TestGType::parse(::mlir::AsmParser &odsParser) {
-// TYPE: if (::mlir::failed(_result_a))
+// TYPE: if (::llvm::failed(_result_a))
// TYPE: return {};
-// TYPE: if (::mlir::succeeded(_result_a) && !((*_result_a) == int()))
+// TYPE: if (::llvm::succeeded(_result_a) && !((*_result_a) == int()))
// TYPE: if (odsParser.parseComma())
// TYPE: return {};
@@ -567,11 +567,11 @@ def TypeF : TestType<"TestH"> {
// TYPE: do {
// TYPE: _result_a = ::mlir::FieldParser<int>::parse(odsParser);
-// TYPE: if (::mlir::failed(_result_a))
+// TYPE: if (::llvm::failed(_result_a))
// TYPE: return {};
// TYPE: if (odsParser.parseOptionalComma()) break;
// TYPE: _result_b = ::mlir::FieldParser<int>::parse(odsParser);
-// TYPE: if (::mlir::failed(_result_b))
+// TYPE: if (::llvm::failed(_result_b))
// TYPE: return {};
// TYPE: } while(false);
@@ -586,12 +586,12 @@ def TypeG : TestType<"TestI"> {
// TYPE: if (odsParser.parseKeyword("x")) return {};
// TYPE: } else {
// TYPE: _result_b = ::mlir::FieldParser<int>::parse(odsParser);
-// TYPE: if (::mlir::failed(_result_b))
+// TYPE: if (::llvm::failed(_result_b))
// TYPE: return {};
// TYPE: if (odsParser.parseRParen()) return {};
// TYPE: }
// TYPE: _result_a = ::mlir::FieldParser<int>::parse(odsParser);
-// TYPE: if (::mlir::failed(_result_a))
+// TYPE: if (::llvm::failed(_result_a))
// TYPE: return {};
// TYPE: void TestJType::print(::mlir::AsmPrinter &odsPrinter) const {
@@ -627,8 +627,8 @@ def TypeI : TestType<"TestK"> {
// TYPE: auto odsCustomLoc = odsParser.getCurrentLocation()
// TYPE: auto odsCustomResult = parseA(odsParser,
// TYPE-NEXT: _result_a
-// TYPE: if (::mlir::failed(odsCustomResult)) return {}
-// TYPE: if (::mlir::failed(_result_a))
+// TYPE: if (::llvm::failed(odsCustomResult)) return {}
+// TYPE: if (::llvm::failed(_result_a))
// TYPE-NEXT: odsParser.emitError(odsCustomLoc,
// TYPE: auto odsCustomResult = parseB(odsParser,
// TYPE-NEXT: _result_b
@@ -719,9 +719,9 @@ def TypeN : TestType<"TestP"> {
// TYPE: if (auto result = [&]() -> ::mlir::OptionalParseResult {
// TYPE: auto odsCustomResult = parseAB(odsParser
// TYPE: if (!odsCustomResult.has_value()) return {};
-// TYPE: if (::mlir::failed(*odsCustomResult)) return ::mlir::failure();
-// TYPE: return ::mlir::success();
-// TYPE: }(); result.has_value() && ::mlir::failed(*result)) {
+// TYPE: if (::llvm::failed(*odsCustomResult)) return ::llvm::failure();
+// TYPE: return ::llvm::success();
+// TYPE: }(); result.has_value() && ::llvm::failed(*result)) {
// TYPE: return {};
// TYPE: } else if (result.has_value()) {
// TYPE: // Parse literal 'y'
@@ -738,17 +738,17 @@ def TypeO : TestType<"TestQ"> {
// TYPE: ::llvm::LogicalResult TestPType::verifyInvariantsImpl(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::Type a) {
// TYPE: if (!(((a.isSignlessInteger(16))) || ((a.isSignlessInteger(32))))) {
// TYPE: emitError() << "failed to verify 'a': 16-bit signless integer or 32-bit signless integer";
-// TYPE: return ::mlir::failure();
+// TYPE: return ::llvm::failure();
// TYPE: }
-// TYPE: return ::mlir::success();
+// TYPE: return ::llvm::success();
// TYPE: }
// TYPE: ::llvm::LogicalResult TestPType::verifyInvariants(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::Type a) {
-// TYPE: if (::mlir::failed(verifyInvariantsImpl(emitError, a)))
-// TYPE: return ::mlir::failure();
-// TYPE: if (::mlir::failed(verify(emitError, a)))
-// TYPE: return ::mlir::failure();
-// TYPE: return ::mlir::success();
+// TYPE: if (::llvm::failed(verifyInvariantsImpl(emitError, a)))
+// TYPE: return ::llvm::failure();
+// TYPE: if (::llvm::failed(verify(emitError, a)))
+// TYPE: return ::llvm::failure();
+// TYPE: return ::llvm::success();
// TYPE: }
def TypeP : TestType<"TestP"> {
@@ -761,17 +761,17 @@ def TypeP : TestType<"TestP"> {
// ATTR: ::llvm::LogicalResult TestRAttr::verifyInvariantsImpl(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::IntegerType a) {
// ATTR: if (!((a.isSignlessInteger(32)))) {
// ATTR: emitError() << "failed to verify 'a': 32-bit signless integer";
-// ATTR: return ::mlir::failure();
+// ATTR: return ::llvm::failure();
// ATTR: }
-// ATTR: return ::mlir::success();
+// ATTR: return ::llvm::success();
// ATTR: }
// ATTR: ::llvm::LogicalResult TestRAttr::verifyInvariants(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::IntegerType a) {
-// ATTR: if (::mlir::failed(verifyInvariantsImpl(emitError, a)))
-// ATTR: return ::mlir::failure();
-// ATTR: if (::mlir::failed(verify(emitError, a)))
-// ATTR: return ::mlir::failure();
-// ATTR: return ::mlir::success();
+// ATTR: if (::llvm::failed(verifyInvariantsImpl(emitError, a)))
+// ATTR: return ::llvm::failure();
+// ATTR: if (::llvm::failed(verify(emitError, a)))
+// ATTR: return ::llvm::failure();
+// ATTR: return ::llvm::success();
// ATTR: }
def AttrR : TestAttr<"TestR"> {
@@ -784,17 +784,17 @@ def AttrR : TestAttr<"TestR"> {
// TYPE: ::llvm::LogicalResult TestSType::verifyInvariantsImpl(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::ArrayAttr a) {
// TYPE: if (!((::llvm::isa<::mlir::ArrayAttr>(a)))) {
// TYPE: emitError() << "failed to verify 'a': A collection of other Attribute values";
-// TYPE: return ::mlir::failure();
+// TYPE: return ::llvm::failure();
// TYPE: }
-// TYPE: return ::mlir::success();
+// TYPE: return ::llvm::success();
// TYPE: }
// TYPE: ::llvm::LogicalResult TestSType::verifyInvariants(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::ArrayAttr a) {
-// TYPE: if (::mlir::failed(verifyInvariantsImpl(emitError, a)))
-// TYPE: return ::mlir::failure();
-// TYPE: if (::mlir::failed(verify(emitError, a)))
-// TYPE: return ::mlir::failure();
-// TYPE: return ::mlir::success();
+// TYPE: if (::llvm::failed(verifyInvariantsImpl(emitError, a)))
+// TYPE: return ::llvm::failure();
+// TYPE: if (::llvm::failed(verify(emitError, a)))
+// TYPE: return ::llvm::failure();
+// TYPE: return ::llvm::success();
// TYPE: }
def TypeS : TestType<"TestS"> {
@@ -818,15 +818,15 @@ def TypeS : TestType<"TestS"> {
// ATTR: if (!_seen_v0 && _paramKey == "v0") {
// ATTR: _seen_v0 = true;
// ATTR: _result_v0 = ::parseAttrParamA(odsParser, odsType);
-// ATTR: if (::mlir::failed(_result_v0))
+// ATTR: if (::llvm::failed(_result_v0))
// ATTR: return {};
// ATTR: } else if (!_seen_v1 && _paramKey == "v1") {
// ATTR: _seen_v1 = true;
// ATTR: {
// ATTR: auto odsCustomResult = parseNestedCustom(odsParser,
// ATTR-NEXT: ::mlir::detail::unwrapForCustomParse(_result_v1));
-// ATTR: if (::mlir::failed(odsCustomResult)) return {};
-// ATTR: if (::mlir::failed(_result_v1)) {
+// ATTR: if (::llvm::failed(odsCustomResult)) return {};
+// ATTR: if (::llvm::failed(_result_v1)) {
// ATTR: odsParser.emitError(odsCustomLoc, "custom parser failed to parse parameter 'v1'");
// ATTR: return {};
// ATTR: }
@@ -834,7 +834,7 @@ def TypeS : TestType<"TestS"> {
// ATTR: } else if (!_seen_v2 && _paramKey == "v2") {
// ATTR: _seen_v2 = true;
// ATTR: _result_v2 = ::mlir::FieldParser<AttrParamB>::parse(odsParser);
-// ATTR: if (::mlir::failed(_result_v2)) {
+// ATTR: if (::llvm::failed(_result_v2)) {
// ATTR: odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse AttrT parameter 'v2' which is to be a `AttrParamB`");
// ATTR: return {};
// ATTR: }
@@ -954,5 +954,5 @@ def AttrWithOptArrayRefInStruct : TestAttr<"AttrWithOptArrayRefInStruct"> {
// DEFAULT_TYPE_PARSER: TestDialect::parseType(::mlir::DialectAsmParser &parser)
// DEFAULT_TYPE_PARSER: auto parseResult = parseOptionalDynamicType(mnemonic, parser, genType);
// DEFAULT_TYPE_PARSER: if (parseResult.has_value()) {
-// DEFAULT_TYPE_PARSER: if (::mlir::succeeded(parseResult.value()))
+// DEFAULT_TYPE_PARSER: if (::llvm::succeeded(parseResult.value()))
// DEFAULT_TYPE_PARSER: return genType;
diff --git a/mlir/test/mlir-tblgen/attrdefs.td b/mlir/test/mlir-tblgen/attrdefs.td
index a809611fd0aec1..92ad4c2b733a13 100644
--- a/mlir/test/mlir-tblgen/attrdefs.td
+++ b/mlir/test/mlir-tblgen/attrdefs.td
@@ -26,10 +26,10 @@ include "mlir/IR/OpBase.td"
// DEF: return ::mlir::AsmParser::KeywordSwitch<::mlir::OptionalParseResult>(parser)
// DEF: .Case(::test::IndexAttr::getMnemonic()
// DEF-NEXT: value = ::test::IndexAttr::parse(parser, type);
-// DEF-NEXT: return ::mlir::success(!!value);
+// DEF-NEXT: return ::llvm::success(!!value);
// DEF: .Case(::test::CompoundAAttr::getMnemonic()
// DEF-NEXT: value = ::test::CompoundAAttr::parse(parser, type);
-// DEF-NEXT: return ::mlir::success(!!value);
+// DEF-NEXT: return ::llvm::success(!!value);
// DEF-NEXT: })
// DEF: .Default([&](llvm::StringRef keyword,
// DEF-NEXT: *mnemonic = keyword;
diff --git a/mlir/test/mlir-tblgen/constraint-unique.td b/mlir/test/mlir-tblgen/constraint-unique.td
index 55d6a56e3fc80c..00243b798fa097 100644
--- a/mlir/test/mlir-tblgen/constraint-unique.td
+++ b/mlir/test/mlir-tblgen/constraint-unique.td
@@ -118,38 +118,38 @@ def OpC : NS_Op<"op_c"> {
/// Test that the uniqued constraints are being used.
// CHECK-LABEL: OpA::verifyInvariantsImpl
// CHECK: auto [[$B_ATTR:.*b]] = getProperties().b;
-// CHECK: if (::mlir::failed([[$A_ATTR_CONSTRAINT]](*this, [[$B_ATTR]], "b")))
-// CHECK-NEXT: return ::mlir::failure();
+// CHECK: if (::llvm::failed([[$A_ATTR_CONSTRAINT]](*this, [[$B_ATTR]], "b")))
+// CHECK-NEXT: return ::llvm::failure();
// CHECK: auto [[$A_VALUE_GROUP:.*]] = getODSOperands(0);
// CHECK: for (auto [[$A_VALUE:.*]] : [[$A_VALUE_GROUP]])
-// CHECK-NEXT: if (::mlir::failed([[$A_TYPE_CONSTRAINT]](*this, [[$A_VALUE]].getType(), "operand", index++)))
-// CHECK-NEXT: return ::mlir::failure();
+// CHECK-NEXT: if (::llvm::failed([[$A_TYPE_CONSTRAINT]](*this, [[$A_VALUE]].getType(), "operand", index++)))
+// CHECK-NEXT: return ::llvm::failure();
// CHECK: auto [[$RET_VALUE_GROUP:.*]] = getODSResults(0);
// CHECK: for (auto [[$RET_VALUE:.*]] : [[$RET_VALUE_GROUP]])
-// CHECK-NEXT: if (::mlir::failed([[$A_TYPE_CONSTRAINT]](*this, [[$RET_VALUE]].getType(), "result", index++)))
-// CHECK-NEXT: return ::mlir::failure();
+// CHECK-NEXT: if (::llvm::failed([[$A_TYPE_CONSTRAINT]](*this, [[$RET_VALUE]].getType(), "result", index++)))
+// CHECK-NEXT: return ::llvm::failure();
// CHECK: for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0)))
-// CHECK-NEXT: if (::mlir::failed([[$A_REGION_CONSTRAINT]](*this, region, "d", index++)))
-// CHECK-NEXT: return ::mlir::failure();
-// CHECK: if (::mlir::failed([[$A_SUCCESSOR_CONSTRAINT]](*this, getC(), "c", index++)))
-// CHECK-NEXT: return ::mlir::failure();
+// CHECK-NEXT: if (::llvm::failed([[$A_REGION_CONSTRAINT]](*this, region, "d", index++)))
+// CHECK-NEXT: return ::llvm::failure();
+// CHECK: if (::llvm::failed([[$A_SUCCESSOR_CONSTRAINT]](*this, getC(), "c", index++)))
+// CHECK-NEXT: return ::llvm::failure();
/// Test that the op with the same predicates but different with descriptions
/// uses the different constraints.
// CHECK-LABEL: OpC::verifyInvariantsImpl
// CHECK: auto [[$B_ATTR:.*b]] = getProperties().b;
-// CHECK: if (::mlir::failed([[$O_ATTR_CONSTRAINT]](*this, [[$B_ATTR]], "b")))
-// CHECK-NEXT: return ::mlir::failure();
+// CHECK: if (::llvm::failed([[$O_ATTR_CONSTRAINT]](*this, [[$B_ATTR]], "b")))
+// CHECK-NEXT: return ::llvm::failure();
// CHECK: auto [[$A_VALUE_GROUP:.*]] = getODSOperands(0);
// CHECK: for (auto [[$A_VALUE:.*]] : [[$A_VALUE_GROUP]])
-// CHECK-NEXT: if (::mlir::failed([[$O_TYPE_CONSTRAINT]](*this, [[$A_VALUE]].getType(), "operand", index++)))
-// CHECK-NEXT: return ::mlir::failure();
+// CHECK-NEXT: if (::llvm::failed([[$O_TYPE_CONSTRAINT]](*this, [[$A_VALUE]].getType(), "operand", index++)))
+// CHECK-NEXT: return ::llvm::failure();
// CHECK: auto [[$RET_VALUE_GROUP:.*]] = getODSResults(0);
// CHECK: for (auto [[$RET_VALUE:.*]] : [[$RET_VALUE_GROUP]])
-// CHECK-NEXT: if (::mlir::failed([[$O_TYPE_CONSTRAINT]](*this, [[$RET_VALUE]].getType(), "result", index++)))
-// CHECK-NEXT: return ::mlir::failure();
+// CHECK-NEXT: if (::llvm::failed([[$O_TYPE_CONSTRAINT]](*this, [[$RET_VALUE]].getType(), "result", index++)))
+// CHECK-NEXT: return ::llvm::failure();
// CHECK: for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0)))
-// CHECK-NEXT: if (::mlir::failed([[$O_REGION_CONSTRAINT]](*this, region, "d", index++)))
-// CHECK-NEXT: return ::mlir::failure();
-// CHECK: if (::mlir::failed([[$O_SUCCESSOR_CONSTRAINT]](*this, getC(), "c", index++)))
-// CHECK-NEXT: return ::mlir::failure();
+// CHECK-NEXT: if (::llvm::failed([[$O_REGION_CONSTRAINT]](*this, region, "d", index++)))
+// CHECK-NEXT: return ::llvm::failure();
+// CHECK: if (::llvm::failed([[$O_SUCCESSOR_CONSTRAINT]](*this, getC(), "c", index++)))
+// CHECK-NEXT: return ::llvm::failure();
diff --git a/mlir/test/mlir-tblgen/default-type-attr-print-parser.td b/mlir/test/mlir-tblgen/default-type-attr-print-parser.td
index c0eedb879bcda4..1000fd5f9530cb 100644
--- a/mlir/test/mlir-tblgen/default-type-attr-print-parser.td
+++ b/mlir/test/mlir-tblgen/default-type-attr-print-parser.td
@@ -40,7 +40,7 @@ def AttrA : TestAttr<"AttrA"> {
// ATTR: void TestDialect::printAttribute(::mlir::Attribute attr,
// ATTR: ::mlir::DialectAsmPrinter &printer) const {
-// ATTR: if (::mlir::succeeded(generatedAttributePrinter(attr, printer)))
+// ATTR: if (::llvm::succeeded(generatedAttributePrinter(attr, printer)))
// ATTR: return;
// ATTR: }
@@ -66,7 +66,7 @@ def TypeA : TestType<"TypeA"> {
// TYPE: void TestDialect::printType(::mlir::Type type,
// TYPE: ::mlir::DialectAsmPrinter &printer) const {
-// TYPE: if (::mlir::succeeded(generatedTypePrinter(type, printer)))
+// TYPE: if (::llvm::succeeded(generatedTypePrinter(type, printer)))
// TYPE: return;
// TYPE: }
diff --git a/mlir/test/mlir-tblgen/enums-gen.td b/mlir/test/mlir-tblgen/enums-gen.td
index dc0caab3652d9f..6667e82c111f5a 100644
--- a/mlir/test/mlir-tblgen/enums-gen.td
+++ b/mlir/test/mlir-tblgen/enums-gen.td
@@ -165,7 +165,7 @@ def MyNonQuotedPrintBitEnum
// DEF: } else {
// DEF: return parser.emitError(loc, "expected one of [none, tagged, Bit1, Bit2, Bit3, BitGroup] for Example new-style bit enum, got: ") << enumKeyword;
// DEF: }
-// DEF: } while (::mlir::succeeded(parser.parseOptionalVerticalBar()));
+// DEF: } while (::llvm::succeeded(parser.parseOptionalVerticalBar()));
// DEF: return flags;
// DEF: }
diff --git a/mlir/test/mlir-tblgen/op-decl-and-defs.td b/mlir/test/mlir-tblgen/op-decl-and-defs.td
index 5bc9117f450bb1..28a0fa557f31d6 100644
--- a/mlir/test/mlir-tblgen/op-decl-and-defs.td
+++ b/mlir/test/mlir-tblgen/op-decl-and-defs.td
@@ -146,7 +146,7 @@ def NS_AOp : NS_Op<"a_op", [IsolatedFromAbove, IsolatedFromAbove]> {
// CHECK-NEXT: static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes, unsigned numRegions)
// CHECK-NEXT: static AOp create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes, unsigned numRegions)
// CHECK-NEXT: static AOp create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes, unsigned numRegions)
-// CHECK: static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result);
+// CHECK: static ::llvm::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result);
// CHECK: void print(::mlir::OpAsmPrinter &p);
// CHECK: ::llvm::LogicalResult verifyInvariants();
// CHECK: static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context);
@@ -275,7 +275,7 @@ def NS_FOp : NS_Op<"op_with_all_types_constraint",
// CHECK: static ::llvm::LogicalResult inferReturnTypes
// DEFS: void FOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value a) {
-// DEFS: if (::mlir::succeeded(FOp::inferReturnTypes(odsBuilder.getContext(),
+// DEFS: if (::llvm::succeeded(FOp::inferReturnTypes(odsBuilder.getContext(),
// DEFS: else
// DEFS: ::mlir::detail::reportFatalInferReturnTypesError(odsState);
diff --git a/mlir/test/mlir-tblgen/op-format.td b/mlir/test/mlir-tblgen/op-format.td
index 679d45b7fa0def..d303cdce5e3a66 100644
--- a/mlir/test/mlir-tblgen/op-format.td
+++ b/mlir/test/mlir-tblgen/op-format.td
@@ -65,7 +65,7 @@ def PropDictStrictInferredSegmentAttr : TestStrictPropertiesFormat_Op<[{
// CHECK-SAME: be parsed from attr-dict when strict properties in assembly
// CHECK-SAME: format is enabled");
// CHECK-NOT: verifyInherentAttrs
-// CHECK: return ::mlir::success();
+// CHECK: return ::llvm::success();
def AttrDictStrictInherentAttr : TestStrictPropertiesFormat_Op<[{
$attr attr-dict
}]>, Arguments<(ins I64Attr:$attr)>;
@@ -326,7 +326,7 @@ def LegacyUnquotedBitEnumOp : TestFormat_Op<"$attr attr-dict">,
//===----------------------------------------------------------------------===//
// CHECK-LABEL: OptionalGroupA::parse
-// CHECK: if (::mlir::succeeded(parser.parseOptionalQuestion())
+// CHECK: if (::llvm::succeeded(parser.parseOptionalQuestion())
// CHECK-NEXT: else
// CHECK: ::mlir::detail::parseOptionalOperandInto(parser, aOperands)
// CHECK-LABEL: OptionalGroupA::print
@@ -339,7 +339,7 @@ def OptionalGroupA : TestFormat_Op<[{
}]>, Arguments<(ins Optional<I1>:$a)>;
// CHECK-LABEL: OptionalGroupB::parse
-// CHECK: if (::mlir::succeeded(parser.parseOptionalKeyword("foo")))
+// CHECK: if (::llvm::succeeded(parser.parseOptionalKeyword("foo")))
// CHECK-NEXT: else
// CHECK-NEXT: result.getOrAddProperties<OptionalGroupB::Properties>().a = parser.getBuilder().getUnitAttr()
// CHECK: parser.parseKeyword("bar")
@@ -377,10 +377,10 @@ def OptionalGroupCPropDict : TestFormat_Op<[{
// CHECK: if (auto optResult = [&]() -> ::mlir::OptionalParseResult {
// CHECK: auto odsResult = parseCustom(parser, aOperand, bOperand);
// CHECK: if (!odsResult.has_value()) return {};
-// CHECK: if (::mlir::failed(*odsResult)) return ::mlir::failure();
-// CHECK: return ::mlir::success();
-// CHECK: }(); optResult.has_value() && ::mlir::failed(*optResult)) {
-// CHECK: return ::mlir::failure();
+// CHECK: if (::llvm::failed(*odsResult)) return ::llvm::failure();
+// CHECK: return ::llvm::success();
+// CHECK: }(); optResult.has_value() && ::llvm::failed(*optResult)) {
+// CHECK: return ::llvm::failure();
// CHECK: } else if (optResult.has_value()) {
// CHECK-LABEL: OptionalGroupD::print
@@ -419,7 +419,7 @@ def PropDictSegmentSizesInferred : TestFormat_Op<[{
// CHECK-NEXT: usedKeys.insert(operandSegmentSizesAttrName);
// CHECK-NEXT: auto attr = dict.get(operandSegmentSizesAttrName);
// CHECK-NEXT: if (!attr) {
-// CHECK: if (::mlir::failed(::mlir::convertFromAttribute(prop.operandSegmentSizes, attr,
+// CHECK: if (::llvm::failed(::mlir::convertFromAttribute(prop.operandSegmentSizes, attr,
def PropDictSegmentSizesRequired : TestFormat_Op<[{
`(` operands `)` `:` type(operands) prop-dict attr-dict
}], [AttrSizedOperandSegments]>,
@@ -427,7 +427,7 @@ def PropDictSegmentSizesRequired : TestFormat_Op<[{
// CHECK-LABEL: PropDictStrictInferredSegmentAttr::setPropertiesFromParsedAttr
// CHECK-NOT: segment_sizes
-// CHECK: return ::mlir::success();
+// CHECK: return ::llvm::success();
// CHECK-LABEL: PropDictStrictInferredSegmentAttr::print
// CHECK: elidedProps.push_back("segment_sizes");
diff --git a/mlir/test/mlir-tblgen/op-properties-predicates.td b/mlir/test/mlir-tblgen/op-properties-predicates.td
index dd3f4db7a72c36..9497549686c71e 100644
--- a/mlir/test/mlir-tblgen/op-properties-predicates.td
+++ b/mlir/test/mlir-tblgen/op-properties-predicates.td
@@ -79,30 +79,30 @@ def OpWithPredicates : NS_Op<"op_with_predicates"> {
// CHECK-LABEL: OpWithPredicates::verifyInvariantsImpl()
// Note: for test readability, we capture [[maybe_unused]] into the variable maybe_unused
// CHECK: [[maybe_unused:\[\[maybe_unused\]\]]] int64_t tblgen_scalar = this->getScalar();
-// CHECK: if (::mlir::failed(__mlir_ods_local_prop_constraint_op2Dproperties2Dpredicates1(*this, tblgen_scalar, "scalar")))
-// CHECK-NEXT: return ::mlir::failure()
+// CHECK: if (::llvm::failed(__mlir_ods_local_prop_constraint_op2Dproperties2Dpredicates1(*this, tblgen_scalar, "scalar")))
+// CHECK-NEXT: return ::llvm::failure()
// CHECK: [[maybe_unused]] std::optional<int64_t> tblgen_optional = this->getOptional();
-// CHECK: if (::mlir::failed(__mlir_ods_local_prop_constraint_op2Dproperties2Dpredicates2(*this, tblgen_optional, "optional")))
+// CHECK: if (::llvm::failed(__mlir_ods_local_prop_constraint_op2Dproperties2Dpredicates2(*this, tblgen_optional, "optional")))
// COM: The predicates for "scalar" and "defaulted" are uniqued
// CHECK: [[maybe_unused]] int64_t tblgen_defaulted = this->getDefaulted();
-// CHECK: if (::mlir::failed(__mlir_ods_local_prop_constraint_op2Dproperties2Dpredicates1(*this, tblgen_defaulted, "defaulted")))
+// CHECK: if (::llvm::failed(__mlir_ods_local_prop_constraint_op2Dproperties2Dpredicates1(*this, tblgen_defaulted, "defaulted")))
// CHECK: [[maybe_unused]] int64_t tblgen_moreConstrained = this->getMoreConstrained();
-// CHECK: if (::mlir::failed(__mlir_ods_local_prop_constraint_op2Dproperties2Dpredicates3(*this, tblgen_moreConstrained, "moreConstrained")))
+// CHECK: if (::llvm::failed(__mlir_ods_local_prop_constraint_op2Dproperties2Dpredicates3(*this, tblgen_moreConstrained, "moreConstrained")))
// CHECK: [[maybe_unused]] ::llvm::ArrayRef<int64_t> tblgen_array = this->getArray();
-// CHECK: if (::mlir::failed(__mlir_ods_local_prop_constraint_op2Dproperties2Dpredicates4(*this, tblgen_array, "array")))
+// CHECK: if (::llvm::failed(__mlir_ods_local_prop_constraint_op2Dproperties2Dpredicates4(*this, tblgen_array, "array")))
// CHECK: [[maybe_unused]] ::llvm::ArrayRef<int64_t> tblgen_nonEmptyUnconstrained = this->getNonEmptyUnconstrained();
-// CHECK: if (::mlir::failed(__mlir_ods_local_prop_constraint_op2Dproperties2Dpredicates5(*this, tblgen_nonEmptyUnconstrained, "non_empty_unconstrained")))
+// CHECK: if (::llvm::failed(__mlir_ods_local_prop_constraint_op2Dproperties2Dpredicates5(*this, tblgen_nonEmptyUnconstrained, "non_empty_unconstrained")))
// CHECK: [[maybe_unused]] ::llvm::ArrayRef<int64_t> tblgen_nonEmptyConstrained = this->getNonEmptyConstrained();
-// CHECK: if (::mlir::failed(__mlir_ods_local_prop_constraint_op2Dproperties2Dpredicates6(*this, tblgen_nonEmptyConstrained, "non_empty_constrained")))
+// CHECK: if (::llvm::failed(__mlir_ods_local_prop_constraint_op2Dproperties2Dpredicates6(*this, tblgen_nonEmptyConstrained, "non_empty_constrained")))
// CHECK: [[maybe_unused]] std::optional<::llvm::ArrayRef<int64_t>> tblgen_nonEmptyOptional = this->getNonEmptyOptional();
-// CHECK: if (::mlir::failed(__mlir_ods_local_prop_constraint_op2Dproperties2Dpredicates7(*this, tblgen_nonEmptyOptional, "non_empty_optional")))
+// CHECK: if (::llvm::failed(__mlir_ods_local_prop_constraint_op2Dproperties2Dpredicates7(*this, tblgen_nonEmptyOptional, "non_empty_optional")))
// CHECK-NOT: int64_t tblgen_unconstrained
-// CHECK: return ::mlir::success();
+// CHECK: return ::llvm::success();
diff --git a/mlir/test/mlir-tblgen/op-result.td b/mlir/test/mlir-tblgen/op-result.td
index ddc1ef077d31c8..fa442a078929fd 100644
--- a/mlir/test/mlir-tblgen/op-result.td
+++ b/mlir/test/mlir-tblgen/op-result.td
@@ -36,7 +36,7 @@ def OpB : NS_Op<"same_input_output_type_op", [SameOperandsAndResultType]> {
// CHECK: odsState.addTypes(y);
// CHECK: void OpB::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value x)
// CHECK: ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
-// CHECK: if (::mlir::succeeded(OpB::inferReturnTypes(odsBuilder.getContext(),
+// CHECK: if (::llvm::succeeded(OpB::inferReturnTypes(odsBuilder.getContext(),
// CHECK: odsState.location, odsState.operands,
// CHECK: odsState.attributes.getDictionary(odsState.getContext()),
// CHECK: odsState.regions, inferredReturnTypes)))
@@ -148,7 +148,7 @@ def OpL1 : NS_Op<"op_with_all_types_constraint",
// CHECK-LABEL: LogicalResult OpL1::inferReturnTypes
// CHECK-NOT: }
// CHECK: if (operands.size() <= 0)
-// CHECK-NEXT: return ::mlir::failure();
+// CHECK-NEXT: return ::llvm::failure();
// CHECK: ::mlir::Type odsInferredType0 = operands[0].getType();
// CHECK: inferredReturnTypes[0] = odsInferredType0;
@@ -161,7 +161,7 @@ def OpL2 : NS_Op<"op_with_all_types_constraint",
// CHECK-LABEL: LogicalResult OpL2::inferReturnTypes
// CHECK-NOT: }
// CHECK: if (operands.size() <= 2)
-// CHECK-NEXT: return ::mlir::failure();
+// CHECK-NEXT: return ::llvm::failure();
// CHECK-NOT: if (operands.size() <= 0)
// CHECK: ::mlir::Type odsInferredType0 = operands[2].getType();
// CHECK: ::mlir::Type odsInferredType1 = operands[0].getType();
@@ -189,7 +189,7 @@ def OpL4 : NS_Op<"two_inference_edges", [
// CHECK-LABEL: LogicalResult OpL4::inferReturnTypes
// CHECK: if (operands.size() <= 0)
-// CHECK-NEXT: return ::mlir::failure();
+// CHECK-NEXT: return ::llvm::failure();
// CHECK: odsInferredType0 = fromInput(operands[0].getType())
// CHECK: odsInferredType1 = infer0(odsInferredType0)
// CHECK: odsInferredType2 = infer1(odsInferredType1)
diff --git a/mlir/test/mlir-tblgen/predicate.td b/mlir/test/mlir-tblgen/predicate.td
index ae436885b421f0..5d2ef11177a22d 100644
--- a/mlir/test/mlir-tblgen/predicate.td
+++ b/mlir/test/mlir-tblgen/predicate.td
@@ -39,7 +39,7 @@ def OpA : NS_Op<"op_for_CPred_containing_multiple_same_placeholder", []> {
// CHECK-LABEL: OpA::verify
// CHECK: auto valueGroup0 = getODSOperands(0);
// CHECK: for (auto v : valueGroup0) {
-// CHECK: if (::mlir::failed([[$INTEGER_FLOAT_CONSTRAINT]]
+// CHECK: if (::llvm::failed([[$INTEGER_FLOAT_CONSTRAINT]]
def OpB : NS_Op<"op_for_And_PredOpTrait", [
PredOpTrait<"both first and second holds",
@@ -130,7 +130,7 @@ def OpM : NS_Op<"op_for_AnyTensorOf", []> {
// CHECK-LABEL: OpM::verify
// CHECK: auto valueGroup0 = getODSOperands(0);
// CHECK: for (auto v : valueGroup0) {
-// CHECK: if (::mlir::failed([[$TENSOR_INTEGER_FLOAT_CONSTRAINT]]
+// CHECK: if (::llvm::failed([[$TENSOR_INTEGER_FLOAT_CONSTRAINT]]
def OpN : NS_Op<"op_for_StringEscaping", []> {
let arguments = (ins
diff --git a/mlir/test/mlir-tblgen/rewriter-static-matcher.td b/mlir/test/mlir-tblgen/rewriter-static-matcher.td
index 99a15921dab2e0..66b68b523a9fd7 100644
--- a/mlir/test/mlir-tblgen/rewriter-static-matcher.td
+++ b/mlir/test/mlir-tblgen/rewriter-static-matcher.td
@@ -74,18 +74,18 @@ def FOp: NS_Op<"f_op", []> {
// CHECK-NEXT: static ::llvm::LogicalResult [[$PROP_CONSTRAINT:__mlir_ods_local_prop_constraint.*]](
// CHECK-NEXT: {{.*T prop}}
// CHECK: static ::llvm::LogicalResult [[$DAG_MATCHER:static_dag_matcher.*]](
-// CHECK: if(::mlir::failed([[$ATTR_CONSTRAINT]]
-// CHECK: if(::mlir::failed([[$TYPE_CONSTRAINT]]
+// CHECK: if(::llvm::failed([[$ATTR_CONSTRAINT]]
+// CHECK: if(::llvm::failed([[$TYPE_CONSTRAINT]]
// CHECK: static ::llvm::LogicalResult [[$DAG_MATCHER2:static_dag_matcher.*]](
// CHECK-SAME: int32_t &x
-// CHECK: if(::mlir::failed([[$PROP_CONSTRAINT]]
-// CHECK: if(::mlir::failed([[$TYPE_CONSTRAINT]]
+// CHECK: if(::llvm::failed([[$PROP_CONSTRAINT]]
+// CHECK: if(::llvm::failed([[$TYPE_CONSTRAINT]]
-// CHECK: if(::mlir::failed([[$DAG_MATCHER]](rewriter, op1, tblgen_ops
+// CHECK: if(::llvm::failed([[$DAG_MATCHER]](rewriter, op1, tblgen_ops
def : Pat<(AOp (BOp I32Attr:$attr, I32:$int)),
(AOp $int)>;
-// CHECK: if(::mlir::failed([[$DAG_MATCHER]](rewriter, op1, tblgen_ops
+// CHECK: if(::llvm::failed([[$DAG_MATCHER]](rewriter, op1, tblgen_ops
def : Pat<(COp $_, (BOp I32Attr:$attr, I32:$int)),
(COp $attr, $int)>;
@@ -94,10 +94,10 @@ def : Pat<(COp $_, (BOp I32Attr:$attr, I32:$int)),
// CHECK: [[$ARR]].push_back([[$VAR]]);
def : Pat<(AOp $x), (DOp (variadic (Foo $x)))>;
-// CHECK: if(::mlir::failed([[$DAG_MATCHER2]]({{.*}} x{{[,)]}}
+// CHECK: if(::llvm::failed([[$DAG_MATCHER2]]({{.*}} x{{[,)]}}
def : Pat<(AOp (EOp NonNegProp:$x, NonNegProp:$_, I32:$z)),
(AOp $z)>;
-// CHECK: if(::mlir::failed([[$DAG_MATCHER2]]({{.*}} x{{[,)]}}
+// CHECK: if(::llvm::failed([[$DAG_MATCHER2]]({{.*}} x{{[,)]}}
def : Pat<(FOp $_, (EOp NonNegProp:$x, NonNegProp:$_, I32:$z)),
(COp $x, $z)>;
diff --git a/mlir/test/mlir-tblgen/typedefs.td b/mlir/test/mlir-tblgen/typedefs.td
index b9e3a7954e361d..25fa8f73e16439 100644
--- a/mlir/test/mlir-tblgen/typedefs.td
+++ b/mlir/test/mlir-tblgen/typedefs.td
@@ -26,11 +26,11 @@ include "mlir/IR/OpBase.td"
// DEF-SAME: ::mlir::Type &value) {
// DEF: .Case(::test::CompoundAType::getMnemonic()
// DEF-NEXT: value = ::test::CompoundAType::parse(parser);
-// DEF-NEXT: return ::mlir::success(!!value);
+// DEF-NEXT: return ::llvm::success(!!value);
// DEF-NEXT: })
// DEF-NEXT: .Case(::test::IndexType::getMnemonic()
// DEF-NEXT: value = ::test::IndexType::parse(parser);
-// DEF-NEXT: return ::mlir::success(!!value);
+// DEF-NEXT: return ::llvm::success(!!value);
// DEF: .Default([&](llvm::StringRef keyword,
// DEF-NEXT: *mnemonic = keyword;
// DEF-NEXT: return std::nullopt;
diff --git a/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp b/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp
index 64f35e7fef6d34..128dc68b5a4f92 100644
--- a/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp
+++ b/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp
@@ -363,7 +363,7 @@ void DefGen::emitVerifierDecl() {
static const char *const patternParameterVerificationCode = R"(
if (!({0})) {
emitError() << "failed to verify '{1}': {2}";
- return ::mlir::failure();
+ return ::llvm::failure();
}
)";
@@ -403,14 +403,14 @@ void DefGen::emitInvariantsVerifierImpl() {
verifier->body() << tgfmt(
"if (!($0)) {\n"
" emitError() << \"failed to verify that $1\";\n"
- " return ::mlir::failure();\n"
+ " return ::llvm::failure();\n"
"}\n",
&traitCtx, tgfmt(t->getPredTemplate(), &traitCtx), t->getSummary());
}
}
}
- verifier->body() << "return ::mlir::success();";
+ verifier->body() << "return ::llvm::success();";
}
void DefGen::emitInvariantsVerifier(bool hasImpl, bool hasCustomVerifier) {
@@ -425,13 +425,13 @@ void DefGen::emitInvariantsVerifier(bool hasImpl, bool hasCustomVerifier) {
verifier->body().indent();
auto emitVerifierCall = [&](StringRef name) {
- verifier->body() << strfmt("if (::mlir::failed({0}(", name);
+ verifier->body() << strfmt("if (::llvm::failed({0}(", name);
llvm::interleaveComma(
llvm::map_range(builderParams,
[](auto ¶m) { return param.getName(); }),
verifier->body());
verifier->body() << ")))\n";
- verifier->body() << " return ::mlir::failure();\n";
+ verifier->body() << " return ::llvm::failure();\n";
};
if (hasImpl) {
@@ -442,7 +442,7 @@ void DefGen::emitInvariantsVerifier(bool hasImpl, bool hasCustomVerifier) {
// Call the custom verifier that is provided by the user.
emitVerifierCall("verify");
}
- verifier->body() << "return ::mlir::success();";
+ verifier->body() << "return ::llvm::success();";
}
void DefGen::emitParserPrinter() {
@@ -969,7 +969,7 @@ ::mlir::Attribute {0}::parseAttribute(::mlir::DialectAsmParser &parser,
/// Print an attribute registered to this dialect.
void {0}::printAttribute(::mlir::Attribute attr,
::mlir::DialectAsmPrinter &printer) const {{
- if (::mlir::succeeded(generatedAttributePrinter(attr, printer)))
+ if (::llvm::succeeded(generatedAttributePrinter(attr, printer)))
return;
{2}
}
@@ -981,7 +981,7 @@ static const char *const dialectDynamicAttrParserDispatch = R"(
::mlir::Attribute genAttr;
auto parseResult = parseOptionalDynamicAttr(attrTag, parser, genAttr);
if (parseResult.has_value()) {
- if (::mlir::succeeded(parseResult.value()))
+ if (::llvm::succeeded(parseResult.value()))
return genAttr;
return Attribute();
}
@@ -990,7 +990,7 @@ static const char *const dialectDynamicAttrParserDispatch = R"(
/// The code block for dynamic type printer dispatch boilerplate.
static const char *const dialectDynamicAttrPrinterDispatch = R"(
- if (::mlir::succeeded(printIfDynamicAttr(attr, printer)))
+ if (::llvm::succeeded(printIfDynamicAttr(attr, printer)))
return;
)";
@@ -1015,7 +1015,7 @@ ::mlir::Type {0}::parseType(::mlir::DialectAsmParser &parser) const {{
/// Print a type registered to this dialect.
void {0}::printType(::mlir::Type type,
::mlir::DialectAsmPrinter &printer) const {{
- if (::mlir::succeeded(generatedTypePrinter(type, printer)))
+ if (::llvm::succeeded(generatedTypePrinter(type, printer)))
return;
{2}
}
@@ -1026,7 +1026,7 @@ static const char *const dialectDynamicTypeParserDispatch = R"(
{
auto parseResult = parseOptionalDynamicType(mnemonic, parser, genType);
if (parseResult.has_value()) {
- if (::mlir::succeeded(parseResult.value()))
+ if (::llvm::succeeded(parseResult.value()))
return genType;
return ::mlir::Type();
}
@@ -1035,7 +1035,7 @@ static const char *const dialectDynamicTypeParserDispatch = R"(
/// The code block for dynamic type printer dispatch boilerplate.
static const char *const dialectDynamicTypePrinterDispatch = R"(
- if (::mlir::succeeded(printIfDynamicType(type, printer)))
+ if (::llvm::succeeded(printIfDynamicType(type, printer)))
return;
)";
@@ -1102,7 +1102,7 @@ void DefGenerator::emitParsePrintDispatch(ArrayRef<AttrOrTypeDef> defs) {
const char *const getValueForMnemonic =
R"( .Case({0}::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) {{
value = {0}::{1};
- return ::mlir::success(!!value);
+ return ::llvm::success(!!value);
})
)";
@@ -1112,7 +1112,7 @@ void DefGenerator::emitParsePrintDispatch(ArrayRef<AttrOrTypeDef> defs) {
<< ", ::llvm::LogicalResult>(def)";
const char *const printValue = R"( .Case<{0}>([&](auto t) {{
printer << {0}::getMnemonic();{1}
- return ::mlir::success();
+ return ::llvm::success();
})
)";
for (const AttrOrTypeDef &def : defs) {
@@ -1156,7 +1156,7 @@ void DefGenerator::emitParsePrintDispatch(ArrayRef<AttrOrTypeDef> defs) {
" *mnemonic = keyword;\n"
" return std::nullopt;\n"
" });";
- printer.body() << " .Default([](auto) { return ::mlir::failure(); });";
+ printer.body() << " .Default([](auto) { return ::llvm::failure(); });";
raw_indented_ostream indentedOs(os);
parse.writeDeclTo(indentedOs);
diff --git a/mlir/tools/mlir-tblgen/AttrOrTypeFormatGen.cpp b/mlir/tools/mlir-tblgen/AttrOrTypeFormatGen.cpp
index 853ba5b0d0c71d..914b2a1b66d45a 100644
--- a/mlir/tools/mlir-tblgen/AttrOrTypeFormatGen.cpp
+++ b/mlir/tools/mlir-tblgen/AttrOrTypeFormatGen.cpp
@@ -181,7 +181,6 @@ class StructDirective
return llvm::any_of(getElements(), formatIsOptional);
}
};
-
} // namespace
//===----------------------------------------------------------------------===//
@@ -218,7 +217,7 @@ static const char *const parserErrorStr =
static const char *const variableParser = R"(
// Parse variable '{0}'{5}
_result_{0} = {1};
-if (::mlir::failed(_result_{0})) {{
+if (::llvm::failed(_result_{0})) {{
{2}"failed to parse {3} parameter '{0}' which is to be a `{4}`");
return {{};
}
@@ -366,7 +365,7 @@ void DefFormat::genParser(MethodBody &os) {
// a loop (parsers return FailureOr anyways).
ArrayRef<AttrOrTypeParameter> params = def.getParameters();
for (const AttrOrTypeParameter ¶m : params) {
- os << formatv("::mlir::FailureOr<{0}> _result_{1};\n",
+ os << formatv("::llvm::FailureOr<{0}> _result_{1};\n",
param.getCppStorageType(), param.getName());
if (auto *selfTypeParam = dyn_cast<AttributeSelfTypeParameter>(¶m))
genAttrSelfTypeParser(os, ctx, *selfTypeParam);
@@ -381,7 +380,7 @@ void DefFormat::genParser(MethodBody &os) {
for (const AttrOrTypeParameter ¶m : params) {
if (param.isOptional())
continue;
- os << formatv("assert(::mlir::succeeded(_result_{0}));\n", param.getName());
+ os << formatv("assert(::llvm::succeeded(_result_{0}));\n", param.getName());
}
// Generate call to the attribute or type builder. Use the checked getter
@@ -515,11 +514,11 @@ void DefFormat::genStructParameterParser(ParameterElement *el, FmtContext &ctx,
std::string parser;
llvm::raw_string_ostream parserOS(parser);
- parserOS << "[&]() -> ::mlir::FailureOr<" << param.getCppStorageType()
+ parserOS << "[&]() -> ::llvm::FailureOr<" << param.getCppStorageType()
<< "> {\n auto odsEnumValue = "
<< tgfmt(defaultParameterParser, &ctx, enumType)
- << ";\n if (::mlir::failed(odsEnumValue))\n"
- " return ::mlir::failure();\n return "
+ << ";\n if (::llvm::failed(odsEnumValue))\n"
+ " return ::llvm::failure();\n return "
<< param.getCppStorageType() << "::get(" << tgfmt("$_ctxt", &ctx)
<< ", *odsEnumValue);\n}()";
genVariableParser(el, ctx, os, parserOS.str());
@@ -555,7 +554,7 @@ void DefFormat::genParamsParser(ParamsDirective *el, FmtContext &ctx,
ParameterElement *el = *std::prev(it);
// Parse a comma if the last optional parameter had a value.
if (el->isOptional()) {
- os << formatv("if (::mlir::succeeded(_result_{0}) && !({1})) {{\n",
+ os << formatv("if (::llvm::succeeded(_result_{0}) && !({1})) {{\n",
el->getName(),
el->genIsPresent(ctx, "(*_result_" + el->getName() + ")"));
os.indent();
@@ -757,19 +756,19 @@ void DefFormat::genCustomParser(CustomDirective *el, FmtContext &ctx,
os.unindent() << ");\n";
if (isOptional) {
os << "if (!odsCustomResult.has_value()) return {};\n";
- os << "if (::mlir::failed(*odsCustomResult)) return ::mlir::failure();\n";
+ os << "if (::llvm::failed(*odsCustomResult)) return ::llvm::failure();\n";
} else {
- os << "if (::mlir::failed(odsCustomResult)) return {};\n";
+ os << "if (::llvm::failed(odsCustomResult)) return {};\n";
}
for (FormatElement *arg : el->getElements()) {
if (auto *param = dyn_cast<ParameterElement>(arg)) {
if (param->isOptional())
continue;
- os << formatv("if (::mlir::failed(_result_{0})) {{\n", param->getName());
+ os << formatv("if (::llvm::failed(_result_{0})) {{\n", param->getName());
os.indent() << tgfmt("$_parser.emitError(odsCustomLoc, ", &ctx)
<< "\"custom parser failed to parse parameter '"
<< param->getName() << "'\");\n";
- os << "return " << (isOptional ? "::mlir::failure()" : "{}") << ";\n";
+ os << "return " << (isOptional ? "::llvm::failure()" : "{}") << ";\n";
os.unindent() << "}\n";
}
}
@@ -788,7 +787,7 @@ void DefFormat::genOptionalGroupParser(OptionalElement *el, FmtContext &ctx,
llvm::interleave(
params, os,
[&](ParameterElement *el) {
- os << formatv("(::mlir::succeeded(_result_{0}) && *_result_{0})",
+ os << formatv("(::llvm::succeeded(_result_{0}) && *_result_{0})",
el->getName());
},
" || ");
@@ -807,9 +806,9 @@ void DefFormat::genOptionalGroupParser(OptionalElement *el, FmtContext &ctx,
os << "if (auto result = [&]() -> ::mlir::OptionalParseResult {\n";
os.indent();
genCustomParser(custom, ctx, os, /*isOptional=*/true);
- os << "return ::mlir::success();\n";
+ os << "return ::llvm::success();\n";
os.unindent();
- os << "}(); result.has_value() && ::mlir::failed(*result)) {\n";
+ os << "}(); result.has_value() && ::llvm::failed(*result)) {\n";
os.indent();
os << "return {};\n";
os.unindent();
diff --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
index 62d057af2132b4..6de14a06eb6461 100644
--- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
@@ -146,14 +146,14 @@ static const char *const valueRangeReturnCode = R"(
/// {0}: Number of elements in the segment array
static const char *const parseTextualSegmentSizeFormat = R"(
size_t i = 0;
- auto parseElem = [&]() -> ::mlir::ParseResult {
+ auto parseElem = [&]() -> ::llvm::ParseResult {
if (i >= {0})
return $_parser.emitError($_parser.getCurrentLocation(),
"expected `]` after {0} segment sizes");
if (failed($_parser.parseInteger($_storage[i])))
- return ::mlir::failure();
+ return ::llvm::failure();
i += 1;
- return ::mlir::success();
+ return ::llvm::success();
};
if (failed($_parser.parseCommaSeparatedList(
::mlir::AsmParser::Delimeter::Square, parseElem)))
@@ -182,10 +182,10 @@ static const char *const readBytecodeSegmentSizeLegacy = R"(
if ($_reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) {
auto &$_storage = prop.$_propName;
::mlir::DenseI32ArrayAttr attr;
- if (::mlir::failed($_reader.readAttribute(attr))) return ::mlir::failure();
+ if (::llvm::failed($_reader.readAttribute(attr))) return ::llvm::failure();
if (attr.size() > static_cast<int64_t>(sizeof($_storage) / sizeof(int32_t))) {
$_reader.emitError("size mismatch for operand/result_segment_size");
- return ::mlir::failure();
+ return ::llvm::failure();
}
::llvm::copy(::llvm::ArrayRef<int32_t>(attr), $_storage.begin());
}
@@ -420,7 +420,6 @@ class OpOrAdaptorHelper {
uint32_t operandSegmentSizesLegacyIndex = 0;
uint32_t resultSegmentSizesLegacyIndex = 0;
};
-
} // namespace
void OpOrAdaptorHelper::computeAttrMetadata() {
@@ -771,7 +770,6 @@ class OpEmitter {
// avoid duplicates.
llvm::StringSet<> interfaceUsingNames;
};
-
} // namespace
// Populate the format context `ctx` with substitutions of attributes, operands
@@ -851,8 +849,8 @@ static void genAttributeVerifier(
// {1}: Attribute variable name.
// {2}: Attribute name.
const char *const verifyAttrUnique = R"(
- if (::mlir::failed({0}(*this, {1}, "{2}")))
- return ::mlir::failure();
+ if (::llvm::failed({0}(*this, {1}, "{2}")))
+ return ::llvm::failure();
)";
// Emit the verifier for the attribute.
@@ -930,8 +928,8 @@ static void genPropertyVerifier(
// {1}: Property variable name in interface type.
// {2}: Property name.
const char *const verifyPropertyUniqued = R"(
- if (::mlir::failed({0}(*this, {1}, "{2}")))
- return ::mlir::failure();
+ if (::llvm::failed({0}(*this, {1}, "{2}")))
+ return ::llvm::failure();
)";
// Prefix variables with `tblgen_` to avoid hiding the attribute accessor.
@@ -1313,28 +1311,28 @@ void OpEmitter::genPropertiesSupport() {
::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
if (!dict) {
emitError() << "expected DictionaryAttr to set properties";
- return ::mlir::failure();
+ return ::llvm::failure();
}
)decl";
const char *propFromAttrFmt = R"decl(
auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr,
- ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::mlir::LogicalResult {{
+ ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::llvm::LogicalResult {{
{0}
};
{1};
)decl";
const char *attrGetNoDefaultFmt = R"decl(;
- if (attr && ::mlir::failed(setFromAttr(prop.{0}, attr, [&]() {{
+ if (attr && ::llvm::failed(setFromAttr(prop.{0}, attr, [&]() {{
return emitError() << "for `{0}`: ";
})))
- return ::mlir::failure();
+ return ::llvm::failure();
)decl";
const char *attrGetDefaultFmt = R"decl(;
if (attr) {{
- if (::mlir::failed(setFromAttr(prop.{0}, attr, [&]() {{
+ if (::llvm::failed(setFromAttr(prop.{0}, attr, [&]() {{
return emitError() << "for `{0}`: ";
})))
- return ::mlir::failure();
+ return ::llvm::failure();
} else {{
prop.{0} = {1};
}
@@ -1400,15 +1398,15 @@ void OpEmitter::genPropertiesSupport() {
setPropMethod << formatv(R"decl(
{{
{1}
- if (::mlir::failed(::mlir::detail::setAttributeProperty(
+ if (::llvm::failed(::mlir::detail::setAttributeProperty(
prop.{0}, attr, "{0}", emitError)))
- return ::mlir::failure();
+ return ::llvm::failure();
}
)decl",
name, getAttr);
}
}
- setPropMethod << " return ::mlir::success();\n";
+ setPropMethod << " return ::llvm::success();\n";
// Convert the attribute form to the property.
@@ -1598,14 +1596,14 @@ void OpEmitter::genPropertiesSupport() {
<< formatv(R"(
{{
::mlir::Attribute attr = attrs.get({0}AttrName(opName));
- if (attr && ::mlir::failed({1}(attr, "{2}", emitError)))
- return ::mlir::failure();
+ if (attr && ::llvm::failed({1}(attr, "{2}", emitError)))
+ return ::llvm::failure();
}
)",
name, constraintFn, namedAttr->attrName);
}
}
- verifyInherentAttrsMethod << " return ::mlir::success();";
+ verifyInherentAttrsMethod << " return ::llvm::success();";
// Generate methods to interact with bytecode.
genPropertiesSupportForBytecode(attrOrProperties);
@@ -1679,10 +1677,10 @@ void OpEmitter::genPropertiesSupportForBytecode(
auto &propStorage = prop.{0};
auto readProp = [&]() {
{1};
- return ::mlir::success();
+ return ::llvm::success();
};
- if (::mlir::failed(readProp()))
- return ::mlir::failure();
+ if (::llvm::failed(readProp()))
+ return ::llvm::failure();
}
)",
name,
@@ -1701,16 +1699,16 @@ void OpEmitter::genPropertiesSupportForBytecode(
StringRef name = namedAttr->attrName;
if (namedAttr->isRequired) {
readPropertiesMethod << formatv(R"(
- if (::mlir::failed(reader.readAttribute(prop.{0})))
- return ::mlir::failure();
+ if (::llvm::failed(reader.readAttribute(prop.{0})))
+ return ::llvm::failure();
)",
name);
writePropertiesMethod
<< formatv(" writer.writeAttribute(prop.{0});\n", name);
} else {
readPropertiesMethod << formatv(R"(
- if (::mlir::failed(reader.readOptionalAttribute(prop.{0})))
- return ::mlir::failure();
+ if (::llvm::failed(reader.readOptionalAttribute(prop.{0})))
+ return ::llvm::failure();
)",
name);
writePropertiesMethod << formatv(R"(
@@ -1719,7 +1717,7 @@ void OpEmitter::genPropertiesSupportForBytecode(
name);
}
}
- readPropertiesMethod << " return ::mlir::success();";
+ readPropertiesMethod << " return ::llvm::success();";
}
void OpEmitter::genPropGetters() {
@@ -2511,7 +2509,7 @@ void OpEmitter::genSeparateArgParamBuilder() {
// inferred automatically.
body << formatv(R"(
::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
- if (::mlir::succeeded({0}::inferReturnTypes(odsBuilder.getContext(),
+ if (::llvm::succeeded({0}::inferReturnTypes(odsBuilder.getContext(),
{1}.location, {1}.operands,
{1}.attributes.getDictionary({1}.getContext()),
{1}.getRawProperties(),
@@ -2778,7 +2776,7 @@ void OpEmitter::genInferredTypeCollectiveParamBuilder(
// Result types
body << formatv(R"(
::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
- if (::mlir::succeeded({0}::inferReturnTypes(odsBuilder.getContext(),
+ if (::llvm::succeeded({0}::inferReturnTypes(odsBuilder.getContext(),
{1}.location, operands,
{1}.attributes.getDictionary({1}.getContext()),
{1}.getRawProperties(),
@@ -3670,7 +3668,7 @@ void OpEmitter::genTypeInterfaceMethods() {
}
if (maxAccessedIndex != -1) {
body << " if (operands.size() <= " << Twine(maxAccessedIndex) << ")\n";
- body << " return ::mlir::failure();\n";
+ body << " return ::llvm::failure();\n";
}
// Process the type inference graph in topological order, starting from types
@@ -3706,7 +3704,7 @@ void OpEmitter::genTypeInterfaceMethods() {
"get(\""
<< attr->name << "\")));\n"
<< " if (!odsInferredTypeAttr" << inferredTypeIdx
- << ") return ::mlir::failure();\n";
+ << ") return ::llvm::failure();\n";
typeStr =
("odsInferredTypeAttr" + Twine(inferredTypeIdx) + ".getType()")
.str();
@@ -3732,7 +3730,7 @@ void OpEmitter::genTypeInterfaceMethods() {
for (auto [i, index] : llvm::enumerate(constructedIndices))
body << " inferredReturnTypes[" << i << "] = odsInferredType" << index
<< ";\n";
- body << " return ::mlir::success();";
+ body << " return ::llvm::success();";
}
void OpEmitter::genParser() {
@@ -3746,7 +3744,7 @@ void OpEmitter::genParser() {
paramList.emplace_back("::mlir::OpAsmParser &", "parser");
paramList.emplace_back("::mlir::OperationState &", "result");
- auto *method = opClass.declareStaticMethod("::mlir::ParseResult", "parse",
+ auto *method = opClass.declareStaticMethod("::llvm::ParseResult", "parse",
std::move(paramList));
ERROR_IF_PRUNED(method, "parse", op);
}
@@ -3786,7 +3784,7 @@ void OpEmitter::genVerifier() {
genRegionVerifier(implBody);
genSuccessorVerifier(implBody);
- implBody << " return ::mlir::success();\n";
+ implBody << " return ::llvm::success();\n";
// TODO: Some places use the `verifyInvariants` to do operation verification.
// This may not act as their expectation because this doesn't call any
@@ -3796,10 +3794,10 @@ void OpEmitter::genVerifier() {
ERROR_IF_PRUNED(method, "verifyInvariants", op);
auto &body = method->body();
if (def.getValueAsBit("hasVerifier")) {
- body << " if(::mlir::succeeded(verifyInvariantsImpl()) && "
- "::mlir::succeeded(verify()))\n";
- body << " return ::mlir::success();\n";
- body << " return ::mlir::failure();";
+ body << " if(::llvm::succeeded(verifyInvariantsImpl()) && "
+ "::llvm::succeeded(verify()))\n";
+ body << " return ::llvm::success();\n";
+ body << " return ::llvm::failure();";
} else {
body << " return verifyInvariantsImpl();";
}
@@ -3838,8 +3836,8 @@ void OpEmitter::genOperandResultVerifier(MethodBody &body,
// {2}: "operand" or "result"
const char *const verifyValues = R"(
for (auto v : valueGroup{0}) {
- if (::mlir::failed({1}(*this, v.getType(), "{2}", index++)))
- return ::mlir::failure();
+ if (::llvm::failed({1}(*this, v.getType(), "{2}", index++)))
+ return ::llvm::failure();
}
)";
@@ -3873,9 +3871,9 @@ void OpEmitter::genOperandResultVerifier(MethodBody &body,
body << formatv(verifyOptional, staticValue.index(), valueKind);
} else if (isVariadicOfVariadic) {
body << formatv(
- " if (::mlir::failed(::mlir::OpTrait::impl::verifyValueSizeAttr("
+ " if (::llvm::failed(::mlir::OpTrait::impl::verifyValueSizeAttr("
"*this, \"{0}\", \"{1}\", valueGroup{2}.size())))\n"
- " return ::mlir::failure();\n",
+ " return ::llvm::failure();\n",
value.constraint.getVariadicOfVariadicSegmentSizeAttr(), value.name,
staticValue.index());
}
@@ -3901,8 +3899,8 @@ void OpEmitter::genRegionVerifier(MethodBody &body) {
/// {3}: The region description.
const char *const verifyRegion = R"(
for (auto ®ion : {0})
- if (::mlir::failed({1}(*this, region, "{2}", index++)))
- return ::mlir::failure();
+ if (::llvm::failed({1}(*this, region, "{2}", index++)))
+ return ::llvm::failure();
)";
/// Get a single region.
///
@@ -3942,8 +3940,8 @@ void OpEmitter::genSuccessorVerifier(MethodBody &body) {
// {2}: The successor's name.
const char *const verifyVariadicSuccessor = R"(
for (auto *successor : {0}())
- if (::mlir::failed({1}(*this, successor, "{2}", index++)))
- return ::mlir::failure();
+ if (::llvm::failed({1}(*this, successor, "{2}", index++)))
+ return ::llvm::failure();
)";
// Code to verify a single successor. The accessor returns a `Block *` by
// value, which can't be wrapped in a `MutableArrayRef`, so verify it
@@ -3953,8 +3951,8 @@ void OpEmitter::genSuccessorVerifier(MethodBody &body) {
// {1}: The successor constraint.
// {2}: The successor's name.
const char *const verifySingleSuccessor = R"(
- if (::mlir::failed({1}(*this, {0}(), "{2}", index++)))
- return ::mlir::failure();
+ if (::llvm::failed({1}(*this, {0}(), "{2}", index++)))
+ return ::llvm::failure();
)";
// If we have no successors, there is nothing more to do.
@@ -4554,7 +4552,7 @@ void OpOperandAdaptorEmitter::addVerification() {
genPropertyVerifier(emitHelper, verifyCtx, body, staticVerifierEmitter);
genAttributeVerifier(emitHelper, verifyCtx, body, staticVerifierEmitter);
- body << " return ::mlir::success();";
+ body << " return ::llvm::success();";
}
void OpOperandAdaptorEmitter::emitDecl(
diff --git a/mlir/tools/mlir-tblgen/OpFormatGen.cpp b/mlir/tools/mlir-tblgen/OpFormatGen.cpp
index 1fd993cc197a9a..331c39ecf071b3 100644
--- a/mlir/tools/mlir-tblgen/OpFormatGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpFormatGen.cpp
@@ -16,10 +16,10 @@
#include "mlir/TableGen/Operator.h"
#include "mlir/TableGen/Trait.h"
#include "llvm/ADT/MapVector.h"
+#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/Sequence.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallBitVector.h"
-#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/Twine.h"
#include "llvm/ADT/TypeSwitch.h"
@@ -306,7 +306,6 @@ class OIListElement : public DirectiveElementBase<DirectiveElement::OIList> {
//===----------------------------------------------------------------------===//
namespace {
-
using ConstArgument =
llvm::PointerUnion<const NamedAttribute *, const NamedTypeConstraint *>;
@@ -529,7 +528,7 @@ const char *const getPropertiesCode =
/// {1}: The type for the attribute.
const char *const attrParserCode = R"(
if (parser.parseCustomAttributeWithFallback({0}Attr, {1})) {{
- return ::mlir::failure();
+ return ::llvm::failure();
}
)";
@@ -539,14 +538,14 @@ const char *const attrParserCode = R"(
/// {1}: The type for the attribute.
const char *const genericAttrParserCode = R"(
if (parser.parseAttribute({0}Attr, {1}))
- return ::mlir::failure();
+ return ::llvm::failure();
)";
const char *const optionalAttrParserCode = R"(
::mlir::OptionalParseResult parseResult{0}Attr =
parser.parseOptionalAttribute({0}Attr, {1});
if (parseResult{0}Attr.has_value() && failed(*parseResult{0}Attr))
- return ::mlir::failure();
+ return ::llvm::failure();
if (parseResult{0}Attr.has_value() && succeeded(*parseResult{0}Attr))
)";
@@ -555,7 +554,7 @@ const char *const optionalAttrParserCode = R"(
/// {0}: The name of the attribute.
const char *const symbolNameAttrParserCode = R"(
if (parser.parseSymbolName({0}Attr))
- return ::mlir::failure();
+ return ::llvm::failure();
)";
const char *const optionalSymbolNameAttrParserCode = R"(
// Parsing an optional symbol name doesn't fail, so no need to check the
@@ -585,7 +584,7 @@ const char *const enumAttrParserCode = R"(
"{0}", attrStorage);
if (parseResult.has_value()) {{
if (failed(*parseResult))
- return ::mlir::failure();
+ return ::llvm::failure();
attrStr = attrVal.getValue();
} else {
{5}
@@ -632,7 +631,7 @@ const char *const unquotedBitEnumAttrParserCode = R"(
if (failed(parser.{8}()))
break;
if (parser.parseKeyword(&attrStr))
- return ::mlir::failure();
+ return ::llvm::failure();
}
auto attrOptional = ::std::optional<{7}>(flags);
{0}Attr = {3};
@@ -649,9 +648,9 @@ const char *const unquotedBitEnumAttrParserCode = R"(
/// expected property for the error message.
const char *const propertyParserCode = R"(
auto {0}PropLoc = parser.getCurrentLocation();
- auto {0}PropParseResult = [&](auto& propStorage) -> ::mlir::ParseResult {{
+ auto {0}PropParseResult = [&](auto& propStorage) -> ::llvm::ParseResult {{
{2}
- return ::mlir::success();
+ return ::llvm::success();
}({1}.{0});
if (failed({0}PropParseResult)) {{
return parser.emitError({0}PropLoc, "invalid value for property {0}, expected {3}");
@@ -666,10 +665,10 @@ const char *const propertyParserCode = R"(
const char *const optionalPropertyParserCode = R"(
auto {0}PropParseResult = [&](auto& propStorage) -> ::mlir::OptionalParseResult {{
{2}
- return ::mlir::success();
+ return ::llvm::success();
}({1}.{0});
if ({0}PropParseResult.has_value() && failed(*{0}PropParseResult)) {{
- return ::mlir::failure();
+ return ::llvm::failure();
}
)";
@@ -679,17 +678,17 @@ const char *const optionalPropertyParserCode = R"(
const char *const variadicOperandParserCode = R"(
{0}OperandsLoc = parser.getCurrentLocation();
if (parser.parseOperandList({0}Operands))
- return ::mlir::failure();
+ return ::llvm::failure();
)";
const char *const optionalOperandParserCode = R"(
{0}OperandsLoc = parser.getCurrentLocation();
if (::mlir::detail::parseOptionalOperandInto(parser, {0}Operands))
- return ::mlir::failure();
+ return ::llvm::failure();
)";
const char *const operandParserCode = R"(
{0}OperandsLoc = parser.getCurrentLocation();
if (parser.parseOperand({0}RawOperand))
- return ::mlir::failure();
+ return ::llvm::failure();
)";
/// The code snippet used to generate a parser call for a VariadicOfVariadic
/// operand.
@@ -704,7 +703,7 @@ const char *const variadicOfVariadicOperandParserCode = R"(
if (parser.parseOptionalLParen())
break;
if (parser.parseOperandList({0}Operands) || parser.parseRParen())
- return ::mlir::failure();
+ return ::llvm::failure();
{0}OperandGroupSizes.push_back({0}Operands.size() - curSize);
curSize = {0}Operands.size();
} while (succeeded(parser.parseOptionalComma()));
@@ -720,28 +719,28 @@ const char *const variadicOfVariadicTypeParserCode = R"(
break;
if (parser.parseOptionalRParen() &&
(parser.parseTypeList({0}Types) || parser.parseRParen()))
- return ::mlir::failure();
+ return ::llvm::failure();
} while (succeeded(parser.parseOptionalComma()));
)";
const char *const variadicTypeParserCode = R"(
if (parser.parseTypeList({0}Types))
- return ::mlir::failure();
+ return ::llvm::failure();
)";
const char *const optionalTypeParserCode = R"(
if (::mlir::detail::parseOptionalTypeInto(parser, {0}Types))
- return ::mlir::failure();
+ return ::llvm::failure();
)";
const char *const typeParserCode = R"(
{
{0} type;
if (parser.parseCustomTypeWithFallback(type))
- return ::mlir::failure();
+ return ::llvm::failure();
{1}RawType = type;
}
)";
const char *const qualifiedTypeParserCode = R"(
if (parser.parseType({1}RawType))
- return ::mlir::failure();
+ return ::llvm::failure();
)";
/// The code snippet used to generate a parser call for a functional type.
@@ -751,7 +750,7 @@ const char *const qualifiedTypeParserCode = R"(
const char *const functionalTypeParserCode = R"(
::mlir::FunctionType {0}__{1}_functionType;
if (parser.parseType({0}__{1}_functionType))
- return ::mlir::failure();
+ return ::llvm::failure();
{0}Types = {0}__{1}_functionType.getInputs();
{1}Types = {0}__{1}_functionType.getResults();
)";
@@ -761,12 +760,12 @@ const char *const functionalTypeParserCode = R"(
/// {0}: The operation class name
const char *const inferReturnTypesParserCode = R"(
::llvm::SmallVector<::mlir::Type> inferredReturnTypes;
- if (::mlir::failed({0}::inferReturnTypes(parser.getContext(),
+ if (::llvm::failed({0}::inferReturnTypes(parser.getContext(),
result.location, result.operands,
result.attributes.getDictionary(parser.getContext()),
result.getRawProperties(),
result.regions, inferredReturnTypes)))
- return ::mlir::failure();
+ return ::llvm::failure();
result.addTypes(inferredReturnTypes);
)";
@@ -779,14 +778,14 @@ static const char *regionListParserCode = R"(
auto firstRegionResult = parser.parseOptionalRegion(region);
if (firstRegionResult.has_value()) {
if (failed(*firstRegionResult))
- return ::mlir::failure();
+ return ::llvm::failure();
{0}Regions.emplace_back(std::move(region));
// Parse any trailing regions.
while (succeeded(parser.parseOptionalComma())) {
region = std::make_unique<::mlir::Region>();
if (parser.parseRegion(*region))
- return ::mlir::failure();
+ return ::llvm::failure();
{0}Regions.emplace_back(std::move(region));
}
}
@@ -816,7 +815,7 @@ static const char *optionalRegionParserCode = R"(
{
auto parseResult = parser.parseOptionalRegion(*{0}Region);
if (parseResult.has_value() && failed(*parseResult))
- return ::mlir::failure();
+ return ::llvm::failure();
}
)";
@@ -825,7 +824,7 @@ static const char *optionalRegionParserCode = R"(
/// {0}: The name of the region.
static const char *regionParserCode = R"(
if (parser.parseRegion(*{0}Region))
- return ::mlir::failure();
+ return ::llvm::failure();
)";
/// The code snippet used to ensure a region has a terminator.
@@ -851,13 +850,13 @@ static const char *successorListParserCode = R"(
auto firstSucc = parser.parseOptionalSuccessor(succ);
if (firstSucc.has_value()) {
if (failed(*firstSucc))
- return ::mlir::failure();
+ return ::llvm::failure();
{0}Successors.emplace_back(succ);
// Parse any trailing successors.
while (succeeded(parser.parseOptionalComma())) {
if (parser.parseSuccessor(succ))
- return ::mlir::failure();
+ return ::llvm::failure();
{0}Successors.emplace_back(succ);
}
}
@@ -869,7 +868,7 @@ static const char *successorListParserCode = R"(
/// {0}: The name of the successor.
static const char *successorParserCode = R"(
if (parser.parseSuccessor({0}Successor))
- return ::mlir::failure();
+ return ::llvm::failure();
)";
/// The code snippet used to generate a parser for OIList
@@ -1017,9 +1016,9 @@ static void genElementParserStorage(FormatElement *element, const Operator &op,
body << " auto &" << name << "Operands = odsOperandVectors[" << index
<< "];\n";
} else {
- body
- << " ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> "
- << name << "Operands;\n";
+ body << " ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, "
+ "4> "
+ << name << "Operands;\n";
}
if (operand->getVar()->isVariadicOfVariadic()) {
body << " llvm::SmallVector<int32_t> " << name
@@ -1212,9 +1211,9 @@ static void genCustomDirectiveParser(CustomDirective *dir, MethodBody &body,
if (isOptional) {
body << " if (!odsResult.has_value()) return {};\n"
- << " if (::mlir::failed(*odsResult)) return ::mlir::failure();\n";
+ << " if (::llvm::failed(*odsResult)) return ::llvm::failure();\n";
} else {
- body << " if (odsResult) return ::mlir::failure();\n";
+ body << " if (odsResult) return ::llvm::failure();\n";
}
// After parsing, add handling for any of the optional constructs.
@@ -1419,7 +1418,7 @@ static void genParsedAttrPropertiesSetter(OperationFormat &fmt, Operator &op,
::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
if (!dict) {
emitError() << "expected DictionaryAttr to set properties";
- return ::mlir::failure();
+ return ::llvm::failure();
}
// keep track of used keys in the input dictionary to be able to error out
// if there are some unknown ones.
@@ -1449,12 +1448,12 @@ auto attr = dict.get({0}AttrName);
if (!attr) {{
emitError() << "expected key entry for {0} in DictionaryAttr to set "
"Properties.";
- return ::mlir::failure();
+ return ::llvm::failure();
}
-if (::mlir::failed(::mlir::convertFromAttribute(prop.{0}, attr, [&]() {{
+if (::llvm::failed(::mlir::convertFromAttribute(prop.{0}, attr, [&]() {{
return emitError() << "for `{0}`: ";
})))
- return ::mlir::failure();
+ return ::llvm::failure();
)decl";
bool hasNoDeclarativeFormat = !op.hasAssemblyFormat();
if (op.getTrait("::mlir::OpTrait::AttrSizedOperandSegments") &&
@@ -1473,7 +1472,7 @@ if (::mlir::failed(::mlir::convertFromAttribute(prop.{0}, attr, [&]() {{
// {2}: isRequired
const char *propFromAttrFmt = R"decl(
auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr,
- ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::mlir::LogicalResult {{
+ ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::llvm::LogicalResult {{
{0};
};
auto {1}AttrName = ::mlir::StringAttr::get(ctx, "{1}");
@@ -1482,12 +1481,12 @@ auto attr = dict.get({1}AttrName);
if (!attr && {2}) {{
emitError() << "expected key entry for {1} in DictionaryAttr to set "
"Properties.";
- return ::mlir::failure();
+ return ::llvm::failure();
}
-if (attr && ::mlir::failed(setFromAttr(prop.{1}, attr, [&]() {{
+if (attr && ::llvm::failed(setFromAttr(prop.{1}, attr, [&]() {{
return emitError() << "for `{1}`: ";
})))
- return ::mlir::failure();
+ return ::llvm::failure();
)decl";
// Generate the setter for any property not parsed elsewhere.
@@ -1537,14 +1536,14 @@ if (attr || /*isRequired=*/{1}) {{
if (!attr) {{
emitError() << "expected key entry for {0} in DictionaryAttr to set "
"Properties.";
- return ::mlir::failure();
+ return ::llvm::failure();
}
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
if (convertedAttr) {{
propStorage = convertedAttr;
} else {{
emitError() << "Invalid attribute `{0}` in property conversion: " << attr;
- return ::mlir::failure();
+ return ::llvm::failure();
}
}
)decl",
@@ -1556,7 +1555,7 @@ for (::mlir::NamedAttribute attr : dict) {
return emitError() << "unknown key '" << attr.getName() <<
"' when parsing properties dictionary";
}
-return ::mlir::success();
+return ::llvm::success();
)decl";
}
@@ -1577,7 +1576,7 @@ static void genKeyValuePropDictParser(OperationFormat &fmt, Operator &op,
paramList.emplace_back("::mlir::OpAsmParser &", "parser");
paramList.emplace_back("::mlir::OperationState &", "result");
- Method *method = opClass.addStaticMethod("::mlir::ParseResult",
+ Method *method = opClass.addStaticMethod("::llvm::ParseResult",
"parsePropertiesFromKeyValueList",
std::move(paramList));
MethodBody &body = method->body().indent();
@@ -1621,10 +1620,10 @@ if (succeeded(parser.parseOptionalLess())) {
::llvm::SMLoc dictionaryLoc = parser.getCurrentLocation();
::mlir::NamedAttrList propertyAttributes;
if (parser.parseOptionalAttrDict(propertyAttributes))
- return ::mlir::failure();
+ return ::llvm::failure();
if (dictionaryLoc != parser.getCurrentLocation()) {
if (parser.parseGreater())
- return ::mlir::failure();
+ return ::llvm::failure();
auto propertyDictionary =
::mlir::DictionaryAttr::get(parser.getContext(), propertyAttributes);
return setPropertiesFromParsedAttr(prop, propertyDictionary, [&]() {
@@ -1638,7 +1637,7 @@ if (succeeded(parser.parseOptionalLess())) {
::llvm::SMLoc keyLoc = parser.getCurrentLocation();
::llvm::StringRef key;
if (parser.parseKeyword(&key))
- return ::mlir::failure();
+ return ::llvm::failure();
)decl";
SmallVector<StringRef> unitKeys;
@@ -1659,7 +1658,7 @@ if (succeeded(parser.parseOptionalLess())) {
body << ";\n"
<< " if (!isUnitKey && parser.parseEqual())\n";
}
- body << " return ::mlir::failure();\n";
+ body << " return ::llvm::failure();\n";
bool isFirst = true;
FmtContext attrTypeCtx;
@@ -1675,11 +1674,11 @@ if (succeeded(parser.parseOptionalLess())) {
::mlir::AsmParser::Delimiter::Square, [&]() {
int32_t size;
if (parser.parseInteger(size))
- return ::mlir::failure();
+ return ::llvm::failure();
parsedSegmentSizes.push_back(size);
- return ::mlir::success();
+ return ::llvm::success();
}))
- return ::mlir::failure();
+ return ::llvm::failure();
)decl"
<< " if (parsedSegmentSizes.size() != prop." << name
<< ".size())\n"
@@ -1726,7 +1725,7 @@ auto parseResult = ::mlir::detail::parsePropertyWithFallback(
parser, prop.)decl"
<< property.name << R"decl(,
[&](auto &propStorage,
- ::mlir::Attribute propertyAttr) -> ::mlir::LogicalResult {
+ ::mlir::Attribute propertyAttr) -> ::llvm::LogicalResult {
auto emitError = [&]() {
return parser.emitError(parser.getCurrentLocation())
<< "invalid value for property " << key << ": ";
@@ -1736,7 +1735,7 @@ auto parseResult = ::mlir::detail::parsePropertyWithFallback(
<< ";\n";
body << "});\n"
<< "if (failed(parseResult))\n"
- << " return ::mlir::failure();\n";
+ << " return ::llvm::failure();\n";
body.unindent();
}
body.unindent() << " }\n";
@@ -1768,14 +1767,14 @@ auto parseResult = ::mlir::detail::parsePropertyWithFallback(
bool useBrackets = needsPropDictEnumBrackets(&attribute);
if (useBrackets)
body << " if (parser.parseLSquare())\n"
- " return ::mlir::failure();\n";
+ " return ::llvm::failure();\n";
genEnumAttrParser(&attribute, body.indent(), attrTypeCtx,
/*parseAsOptional=*/false, fmt.opCppClassName,
/*formatAsEnumDirective=*/true,
/*formatBitEnumAsUnquoted=*/true);
if (useBrackets)
body << " if (parser.parseRSquare())\n"
- " return ::mlir::failure();\n";
+ " return ::llvm::failure();\n";
} else {
genAttrParser(&attributeVariable, body.indent(), attrTypeCtx,
/*parseAsOptional=*/false, fmt.opCppClassName);
@@ -1805,7 +1804,7 @@ auto parseResult = ::mlir::detail::parsePropertyWithFallback(
body << R"decl(
reachedEnd = succeeded(parser.parseOptionalGreater());
if (!reachedEnd && parser.parseComma())
- return ::mlir::failure();
+ return ::llvm::failure();
}
}
)decl";
@@ -1836,7 +1835,7 @@ auto parseResult = ::mlir::detail::parsePropertyWithFallback(
"\"properties dictionary is missing required attribute: "
<< attribute.name << "\");\n";
}
- body << "return ::mlir::success();\n";
+ body << "return ::llvm::success();\n";
}
void OperationFormat::genParser(Operator &op, OpClass &opClass) {
@@ -1844,15 +1843,15 @@ void OperationFormat::genParser(Operator &op, OpClass &opClass) {
paramList.emplace_back("::mlir::OpAsmParser &", "parser");
paramList.emplace_back("::mlir::OperationState &", "result");
- auto *method = opClass.addStaticMethod("::mlir::ParseResult", "parse",
+ auto *method = opClass.addStaticMethod("::llvm::ParseResult", "parse",
std::move(paramList));
auto &body = method->body();
// Generate variables to store the operands and type within the format. This
// allows for referencing these variables in the presence of optional
// groupings.
- unsigned numVariableLengthOperands = llvm::count_if(
- op.getOperands(), [](const NamedTypeConstraint &operand) {
+ unsigned numVariableLengthOperands =
+ llvm::count_if(op.getOperands(), [](const NamedTypeConstraint &operand) {
return operand.isVariableLength();
});
bool groupOperandStorage = !allOperands && numVariableLengthOperands > 1;
@@ -1877,7 +1876,7 @@ void OperationFormat::genParser(Operator &op, OpClass &opClass) {
genParserVariadicSegmentResolution(op, body);
genParserTypeResolution(op, body);
- body << " return ::mlir::success();\n";
+ body << " return ::llvm::success();\n";
genParsedAttrPropertiesSetter(*this, op, opClass);
genKeyValuePropDictParser(*this, op, opClass);
@@ -1938,7 +1937,7 @@ void OperationFormat::genElementParser(FormatElement *element, MethodBody &body,
propVar->getVar()->name)
<< " {\n";
} else if (auto *literal = dyn_cast<LiteralElement>(firstElement)) {
- body << " if (::mlir::succeeded(parser.parseOptional";
+ body << " if (::llvm::succeeded(parser.parseOptional";
genLiteralParser(literal->getSpelling(), body);
body << ")) {\n";
} else if (auto *opVar = dyn_cast<OperandVariable>(firstElement)) {
@@ -1961,9 +1960,9 @@ void OperationFormat::genElementParser(FormatElement *element, MethodBody &body,
body << " if (auto optResult = [&]() -> ::mlir::OptionalParseResult {\n";
genCustomDirectiveParser(custom, body, opCppClassName,
/*isOptional=*/true);
- body << " return ::mlir::success();\n"
- << " }(); optResult.has_value() && ::mlir::failed(*optResult)) {\n"
- << " return ::mlir::failure();\n"
+ body << " return ::llvm::success();\n"
+ << " }(); optResult.has_value() && ::llvm::failed(*optResult)) {\n"
+ << " return ::llvm::failure();\n"
<< " } else if (optResult.has_value()) {\n";
}
@@ -2061,7 +2060,7 @@ void OperationFormat::genElementParser(FormatElement *element, MethodBody &body,
} else if (LiteralElement *literal = dyn_cast<LiteralElement>(element)) {
body << " if (parser.parse";
genLiteralParser(literal->getSpelling(), body);
- body << ")\n return ::mlir::failure();\n";
+ body << ")\n return ::llvm::failure();\n";
/// Whitespaces.
} else if (isa<WhitespaceElement>(element)) {
@@ -2112,14 +2111,14 @@ void OperationFormat::genElementParser(FormatElement *element, MethodBody &body,
<< "if (parser.parseOptionalAttrDict"
<< (attrDict->isWithKeyword() ? "WithKeyword" : "")
<< "(result.attributes))\n"
- << " return ::mlir::failure();\n";
+ << " return ::llvm::failure();\n";
if (!useStrictPropertiesInAssemblyFormat) {
body << "if (failed(verifyInherentAttrs(result.name, result.attributes, "
"[&]() {\n"
<< " return parser.emitError(loc) << \"'\" << "
"result.name.getStringRef() << \"' op \";\n"
<< " })))\n"
- << " return ::mlir::failure();\n";
+ << " return ::llvm::failure();\n";
} else {
for (StringRef name : inherentAttrNames) {
body << "if (result.attributes.get(\"" << name << "\"))\n"
@@ -2132,14 +2131,14 @@ void OperationFormat::genElementParser(FormatElement *element, MethodBody &body,
body.unindent();
} else if (isa<PropDictDirective>(element)) {
body << " if (parseProperties(parser, result))\n"
- << " return ::mlir::failure();\n";
+ << " return ::llvm::failure();\n";
} else if (auto *customDir = dyn_cast<CustomDirective>(element)) {
genCustomDirectiveParser(customDir, body, opCppClassName);
} else if (isa<OperandsDirective>(element)) {
body << " [[maybe_unused]] ::llvm::SMLoc allOperandLoc ="
<< " parser.getCurrentLocation();\n"
<< " if (parser.parseOperandList(allOperands))\n"
- << " return ::mlir::failure();\n";
+ << " return ::llvm::failure();\n";
} else if (isa<RegionsDirective>(element)) {
body << formatv(regionListParserCode, "full");
@@ -2293,7 +2292,7 @@ void OperationFormat::genParserOperandTypeResolution(
emitArrayVsSingletonSuppression();
body << " if (parser.resolveOperands(allOperands, allOperandTypes, "
"allOperandLoc, result.operands))\n"
- " return ::mlir::failure();\n";
+ " return ::llvm::failure();\n";
return;
}
@@ -2311,7 +2310,7 @@ void OperationFormat::genParserOperandTypeResolution(
body << op.operand_begin()->name << "Operands";
}
body << ", allOperandTypes, parser.getNameLoc(), result.operands))\n"
- << " return ::mlir::failure();\n";
+ << " return ::llvm::failure();\n";
return;
}
@@ -2337,7 +2336,7 @@ void OperationFormat::genParserOperandTypeResolution(
}
body << ", allOperandLoc, result.operands))\n return "
- "::mlir::failure();\n";
+ "::llvm::failure();\n";
return;
}
@@ -2360,7 +2359,7 @@ void OperationFormat::genParserOperandTypeResolution(
emitTypeResolver(operandType, operand.name);
body << ", " << operand.name
- << "OperandsLoc, result.operands))\n return ::mlir::failure();\n";
+ << "OperandsLoc, result.operands))\n return ::llvm::failure();\n";
if (guardOptionalOperand)
body << " }\n";
}
diff --git a/mlir/tools/mlir-tblgen/RewriterGen.cpp b/mlir/tools/mlir-tblgen/RewriterGen.cpp
index a53ced0e394cb0..59849d0ddbb8fd 100644
--- a/mlir/tools/mlir-tblgen/RewriterGen.cpp
+++ b/mlir/tools/mlir-tblgen/RewriterGen.cpp
@@ -59,7 +59,6 @@ struct format_provider<mlir::tblgen::Pattern::IdentifierLine> {
//===----------------------------------------------------------------------===//
namespace {
-
class StaticMatcherHelper;
class PatternEmitter {
@@ -349,7 +348,6 @@ class StaticMatcherHelper {
// Static type/attribute verification function emitter.
StaticVerifierFunctionEmitter staticVerifierEmitter;
};
-
} // namespace
PatternEmitter::PatternEmitter(const Record *pat, RecordOperatorMap *mapper,
@@ -391,7 +389,7 @@ void PatternEmitter::emitStaticMatcher(DagNode tree, std::string funcName) {
// entry.
emitMatch(tree, "op0", /*depth=*/1);
- os << "return ::mlir::success();\n";
+ os << "return ::llvm::success();\n";
os.unindent();
os << "}\n\n";
}
@@ -413,7 +411,7 @@ void PatternEmitter::emitMatch(DagNode tree, StringRef name, int depth) {
void PatternEmitter::emitStaticMatchCall(DagNode tree, StringRef opName) {
std::string funcName = staticMatcherHelper.getMatcherName(tree);
- os << formatv("if(::mlir::failed({0}(rewriter, {1}, tblgen_ops", funcName,
+ os << formatv("if(::llvm::failed({0}(rewriter, {1}, tblgen_ops", funcName,
opName);
// TODO(chiahungduan): Add a lookupBoundSymbols() to do the subtree lookup in
@@ -436,16 +434,16 @@ void PatternEmitter::emitStaticMatchCall(DagNode tree, StringRef opName) {
}
os << "))) {\n";
- os.scope().os << "return ::mlir::failure();\n";
+ os.scope().os << "return ::llvm::failure();\n";
os << "}\n";
}
void PatternEmitter::emitStaticVerifierCall(StringRef funcName,
StringRef opName, StringRef arg,
StringRef failureStr) {
- os << formatv("if(::mlir::failed({0}(rewriter, {1}, {2}, {3}))) {{\n",
+ os << formatv("if(::llvm::failed({0}(rewriter, {1}, {2}, {3}))) {{\n",
funcName, opName, arg, failureStr);
- os.scope().os << "return ::mlir::failure();\n";
+ os.scope().os << "return ::llvm::failure();\n";
os << "}\n";
}
@@ -525,8 +523,8 @@ void PatternEmitter::emitNativeCodeMatch(DagNode tree, StringRef opName,
tgfmtv(fmt, &fmtCtx.addSubst("_loc", locToUse).withSelf(opName.str()),
static_cast<ArrayRef<std::string>>(capture)));
- emitMatchCheck(opName, formatv("!::mlir::failed({0})", nativeCodeCall),
- formatv("\"{0} return ::mlir::failure\"", nativeCodeCall));
+ emitMatchCheck(opName, formatv("!::llvm::failed({0})", nativeCodeCall),
+ formatv("\"{0} return ::llvm::failure\"", nativeCodeCall));
for (int i = 0, e = tree.getNumArgs() - tail.numDirectives; i != e; ++i) {
auto name = tree.getArgName(i);
@@ -802,7 +800,7 @@ void PatternEmitter::emitEitherOperandMatch(DagNode tree, DagNode eitherArgTree,
}
os << tblgenOps.str();
- os << "return ::mlir::success();\n";
+ os << "return ::llvm::success();\n";
os.unindent() << "};\n";
os << "{\n";
@@ -813,11 +811,11 @@ void PatternEmitter::emitEitherOperandMatch(DagNode tree, DagNode eitherArgTree,
os << formatv("auto eitherOperand1 = {0}.getODSOperands({1});\n", opName,
operandIndex - 1);
- os << formatv("if(::mlir::failed({0}(eitherOperand0, eitherOperand1)) && "
- "::mlir::failed({0}(eitherOperand1, "
+ os << formatv("if(::llvm::failed({0}(eitherOperand0, eitherOperand1)) && "
+ "::llvm::failed({0}(eitherOperand1, "
"eitherOperand0)))\n",
lambda);
- os.indent() << "return ::mlir::failure();\n";
+ os.indent() << "return ::llvm::failure();\n";
os.unindent().unindent() << "}\n";
}
@@ -834,7 +832,7 @@ void PatternEmitter::emitVariadicOperandMatch(DagNode tree,
os << formatv("auto variadic_operand_range = {0}.getODSOperands({1});\n",
opName, operandIndex);
os << formatv("if (variadic_operand_range.size() != {0}) "
- "return ::mlir::failure();\n",
+ "return ::llvm::failure();\n",
variadicArgTree.getNumArgs());
StringRef variadicTreeName = variadicArgTree.getSymbol();
@@ -933,7 +931,7 @@ void PatternEmitter::emitAttributeMatch(DagNode tree, StringRef castedName,
// through.
if (!StringRef(matcher.getConditionTemplate()).contains("!$_self") &&
StringRef(matcher.getConditionTemplate()).contains("$_self")) {
- os << "if (!tblgen_attr) return ::mlir::failure();\n";
+ os << "if (!tblgen_attr) return ::llvm::failure();\n";
}
}
emitStaticVerifierCall(
@@ -1177,7 +1175,7 @@ void PatternEmitter::emit(StringRef rewriteName) {
os << "\n// Rewrite\n";
emitRewriteLogic();
- os << "return ::mlir::success();\n";
+ os << "return ::llvm::success();\n";
}
os << "}\n";
}
More information about the Mlir-commits
mailing list