Skip to content

Add RenameFieldsets transform#141

Closed
datdenkikniet wants to merge 1 commit intoembassy-rs:mainfrom
datdenkikniet:rename-fieldsets
Closed

Add RenameFieldsets transform#141
datdenkikniet wants to merge 1 commit intoembassy-rs:mainfrom
datdenkikniet:rename-fieldsets

Conversation

@datdenkikniet
Copy link
Copy Markdown
Contributor

@datdenkikniet datdenkikniet commented Apr 23, 2026

For more context, see: #136 (comment)

The core issue is that when trying to generate unique names, we must use something to delimit the names. Underscores seems most sensible (alternatives are random-looking numbers at the end of strings, other random text). However, those unique names (i.e. CFDRMDF_12 and CFDRMDF_1_2) resolve to the same sanitized name (Cfdrmfd12). We have no way to not do that, assuming the following alternatives (and why I think they don't solve the problem) aren't preferable:

  1. When Sanitize-ing, remove _ as boundary, but only for fieldsets (lots more ugly names, weird special-casing for fieldset names)
  2. Force the chiptool user to MergeFieldsets on non-sanitized fieldsets (has exceptions: there's nothing preventing similarly-named fieldsets from being entirely different, so we may be forced to RenameFieldsets)
  3. Just get rid of them with DeleteFieldsets (prevents user from using certain fieldsets, quite sucky)
  4. Find a different way to generate unique names that doesn't cause issues during Sanitize (how? Most (all?) other non-text characters are stripped when casing to PascalCase, so whatever we pick, it won't work)
  5. Don't deduplicate names in svd2ir: we can, of course, generate individual FieldSets for each dim. Then fieldset names will be unique by SVD spec/requirement. (this throws away useful info directly provided by the SVD (= certain regs are identical), and forces users to MergeFieldsets on fieldsets that the SVD already tells us are identical.)

With RenameFieldsets, we don't have to do any additional special-casing. Just force the user to pick good names in case the ones uniquely generated by svd2ir are not immediately sanitizable.

@inferiorhumanorgans
Copy link
Copy Markdown
Contributor

inferiorhumanorgans commented Apr 28, 2026

With this level of complexity I think a brief explanation of how the pieces fit together (e.g. when to use santitize, what its dependencies are) would be good for the top-level transform module.

Beyond that, I think the Rename transform already handles the fieldset case, yeah? If anything perhaps the stray rename transforms should be consolidated into that?

@datdenkikniet
Copy link
Copy Markdown
Contributor Author

Ah 🤦.

Closing as this already exists as Rename.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants