svd2ir: rework handling of names with placeholders#136
svd2ir: rework handling of names with placeholders#136datdenkikniet wants to merge 4 commits intoembassy-rs:mainfrom
Conversation
4f94476 to
9a9d61d
Compare
|
This works with the SVDs for:
This does not work for these SVDs:
Also, it would be nice to keep the indices noted somewhere (appended to the description, as a replacement for %s in the description, or as a separate ir field). |
|
Added an ugly-hack workaround for now. It seems to handle the RA4L1 SVD now, but not sure it'll also hold up to the transforms. There is a better way to do it but I cannot come up with it right now :P |
|
Yeah, there are lots of ugly hacks to deal with these SVDs unfortunately (and the less said about the other metadata I'm ingesting the better 😂). FWIW the MCUs I've got on hand are the 2A1, 4L1, 4M1, 6M5, and 8M1 so that's what I'm checking. The 8M1's SVD causes the I'm testing these with the |
e145d1e to
81c3d1a
Compare
|
Did some mucking about and have come to the conclusion that having an underscore suffix, and just checking if the new name has been used at all, is easiest and is most likely to resolve most issues. There is probably a better way to find a unique name beyond "iterate until we've found one that doesn't exist yet" but I don't want to figure that one out just yet |
|
I think the more elegant solution would be to include the indicies in the name, but that has the potential for unreasonably long fieldset names. What I landed on was to keep a hashmap of seen fieldset names to keep track of the counts. |
Like you say, this could cause really long names. Additionally, it doesn't necessarily improve the naming: inserting the dimension indices at the end of the name is equally "bad" IMO, and inserting them at the placeholder name doesn't really make it any better either. Take, for example,
I don't really see including the indices helping much of anything. We could/should include them in the description, but then they become stale as soon as anyone merges or deletes anything, and having some sort of two-way binding seems really heavy. |
|
In the case of That breaks down with Ultimately I'm not so concerned with the generated form as with |
I may have misunderstood the intent of your comment, but to make sure we're on the same page: I agree that this as an end result would be great, but it also sounds like something that is way out of scope for An alternative would be that we always expand all placeholders (except for arrays, Since we'll have to do manual transforms to get it into a good shape anyways, I don't think the naming scheme matters beyond that it is mostly recognizable as belonging to certain inner blocks, which it is with the current naming scheme.
OK, let's conclude the naming discussion then: the name of the fieldset doesn't really matter so long as it is unique and can be associated with the inner block functions that use it, because whatever it becomes, it is likely to get renamed anyways. The current approach does that, while preserving the names we could already generate, and doesn't generate comically long names. Opinions? I don't think bikeshedding the naming thing any more will help. |
Agreed. However as of 163fc34 chiptool still chokes on the CANFD peripheral in the 4L1 and 6M5. 4L1: 6M5: The minimal set of transforms I'm applying is:
|
|
Ahh, okay: |
|
OK, after some thinking, I think the way to go here is:
I've listed some other alternatives in #141, but I don't think any of them are better than this. ETA: Have opened #141 With - !RenameFieldsets
from: CANFD::regs::CFDRMDF_(\d+)_(\d+)
to: CANFD::regs::CFDRMDF${1}copy${2}
- !Sanitize
- !MergeFieldsets
from: canfd::regs::Cfdrmdf(\d+)(copy(\d+))?
to: canfd::regs::Cfdrmdfbut of course, in this case, one could: - !MergeFieldsets
from: CANFD::regs::CFDRMDF_(\d+)(_(\d+))?
to: CANFD::regs::CFDRMDf
- !Sanitizeinstead, even without |
|
Another alternative might be to have the counts zero padded. so that 11,1 → 011_001 and 1,1 → 001_001 don't collide. It would be nice (but is not a deal breaker for me) to not have to pre-sanitize input. |
Some parts of Renesas' SVDs have the following pattern:
Currently,
chiptoolcrashes while generating fieldsets for such patterns, as it normalizes bothBUSSCNT%stoBUSSCNTand fails to find unique names for the individual fieldsets.In order to improve that behaviour, we add an extra level of mapping:
fieldset_name(n: usize)) to get fieldsets at offsets.This has the pleasant side effect of resolving the fact that
convert_periperhalconverts input like this:into
instead, we now get this (identical fieldsets are returned, but at different offsets):
We can probably do the same for fields, but this PR doesn't do that yet.
This fixes #90 and closes #92