This patch introduces an abstraction layer for TableGen backends. It separates the code generation logic and the syntax string output into separated modules.
One module is the backend (RegisterInfo in this patch), the other PrinterLLVM.
The code generation stays in the TableGen backend. The syntax generation however is moved to PrinterLLVM, which writes the result to the output stream.
Whenever the backend has generated a piece of code it requests PrinterLLVM to write the syntax to the output stream.
Before this patch the TableGen backend generated the syntax on its own.
This had the disadvantage that no other languages, then the default C++ syntax, could be output easily.
With the separation of the code generation (backend) and syntax generation (PrinterLLVM) it is easier to output syntax of other languages.
It is also possible write a printer which emits only specific parts of the generated code.
A new printer only implements the methods of the PrinterLLVM it needs and emits its language syntax.
In this patch the RegisterInfo backend was refactored to use PrinterLLVM as output module.
If this gets upstreamed I can provide the refactor for the following modules in the next days:
For more background info and where this idea is coming from you can take a look at:
_Discussion in discourse.llvm.org_