File indexing completed on 2026-05-10 08:44:12
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 #ifndef LLVM_MC_LANEBITMASK_H
0030 #define LLVM_MC_LANEBITMASK_H
0031
0032 #include "llvm/Support/Compiler.h"
0033 #include "llvm/Support/Format.h"
0034 #include "llvm/Support/MathExtras.h"
0035 #include "llvm/Support/Printable.h"
0036 #include "llvm/Support/raw_ostream.h"
0037
0038 namespace llvm {
0039
0040 struct LaneBitmask {
0041
0042 using Type = uint64_t;
0043 enum : unsigned { BitWidth = 8*sizeof(Type) };
0044 constexpr static const char *const FormatStr = "%016llX";
0045
0046 constexpr LaneBitmask() = default;
0047 explicit constexpr LaneBitmask(Type V) : Mask(V) {}
0048
0049 constexpr bool operator== (LaneBitmask M) const { return Mask == M.Mask; }
0050 constexpr bool operator!= (LaneBitmask M) const { return Mask != M.Mask; }
0051 constexpr bool operator< (LaneBitmask M) const { return Mask < M.Mask; }
0052 constexpr bool none() const { return Mask == 0; }
0053 constexpr bool any() const { return Mask != 0; }
0054 constexpr bool all() const { return ~Mask == 0; }
0055
0056 constexpr LaneBitmask operator~() const {
0057 return LaneBitmask(~Mask);
0058 }
0059 constexpr LaneBitmask operator|(LaneBitmask M) const {
0060 return LaneBitmask(Mask | M.Mask);
0061 }
0062 constexpr LaneBitmask operator&(LaneBitmask M) const {
0063 return LaneBitmask(Mask & M.Mask);
0064 }
0065 LaneBitmask &operator|=(LaneBitmask M) {
0066 Mask |= M.Mask;
0067 return *this;
0068 }
0069 LaneBitmask &operator&=(LaneBitmask M) {
0070 Mask &= M.Mask;
0071 return *this;
0072 }
0073
0074 constexpr Type getAsInteger() const { return Mask; }
0075
0076 unsigned getNumLanes() const { return llvm::popcount(Mask); }
0077 unsigned getHighestLane() const {
0078 return Log2_64(Mask);
0079 }
0080
0081 static constexpr LaneBitmask getNone() { return LaneBitmask(0); }
0082 static constexpr LaneBitmask getAll() { return ~LaneBitmask(0); }
0083 static constexpr LaneBitmask getLane(unsigned Lane) {
0084 return LaneBitmask(Type(1) << Lane);
0085 }
0086
0087 private:
0088 Type Mask = 0;
0089 };
0090
0091
0092 inline Printable PrintLaneMask(LaneBitmask LaneMask) {
0093 return Printable([LaneMask](raw_ostream &OS) {
0094 OS << format(LaneBitmask::FormatStr, LaneMask.getAsInteger());
0095 });
0096 }
0097
0098 }
0099
0100 #endif