Introduce a new Location abstraction to represent location data in a structured
(and more useful) way rather than hacking up a pile of attributes for it. In
the future this will grow to represent inlined locations, fusion cases etc, but
for now we start with simple Unknown and File/Line/Col locations. NFC.
PiperOrigin-RevId: 210485775
diff --git a/lib/IR/Builders.cpp b/lib/IR/Builders.cpp
index 376d54e..8d0f223 100644
--- a/lib/IR/Builders.cpp
+++ b/lib/IR/Builders.cpp
@@ -20,6 +20,7 @@
#include "mlir/IR/AffineMap.h"
#include "mlir/IR/Attributes.h"
#include "mlir/IR/IntegerSet.h"
+#include "mlir/IR/Location.h"
#include "mlir/IR/Module.h"
#include "mlir/IR/Types.h"
using namespace mlir;
@@ -33,6 +34,21 @@
Module *Builder::createModule() { return new Module(context); }
//===----------------------------------------------------------------------===//
+// Locations.
+//===----------------------------------------------------------------------===//
+
+UnknownLoc *Builder::getUnknownLoc() { return UnknownLoc::get(context); }
+
+UniquedFilename Builder::getUniquedFilename(StringRef filename) {
+ return UniquedFilename::get(filename, context);
+}
+
+FileLineColLoc *Builder::getFileLineColLoc(UniquedFilename filename,
+ unsigned line, unsigned column) {
+ return FileLineColLoc::get(filename, line, column, context);
+}
+
+//===----------------------------------------------------------------------===//
// Types.
//===----------------------------------------------------------------------===//
@@ -227,7 +243,7 @@
return op;
}
-ForStmt *MLFuncBuilder::createFor(Attribute *location,
+ForStmt *MLFuncBuilder::createFor(Location *location,
ArrayRef<MLValue *> lbOperands,
AffineMap *lbMap,
ArrayRef<MLValue *> ubOperands,
@@ -238,7 +254,7 @@
return stmt;
}
-IfStmt *MLFuncBuilder::createIf(Attribute *location, IntegerSet *condition) {
+IfStmt *MLFuncBuilder::createIf(Location *location, IntegerSet *condition) {
auto *stmt = new IfStmt(location, condition);
block->getStatements().insert(insertPoint, stmt);
return stmt;