What is the best practice for defining optimization rules for the generator of a language?
I have several ideas for this:
(1) The optimization rules could be implemented in the pre-processing scripts of the generator.
(2) Or another lower-level language could be defined, with the generator targeting this language, and some transformations could be done for optimization.
(3) Or the generator could generate complete external format outputs, e.g. in JSON, and the optimization is done in other tools. This seems suboptimal as a lot of information could be lost in the external format.
Thanks in advance.