Patch 1/3 does two things at once [introduces a helper and changes allocate_register()], which made it somewhat harder to review.
I split that patch in two, albeit the intermediate state is a little weird since I have to pass the `reg_size` twice in the callers in order to preserve the current behavior. The patch that solves the problem is still the one that introduces the helper.
Otherwise I would have had to add *ifs* around all `allocate_register()` calls during the intermediate state.
Anyway, the concept seems fine, but "dimx" and "component_count" aren't great names. Honestly I'd use "component_count" and "reg_size" respectively.
I agree. It is worth noting that this only makes sense if we rename the old "component_count" as "reg_size" and "dimx" is a new "component_count". So, it also made sense to do the rename "component_count" -> "reg_size" in the other functions related to register allocation to avoid confusion. I prepended a patch for that purpose.