-
Notifications
You must be signed in to change notification settings - Fork 444
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
dpdk: Eliminate unused metadata fields #3096
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -135,6 +135,30 @@ class RemoveLabelAfterLabel : public Transform { | |
} | ||
}; | ||
|
||
|
||
// This pass Collects all metadata struct member used in program | ||
class CollectUsedMetadataField : public Inspector { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alternatively, if this pass is used only within dpdkAsmOpt.cpp, it does not need to have a declaration in the header, it can be local to the file (within an empty namespace to avoid name clashes). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now it's used in backend.cpp |
||
ordered_set<cstring>& used_fields; | ||
public: | ||
explicit CollectUsedMetadataField(ordered_set<cstring>& used_fields) | ||
: used_fields(used_fields) {} | ||
bool preorder(const IR::Member *m) override { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not necessarily a field of the metadata structure, but I guess it will include all the fields. So you may keep some extra fields here if they happen to show up in other structures. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now only insert if it's metadata's member. |
||
// metadata struct field used like m.<field_name> in expressions | ||
if (m->expr->toString() == "m") | ||
used_fields.insert(m->member.toString()); | ||
return true; | ||
} | ||
}; | ||
|
||
// This pass removes all unused fields from metadata struct | ||
class RemoveUnusedMetadataFields : public Transform { | ||
ordered_set<cstring>& used_fields; | ||
public: | ||
explicit RemoveUnusedMetadataFields(ordered_set<cstring>& used_fields) | ||
: used_fields(used_fields) {} | ||
const IR::Node* preorder(IR::DpdkAsmProgram *p) override; | ||
}; | ||
|
||
// Instructions can only appear in actions and apply block of .spec file. | ||
// All these individual passes work on the actions and apply block of .spec file. | ||
class DpdkAsmOptimization : public PassRepeated { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would call this "foundMetadataStruct".
Perhaps you can change it in a future PR.