Add the `dbg.scope` operation to the debug dialect. The op creates an
additional level of hierarchy in the DI, a "scope", which can be used to
group variables and other scopes.
Operations such as `hw.module` introduce an implicit scope. All debug
operations within a module are added to that implicit scope, unless they
have an explicit `scope` operand. Providing an explicit scope can be
used to represent inlined modules.
Scopes in DI do not necessarily have to correspond to levels of a module
hierarchy. They can also be used to model things like control flow
scopes, call stacks, and other source-language concepts.
This commit also introduces an optional `scope` operand on
`dbg.variable`. The `DebugInfo` analysis, which traverses the IR and
builds up a canonical representation of the DI, honors this operand and
adds the variables to the corresponding scope.
Add the `dbg` dialect, alongside a rationale document, basic types, and
the three essential `dbg.variable`, `dbg.struct`, and `dbg.array`
operations.
The goal is for this dialect to be a home for all the machinery needed
to track debug information in the IR. After discussions with a few
people in the LLVM/MLIR space, I chose to create dedicated operations to
track debug info in the IR, as opposed to an attribute/metadata based
approach. The details are outlined in the rationale document.
Subsequent PRs add simple debug info tracking to FIRRTL and firtool, and
extend debug info emission to consider these operations.