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

Cleanup some P4Testgen code. #3978

Merged
merged 4 commits into from
Apr 14, 2023
Merged

Cleanup some P4Testgen code. #3978

merged 4 commits into from
Apr 14, 2023

Conversation

fruffy
Copy link
Collaborator

@fruffy fruffy commented Apr 11, 2023

Some issues that came up while implementing a new module for P4Testgen.

  • The arch spec file is quite general, move it to the common folder. The same applies to the namespace context.
  • Naming was quite inconsistent. Try to remove all instances of snake case within camel case.
  • Try to use concatenated namespaces as much as possible.
  • Program info does not really need the namespace context. Everything can be derived from the program object.
  • Bmv2V1Model should be the name for the BMv2 extension, not BMv2V1Model or BMv2_V1Model or BMv2Model.
  • The gtest helpers had a hardcoded path to the P4 source file. Make them relative to the file instead.

@fruffy fruffy added the p4tools Topics related to the P4Tools back end label Apr 11, 2023
@fruffy fruffy marked this pull request as ready for review April 12, 2023 13:29

/// Looks up a declaration from a path expression. A BUG occurs if no declaration is found.
const IR::IDeclaration *findProgramDecl(const IR::PathExpression *pathExpr) const;
static const IR::IDeclaration *findProgramDecl(const IR::IGeneralNamespace *ns,
const IR::PathExpression *pathExpr);

/// Resolves a Type_Name in the current environment.
Copy link
Contributor

Choose a reason for hiding this comment

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

Update comment?

@@ -51,12 +75,13 @@ void TestgenTarget::argumentsToTypeDeclarations(
const auto *constructedTypeName = ctorCall->constructedType->checkedTo<IR::Type_Name>();

// Find the corresponding type declaration in the namespace.
Copy link
Contributor

Choose a reason for hiding this comment

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

Update comment.

@@ -137,7 +137,7 @@ void BMv2_V1ModelExprStepper::evalExternMethodCall(const IR::MethodCallExpressio
};

// Provides implementations of BMv2 externs.
static const ExternMethodImpls EXTERN_METHOD_IMPLS({
static const ExternMethodImpls EXTERN_METHODImplS({
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the naming intentional?

Copy link
Contributor

@pkotikal pkotikal left a comment

Choose a reason for hiding this comment

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

Looks nice!

@fruffy
Copy link
Collaborator Author

fruffy commented Apr 13, 2023

Thanks!

@fruffy fruffy merged commit b12fcd3 into main Apr 14, 2023
@fruffy fruffy deleted the fruffy/cleanup branch April 14, 2023 01:37
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.

2 participants