diff options
author | Alex MacLean <amaclean@nvidia.com> | 2025-08-27 16:32:28 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-08-27 16:32:28 -0700 |
commit | 06bcc34e3d80403f22e9b1317f6519e3c63dc5df (patch) | |
tree | 75051a34c85e50abcfc409265427b19a8e2330db /llvm/lib/IR/AutoUpgrade.cpp | |
parent | 5bca8f2f97d23c3562544e959702826eb20696af (diff) | |
download | llvm-06bcc34e3d80403f22e9b1317f6519e3c63dc5df.zip llvm-06bcc34e3d80403f22e9b1317f6519e3c63dc5df.tar.gz llvm-06bcc34e3d80403f22e9b1317f6519e3c63dc5df.tar.bz2 |
[NVPTX] Auto-upgrade nvvm.grid_constant to param attribute (#155489)
Upgrade the !"grid_constant" !nvvm.annotation to a "nvvm.grid_constant"
attribute. This attribute is much simpler for front-ends to apply and
faster and simpler to query.
Diffstat (limited to 'llvm/lib/IR/AutoUpgrade.cpp')
-rw-r--r-- | llvm/lib/IR/AutoUpgrade.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp index e200f36..7ea9c6d 100644 --- a/llvm/lib/IR/AutoUpgrade.cpp +++ b/llvm/lib/IR/AutoUpgrade.cpp @@ -5381,6 +5381,16 @@ bool static upgradeSingleNVVMAnnotation(GlobalValue *GV, StringRef K, upgradeNVVMFnVectorAttr("nvvm.cluster_dim", K[0], GV, V); return true; } + if (K == "grid_constant") { + const auto Attr = Attribute::get(GV->getContext(), "nvvm.grid_constant"); + for (const auto &Op : cast<MDNode>(V)->operands()) { + // For some reason, the index is 1-based in the metadata. Good thing we're + // able to auto-upgrade it! + const auto Index = mdconst::extract<ConstantInt>(Op)->getZExtValue() - 1; + cast<Function>(GV)->addParamAttr(Index, Attr); + } + return true; + } return false; } |