LLVM 17.0.0git
FloatingPointMode.cpp
Go to the documentation of this file.
1//===- FloatingPointMode.cpp ------------------------------------*- C++ -*-===//
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
11
12using namespace llvm;
13
15 FPClassTest NewMask = Mask & fcNan;
16 if (Mask & fcNegInf)
17 NewMask |= fcPosInf;
18 if (Mask & fcNegNormal)
19 NewMask |= fcPosNormal;
20 if (Mask & fcNegSubnormal)
21 NewMask |= fcPosSubnormal;
22 if (Mask & fcNegZero)
23 NewMask |= fcPosZero;
24 if (Mask & fcPosZero)
25 NewMask |= fcNegZero;
26 if (Mask & fcPosSubnormal)
27 NewMask |= fcNegSubnormal;
28 if (Mask & fcPosNormal)
29 NewMask |= fcNegNormal;
30 if (Mask & fcPosInf)
31 NewMask |= fcNegInf;
32 return NewMask;
33}
34
36 FPClassTest NewMask = Mask & fcNan;
37 if (Mask & fcPosZero)
38 NewMask |= fcZero;
39 if (Mask & fcPosSubnormal)
40 NewMask |= fcSubnormal;
41 if (Mask & fcPosNormal)
42 NewMask |= fcNormal;
43 if (Mask & fcPosInf)
44 NewMask |= fcInf;
45 return NewMask;
46}
47
48// Every bitfield has a unique name and one or more aliasing names that cover
49// multiple bits. Names should be listed in order of preference, with higher
50// popcounts listed first.
51//
52// Bits are consumed as printed. Each field should only be represented in one
53// printed field.
54static constexpr std::pair<FPClassTest, StringLiteral> NoFPClassName[] = {
55 {fcAllFlags, "all"},
56 {fcNan, "nan"},
57 {fcSNan, "snan"},
58 {fcQNan, "qnan"},
59 {fcInf, "inf"},
60 {fcNegInf, "ninf"},
61 {fcPosInf, "pinf"},
62 {fcZero, "zero"},
63 {fcNegZero, "nzero"},
64 {fcPosZero, "pzero"},
65 {fcSubnormal, "sub"},
66 {fcNegSubnormal, "nsub"},
67 {fcPosSubnormal, "psub"},
68 {fcNormal, "norm"},
69 {fcNegNormal, "nnorm"},
70 {fcPosNormal, "pnorm"}
71};
72
74 OS << '(';
75
76 if (Mask == fcNone) {
77 OS << "none)";
78 return OS;
79 }
80
81 ListSeparator LS(" ");
82 for (auto [BitTest, Name] : NoFPClassName) {
83 if ((Mask & BitTest) == BitTest) {
84 OS << LS << Name;
85
86 // Clear the bits so we don't print any aliased names later.
87 Mask &= ~BitTest;
88 }
89 }
90
91 assert(Mask == 0 && "didn't print some mask bits");
92
93 OS << ')';
94 return OS;
95}
std::string Name
static constexpr std::pair< FPClassTest, StringLiteral > NoFPClassName[]
Utilities for dealing with flags related to floating point properties and mode controls.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
raw_pwrite_stream & OS
This file contains some functions that are useful when dealing with strings.
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
FPClassTest fabs(FPClassTest Mask)
Return the test mask which returns true if the value's sign bit is cleared.
FPClassTest fneg(FPClassTest Mask)
Return the test mask which returns true if the value's sign bit is flipped.
FPClassTest
Floating-point class tests, supported by 'is_fpclass' intrinsic.
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
Definition: APFixedPoint.h:292