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

Allow extending ToP4, clean its constructors #4899

Merged
merged 6 commits into from
Sep 23, 2024
Merged

Conversation

vlstill
Copy link
Contributor

@vlstill vlstill commented Sep 4, 2024

  • Replaced the cstring argument in ToP4 with std::filesystem::path. This is the breaking change.
  • Cleaned up its constructors to avoid duplication.
  • Allow re-using the dumper in ParserOptions with a descendant of ToP4 -- the way I did this is not exactly nice, but I don't see other clear way to create the instance on demand.
  • The ToP4 pass is a good candidate for larger refactoring, but I don't have time for that now.

@vlstill vlstill added the breaking-change This change may break assumptions of compiler back ends. label Sep 4, 2024
@vlstill vlstill self-assigned this Sep 4, 2024
@vlstill vlstill force-pushed the vstill/top4-extensions branch from 82ccc21 to 81ce8f4 Compare September 4, 2024 08:41
@vlstill vlstill marked this pull request as ready for review September 4, 2024 12:45
@vlstill vlstill requested review from asl, qobilidop and fruffy September 4, 2024 12:45
@asl
Copy link
Contributor

asl commented Sep 4, 2024

but I don't see other clear way to create the instance on demand.

We'd probably go with some value-based semantics here. But it seems pretty heavyweight for a task. And essentially the same wrapped smart pointer. :)

@@ -472,8 +472,8 @@ static std::filesystem::path makeFileName(const std::filesystem::path &folder,

bool ParserOptions::isv1() const { return langVersion == ParserOptions::FrontendVersion::P4_14; }

void ParserOptions::dumpPass(const char *manager, unsigned seq, const char *pass,
const IR::Node *node) const {
void ParserOptions::dumpPass(ToP4Factory toP4Fact, const char *manager, unsigned seq,
Copy link
Collaborator

@fruffy fruffy Sep 4, 2024

Choose a reason for hiding this comment

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

Make this a virtual function of the options that returns the appropriate ToP4 instance? E.g., ToP4 * toP4Printer(). Then you can also change the priner with the options you are using.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea. I left the unique_ptr there as I think we should not rely on GC especially in the places where the memory management is very straight-forward

@fruffy fruffy added the core Topics concerning the core segments of the compiler (frontend, midend, parser) label Sep 4, 2024
@vlstill vlstill force-pushed the vstill/top4-extensions branch from 81ce8f4 to 41e4bf0 Compare September 22, 2024 19:23
@vlstill vlstill requested a review from fruffy September 22, 2024 19:25
@vlstill vlstill force-pushed the vstill/top4-extensions branch from 41e4bf0 to 3c78563 Compare September 22, 2024 19:59
@vlstill vlstill enabled auto-merge September 23, 2024 19:09
@vlstill vlstill added this pull request to the merge queue Sep 23, 2024
Merged via the queue into main with commit a9f0e67 Sep 23, 2024
18 checks passed
@vlstill vlstill deleted the vstill/top4-extensions branch September 23, 2024 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change This change may break assumptions of compiler back ends. core Topics concerning the core segments of the compiler (frontend, midend, parser)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants