aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/Attributes.cpp
diff options
context:
space:
mode:
authorMatt Arsenault <Matthew.Arsenault@amd.com>2023-02-24 10:35:49 -0400
committerMatt Arsenault <arsenm2@gmail.com>2023-03-03 18:20:47 -0400
commit0eb59cab95a01fa84188049fa08348c3bf97e356 (patch)
treebfc8e931a32c7107ac8babd43f6637202b71958a /llvm/lib/IR/Attributes.cpp
parent55cf53fd0f5594eb701b5760729fdc2bd4a70584 (diff)
downloadllvm-0eb59cab95a01fa84188049fa08348c3bf97e356.zip
llvm-0eb59cab95a01fa84188049fa08348c3bf97e356.tar.gz
llvm-0eb59cab95a01fa84188049fa08348c3bf97e356.tar.bz2
ADT: Move FPClassTest printing functions to common place
Diffstat (limited to 'llvm/lib/IR/Attributes.cpp')
-rw-r--r--llvm/lib/IR/Attributes.cpp58
1 files changed, 6 insertions, 52 deletions
diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp
index 21f119d..3858f5f 100644
--- a/llvm/lib/IR/Attributes.cpp
+++ b/llvm/lib/IR/Attributes.cpp
@@ -431,56 +431,6 @@ static const char *getModRefStr(ModRefInfo MR) {
llvm_unreachable("Invalid ModRefInfo");
}
-// Every bitfield has a unique name and one or more aliasing names that cover
-// multiple bits. Names should be listed in order of preference, with higher
-// popcounts listed first.
-//
-// Bits are consumed as printed. Each field should only be represented in one
-// printed field.
-static constexpr std::pair<unsigned, StringLiteral> NoFPClassName[] = {
- {fcAllFlags, "all"},
- {fcNan, "nan"},
- {fcSNan, "snan"},
- {fcQNan, "qnan"},
- {fcInf, "inf"},
- {fcNegInf, "ninf"},
- {fcPosInf, "pinf"},
- {fcZero, "zero"},
- {fcNegZero, "nzero"},
- {fcPosZero, "pzero"},
- {fcSubnormal, "sub"},
- {fcNegSubnormal, "nsub"},
- {fcPosSubnormal, "psub"},
- {fcNormal, "norm"},
- {fcNegNormal, "nnorm"},
- {fcPosNormal, "pnorm"}
-};
-
-static std::string getNoFPClassAttrAsString(unsigned Mask) {
- std::string Result("nofpclass(");
- raw_string_ostream OS(Result);
-
- if (Mask == 0) {
- OS << "none)";
- return Result;
- }
-
- ListSeparator LS(" ");
- for (auto [BitTest, Name] : NoFPClassName) {
- if ((Mask & BitTest) == BitTest) {
- OS << LS << Name;
-
- // Clear the bits so we don't print any aliased names later.
- Mask &= ~BitTest;
- }
- }
-
- assert(Mask == 0 && "didn't print some mask bits");
-
- OS << ')';
- return Result;
-}
-
std::string Attribute::getAsString(bool InAttrGrp) const {
if (!pImpl) return {};
@@ -614,8 +564,12 @@ std::string Attribute::getAsString(bool InAttrGrp) const {
return Result;
}
- if (hasAttribute(Attribute::NoFPClass))
- return getNoFPClassAttrAsString(getValueAsInt());
+ if (hasAttribute(Attribute::NoFPClass)) {
+ std::string Result = "nofpclass";
+ raw_string_ostream OS(Result);
+ OS << getNoFPClass();
+ return Result;
+ }
// Convert target-dependent attributes to strings of the form:
//