[Mlir-commits] [mlir] [mlir][AsmParser] Expose `parseMinus()` (PR #106881)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Sat Aug 31 19:24:07 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir
Author: Ivan Butygin (Hardcode84)
<details>
<summary>Changes</summary>
Found while working on custom expression type for my dialect.
Builtin `AffineExpr` uses low-level parser API which is not available for external users.
---
Full diff: https://github.com/llvm/llvm-project/pull/106881.diff
2 Files Affected:
- (modified) mlir/include/mlir/IR/OpImplementation.h (+6)
- (modified) mlir/lib/AsmParser/AsmParserImpl.h (+10)
``````````diff
diff --git a/mlir/include/mlir/IR/OpImplementation.h b/mlir/include/mlir/IR/OpImplementation.h
index ae412c7227f8ea..e2472eea8a3714 100644
--- a/mlir/include/mlir/IR/OpImplementation.h
+++ b/mlir/include/mlir/IR/OpImplementation.h
@@ -641,6 +641,12 @@ class AsmParser {
/// Parse a '+' token if present.
virtual ParseResult parseOptionalPlus() = 0;
+ /// Parse a '-' token.
+ virtual ParseResult parseMinus() = 0;
+
+ /// Parse a '-' token if present.
+ virtual ParseResult parseOptionalMinus() = 0;
+
/// Parse a '*' token.
virtual ParseResult parseStar() = 0;
diff --git a/mlir/lib/AsmParser/AsmParserImpl.h b/mlir/lib/AsmParser/AsmParserImpl.h
index b12687833e3fde..04250f63dcd253 100644
--- a/mlir/lib/AsmParser/AsmParserImpl.h
+++ b/mlir/lib/AsmParser/AsmParserImpl.h
@@ -226,6 +226,16 @@ class AsmParserImpl : public BaseT {
return success(parser.consumeIf(Token::plus));
}
+ /// Parses a '-' token.
+ ParseResult parseMinus() override {
+ return parser.parseToken(Token::minus, "expected '-'");
+ }
+
+ /// Parses a '-' token if present.
+ ParseResult parseOptionalMinus() override {
+ return success(parser.consumeIf(Token::minus));
+ }
+
/// Parse a '|' token.
ParseResult parseVerticalBar() override {
return parser.parseToken(Token::vertical_bar, "expected '|'");
``````````
</details>
https://github.com/llvm/llvm-project/pull/106881
More information about the Mlir-commits
mailing list