llvm-project/mlir/tools/mlir-tblgen
Mogball b0774e5f50 [mlir][ods] ODS ops get an `extraClassDefinition`
Extra definitions are placed in the generated source file for each op class. The substitution `$cppClass` is replaced by the op's C++ class name.

This is useful when declaring but not defining methods in TableGen base classes:

```
class BaseOp<string mnemonic>
    : Op<MyDialect, mnemonic, [DeclareOpInterfaceMethods<SomeInterface>] {
  let extraClassDeclaration = [{
    // ZOp is declared at at the bottom of the file and is incomplete here
    ZOp getParent();
  }];
  let extraClassDefinition = [{
    int $cppClass::someInterfaceMethod() {
      return someUtilityFunction(*this);
    }
    ZOp $cppClass::getParent() {
      return dyn_cast<ZOp>(this->getParentOp());
    }
  }];
}
```

Certain things may prevent defining these functions inline, in the declaration. In this example, `ZOp` in the same dialect is incomplete at the function declaration because ops classes are declared in alphabetical order. Alternatively, functions may be too big to be desired as inlined, or they may require dependencies that create cyclic includes, or they may be calling a templated utility function that one may not want to expose in a header. If the functions are not inlined, then inheriting from the base class N times means that each function will need to be defined N times. With `extraClassDefinitions`, they only need to be defined once.

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D115783
2022-01-06 01:43:26 +00:00
..
AttrOrTypeDefGen.cpp Revert "Define a `cppAccessorType` to const-ref in APFloatParameter and update ODS emitter to use it for verifier signatures" 2022-01-03 06:32:50 +00:00
AttrOrTypeFormatGen.cpp Apply clang-tidy fixes for performance-for-range-copy to MLIR (NFC) 2022-01-02 01:13:42 +00:00
AttrOrTypeFormatGen.h Adjust "end namespace" comment in MLIR to match new agree'd coding style 2021-12-08 06:05:26 +00:00
CMakeLists.txt [mlir][ods] AttrOrTypeGen uses Class 2021-12-01 16:53:23 +00:00
CodeGenHelpers.cpp [mlir][ods] Fix unused uniqued attr constraint 2021-11-14 23:23:14 +00:00
DialectGen.cpp Apply clang-tidy fixes for performance-unnecessary-value-param to MLIR (NFC) 2022-01-02 01:45:18 +00:00
DirectiveCommonGen.cpp Apply clang-tidy fixes for readability-container-size-empty for MLIR (NFC) 2022-01-02 01:56:38 +00:00
DocGenUtilities.h Mass update the MLIR license header to mention "Part of the LLVM project" 2020-01-26 03:58:30 +00:00
EnumsGen.cpp [mlir][ODS] Support specialized Attribute class for Enums 2021-03-17 16:44:24 +03:00
FormatGen.cpp Improve error message when declarativeAssembly contains invalid literals 2021-12-04 00:27:32 +00:00
FormatGen.h Adjust "end namespace" comment in MLIR to match new agree'd coding style 2021-12-08 06:05:26 +00:00
LLVMIRConversionGen.cpp Fix more clang-tidy cleanups in mlir/ (NFC) 2021-12-22 20:53:11 +00:00
LLVMIRIntrinsicGen.cpp Apply clang-tidy fixes for performance-for-range-copy to MLIR (NFC) 2022-01-02 01:13:42 +00:00
OpClass.cpp [mlir][ods] ODS ops get an `extraClassDefinition` 2022-01-06 01:43:26 +00:00
OpClass.h [mlir][ods] ODS ops get an `extraClassDefinition` 2022-01-06 01:43:26 +00:00
OpDefinitionsGen.cpp [mlir][ods] ODS ops get an `extraClassDefinition` 2022-01-06 01:43:26 +00:00
OpDocGen.cpp Apply clang-tidy fixes for performance-unnecessary-value-param to MLIR (NFC) 2022-01-02 01:45:18 +00:00
OpFormatGen.cpp [mlir][ods] Handle DeclareOpInterfaceMethods in formatgen 2022-01-04 08:28:59 -08:00
OpFormatGen.h Adjust "end namespace" comment in MLIR to match new agree'd coding style 2021-12-08 06:05:26 +00:00
OpGenHelpers.cpp [mlir] Hoist out getRequestedOpDefinitions helper 2021-04-06 12:53:28 -07:00
OpGenHelpers.h Adjust "end namespace" comment in MLIR to match new agree'd coding style 2021-12-08 06:05:26 +00:00
OpInterfacesGen.cpp Apply clang-tidy fixes for performance-unnecessary-value-param to MLIR (NFC) 2022-01-02 01:45:18 +00:00
OpPythonBindingGen.cpp Apply clang-tidy fixes for performance-for-range-copy to MLIR (NFC) 2022-01-02 01:13:42 +00:00
PassCAPIGen.cpp Add basic Python bindings for the PassManager and bind libTransforms 2020-11-10 19:55:21 +00:00
PassDocGen.cpp [mlir][Pass] Update the PassGen to generate base classes instead of utilities 2020-04-07 14:08:52 -07:00
PassGen.cpp Fix more clang-tidy cleanups in mlir/ (NFC) 2021-12-22 20:53:11 +00:00
RewriterGen.cpp Adjust "end namespace" comment in MLIR to match new agree'd coding style 2021-12-08 06:05:26 +00:00
SPIRVUtilsGen.cpp [mlir] Remove unused "using" (NFC) 2022-01-01 09:14:19 -08:00
StructsGen.cpp [mlir][NFC] Replace references to Identifier with StringAttr 2021-11-16 17:36:26 +00:00
mlir-tblgen.cpp Apply clang-tidy fixes for performance-unnecessary-value-param to MLIR (NFC) 2022-01-02 01:45:18 +00:00