How to use Tablegen to generate <Target>LegalizerInfo

Hello llvm developers,
I’m new to llvm backend and want to use GlobalIsel in my toy target. When I try to implement TableGen backend for LegalizerInfo​, I realized I just reexport the method from the LegalizeRuleSet​ and it is not a good solution apparently, too many templates in td files.
So, is there any better practice about generating these data in TableGen?
Thanks