-
Notifications
You must be signed in to change notification settings - Fork 445
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
Doxygen comments #614
Doxygen comments #614
Conversation
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.
Overall, looks great. Just some minor typesetting and phrasing suggestions.
Also, it'd be nice to have @pre/@post conditions for the passes.
midend/removeLeftSlices.h
Outdated
/** | ||
* This pass removes Slices on the lhs of an assignment | ||
* | ||
* a[m:l] = e; -> a = (a & ~mask) | (((cast)e << l) & mask); |
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.
Nice! The example illustrates this transformation perfectly.
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.
Will this be typeset as code in Doxygen?
midend/removeParameters.cpp
Outdated
|
||
/** | ||
* This is needed because of this case: | ||
* action a(inout x) { x = x + 1 } |
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.
Will this be typeset as code in Doxygen?
/** | ||
* For each action that is invoked keep the list of arguments that | ||
* it's called with. There must be only one call of each action; | ||
* this is done by LocalizeActions. |
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.
Would be nice to use @pre
and @post
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.
Done
midend/removeParameters.h
Outdated
/** | ||
Removes parameters of an action which are in/inout/out. | ||
|
||
control c(inout bit<32> x) { |
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.
Doxygen formatting for code?
midend/simplifyKey.h
Outdated
// Policy which returns 'true' whenever a key is not a left value | ||
// or a call to the isValid(). | ||
/** | ||
* Policy which returns 'true' whenever a key is not a left value |
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.
Instead of saying "returns" how about a different verb? For example "Policy that tracks whether a key is..."
@@ -42,7 +46,9 @@ class NonLeftValue : public KeyIsComplex { | |||
bool isTooComplex(const IR::Expression* expression) const; |
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.
How does "too complex" related to l-value-ness?
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.
The pass applies to non-lvalue expressions. All lvalues are considered not complex and therefore not transformed.
midend/simplifyKey.h
Outdated
@@ -42,7 +46,9 @@ class NonLeftValue : public KeyIsComplex { | |||
bool isTooComplex(const IR::Expression* expression) const; | |||
}; | |||
|
|||
// Policy that allows masked lvalues as well as simple lvalues or isValid() | |||
/** | |||
* Policy that allows masked lvalues as well as simple lvalues or isValid() |
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.
Again, reword as something like "Policy that tracks whether an lvalue is masked, simple, ..."
midend/simplifyKey.h
Outdated
// If some of the fields of a table key are "too complex", | ||
// turn them into simpler expressions. | ||
/** | ||
* If some of the fields of a table key are "too complex", |
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.
"Transforms complex table keys into..."
midend/simplifyKey.h
Outdated
@@ -86,7 +116,9 @@ class DoSimplifyKey : public Transform { | |||
const IR::Node* postorder(IR::P4Table* table) override; | |||
}; | |||
|
|||
// Use a policy to decide when a key expression is too complex. | |||
/** | |||
* This pass uses a policy to decide when a key expression is too complex. |
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.
"Determine whether a key expression is too complex"
Also, "too complex" should be defined above.
midend/removeParameters.cpp
Outdated
/** | ||
* This is needed because of this case: | ||
* | ||
* \code{.cpp} |
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.
This comment is in the wrong place, it was explaining why MoveDeclarations is required. This is not what this pass is doing. The comment for the pass is in the header file. This is a code comment.
midend/removeParameters.h
Outdated
@@ -45,10 +48,10 @@ class ActionInvocation { | |||
} | |||
void bindDefaultAction(const IR::P4Action* action, | |||
const IR::MethodCallExpression* defaultInvocation) { | |||
// We must have a binding for this action already. | |||
/// We must have a binding for this action already. |
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.
These should not be Doxygen comments, they are commenting code, not APIs.
midend/removeParameters.h
Outdated
// table t() { actions = { a; } } | ||
// apply { ... } } | ||
/** | ||
Removes parameters of an action which are in/inout/out. |
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.
Your commenting style is inconsistent, sometimes you use a star, sometimes you just indent, and sometimes you don't indent.
midend/removeParameters.h
Outdated
const IR::Node* postorder(IR::ActionListElement* element) override; | ||
/// Remove arguments from method call |
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 think that these comments are unnecessary.
Moreover, this only does this for method calls that are calling actions, to the comment is inaccurate.
// Policy used to decide whether a key expression is too complex. | ||
/** | ||
* Policy used to decide whether a key expression is too complex. | ||
*/ | ||
class KeyIsComplex { | ||
public: | ||
virtual ~KeyIsComplex() {} | ||
virtual bool isTooComplex(const IR::Expression* expression) const = 0; |
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.
The isTooComplex function requires a comment.
@@ -86,7 +120,13 @@ class DoSimplifyKey : public Transform { | |||
const IR::Node* postorder(IR::P4Table* table) override; | |||
}; | |||
|
|||
// Use a policy to decide when a key expression is too complex. | |||
/** |
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.
This is incorrect, this pass actually simplifies the keys, it does not determine anything.
You deleted the original comment, which indicated what the policy parameter is about; that should become a @param
comment.
midend/simplifySelectCases.h
Outdated
* If requireConstants is true this pass requires that | ||
* all select labels evaluate to constants. | ||
* | ||
* @pre None |
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.
Well, at least the typeMap must be correct. But maybe that is implied.
This pass assumes that there are no side-effects in the evaluation of select labels, something which is not yet enforced by the compiler or the spec.
midend/validateProperties.h
Outdated
@@ -36,7 +41,7 @@ class ValidateTableProperties : public Inspector { | |||
legalProperties.emplace(l); | |||
} | |||
void postorder(const IR::Property* property) override; | |||
/* don't check properties in externs (Declaration_Instances) */ | |||
/// don't check properties in externs (Declaration_Instances) |
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.
This should probably not be a Doxygen comment.
midend/validateProperties.h
Outdated
* Checks to see if there are any unknown properties. | ||
* | ||
* @pre none | ||
* @post no invalid table properties in P4 program. |
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.
Actually the properties are not removed, but an error is given if such properties are found.
midend/simplifyKey.h
Outdated
* | ||
* Any non-lvalues, except built-in method invocation (isValid), | ||
* are considered complex expressions. | ||
* This pass considers any non-lvalues, except built-in method invocation (isValid), |
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.
This is incorrect, whether a key is complex or not is determined by the policy.
This pass does not know whether non l-values are complex or not.
midend/simplifyKey.h
Outdated
* | ||
* @param policy Use 'policy' to determine whether a key expression is too complex. | ||
* This pass uses 'policy' to determine whether a key expression is too complex. | ||
* Policies are defined in 'NonLeftValue' and 'NonMaskLeftValue', which consider |
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.
This pass should not list all possible policies; we can't be updating this comment every time we write a new policy.
Each policy has its own comments. This pass also simplifies keys which are complex according to the policy.
midend/simplifyKey.h
Outdated
* Policies are defined in 'NonLeftValue' and 'NonMaskLeftValue', which consider | ||
* any non-lvalue, except built-in method (isValid) in table key expressions | ||
* as complex expressions. | ||
* and simplifies keys which are complex according to the policy. |
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 think you also need to remove the do after 'complex'
Comment improvements for these four passes: