in lib/Dialect/mhlo/IR/hlo_ops.cc [5648:5681]
ParseResult parseWhileOp(OpAsmParser& parser, OperationState& result) {
llvm::SMLoc loc = parser.getCurrentLocation();
// Parse the operands of the while: these are of the form:
// %iter_arg = %init_val
// where %iter_arg is the name of the block argument in the cond/body blocks
// and %init_val is the actual operand.
SmallVector<OpAsmParser::OperandType> operands;
SmallVector<OpAsmParser::OperandType> iterArgs;
if (parser.parseLParen()) return failure();
do {
if (succeeded(parser.parseOptionalRParen())) break;
OpAsmParser::OperandType operand, iterArg;
if (parser.parseOperand(iterArg) || parser.parseEqual() ||
parser.parseOperand(operand))
return failure();
iterArgs.push_back(iterArg);
operands.push_back(operand);
if (succeeded(parser.parseOptionalRParen())) break;
parser.parseComma();
} while (true);
if (!operands.empty()) {
if (parser.parseColon() || parser.parseTypeList(result.types))
return failure();
}
if (parser.resolveOperands(operands, result.types, loc, result.operands) ||
parser.parseOptionalAttrDictWithKeyword(result.attributes) ||
parser.parseKeyword("cond") ||
parser.parseRegion(*result.addRegion(), iterArgs, result.types) ||
parser.parseKeyword("do") ||
parser.parseRegion(*result.addRegion(), iterArgs, result.types))
return failure();
return success();
}