From b33a7232a2634793512b109d5410c97ae4f315d4 Mon Sep 17 00:00:00 2001 From: River Riddle Date: Sun, 26 May 2019 08:28:28 -0700 Subject: [PATCH] Add a 'getDialectNamespace' utility to a few dialects. -- PiperOrigin-RevId: 250049416 --- mlir/examples/Linalg/Linalg1/include/linalg1/Dialect.h | 1 + mlir/examples/Linalg/Linalg1/lib/DialectConstruction.cpp | 2 +- mlir/include/mlir/AffineOps/AffineOps.h | 1 + mlir/include/mlir/StandardOps/Ops.h | 1 + mlir/lib/AffineOps/AffineOps.cpp | 2 +- mlir/lib/StandardOps/Ops.cpp | 2 +- 6 files changed, 6 insertions(+), 3 deletions(-) diff --git a/mlir/examples/Linalg/Linalg1/include/linalg1/Dialect.h b/mlir/examples/Linalg/Linalg1/include/linalg1/Dialect.h index 70023e1..b14e626 100644 --- a/mlir/examples/Linalg/Linalg1/include/linalg1/Dialect.h +++ b/mlir/examples/Linalg/Linalg1/include/linalg1/Dialect.h @@ -29,6 +29,7 @@ public: /// Create a new Dialect that is registered on construction and adds the /// relevant types and operations. explicit LinalgDialect(mlir::MLIRContext *context); + static llvm::StringRef getDialectNamespace() { return "linalg"; } /// Parse a type registered to this dialect. mlir::Type parseType(llvm::StringRef spec, mlir::Location loc) const override; diff --git a/mlir/examples/Linalg/Linalg1/lib/DialectConstruction.cpp b/mlir/examples/Linalg/Linalg1/lib/DialectConstruction.cpp index 0eaab6a..bd74676 100644 --- a/mlir/examples/Linalg/Linalg1/lib/DialectConstruction.cpp +++ b/mlir/examples/Linalg/Linalg1/lib/DialectConstruction.cpp @@ -29,7 +29,7 @@ using namespace mlir; using namespace linalg; LinalgDialect::LinalgDialect(MLIRContext *context) - : Dialect("linalg", context) { + : Dialect(getDialectNamespace(), context) { addTypes(); addOperations(); } diff --git a/mlir/include/mlir/AffineOps/AffineOps.h b/mlir/include/mlir/AffineOps/AffineOps.h index d4dd214..a3749a3 100644 --- a/mlir/include/mlir/AffineOps/AffineOps.h +++ b/mlir/include/mlir/AffineOps/AffineOps.h @@ -41,6 +41,7 @@ bool isTopLevelSymbol(Value *value); class AffineOpsDialect : public Dialect { public: AffineOpsDialect(MLIRContext *context); + static StringRef getDialectNamespace() { return "affine"; } }; /// The "affine.apply" operation applies an affine map to a list of operands, diff --git a/mlir/include/mlir/StandardOps/Ops.h b/mlir/include/mlir/StandardOps/Ops.h index b399fbe..1668d84 100644 --- a/mlir/include/mlir/StandardOps/Ops.h +++ b/mlir/include/mlir/StandardOps/Ops.h @@ -35,6 +35,7 @@ class Builder; class StandardOpsDialect : public Dialect { public: StandardOpsDialect(MLIRContext *context); + static StringRef getDialectNamespace() { return "std"; } }; /// The predicate indicates the type of the comparison to perform: diff --git a/mlir/lib/AffineOps/AffineOps.cpp b/mlir/lib/AffineOps/AffineOps.cpp index 1a34c71..ffb1dd2 100644 --- a/mlir/lib/AffineOps/AffineOps.cpp +++ b/mlir/lib/AffineOps/AffineOps.cpp @@ -36,7 +36,7 @@ using llvm::dbgs; //===----------------------------------------------------------------------===// AffineOpsDialect::AffineOpsDialect(MLIRContext *context) - : Dialect(/*name=*/"affine", context) { + : Dialect(getDialectNamespace(), context) { addOperations(); } diff --git a/mlir/lib/StandardOps/Ops.cpp b/mlir/lib/StandardOps/Ops.cpp index dd67546..316d36d 100644 --- a/mlir/lib/StandardOps/Ops.cpp +++ b/mlir/lib/StandardOps/Ops.cpp @@ -80,7 +80,7 @@ template static LogicalResult verifyCastOp(T op) { } StandardOpsDialect::StandardOpsDialect(MLIRContext *context) - : Dialect(/*name=*/"std", context) { + : Dialect(getDialectNamespace(), context) { addOperations