-
Notifications
You must be signed in to change notification settings - Fork 13.3k
[NVPTX] Convert scalar function nvvm.annotations to attributes #125908
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -179,6 +179,13 @@ static bool argHasNVVMAnnotation(const Value &Val, | |
return false; | ||
} | ||
|
||
static std::optional<unsigned> getFnAttrParsedInt(const Function &F, | ||
StringRef Attr) { | ||
return F.hasFnAttribute(Attr) | ||
? std::optional(F.getFnAttributeAsParsedInteger(Attr)) | ||
: std::nullopt; | ||
Comment on lines
+184
to
+186
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. Ugh. Just in case. Comments marked as "nit" are up to you. It includes ignoring them or pushing back when those suggestions don't make sense or turn out not being worth it. 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. No worries! I agree it is basically a wash and will leave it as it currently is. |
||
} | ||
|
||
bool isParamGridConstant(const Value &V) { | ||
if (const Argument *Arg = dyn_cast<Argument>(&V)) { | ||
// "grid_constant" counts argument indices starting from 1 | ||
|
@@ -277,7 +284,7 @@ std::optional<unsigned> getClusterDimz(const Function &F) { | |
} | ||
|
||
std::optional<unsigned> getMaxClusterRank(const Function &F) { | ||
return findOneNVVMAnnotation(&F, "maxclusterrank"); | ||
return getFnAttrParsedInt(F, "nvvm.maxclusterrank"); | ||
} | ||
|
||
std::optional<unsigned> getReqNTIDx(const Function &F) { | ||
|
@@ -303,11 +310,11 @@ std::optional<unsigned> getReqNTID(const Function &F) { | |
} | ||
|
||
std::optional<unsigned> getMinCTASm(const Function &F) { | ||
return findOneNVVMAnnotation(&F, "minctasm"); | ||
return getFnAttrParsedInt(F, "nvvm.minctasm"); | ||
} | ||
|
||
std::optional<unsigned> getMaxNReg(const Function &F) { | ||
return findOneNVVMAnnotation(&F, "maxnreg"); | ||
return getFnAttrParsedInt(F, "nvvm.maxnreg"); | ||
} | ||
|
||
MaybeAlign getAlign(const Function &F, unsigned Index) { | ||
|
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.
We should eventually create a list of strings for valid
nvvm.
function attributes and use them here instead of hard-coding strings. It would serve as a single-source-of-truth for the set of valid attributes. Not necessary for this PR, but something to consider for the future.