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
/// 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.
///
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.