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

[P4Testgen] Unify compiler options and tool options. Ensure options context is always initialized correctly. #4787

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

Conversation

fruffy
Copy link
Collaborator

@fruffy fruffy commented Jul 8, 2024

This is a larger rewrite of the core parts of P4Testgen's target initialization. The goal is to fix several problems when trying to use P4Testgen and other tools as a library. We need to make sure that the CompileContext we are accessing is the correct one.

  • We decouple initialization of the options and the initialization of the target. This way we can initialize a target before we even know which options we need. This means we can make the options target-dependent (e.g., different options for BMv2, Tofino, etc). This can be really nice for usability since we can create bespoke options per target.

  • To reduce the amount of random static objects floating around we fold P4ToolsOptions and the CompilerOptions together. There is no reason why need two classes here.

  • Options are only accessed by passing them along or retrieving them from the context stack. Ideally, we get rid of the context stack entirely but this requires a lot more work.

@fruffy fruffy added the p4tools Topics related to the P4Tools back end label Jul 8, 2024
@fruffy fruffy force-pushed the fruffy/testgen_options_cleanup branch 2 times, most recently from 0bb6a4b to c478a18 Compare July 17, 2024 14:11
@fruffy fruffy force-pushed the fruffy/testgen_options_cleanup branch 2 times, most recently from cf25391 to 167fe11 Compare July 31, 2024 17:29
@fruffy fruffy force-pushed the fruffy/testgen_options_cleanup branch from 167fe11 to ba435db Compare August 1, 2024 08:17
@fruffy fruffy force-pushed the fruffy/testgen_options_cleanup branch 2 times, most recently from 269d0d3 to 093029b Compare August 28, 2024 17:57
@fruffy fruffy marked this pull request as ready for review August 28, 2024 19:27
Signed-off-by: fruffy <fruffy@nyu.edu>
@fruffy fruffy force-pushed the fruffy/testgen_options_cleanup branch from 093029b to b683f0d Compare September 13, 2024 11:15

#include "backends/p4tools/common/lib/variables.h"
#include "ir/irutils.h"

namespace P4::P4Tools {

Target::Spec::Spec(std::string deviceName, std::string archName)
: deviceName(std::move(deviceName)), archName(std::move(archName)) {
Target::Spec::Spec(std::string_view deviceName, std::string_view archName)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure about string_view here, can revert if necessary.

@fruffy fruffy requested a review from vlstill September 13, 2024 11:16
@fruffy
Copy link
Collaborator Author

fruffy commented Sep 19, 2024

@vlstill Could you give this a review? This is a rather major change to the way options work for P4Testgen but is required to fix issues with using the tool as a library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p4tools Topics related to the P4Tools back end
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant