forked from OSchip/llvm-project
[mlir] Provide CustomOpAsmParser::parseOptionalOperand
Summary: Some operations have custom syntax where an operand is always followed by a specific token of streams if the operand is present. Parsing such operations requires the ability to optionally parse an operand. Provide a relevant function in the custom Op parser. Differential Revision: https://reviews.llvm.org/D76779
This commit is contained in:
parent
f1a9efabcb
commit
ec74867c5e
|
@ -452,6 +452,9 @@ public:
|
||||||
/// Parse a single operand.
|
/// Parse a single operand.
|
||||||
virtual ParseResult parseOperand(OperandType &result) = 0;
|
virtual ParseResult parseOperand(OperandType &result) = 0;
|
||||||
|
|
||||||
|
/// Parse a single operand if present.
|
||||||
|
virtual OptionalParseResult parseOptionalOperand(OperandType &result) = 0;
|
||||||
|
|
||||||
/// These are the supported delimiters around operand lists and region
|
/// These are the supported delimiters around operand lists and region
|
||||||
/// argument lists, used by parseOperandList and parseRegionArgumentList.
|
/// argument lists, used by parseOperandList and parseRegionArgumentList.
|
||||||
enum class Delimiter {
|
enum class Delimiter {
|
||||||
|
|
|
@ -4253,6 +4253,13 @@ public:
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Parse a single operand if present.
|
||||||
|
OptionalParseResult parseOptionalOperand(OperandType &result) override {
|
||||||
|
if (parser.getToken().is(Token::percent_identifier))
|
||||||
|
return parseOperand(result);
|
||||||
|
return llvm::None;
|
||||||
|
}
|
||||||
|
|
||||||
/// Parse zero or more SSA comma-separated operand references with a specified
|
/// Parse zero or more SSA comma-separated operand references with a specified
|
||||||
/// surrounding delimiter, and an optional required operand count.
|
/// surrounding delimiter, and an optional required operand count.
|
||||||
ParseResult parseOperandList(SmallVectorImpl<OperandType> &result,
|
ParseResult parseOperandList(SmallVectorImpl<OperandType> &result,
|
||||||
|
|
Loading…
Reference in New Issue