[llvm] [KnownFPClass] Refactor NaN sign encoding for KnownFPClass (PR #220606)
Eric Ross via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 23 14:01:18 PDT 2026
================
@@ -24,41 +24,219 @@ class APInt;
struct fltSemantics;
struct KnownBits;
+enum FPClassMask : unsigned {
+ kfcNone = 0,
+
+ kfcNegQNan = 0x0001,
+ kfcNegSNan = 0x0002,
+ kfcNegInf = 0x0004,
+ kfcNegNormal = 0x0008,
+ kfcNegSubnormal = 0x0010,
+ kfcNegZero = 0x0020,
+ kfcPosZero = 0x0040,
+ kfcPosSubnormal = 0x0080,
+ kfcPosNormal = 0x0100,
+ kfcPosInf = 0x0200,
+ kfcPosSNan = 0x0400,
+ kfcPosQNan = 0x0800,
+
+ kfcSNan = kfcPosSNan | kfcNegSNan,
+ kfcQNan = kfcPosQNan | kfcNegQNan,
+ kfcPosNan = kfcPosSNan | kfcPosQNan,
+ kfcNegNan = kfcNegSNan | kfcNegQNan,
+ kfcNan = kfcSNan | kfcQNan,
+ kfcInf = kfcPosInf | kfcNegInf,
+ kfcNormal = kfcPosNormal | kfcNegNormal,
+ kfcSubnormal = kfcPosSubnormal | kfcNegSubnormal,
+ kfcZero = kfcPosZero | kfcNegZero,
+ kfcPosFinite = kfcPosNormal | kfcPosSubnormal | kfcPosZero,
+ kfcNegFinite = kfcNegNormal | kfcNegSubnormal | kfcNegZero,
+ kfcFinite = kfcPosFinite | kfcNegFinite,
+ kfcPositive = kfcPosFinite | kfcPosInf,
+ kfcNegative = kfcNegFinite | kfcNegInf,
+ kfcPosSignBit = kfcPositive | kfcPosNan,
+ kfcNegSignBit = kfcNegative | kfcNegNan,
+
+ kfcAllFlags = kfcNan | kfcInf | kfcFinite,
+};
+
+LLVM_DECLARE_ENUM_AS_BITMASK(FPClassMask, /* LargestValue */ kfcPosQNan);
----------------
ZERICO2005 wrote:
`LLVM_MARK_AS_BITMASK_ENUM` does not work for `enum FPClassTest : unsigned {}`:
```c++
In file included from /home/zerico/programming/llvm-project/llvm/include/llvm/Support/BinaryStreamRef.h:13:
/home/zerico/programming/llvm-project/llvm/include/llvm/Support/BinaryStream.h:24:3: error: redefinition of enumerator 'LLVM_BITMASK_LARGEST_ENUMERATOR'
24 | LLVM_MARK_AS_BITMASK_ENUM(/* LargestValue = */ BSF_Append)
| ^
/home/zerico/programming/llvm-project/llvm/include/llvm/ADT/BitmaskEnum.h:43:3: note: expanded from macro 'LLVM_MARK_AS_BITMASK_ENUM'
43 | LLVM_BITMASK_LARGEST_ENUMERATOR = LargestValue
| ^
/home/zerico/programming/llvm-project/llvm/include/llvm/Support/KnownFPClass.h:62:3: note: previous definition is here
62 | LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/kfcPosQNan)
| ^
/home/zerico/programming/llvm-project/llvm/include/llvm/ADT/BitmaskEnum.h:43:3: note: expanded from macro 'LLVM_MARK_AS_BITMASK_ENUM'
43 | LLVM_BITMASK_LARGEST_ENUMERATOR = LargestValue
| ^
1 error generated.
[383/579] Building CXX object lib/CodeGen/SelectionDAG/CMakeFiles/LLVMSelectionDAG.dir/TargetLowering.cpp.o^C
ninja: build stopped: interrupted by user.
```
https://github.com/llvm/llvm-project/pull/220606
More information about the llvm-commits
mailing list