I don't like the idea very much. We often would want (in this MR patches and later) to iterate over the elements in a specific regset.
How many such cases are there? I can't easily think of cases where we need to know the register offset and haven't already gotten that information from RA.
The larger loop looks pretty reasonable to me; if nothing else, it's quite clear what it's doing.
In fact, we could potentially expand this in the future to store other per-component logic. One particularly salient thing that comes to mind is tracking whether we need to use a bool / int variable for sm1 uniforms—which itself determines the size of each register set.
I think that in this case we would rather store this information variable-wise. Since we only need the maximum register index used, and no information for every component, as we do for samplers (sampler_dim), and textures in SM 5 (we need to write a resource entry for every used component).
I don't understand, how can this information be stored per variable? IIRC sm1 cares about things like int and bool on a per-register basis, or at least a per-struct-field basis.