format](DeclarativeRewrites.md).
Note that dialect names should not generally be suffixed with “Ops”,
-although some files pertaining to the operations of a dialect (e.g.
+although some files pertaining only to the operations of a dialect (e.g.
FooOps.cpp) might be.
## CMake best practices
is declared using add_mlir_dialect().
```cmake
-
add_mlir_dialect(FooOps foo)
add_mlir_doc(FooOps -gen-dialect-doc FooDialect Dialects/)
-
```
This generates the correct rules to run mlir-tblgen, along with a
Dialect transformations are typically declared in a file FooTransforms.td.
Targets for TableGen are described in typical llvm fashion.
+
```cmake
set(LLVM_TARGET_DEFINITIONS FooTransforms.td)
mlir_tablegen(FooTransforms.h.inc -gen-rewriters)
target_link_libraries() and the PUBLIC keyword. For instance:
```cmake
-
-add_mlir_dialect_library(FooOps
- DEPENDS
- MLIRFooOpsIncGen
- MLIRFooTransformsIncGen
-
- LINK_COMPONENTS
- Core
-
- LINK_LIBS PUBLIC
- BarOps
- <some-other-library>
- )
-
+add_mlir_dialect_library(MLIRFoo
+ DEPENDS
+ MLIRFooOpsIncGen
+ MLIRFooTransformsIncGen
+
+ LINK_COMPONENTS
+ Core
+
+ LINK_LIBS PUBLIC
+ MLIRBar
+ <some-other-library>
+ )
```
add_mlir_dialect_library() is a thin wrapper around add_llvm_library()
The list can be retrieved from the MLIR_DIALECT_LIBS global property:
```cmake
-
get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
-
```
Note that although the Bar dialect also uses TableGen to declare its
using target_link_libraries() and the PUBLIC keyword. For instance:
```cmake
-
add_mlir_conversion_library(MLIRBarToFoo
- BarToFoo.cpp
+ BarToFoo.cpp
- ADDITIONAL_HEADER_DIRS
- ${MLIR_MAIN_INCLUDE_DIR}/mlir/Conversion/BarToFoo
-
- LINK_LIBS PUBLIC
- BarOps
- FooOps
- )
+ ADDITIONAL_HEADER_DIRS
+ ${MLIR_MAIN_INCLUDE_DIR}/mlir/Conversion/BarToFoo
+ LINK_LIBS PUBLIC
+ MLIRBar
+ MLIRFoo
+ )
```
add_mlir_conversion_library() is a thin wrapper around
MLIR_CONVERSION_LIBS global property:
```cmake
-
get_property(dialect_libs GLOBAL PROPERTY MLIR_CONVERSION_LIBS)
-
```
Note that it is only necessary to specify a PUBLIC dependence against