[llvm] [NVVM] Move print functions from NVVMIntrinsicUtils.h to cpp file (PR #168997)
Dharuni R Acharya via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 21 00:07:22 PST 2025
https://github.com/DharuniRAcharya updated https://github.com/llvm/llvm-project/pull/168997
>From 0921ed1f925c11e98c4320a5ab23d750def3ccdb Mon Sep 17 00:00:00 2001
From: Dharuni R Acharya <dharunira at nvidia.com>
Date: Fri, 21 Nov 2025 04:39:01 +0000
Subject: [PATCH 1/3] [NVVM] Move print functions from NVVMIntrinsicUtils.h to
cpp file
This patch moves the print functions from NVVMIntrinsicUtils.h to NVVMIntrinsicUtils.cpp, a file created in the llvm/lib/IR directory.
Signed-off-by: Dharuni R Acharya <dharunira at nvidia.com>
---
llvm/include/llvm/IR/NVVMIntrinsicUtils.h | 45 +----------------
llvm/lib/IR/CMakeLists.txt | 1 +
llvm/lib/IR/NVVMIntrinsicUtils.cpp | 61 +++++++++++++++++++++++
3 files changed, 64 insertions(+), 43 deletions(-)
create mode 100644 llvm/lib/IR/NVVMIntrinsicUtils.cpp
diff --git a/llvm/include/llvm/IR/NVVMIntrinsicUtils.h b/llvm/include/llvm/IR/NVVMIntrinsicUtils.h
index d383769043605..a6356a99b9c77 100644
--- a/llvm/include/llvm/IR/NVVMIntrinsicUtils.h
+++ b/llvm/include/llvm/IR/NVVMIntrinsicUtils.h
@@ -662,50 +662,9 @@ inline APFloat::roundingMode GetFMARoundingMode(Intrinsic::ID IntrinsicID) {
llvm_unreachable("Invalid FP instrinsic rounding mode for NVVM fma");
}
-inline void printTcgen05MMAKind(raw_ostream &OS, const Constant *ImmArgVal) {
- if (const auto *CI = dyn_cast<ConstantInt>(ImmArgVal)) {
- uint64_t Val = CI->getZExtValue();
- switch (static_cast<Tcgen05MMAKind>(Val)) {
- case Tcgen05MMAKind::F16:
- OS << "f16";
- return;
- case Tcgen05MMAKind::TF32:
- OS << "tf32";
- return;
- case Tcgen05MMAKind::F8F6F4:
- OS << "f8f6f4";
- return;
- case Tcgen05MMAKind::I8:
- OS << "i8";
- return;
- }
- }
- llvm_unreachable(
- "printTcgen05MMAKind called with invalid value for immediate argument");
-}
+void printTcgen05MMAKind(raw_ostream &OS, const Constant *ImmArgVal);
-inline void printTcgen05CollectorUsageOp(raw_ostream &OS,
- const Constant *ImmArgVal) {
- if (const auto *CI = dyn_cast<ConstantInt>(ImmArgVal)) {
- uint64_t Val = CI->getZExtValue();
- switch (static_cast<Tcgen05CollectorUsageOp>(Val)) {
- case Tcgen05CollectorUsageOp::DISCARD:
- OS << "discard";
- return;
- case Tcgen05CollectorUsageOp::LASTUSE:
- OS << "lastuse";
- return;
- case Tcgen05CollectorUsageOp::FILL:
- OS << "fill";
- return;
- case Tcgen05CollectorUsageOp::USE:
- OS << "use";
- return;
- }
- }
- llvm_unreachable("printTcgen05CollectorUsageOp called with invalid value for "
- "immediate argument");
-}
+void printTcgen05CollectorUsageOp(raw_ostream &OS, const Constant *ImmArgVal);
} // namespace nvvm
} // namespace llvm
diff --git a/llvm/lib/IR/CMakeLists.txt b/llvm/lib/IR/CMakeLists.txt
index 10572ff708bd3..31821a2d6b208 100644
--- a/llvm/lib/IR/CMakeLists.txt
+++ b/llvm/lib/IR/CMakeLists.txt
@@ -35,6 +35,7 @@ add_llvm_component_library(LLVMCore
GVMaterializer.cpp
Globals.cpp
Intrinsics.cpp
+ NVVMIntrinsicUtils.cpp
IRBuilder.cpp
IRPrintingPasses.cpp
SSAContext.cpp
diff --git a/llvm/lib/IR/NVVMIntrinsicUtils.cpp b/llvm/lib/IR/NVVMIntrinsicUtils.cpp
new file mode 100644
index 0000000000000..bf5c25c891cea
--- /dev/null
+++ b/llvm/lib/IR/NVVMIntrinsicUtils.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements functions associated with NVVM Intrinsics.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/IR/NVVMIntrinsicUtils.h"
+
+using namespace llvm;
+using namespace nvvm;
+
+void nvvm::printTcgen05MMAKind(raw_ostream &OS, const Constant *ImmArgVal) {
+ if (const auto *CI = dyn_cast<ConstantInt>(ImmArgVal)) {
+ uint64_t Val = CI->getZExtValue();
+ switch (static_cast<Tcgen05MMAKind>(Val)) {
+ case Tcgen05MMAKind::F16:
+ OS << "f16";
+ return;
+ case Tcgen05MMAKind::TF32:
+ OS << "tf32";
+ return;
+ case Tcgen05MMAKind::F8F6F4:
+ OS << "f8f6f4";
+ return;
+ case Tcgen05MMAKind::I8:
+ OS << "i8";
+ return;
+ }
+ }
+ llvm_unreachable(
+ "printTcgen05MMAKind called with invalid value for immediate argument");
+}
+
+void nvvm::printTcgen05CollectorUsageOp(raw_ostream &OS,
+ const Constant *ImmArgVal) {
+ if (const auto *CI = dyn_cast<ConstantInt>(ImmArgVal)) {
+ uint64_t Val = CI->getZExtValue();
+ switch (static_cast<Tcgen05CollectorUsageOp>(Val)) {
+ case Tcgen05CollectorUsageOp::DISCARD:
+ OS << "discard";
+ return;
+ case Tcgen05CollectorUsageOp::LASTUSE:
+ OS << "lastuse";
+ return;
+ case Tcgen05CollectorUsageOp::FILL:
+ OS << "fill";
+ return;
+ case Tcgen05CollectorUsageOp::USE:
+ OS << "use";
+ return;
+ }
+ }
+ llvm_unreachable("printTcgen05CollectorUsageOp called with invalid value for "
+ "immediate argument");
+}
>From 7c9e410917c9d19da1c4e70f2f00ed8052b70196 Mon Sep 17 00:00:00 2001
From: Dharuni R Acharya <dharunira at nvidia.com>
Date: Fri, 21 Nov 2025 04:48:36 +0000
Subject: [PATCH 2/3] Fix formatting
---
llvm/lib/IR/NVVMIntrinsicUtils.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/lib/IR/NVVMIntrinsicUtils.cpp b/llvm/lib/IR/NVVMIntrinsicUtils.cpp
index bf5c25c891cea..4389fa38ad3af 100644
--- a/llvm/lib/IR/NVVMIntrinsicUtils.cpp
+++ b/llvm/lib/IR/NVVMIntrinsicUtils.cpp
@@ -38,7 +38,7 @@ void nvvm::printTcgen05MMAKind(raw_ostream &OS, const Constant *ImmArgVal) {
}
void nvvm::printTcgen05CollectorUsageOp(raw_ostream &OS,
- const Constant *ImmArgVal) {
+ const Constant *ImmArgVal) {
if (const auto *CI = dyn_cast<ConstantInt>(ImmArgVal)) {
uint64_t Val = CI->getZExtValue();
switch (static_cast<Tcgen05CollectorUsageOp>(Val)) {
>From db59bb5bd3b65be5bca7c9895829a5d230187165 Mon Sep 17 00:00:00 2001
From: Dharuni R Acharya <dharunira at nvidia.com>
Date: Fri, 21 Nov 2025 08:07:04 +0000
Subject: [PATCH 3/3] Address comments
---
llvm/include/llvm/IR/NVVMIntrinsicUtils.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/llvm/include/llvm/IR/NVVMIntrinsicUtils.h b/llvm/include/llvm/IR/NVVMIntrinsicUtils.h
index a6356a99b9c77..62f2a249b1357 100644
--- a/llvm/include/llvm/IR/NVVMIntrinsicUtils.h
+++ b/llvm/include/llvm/IR/NVVMIntrinsicUtils.h
@@ -59,6 +59,10 @@ enum class Tcgen05CollectorUsageOp : uint8_t {
USE = 3,
};
+void printTcgen05MMAKind(raw_ostream &OS, const Constant *ImmArgVal);
+
+void printTcgen05CollectorUsageOp(raw_ostream &OS, const Constant *ImmArgVal);
+
inline bool FPToIntegerIntrinsicShouldFTZ(Intrinsic::ID IntrinsicID) {
switch (IntrinsicID) {
case Intrinsic::nvvm_f2i_rm_ftz:
@@ -662,10 +666,6 @@ inline APFloat::roundingMode GetFMARoundingMode(Intrinsic::ID IntrinsicID) {
llvm_unreachable("Invalid FP instrinsic rounding mode for NVVM fma");
}
-void printTcgen05MMAKind(raw_ostream &OS, const Constant *ImmArgVal);
-
-void printTcgen05CollectorUsageOp(raw_ostream &OS, const Constant *ImmArgVal);
-
} // namespace nvvm
} // namespace llvm
#endif // LLVM_IR_NVVMINTRINSICUTILS_H
More information about the llvm-commits
mailing list