Skip to content

Commit f994cb1

Browse files
Vladislav VinogradovMaxim-Doronin
authored andcommitted
[mlir] Relax ASM parser requirements about operands Type presence
1 parent be056d3 commit f994cb1

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

mlir/include/mlir/IR/OpImplementation.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1449,13 +1449,19 @@ class OpAsmParser : public AsmParser {
14491449
SmallVectorImpl<Value> &result) {
14501450
size_t operandSize = llvm::range_size(operands);
14511451
size_t typeSize = llvm::range_size(types);
1452-
if (operandSize != typeSize)
1452+
if (typeSize != 0 && operandSize != typeSize)
14531453
return emitError(loc)
14541454
<< operandSize << " operands present, but expected " << typeSize;
14551455

1456-
for (auto [operand, type] : llvm::zip_equal(operands, types))
1457-
if (resolveOperand(operand, type, result))
1458-
return failure();
1456+
if (typeSize == 0) {
1457+
for (auto it : operands)
1458+
if (resolveOperand(it, Type(), result))
1459+
return failure();
1460+
} else {
1461+
for (auto [operand, type] : llvm::zip_equal(operands, types))
1462+
if (resolveOperand(operand, type, result))
1463+
return failure();
1464+
}
14591465
return success();
14601466
}
14611467

mlir/lib/AsmParser/Parser.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -984,17 +984,6 @@ Value OperationParser::resolveSSAUse(UnresolvedOperand useInfo, Type type) {
984984
return nullptr;
985985
}
986986

987-
// Explicit type specification can be omitted, only if the Value was already
988-
// defined prior in the same block.
989-
if (!type && result.getParentBlock() != opBuilder.getBlock()) {
990-
emitError(useInfo.location, "value '")
991-
.append(useInfo.name, "' was defined in separate block and requires "
992-
"explicit type definition")
993-
.attachNote(getEncodedSourceLocation(entries[useInfo.number].loc))
994-
.append("defined here");
995-
return nullptr;
996-
}
997-
998987
return maybeRecordUse(result);
999988
}
1000989

0 commit comments

Comments
 (0)