[mlir][TableGen] Emit interface traits after all interfaces (#147699)

Interface traits may provide default implementation of methods. When
this happens, the implementation may rely on another interface that is
not yet defined meaning that one gets "incomplete type" error during C++
compilation. In pseudo-code, the problem is the following:
```
InterfaceA has methodB() { return InterfaceB(); }
InterfaceB defined later

// What's generated is:
class InterfaceA { ... }
class InterfaceATrait {
  // error: InterfaceB is an incomplete type
  InterfaceB methodB() { return InterfaceB(); }
}
class InterfaceB { ... } // defined here
```

The two more "advanced" cases are:
* Cyclic dependency (A requires B and B requires A)
* Type-traited usage of an incomplete type (e.g.
`FailureOr<InterfaceB>`)

It seems reasonable to emit interface traits *after* all of the
interfaces have been defined to avoid the problem altogether.

As a drive by, make forward declarations of the interfaces early so that
user code does not need to forward declare.

GitOrigin-RevId: f5d3cf4a643fc13194e09cb39905f7f3b083f85e
3 files changed
tree: b62a87ca34be0695eade69687552a5a71eac1975
  1. benchmark/
  2. cmake/
  3. docs/
  4. examples/
  5. include/
  6. lib/
  7. python/
  8. test/
  9. tools/
  10. unittests/
  11. utils/
  12. .clang-format
  13. .clang-tidy
  14. CMakeLists.txt
  15. LICENSE.TXT
  16. Maintainers.md
  17. README.md
README.md

Multi-Level Intermediate Representation

See https://mlir.llvm.org/ for more information.