Skip to content

Commit

Permalink
Revert "[NFC] Make FPClassTest a bitmask enumeration"
Browse files Browse the repository at this point in the history
This reverts commit e7613c1.

GCC issues an error:

In file included from /home/buildbot/as-builder-4/lld-x86_64-ubuntu-fast/llvm-project/llvm/unittests/ADT/BitmaskEnumTest.cpp:9:
/home/buildbot/as-builder-4/lld-x86_64-ubuntu-fast/llvm-project/llvm/include/llvm/ADT/BitmaskEnum.h:66:22: error: explicit specialization of template<class E, class Enable> struct llvm::is_bitmask_enum outside its namespace must use a nested-name-specifier [-fpermissive]
   66 |   template <> struct is_bitmask_enum<Enum> : std::true_type {};                \
      |                      ^~~~~~~~~~~~~~~~~~~~~
/home/buildbot/as-builder-4/lld-x86_64-ubuntu-fast/llvm-project/llvm/unittests/ADT/BitmaskEnumTest.cpp:30:1: note: in expansion of macro LLVM_DECLARE_ENUM_AS_BITMASK
   30 | LLVM_DECLARE_ENUM_AS_BITMASK(Flags2, V4);
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • Loading branch information
spavloff committed Feb 23, 2023
1 parent e7613c1 commit 08a0923
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 24 deletions.
6 changes: 3 additions & 3 deletions llvm/include/llvm/ADT/BitmaskEnum.h
Expand Up @@ -56,15 +56,15 @@
/// The second parameter to LLVM_DECLARE_ENUM_AS_BITMASK specifies the largest
/// bit value of the enum type.
///
/// LLVM_DECLARE_ENUM_AS_BITMASK should be used in llvm namespace.
/// LLVM_DECLARE_ENUM_AS_BITMASK should be used in global or llvm namespace.
///
/// This a non-intrusive alternative for LLVM_MARK_AS_BITMASK_ENUM. It allows
/// declaring more than one non-scoped enumerations as bitmask types in the same
/// scope. Otherwise it provides the same functionality as
/// LLVM_MARK_AS_BITMASK_ENUM.
#define LLVM_DECLARE_ENUM_AS_BITMASK(Enum, LargestValue) \
template <> struct is_bitmask_enum<Enum> : std::true_type {}; \
template <> struct largest_bitmask_enum_bit<Enum> { \
template <> struct llvm::is_bitmask_enum<Enum> : std::true_type {}; \
template <> struct llvm::largest_bitmask_enum_bit<Enum> { \
static constexpr std::underlying_type_t<Enum> value = LargestValue; \
}

Expand Down
13 changes: 4 additions & 9 deletions llvm/include/llvm/ADT/FloatingPointMode.h
Expand Up @@ -15,7 +15,6 @@
#ifndef LLVM_ADT_FLOATINGPOINTMODE_H
#define LLVM_ADT_FLOATINGPOINTMODE_H

#include "llvm/ADT/BitmaskEnum.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Support/raw_ostream.h"

Expand Down Expand Up @@ -193,11 +192,11 @@ void DenormalMode::print(raw_ostream &OS) const {
OS << denormalModeKindName(Output) << ',' << denormalModeKindName(Input);
}

} // namespace llvm

