[Mlir-commits] [mlir] e403488 - [MLIR] Specify namespace for standard dialect using cppNamespace field
Arjun P
llvmlistbot at llvm.org
Mon May 31 10:13:46 PDT 2021
Author: Andi Drebes
Date: 2021-05-31T22:43:25+05:30
New Revision: e4034881c3537d914b3208ddcf8200fb437073c8
URL: https://github.com/llvm/llvm-project/commit/e4034881c3537d914b3208ddcf8200fb437073c8
DIFF: https://github.com/llvm/llvm-project/commit/e4034881c3537d914b3208ddcf8200fb437073c8.diff
LOG: [MLIR] Specify namespace for standard dialect using cppNamespace field
The `::mlir` namespace for operations from standard is currently
defined by enclosing the header file generated from the ODS in
`Ops.td` in a namespace in `Ops.h`. However, when referencing
operations from `Ops.td` in other TableGen files, this causes the
generated C++ code to refer to classes from the global namespace
instead of `::mlir`.
By defining the namespace through the `cppNamespace` field for
`StandardOps_Dialect` directly in `Ops.td` instead, the ODS
becomes reusable in other TableGen files through simple
inclusion.
Reviewed By: mehdi_amini
Differential Revision: https://reviews.llvm.org/D103234
Added:
Modified:
mlir/include/mlir/Dialect/StandardOps/IR/Ops.h
mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.h b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.h
index 7d3c72349bf8..65cac17098c8 100644
--- a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.h
+++ b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.h
@@ -41,12 +41,14 @@ class PatternRewriter;
/// with `b` at location `loc`.
SmallVector<Range, 8> getOrCreateRanges(OffsetSizeAndStrideOpInterface op,
OpBuilder &b, Location loc);
+} // namespace mlir
#define GET_OP_CLASSES
#include "mlir/Dialect/StandardOps/IR/Ops.h.inc"
#include "mlir/Dialect/StandardOps/IR/OpsDialect.h.inc"
+namespace mlir {
/// This is a refinement of the "constant" op for the case where it is
/// returning a float value of FloatType.
///
diff --git a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
index 74efd0f7960c..8f863978456c 100644
--- a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
+++ b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
@@ -25,7 +25,7 @@ include "mlir/Interfaces/ViewLikeInterface.td"
def StandardOps_Dialect : Dialect {
let name = "std";
- let cppNamespace = "";
+ let cppNamespace = "::mlir";
let hasConstantMaterializer = 1;
// TODO: This dependency is needed to handle memref ops in the
// canonicalize pass and should be resolved.
More information about the Mlir-commits
mailing list