-
Notifications
You must be signed in to change notification settings - Fork 446
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
Combo of duplication action name check and LocalizeAllActions fix #4975
Open
jafingerhut
wants to merge
62
commits into
p4lang:main
Choose a base branch
from
jafingerhut:combo-of-duplication-action-name-check-and-localizeallactions-fix
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
62 commits
Select commit
Hold shift + click to select a range
e429c8a
Add pass to give error if duplicate hierarchical names are present
jafingerhut 39538bf
Add new source files to CMakeLists.txt
jafingerhut 98940fb
Skip new checks when compiling certain source files including: + Sour…
jafingerhut a2792ce
Skip new checks for P4-14 source files in run-bmv2-test.py
jafingerhut a553fe1
Fix lint error
jafingerhut 26f0501
Fix lint problems.
jafingerhut da456fe
Do not give errors for variable declarations with identical names
jafingerhut b683571
Limit search for duplicate names to actions, tables, or "other objects"
jafingerhut ad40fe9
Update test programs that had errors in their name annotations
jafingerhut 91166c8
Update expected output files for modified test programs
jafingerhut 9acb7e0
Move new test program with error into p4_16_errors directory
jafingerhut b133b28
Add expected output files for new test programs
jafingerhut 76bf24f
More fine-tuning to enable tests to pass
jafingerhut f7ec2fe
Fix lint error
jafingerhut 1cc8224
Fix lint error
jafingerhut 4b03eb5
Merge branch 'master' into add-duplicate-hierarchical-name-check-pass
jafingerhut 93daba5
Address some review comments
jafingerhut 66a0a0a
Rewording documentation of new pass for clarity.
jafingerhut 083db34
Merge remote-tracking branch 'upstream/main' into add-duplicate-hiera…
jafingerhut 99beb30
Enable the new pass only if P4Runtime control plane API gen is enabled
jafingerhut 2b7c58a
Merge branch 'add-duplicate-hierarchical-name-check-pass' of github.c…
jafingerhut 54007df
Merge remote-tracking branch 'upstream/main' into add-duplicate-hiera…
jafingerhut d89f214
Undo changes to Python test scripts
jafingerhut 7424db3
Undo changes to gtestp4c source
jafingerhut 55ad18f
Merge remote-tracking branch 'upstream/main' into add-duplicate-hiera…
jafingerhut 799448a
Use abseil StrCat and StrAppend instead of loop
jafingerhut 377f41a
Fix formatting with clang-format
jafingerhut 682564b
Fix #4969 by modifying pass LocalizeActions
jafingerhut bb88b7d
Fix clang-format error
jafingerhut d265e1c
Also catch duplicates involving top-level actions without @name annot…
jafingerhut 606300e
Merge remote-tracking branch 'upstream/main' into add-duplicate-hiera…
jafingerhut 6bcb614
Add new test program to exercise latest code changes
jafingerhut 55da2c3
Change pass name to reflect only checking action control plane names
jafingerhut d67df83
Fix lint warning, and add one more successful test program
jafingerhut 42c1dee
Merge remote-tracking branch 'origin/fix-localizeallactions-bug' into…
jafingerhut 95dc4e2
A few more fixes and test cases for duplicate action name checks
jafingerhut efd0d52
Fix code formatting to pass lint check
jafingerhut 4540f2a
Fix lint warning for Python code
jafingerhut 39a9251
Update old file name in CMakeLists.txt
jafingerhut 62fe180
Merge remote-tracking branch 'upstream/main' into combo-of-duplicatio…
jafingerhut b614ff9
Add another case of conflicting action names between control and sub-…
jafingerhut 968af1f
Merge remote-tracking branch 'upstream/main' into combo-of-duplicatio…
jafingerhut a2e913b
Add another correct case of not-conflicting @name annotations involvi…
jafingerhut 72827dd
Fix comment, and remove unnecessary comment in P4 test program
jafingerhut b9a0ee9
Merge remote-tracking branch 'upstream/main' into combo-of-duplicatio…
jafingerhut 019f3c6
Merge remote-tracking branch 'upstream/main' into combo-of-duplicatio…
jafingerhut bb50cc6
Put method controlPlaneAPIGenEnabled in class CompilerOptions
jafingerhut a840163
Fixes for incorrect previous commit.
jafingerhut 19956fc
Fix cpplint warning from clang-format
jafingerhut e563b90
Merge remote-tracking branch 'upstream/main' into combo-of-duplicatio…
jafingerhut 62ee2c1
Updates due to recent changes in annotation APIs
jafingerhut c3feb19
More modifications required to make the code work with ...
jafingerhut 31f0b10
Simplify string manipulation code using latest abseil changes
jafingerhut bd31e6b
Fix clang-format warning
jafingerhut a853313
Merge branch 'master' into combo-of-duplication-action-name-check-and…
jafingerhut c111ab1
Updates required to work with recent changes to annotation implementa…
jafingerhut b542540
Address review comments
jafingerhut beb87b0
Removed an old line of commented-out code.
jafingerhut 87feba6
Reword some comments for clarity.
jafingerhut e586849
Fix lint warning
jafingerhut 381ec48
Address review comment
jafingerhut 2f861cf
Merge remote-tracking branch 'upstream/main' into combo-of-duplicatio…
jafingerhut File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
More modifications required to make the code work with ...
... the recent annotations infra changes Signed-off-by: Andy Fingerhut <andy_fingerhut@alum.wustl.edu>
- Loading branch information
commit c3feb19495c661a060f9daaf88ca7aa38dced88b
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -40,53 +40,40 @@ void DuplicateActionControlPlaneNameCheck::checkForDuplicateName(cstring name, | |||||
} | ||||||
|
||||||
const IR::Node *DuplicateActionControlPlaneNameCheck::postorder(IR::P4Action *action) { | ||||||
// Actions declared at the top level that the developer did not | ||||||
// write a @name annotation for it, should be included in the | ||||||
// duplicate name check. They do not yet have a @name annotation | ||||||
// by the time this pass executes, so this method will handle | ||||||
// such actions. | ||||||
if (findContext<IR::P4Control>() == nullptr) { | ||||||
auto nameAnno = action->getAnnotation(IR::Annotation::nameAnnotation); | ||||||
if (!nameAnno) { | ||||||
// name is what this top-level action's @name annotation | ||||||
// will be, after LocalizeAllActions pass adds one. | ||||||
cstring name = "." + action->name; | ||||||
checkForDuplicateName(name, action); | ||||||
} | ||||||
} | ||||||
return action; | ||||||
} | ||||||
bool topLevel = findContext<IR::P4Control>() == nullptr; | ||||||
auto nameAnno = action->getAnnotation(IR::Annotation::nameAnnotation); | ||||||
if (!nameAnno && topLevel) { | ||||||
// Actions declared at the top level that the developer did not | ||||||
// write a @name annotation for it, should be included in the | ||||||
// duplicate name check. They do not yet have a @name annotation | ||||||
// by the time this pass executes, so this method will handle | ||||||
// such actions. | ||||||
|
||||||
const IR::Node *DuplicateActionControlPlaneNameCheck::postorder(IR::Annotation *annotation) { | ||||||
if (annotation->name != IR::Annotation::nameAnnotation) return annotation; | ||||||
// The node the annotation belongs to | ||||||
CHECK_NULL(getContext()->parent); | ||||||
auto *annotatedNode = getContext()->parent->node; | ||||||
CHECK_NULL(annotatedNode); | ||||||
// We are only interested in name annotations on actions here, as | ||||||
// the P4Runtime API control plane generation code already checks | ||||||
// for duplicate control plane names for other kinds of objects. | ||||||
if (!annotatedNode->is<IR::P4Action>()) { | ||||||
return annotation; | ||||||
} | ||||||
cstring name = annotation->getName(); | ||||||
if (!name.startsWith(".")) { | ||||||
// Create a fully hierarchical name beginning with ".", so we | ||||||
// can compare it against any other @name annotation value | ||||||
// that begins with "." and is equal. | ||||||
if (stack.empty()) { | ||||||
name = absl::StrCat(".", name.string_view()); | ||||||
} else { | ||||||
name = absl::StrCat(".", | ||||||
absl::StrJoin(stack, ".", | ||||||
[](std::string *out, cstring s) { | ||||||
absl::StrAppend(out, s.string_view()); | ||||||
}), | ||||||
".", name.string_view()); | ||||||
// name is what this top-level action's @name annotation | ||||||
// will be, after LocalizeAllActions pass adds one. | ||||||
cstring name = "." + action->name; | ||||||
checkForDuplicateName(name, action); | ||||||
} else { | ||||||
const auto *e0 = nameAnno->expr.at(0); | ||||||
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.
Suggested change
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. Changed in commit 55, IIRC |
||||||
cstring name = e0->to<IR::StringLiteral>()->value; | ||||||
if (!name.startsWith(".")) { | ||||||
// Create a fully hierarchical name beginning with ".", so we | ||||||
// can compare it against any other @name annotation value | ||||||
// that begins with "." and is equal. | ||||||
if (stack.empty()) { | ||||||
asl marked this conversation as resolved.
Show resolved
Hide resolved
kfcripps marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
name = absl::StrCat(".", name.string_view()); | ||||||
} else { | ||||||
name = absl::StrCat(".", | ||||||
absl::StrJoin(stack, ".", | ||||||
[](std::string *out, cstring s) { | ||||||
absl::StrAppend(out, s.string_view()); | ||||||
}), | ||||||
".", name.string_view()); | ||||||
} | ||||||
} | ||||||
checkForDuplicateName(name, action); | ||||||
} | ||||||
checkForDuplicateName(name, annotatedNode); | ||||||
return annotation; | ||||||
return action; | ||||||
} | ||||||
|
||||||
} // namespace P4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
has some chances to be a tiny bit more efficient, I believe.
(this requires the previously suggested change for not pushing parsers onto the stack).
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.
Changed to
bool topLevel = stack.empty();
in commit 57