/// Floating-point class tests, supported by 'is_fpclass' intrinsic. Actual
/// test may be an OR combination of basic tests.
enum FPClassTest : unsigned {
fcNone = 0,

enum FPClassTest {
fcSNan = 0x0001,
fcQNan = 0x0002,
fcNegInf = 0x0004,
Expand All @@ -217,11 +216,7 @@ enum FPClassTest : unsigned {
fcPosFinite = fcPosNormal | fcPosSubnormal | fcPosZero,
fcNegFinite = fcNegNormal | fcNegSubnormal | fcNegZero,
fcFinite = fcPosFinite | fcNegFinite,
fcAllFlags = fcNan | fcInf | fcFinite,
fcAllFlags = fcNan | fcInf | fcFinite
};

LLVM_DECLARE_ENUM_AS_BITMASK(FPClassTest, /* LargestValue */ fcPosInf);

} // namespace llvm

#endif // LLVM_ADT_FLOATINGPOINTMODE_H
4 changes: 1 addition & 3 deletions llvm/include/llvm/CodeGen/CodeGenCommonISel.h
Expand Up @@ -19,8 +19,6 @@
namespace llvm {

class BasicBlock;
enum FPClassTest : unsigned;

/// Encapsulates all of the information needed to generate a stack protector
/// check, and signals to isel when initialized that one needs to be generated.
///
Expand Down Expand Up @@ -220,7 +218,7 @@ findSplitPointForStackProtector(MachineBasicBlock *BB,
/// \param Test The test as specified in 'is_fpclass' intrinsic invocation.
/// \returns The inverted test, or zero, if inversion does not produce simpler
/// test.
FPClassTest getInvertedFPClassTest(FPClassTest Test);
unsigned getInvertedFPClassTest(unsigned Test);

/// Assuming the instruction \p MI is going to be deleted, attempt to salvage
/// debug users of \p MI by writing the effect of \p MI in a DIExpression.
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/CodeGen/TargetLowering.h
Expand Up @@ -4962,7 +4962,7 @@ class TargetLowering : public TargetLoweringBase {
/// \param Test The test to perform.
/// \param Flags The optimization flags.
/// \returns The expansion result or SDValue() if it fails.
SDValue expandIS_FPCLASS(EVT ResultVT, SDValue Op, FPClassTest Test,
SDValue expandIS_FPCLASS(EVT ResultVT, SDValue Op, unsigned Test,
SDNodeFlags Flags, const SDLoc &DL,
SelectionDAG &DAG) const;

Expand Down
6 changes: 3 additions & 3 deletions llvm/lib/CodeGen/CodeGenCommonISel.cpp
Expand Up @@ -173,8 +173,8 @@ llvm::findSplitPointForStackProtector(MachineBasicBlock *BB,
return SplitPoint;
}

FPClassTest llvm::getInvertedFPClassTest(FPClassTest Test) {
FPClassTest InvertedTest = ~Test & fcAllFlags;
unsigned llvm::getInvertedFPClassTest(unsigned Test) {
unsigned InvertedTest = ~Test & fcAllFlags;
switch (InvertedTest) {
default:
break;
Expand All @@ -198,7 +198,7 @@ FPClassTest llvm::getInvertedFPClassTest(FPClassTest Test) {
case fcNegFinite:
return InvertedTest;
}
return fcNone;
return 0;
}

static MachineOperand *getSalvageOpsForCopy(const MachineRegisterInfo &MRI,
Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
Expand Up @@ -6510,8 +6510,7 @@ void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I,
const DataLayout DLayout = DAG.getDataLayout();
EVT DestVT = TLI.getValueType(DLayout, I.getType());
EVT ArgVT = TLI.getValueType(DLayout, I.getArgOperand(0)->getType());
FPClassTest Test = static_cast<FPClassTest>(
cast<ConstantInt>(I.getArgOperand(1))->getZExtValue());
unsigned Test = cast<ConstantInt>(I.getArgOperand(1))->getZExtValue();
MachineFunction &MF = DAG.getMachineFunction();
const Function &F = MF.getFunction();
SDValue Op = getValue(I.getArgOperand(0));
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
Expand Up @@ -8004,7 +8004,7 @@ SDValue TargetLowering::expandFMINNUM_FMAXNUM(SDNode *Node,
}

SDValue TargetLowering::expandIS_FPCLASS(EVT ResultVT, SDValue Op,
FPClassTest Test, SDNodeFlags Flags,
unsigned Test, SDNodeFlags Flags,
const SDLoc &DL,
SelectionDAG &DAG) const {
EVT OperandVT = Op.getValueType();
Expand All @@ -8027,7 +8027,7 @@ SDValue TargetLowering::expandIS_FPCLASS(EVT ResultVT, SDValue Op,
// Some checks may be represented as inversion of simpler check, for example
// "inf|normal|subnormal|zero" => !"nan".
bool IsInverted = false;
if (FPClassTest InvertedCheck = getInvertedFPClassTest(Test)) {
if (unsigned InvertedCheck = getInvertedFPClassTest(Test)) {
IsInverted = true;
Test = InvertedCheck;
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/IR/Verifier.cpp
Expand Up @@ -5070,7 +5070,7 @@ void Verifier::visitIntrinsicCall(Intrinsic::ID ID, CallBase &Call) {
}
case Intrinsic::is_fpclass: {
const ConstantInt *TestMask = cast<ConstantInt>(Call.getOperand(1));
Check((TestMask->getZExtValue() & ~static_cast<unsigned>(fcAllFlags)) == 0,
Check((TestMask->getZExtValue() & ~fcAllFlags) == 0,
"unsupported bits for llvm.is.fpclass test mask");
break;
}
Expand Down

0 comments on commit 08a0923

Please sign in to comment.