[MLIR] Specify namespace for standard dialect using cppNamespace field
authorAndi Drebes <andi@drebesium.org>
Mon, 31 May 2021 15:53:32 +0000 (21:23 +0530)
committerArjun P <arjunpitchanathan@gmail.com>
Mon, 31 May 2021 17:13:25 +0000 (22:43 +0530)
commite4034881c3537d914b3208ddcf8200fb437073c8
tree58c0edb71473c60acd9c2e30bbc97d43308bc979
parent2c3afa32377693514e400aee10f27b691887b4cf
[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
mlir/include/mlir/Dialect/StandardOps/IR/Ops.h
mlir/include/mlir/Dialect/StandardOps/IR/Ops.td