[WIP] Sketching IR and parsing support for affine maps, affine expressions
Run test case:
$ mlir-opt test/IR/parser-affine-map.mlir
test/IR/parser-affine-map.mlir:3:30: error: expect '(' at start of map range
#hello_world2 (i, j) [s0] -> i+s0, j)
^
PiperOrigin-RevId: 202736856
diff --git a/lib/IR/AsmPrinter.cpp b/lib/IR/AsmPrinter.cpp
index 639000b..067697c 100644
--- a/lib/IR/AsmPrinter.cpp
+++ b/lib/IR/AsmPrinter.cpp
@@ -20,13 +20,15 @@
//
//===----------------------------------------------------------------------===//
+#include "mlir/IR/AffineExpr.h"
+#include "mlir/IR/AffineMap.h"
#include "mlir/IR/CFGFunction.h"
#include "mlir/IR/MLFunction.h"
#include "mlir/IR/Module.h"
#include "mlir/IR/Types.h"
#include "mlir/Support/STLExtras.h"
-#include "llvm/Support/raw_ostream.h"
#include "llvm/ADT/DenseMap.h"
+#include "llvm/Support/raw_ostream.h"
using namespace mlir;
@@ -162,6 +164,15 @@
print(llvm::errs());
}
+void AffineExpr::print(raw_ostream &os) const {
+ // TODO(bondhugula): print out affine expression
+}
+
+void AffineMap::print(raw_ostream &os) const {
+ // TODO(andydavis) Print out affine map based on dimensionCount and
+ // symbolCount: (d0, d1) [S0, S1] -> (d0 + S0, d1 + S1)
+}
+
void BasicBlock::print(raw_ostream &os) const {
CFGFunctionState state(getFunction(), os);
state.print();
@@ -208,6 +219,8 @@
}
void Module::print(raw_ostream &os) const {
+ for (auto *map : affineMapList)
+ map->print(os);
for (auto *fn : functionList)
fn->print(os);
}