[llvm] [NVPTX] Add intrinsics and codegen for tensormap.replace (PR #172458)

Durgadoss R via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 16 05:08:15 PST 2025


================
@@ -59,3 +60,105 @@ void nvvm::printTcgen05CollectorUsageOp(raw_ostream &OS,
   llvm_unreachable("printTcgen05CollectorUsageOp called with invalid value for "
                    "immediate argument");
 }
+
+void nvvm::printTensormapElemType(raw_ostream &OS, const Constant *ImmArgVal) {
+  static constexpr StringRef TensormapElemTypes[] = {
+      "u8",       "u16",   "u32",       "s32",      "u64",  "s64",
+      "f16",      "f32",   "f32.ftz",   "f64",      "bf16", "tf32",
+      "tf32.ftz", "b4x16", "b4x16_p64", "b6x16_p32"};
+  if (const auto *CI = dyn_cast<ConstantInt>(ImmArgVal)) {
+    uint64_t Val = CI->getZExtValue();
+    if (Val <= static_cast<uint64_t>(nvvm::TensormapElemType::B6x16_p32)) {
+      OS << TensormapElemTypes[Val];
+      return;
+    }
+  }
+  llvm_unreachable("printTensormapElemType called with invalid value for "
+                   "immediate argument");
----------------
durga4github wrote:

Since we have the `Range` attached, doesn't it capture the out-of-bounds cases?
In other words, when/how do we hit this here?

https://github.com/llvm/llvm-project/pull/172458


More information about the llvm-commits mailing list