This is recommit of
2e416cdd52, reverted in
8555ab2fcd, because GCC
complains on extra qualification. The macro LLVM_DECLARE_ENUM_AS_BITMASK
does not specify llvm:: anymore, so the macro must occur in the namespace
llvm. Documentation updated accordingly. The original commit message is below.
With this change bitwise operations are allowed for FPClassTest
enumeration, it must simplify using this type. Also some functions
changed to get argument of type FPClassTest instead of unsigned.
Differential Revision: https://reviews.llvm.org/D144241
/// 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 global or llvm namespace.
+/// LLVM_DECLARE_ENUM_AS_BITMASK should be used in 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 llvm::is_bitmask_enum<Enum> : std::true_type {}; \
- template <> struct llvm::largest_bitmask_enum_bit<Enum> { \
+ template <> struct is_bitmask_enum<Enum> : std::true_type {}; \
+ template <> struct largest_bitmask_enum_bit<Enum> { \
static constexpr std::underlying_type_t<Enum> value = LargestValue; \
}
#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"
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 {
+enum FPClassTest : unsigned {
+ fcNone = 0,
+
fcSNan = 0x0001,
fcQNan = 0x0002,
fcNegInf = 0x0004,
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
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.
///
/// \param Test The test as specified in 'is_fpclass' intrinsic invocation.
/// \returns The inverted test, or zero, if inversion does not produce simpler
/// test.
-unsigned getInvertedFPClassTest(unsigned Test);
+FPClassTest getInvertedFPClassTest(FPClassTest 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.
/// \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, unsigned Test,
+ SDValue expandIS_FPCLASS(EVT ResultVT, SDValue Op, FPClassTest Test,
SDNodeFlags Flags, const SDLoc &DL,
SelectionDAG &DAG) const;
return SplitPoint;
}
-unsigned llvm::getInvertedFPClassTest(unsigned Test) {
- unsigned InvertedTest = ~Test & fcAllFlags;
+FPClassTest llvm::getInvertedFPClassTest(FPClassTest Test) {
+ FPClassTest InvertedTest = ~Test & fcAllFlags;
switch (InvertedTest) {
default:
break;
case fcNegFinite:
return InvertedTest;
}
- return 0;
+ return fcNone;
}
static MachineOperand *getSalvageOpsForCopy(const MachineRegisterInfo &MRI,
const DataLayout DLayout = DAG.getDataLayout();
EVT DestVT = TLI.getValueType(DLayout, I.getType());
EVT ArgVT = TLI.getValueType(DLayout, I.getArgOperand(0)->getType());
- unsigned Test = cast<ConstantInt>(I.getArgOperand(1))->getZExtValue();
+ FPClassTest Test = static_cast<FPClassTest>(
+ cast<ConstantInt>(I.getArgOperand(1))->getZExtValue());
MachineFunction &MF = DAG.getMachineFunction();
const Function &F = MF.getFunction();
SDValue Op = getValue(I.getArgOperand(0));
}
SDValue TargetLowering::expandIS_FPCLASS(EVT ResultVT, SDValue Op,
- unsigned Test, SDNodeFlags Flags,
+ FPClassTest Test, SDNodeFlags Flags,
const SDLoc &DL,
SelectionDAG &DAG) const {
EVT OperandVT = Op.getValueType();
// Some checks may be represented as inversion of simpler check, for example
// "inf|normal|subnormal|zero" => !"nan".
bool IsInverted = false;
- if (unsigned InvertedCheck = getInvertedFPClassTest(Test)) {
+ if (FPClassTest InvertedCheck = getInvertedFPClassTest(Test)) {
IsInverted = true;
Test = InvertedCheck;
}
}
case Intrinsic::is_fpclass: {
const ConstantInt *TestMask = cast<ConstantInt>(Call.getOperand(1));
- Check((TestMask->getZExtValue() & ~fcAllFlags) == 0,
+ Check((TestMask->getZExtValue() & ~static_cast<unsigned>(fcAllFlags)) == 0,
"unsupported bits for llvm.is.fpclass test mask");
break;
}