Skip to content

Commit a39af12

Browse files
[NVVM] Move pretty-print functions from NVVMIntrinsicUtils.h to cpp file (#168997)
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 <[email protected]>
1 parent f817a1b commit a39af12

File tree

3 files changed

+66
-45
lines changed

3 files changed

+66
-45
lines changed

llvm/include/llvm/IR/NVVMIntrinsicUtils.h

Lines changed: 4 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ enum class Tcgen05CollectorUsageOp : uint8_t {
5959
USE = 3,
6060
};
6161

62+
void printTcgen05MMAKind(raw_ostream &OS, const Constant *ImmArgVal);
63+
64+
void printTcgen05CollectorUsageOp(raw_ostream &OS, const Constant *ImmArgVal);
65+
6266
inline bool FPToIntegerIntrinsicShouldFTZ(Intrinsic::ID IntrinsicID) {
6367
switch (IntrinsicID) {
6468
case Intrinsic::nvvm_f2i_rm_ftz:
@@ -662,51 +666,6 @@ inline APFloat::roundingMode GetFMARoundingMode(Intrinsic::ID IntrinsicID) {
662666
llvm_unreachable("Invalid FP instrinsic rounding mode for NVVM fma");
663667
}
664668

665-
inline void printTcgen05MMAKind(raw_ostream &OS, const Constant *ImmArgVal) {
666-
if (const auto *CI = dyn_cast<ConstantInt>(ImmArgVal)) {
667-
uint64_t Val = CI->getZExtValue();
668-
switch (static_cast<Tcgen05MMAKind>(Val)) {
669-
case Tcgen05MMAKind::F16:
670-
OS << "f16";
671-
return;
672-
case Tcgen05MMAKind::TF32:
673-
OS << "tf32";
674-
return;
675-
case Tcgen05MMAKind::F8F6F4:
676-
OS << "f8f6f4";
677-
return;
678-
case Tcgen05MMAKind::I8:
679-
OS << "i8";
680-
return;
681-
}
682-
}
683-
llvm_unreachable(
684-
"printTcgen05MMAKind called with invalid value for immediate argument");
685-
}
686-
687-
inline void printTcgen05CollectorUsageOp(raw_ostream &OS,
688-
const Constant *ImmArgVal) {
689-
if (const auto *CI = dyn_cast<ConstantInt>(ImmArgVal)) {
690-
uint64_t Val = CI->getZExtValue();
691-
switch (static_cast<Tcgen05CollectorUsageOp>(Val)) {
692-
case Tcgen05CollectorUsageOp::DISCARD:
693-
OS << "discard";
694-
return;
695-
case Tcgen05CollectorUsageOp::LASTUSE:
696-
OS << "lastuse";
697-
return;
698-
case Tcgen05CollectorUsageOp::FILL:
699-
OS << "fill";
700-
return;
701-
case Tcgen05CollectorUsageOp::USE:
702-
OS << "use";
703-
return;
704-
}
705-
}
706-
llvm_unreachable("printTcgen05CollectorUsageOp called with invalid value for "
707-
"immediate argument");
708-
}
709-
710669
} // namespace nvvm
711670
} // namespace llvm
712671
#endif // LLVM_IR_NVVMINTRINSICUTILS_H

llvm/lib/IR/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ add_llvm_component_library(LLVMCore
3535
GVMaterializer.cpp
3636
Globals.cpp
3737
Intrinsics.cpp
38+
NVVMIntrinsicUtils.cpp
3839
IRBuilder.cpp
3940
IRPrintingPasses.cpp
4041
SSAContext.cpp

llvm/lib/IR/NVVMIntrinsicUtils.cpp

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This file implements functions associated with NVVM Intrinsics.
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#include "llvm/IR/NVVMIntrinsicUtils.h"
14+
15+
using namespace llvm;
16+
using namespace nvvm;
17+
18+
void nvvm::printTcgen05MMAKind(raw_ostream &OS, const Constant *ImmArgVal) {
19+
if (const auto *CI = dyn_cast<ConstantInt>(ImmArgVal)) {
20+
uint64_t Val = CI->getZExtValue();
21+
switch (static_cast<Tcgen05MMAKind>(Val)) {
22+
case Tcgen05MMAKind::F16:
23+
OS << "f16";
24+
return;
25+
case Tcgen05MMAKind::TF32:
26+
OS << "tf32";
27+
return;
28+
case Tcgen05MMAKind::F8F6F4:
29+
OS << "f8f6f4";
30+
return;
31+
case Tcgen05MMAKind::I8:
32+
OS << "i8";
33+
return;
34+
}
35+
}
36+
llvm_unreachable(
37+
"printTcgen05MMAKind called with invalid value for immediate argument");
38+
}
39+
40+
void nvvm::printTcgen05CollectorUsageOp(raw_ostream &OS,
41+
const Constant *ImmArgVal) {
42+
if (const auto *CI = dyn_cast<ConstantInt>(ImmArgVal)) {
43+
uint64_t Val = CI->getZExtValue();
44+
switch (static_cast<Tcgen05CollectorUsageOp>(Val)) {
45+
case Tcgen05CollectorUsageOp::DISCARD:
46+
OS << "discard";
47+
return;
48+
case Tcgen05CollectorUsageOp::LASTUSE:
49+
OS << "lastuse";
50+
return;
51+
case Tcgen05CollectorUsageOp::FILL:
52+
OS << "fill";
53+
return;
54+
case Tcgen05CollectorUsageOp::USE:
55+
OS << "use";
56+
return;
57+
}
58+
}
59+
llvm_unreachable("printTcgen05CollectorUsageOp called with invalid value for "
60+
"immediate argument");
61+
}

0 commit comments

Comments
 (0)