[Mlir-commits] [mlir] mlir/Presburger: contribute a free-standing parser (PR #94916)
Kunwar Grover
llvmlistbot at llvm.org
Mon Jul 8 00:57:23 PDT 2024
================
@@ -11,32 +11,37 @@
//
//===----------------------------------------------------------------------===//
-#ifndef MLIR_UNITTESTS_ANALYSIS_PRESBURGER_PARSER_H
-#define MLIR_UNITTESTS_ANALYSIS_PRESBURGER_PARSER_H
+#ifndef MLIR_ANALYSIS_PRESBURGER_PARSER_H
+#define MLIR_ANALYSIS_PRESBURGER_PARSER_H
#include "mlir/Analysis/Presburger/IntegerRelation.h"
#include "mlir/Analysis/Presburger/PWMAFunction.h"
#include "mlir/Analysis/Presburger/PresburgerRelation.h"
-#include "mlir/AsmParser/AsmParser.h"
-#include "mlir/Dialect/Affine/Analysis/AffineStructures.h"
-#include "mlir/IR/AffineExpr.h"
-#include "mlir/IR/AffineMap.h"
-#include "mlir/IR/IntegerSet.h"
-
-namespace mlir {
-namespace presburger {
-
-/// Parses an IntegerPolyhedron from a StringRef. It is expected that the string
-/// represents a valid IntegerSet.
-inline IntegerPolyhedron parseIntegerPolyhedron(StringRef str) {
- MLIRContext context(MLIRContext::Threading::DISABLED);
- return affine::FlatAffineValueConstraints(parseIntegerSet(str, &context));
-}
+
+namespace mlir::presburger {
+using llvm::StringRef;
+
+/// Parse an IntegerPolyhedron from a StringRef.
+///
+/// integer-set ::= dim-and-symbol-id-lists `:`
+/// '(' affine-constraint-conjunction? ')'
+/// affine-constraint-conjunction ::= affine-constraint (`,`
+/// affine-constraint)*
+///
+IntegerPolyhedron parseIntegerPolyhedron(StringRef str);
+
+/// Parse a MultiAffineFunction from a StringRef.
+///
+/// affine-map ::= dim-and-symbol-id-lists `->` multi-dim-affine-expr
+///
+/// multi-dim-affine-expr ::= `(` `)`
+/// multi-dim-affine-expr ::= `(` affine-expr (`,` affine-expr)* `)`
+MultiAffineFunction parseMultiAffineFunction(StringRef str);
----------------
Groverkss wrote:
I noticed a number of documentation comments in this patch that are directly copy pasted from various places in MLIR. Could you please check them and update them based on where they are used?
For example, here, `affine-map` and `integer-set` are a MLIR thing. If Presburger ends up moving in LLVM, a user has no clue what an affine-map is. Please instead use the relevant naming here.
https://github.com/llvm/llvm-project/pull/94916
More information about the Mlir-commits
mailing list