Skip to content

Commit fbbbd65

Browse files
authored
[MLIR] correct return type of parse() functions (#120180)
The `parseX()` functions that are defined to support `custom<X>` in `assemblyFormat` should return `ParseResult` rather than `LogicalResult`. The `ParseResult` type is necessary due to tablegen generating code that expects this type within an Op `parseX()` function.
1 parent 9d33874 commit fbbbd65

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

mlir/lib/Dialect/GPU/IR/GPUDialect.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2114,8 +2114,8 @@ LogicalResult ObjectAttr::verify(function_ref<InFlightDiagnostic()> emitError,
21142114
}
21152115

21162116
namespace {
2117-
LogicalResult parseObject(AsmParser &odsParser, CompilationTarget &format,
2118-
StringAttr &object) {
2117+
ParseResult parseObject(AsmParser &odsParser, CompilationTarget &format,
2118+
StringAttr &object) {
21192119
std::optional<CompilationTarget> formatResult;
21202120
StringRef enumKeyword;
21212121
auto loc = odsParser.getCurrentLocation();

mlir/lib/Dialect/LLVMIR/IR/LLVMAttrs.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ using namespace mlir::LLVM;
2727
/// Parses DWARF expression arguments with respect to the DWARF operation
2828
/// opcode. Some DWARF expression operations have a specific number of operands
2929
/// and may appear in a textual form.
30-
static LogicalResult parseExpressionArg(AsmParser &parser, uint64_t opcode,
31-
SmallVector<uint64_t> &args);
30+
static ParseResult parseExpressionArg(AsmParser &parser, uint64_t opcode,
31+
SmallVector<uint64_t> &args);
3232

3333
/// Prints DWARF expression arguments with respect to the specific DWARF
3434
/// operation. Some operands are printed in their textual form.
@@ -144,8 +144,8 @@ DIExpressionAttr DIExpressionAttr::get(MLIRContext *context) {
144144
return get(context, ArrayRef<DIExpressionElemAttr>({}));
145145
}
146146

147-
LogicalResult parseExpressionArg(AsmParser &parser, uint64_t opcode,
148-
SmallVector<uint64_t> &args) {
147+
ParseResult parseExpressionArg(AsmParser &parser, uint64_t opcode,
148+
SmallVector<uint64_t> &args) {
149149
auto operandParser = [&]() -> LogicalResult {
150150
uint64_t operand = 0;
151151
if (!args.empty() && opcode == llvm::dwarf::DW_OP_LLVM_convert) {

mlir/test/lib/Dialect/Test/TestTypes.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,14 @@ static llvm::hash_code test::hash_value(const FieldInfo &fi) { // NOLINT
9090
// TestCustomType
9191
//===----------------------------------------------------------------------===//
9292

93-
static LogicalResult parseCustomTypeA(AsmParser &parser, int &aResult) {
93+
static ParseResult parseCustomTypeA(AsmParser &parser, int &aResult) {
9494
return parser.parseInteger(aResult);
9595
}
9696

9797
static void printCustomTypeA(AsmPrinter &printer, int a) { printer << a; }
9898

99-
static LogicalResult parseCustomTypeB(AsmParser &parser, int a,
100-
std::optional<int> &bResult) {
99+
static ParseResult parseCustomTypeB(AsmParser &parser, int a,
100+
std::optional<int> &bResult) {
101101
if (a < 0)
102102
return success();
103103
for (int i : llvm::seq(0, a))
@@ -116,7 +116,7 @@ static void printCustomTypeB(AsmPrinter &printer, int a, std::optional<int> b) {
116116
printer << *b;
117117
}
118118

119-
static LogicalResult parseFooString(AsmParser &parser, std::string &foo) {
119+
static ParseResult parseFooString(AsmParser &parser, std::string &foo) {
120120
std::string result;
121121
if (parser.parseString(&result))
122122
return failure();
@@ -128,7 +128,7 @@ static void printFooString(AsmPrinter &printer, StringRef foo) {
128128
printer << '"' << foo << '"';
129129
}
130130

131-
static LogicalResult parseBarString(AsmParser &parser, StringRef foo) {
131+
static ParseResult parseBarString(AsmParser &parser, StringRef foo) {
132132
return parser.parseKeyword(foo);
133133
}
134134

0 commit comments

Comments
 (0)