Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TableGen][SubtargetEmitter] Remove isSubClassOf check for WriteResDefs and ReadAdvanceDefs where possible #92567

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

michaelmaitland
Copy link
Contributor

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 also isSubClassOf(ReadAdvance), then we could remove the isSubClassOf checks passed to addWriteRes and addReadAdvance where the def is a SchedWriteRes or SchedReadAdvance. Although unlikely, I think its possible for a subtarget to define a Foo : 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.

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.

This improves gen-subtarget on RISC-V by 10%.
Copy link
Contributor

@wangpc-pp wangpc-pp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants