[TableGen][SubtargetEmitter] Remove isSubClassOf check for WriteResDefs and ReadAdvanceDefs where possible #92567
+47
−32
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
WriteResDefs contained WriteRes and SchedWriteRes records. WriteRes and SchedWriteRes are not subclasses of eachother.
ReadAdvanceDefs contained ReadAdvance and SchedReadAdvance records. ReadAdvance and SchedReadAdvance are not subclasses of eachother.
FindWriteResources and FindReadAdvance are the only users of WriteResDefs and ReadAdvanceDefs respectively. These functions call isSubClassOf to skip records that are not WriteRes or ReadAdvance. That means that SchedWriteRes and SchedReadAdvance records are added to the list but always skipped over.
We opt to not put them in the list in the first place so we can remove the isSubClassOf checks in FindWriteResources and FindReadAdvance.
We still call addWriteRes and addReadAdvance for SchedWriteRes and SchedReadAdvance because those functions perform error checking and discover processor resources.
If we were to assume that there is no SchedWriteRes that also
isSubClassOf(WriteRes)
, and there is no SchedReadAdvance that is alsoisSubClassOf(ReadAdvance)
, then we could remove theisSubClassOf
checks passed toaddWriteRes
andaddReadAdvance
where the def is a SchedWriteRes or SchedReadAdvance. Although unlikely, I think its possible for a subtarget to define aFoo : SchedWriteRes, WriteRes
. Feedback on whether we can make this assumption would be appreciated.This improves gen-subtarget on RISC-V by 1% upstream and by 10% downstream.