LLVM 24.0.0git
PISAIntrinsicUtils.cpp
Go to the documentation of this file.
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/// \file
10/// This file implements utility interfaces for PISA intrinsics.
11///
12//===----------------------------------------------------------------------===//
13
16
17using namespace llvm;
18using namespace llvm::pisa;
19
20void pisa::printMemoryOrdering(raw_ostream &OS, const Constant *ImmArgVal) {
21 auto *CI = cast<ConstantInt>(ImmArgVal);
22 uint64_t Val = CI->getZExtValue();
23 if (!isValidAtomicOrdering(Val))
24 return; // invalid value, print nothing
25 OS << toIRString(static_cast<AtomicOrdering>(Val));
26}
27
28void pisa::printRoundingMode(raw_ostream &OS, const Constant *ImmArgVal) {
29 auto *CI = cast<ConstantInt>(ImmArgVal);
30 int64_t Val = CI->getSExtValue();
31 switch (static_cast<RoundingMode>(Val)) {
33 OS << ".rz";
34 break;
36 OS << ".re";
37 break;
39 OS << ".ru";
40 break;
42 OS << ".rd";
43 break;
45 OS << ".rna";
46 break;
48 break;
50 OS << "none";
51 break;
52 }
53}
54
55void pisa::printIRedOp(raw_ostream &OS, const Constant *ImmArgVal) {
56 auto *CI = cast<ConstantInt>(ImmArgVal);
57 int64_t Val = CI->getSExtValue();
58 switch (Val) {
59 case IRedOp::SUM:
60 OS << ".sum";
61 break;
62 case IRedOp::SMIN:
63 OS << ".smin";
64 break;
65 case IRedOp::SMAX:
66 OS << ".smax";
67 break;
68 case IRedOp::UMIN:
69 OS << ".umin";
70 break;
71 case IRedOp::UMAX:
72 OS << ".umax";
73 break;
74 case IRedOp::AND:
75 OS << ".and";
76 break;
77 case IRedOp::OR:
78 OS << ".or";
79 break;
80 case IRedOp::XOR:
81 OS << ".xor";
82 break;
83 case IRedOp::ABSMAX:
84 OS << ".absmax";
85 break;
86 }
87 // invalid value, print nothing
88}
89
90void pisa::printFRedOp(raw_ostream &OS, const Constant *ImmArgVal) {
91 auto *CI = cast<ConstantInt>(ImmArgVal);
92 int64_t Val = CI->getSExtValue();
93 switch (Val) {
94 case FRedOp::MIN:
95 OS << ".min";
96 break;
97 case FRedOp::MAX:
98 OS << ".max";
99 break;
100 case FRedOp::ABSMAX:
101 OS << ".absmax";
102 break;
103 }
104 // invalid value, print nothing
105}
106
107void pisa::printSHFLMode(raw_ostream &OS, const Constant *ImmArgVal) {
108 auto *CI = cast<ConstantInt>(ImmArgVal);
109 int64_t Val = CI->getSExtValue();
110 switch (Val) {
111 case SHFLMode::UP:
112 OS << ".up";
113 break;
114 case SHFLMode::DOWN:
115 OS << ".down";
116 break;
117 case SHFLMode::XOR:
118 OS << ".xor";
119 break;
120 case SHFLMode::IDX:
121 OS << ".idx";
122 break;
123 }
124 // invalid value, print nothing
125}
Atomic ordering constants.
This file declares utility interfaces for PISA intrinsics.
This is an important base class in LLVM.
Definition Constant.h:44
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
LLVM_ABI void printSHFLMode(raw_ostream &OS, const Constant *ImmArgVal)
LLVM_ABI void printFRedOp(raw_ostream &OS, const Constant *ImmArgVal)
LLVM_ABI void printRoundingMode(raw_ostream &OS, const Constant *ImmArgVal)
LLVM_ABI void printIRedOp(raw_ostream &OS, const Constant *ImmArgVal)
LLVM_ABI void printMemoryOrdering(raw_ostream &OS, const Constant *ImmArgVal)
This is an optimization pass for GlobalISel generic memory operations.
bool isValidAtomicOrdering(Int I)
RoundingMode
Rounding mode.
@ TowardZero
roundTowardZero.
@ NearestTiesToEven
roundTiesToEven.
@ Invalid
Denotes invalid value.
@ Dynamic
Denotes mode unknown at compile time.
@ TowardPositive
roundTowardPositive.
@ NearestTiesToAway
roundTiesToAway.
@ TowardNegative
roundTowardNegative.
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559