[TableGen] Store template arguments separately from fields (#234933)
Record used to store template arguments as RecordVals in Values, along
with the fields, and keep a separate list of their names. Store them in
their own vector of RecordVals instead. getValues() now only returns
fields, so the code that skipped template arguments when inheriting,
instantiating, printing or dumping fields goes away. getValue() looks up
only fields and the new getTemplateArg() looks
up only template arguments.
A template argument is added after its default value is parsed, so that
it is still not in scope in its own default value. Duplicate template
arguments are now diagnosed in ParseDeclaration, which also avoids a
misleading type error when the duplicate has a different type.
The only change in output is that --print-detailed-records prints
"Fields: (none)" for a class with template arguments but no fields.
Parser memory usage decreases by about 1% on AMDGPU.td because
VarDefInit::instantiate no longer copies template args from the class to
the def only to remove them again.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: Sergei Barannikov <barannikov88@gmail.com>