LLVM 20.0.0git
Public Types | Static Public Attributes | List of all members
llvm::bitfields_details::BitPatterns< T, Bits > Struct Template Reference

A struct defining useful bit patterns for n-bits integer types. More...

#include "llvm/ADT/Bitfields.h"

Public Types

using Unsigned = std::make_unsigned_t< T >
 Bit patterns are forged using the equivalent Unsigned type because of undefined operations over signed types (e.g.
 

Static Public Attributes

static constexpr unsigned TypeBits = sizeof(Unsigned) * CHAR_BIT
 
static constexpr Unsigned AllZeros = Unsigned(0)
 e.g. with TypeBits == 8 and Bits == 6.
 
static constexpr Unsigned AllOnes = ~Unsigned(0)
 
static constexpr Unsigned Umin = AllZeros
 
static constexpr Unsigned Umax = AllOnes >> (TypeBits - Bits)
 
static constexpr Unsigned SignBitMask = Unsigned(1) << (Bits - 1)
 
static constexpr Unsigned Smax = Umax >> 1U
 
static constexpr Unsigned Smin = ~Smax
 
static constexpr Unsigned SignExtend = Unsigned(Smin << 1U)
 

Detailed Description

template<typename T, unsigned Bits>
struct llvm::bitfields_details::BitPatterns< T, Bits >

A struct defining useful bit patterns for n-bits integer types.

Definition at line 94 of file Bitfields.h.

Member Typedef Documentation

◆ Unsigned

template<typename T , unsigned Bits>
using llvm::bitfields_details::BitPatterns< T, Bits >::Unsigned = std::make_unsigned_t<T>

Bit patterns are forged using the equivalent Unsigned type because of undefined operations over signed types (e.g.

Bitwise shift operators). Moreover same size casting from unsigned to signed is well defined but not the other way around.

Definition at line 99 of file Bitfields.h.

Member Data Documentation

◆ AllOnes

template<typename T , unsigned Bits>
constexpr Unsigned llvm::bitfields_details::BitPatterns< T, Bits >::AllOnes = ~Unsigned(0)
staticconstexpr

Definition at line 107 of file Bitfields.h.

◆ AllZeros

template<typename T , unsigned Bits>
constexpr Unsigned llvm::bitfields_details::BitPatterns< T, Bits >::AllZeros = Unsigned(0)
staticconstexpr

e.g. with TypeBits == 8 and Bits == 6.

Definition at line 106 of file Bitfields.h.

◆ SignBitMask

template<typename T , unsigned Bits>
constexpr Unsigned llvm::bitfields_details::BitPatterns< T, Bits >::SignBitMask = Unsigned(1) << (Bits - 1)
staticconstexpr

◆ SignExtend

template<typename T , unsigned Bits>
constexpr Unsigned llvm::bitfields_details::BitPatterns< T, Bits >::SignExtend = Unsigned(Smin << 1U)
staticconstexpr

◆ Smax

template<typename T , unsigned Bits>
constexpr Unsigned llvm::bitfields_details::BitPatterns< T, Bits >::Smax = Umax >> 1U
staticconstexpr

◆ Smin

template<typename T , unsigned Bits>
constexpr Unsigned llvm::bitfields_details::BitPatterns< T, Bits >::Smin = ~Smax
staticconstexpr

◆ TypeBits

template<typename T , unsigned Bits>
constexpr unsigned llvm::bitfields_details::BitPatterns< T, Bits >::TypeBits = sizeof(Unsigned) * CHAR_BIT
staticconstexpr

Definition at line 102 of file Bitfields.h.

◆ Umax

template<typename T , unsigned Bits>
constexpr Unsigned llvm::bitfields_details::BitPatterns< T, Bits >::Umax = AllOnes >> (TypeBits - Bits)
staticconstexpr

◆ Umin

template<typename T , unsigned Bits>
constexpr Unsigned llvm::bitfields_details::BitPatterns< T, Bits >::Umin = AllZeros
staticconstexpr

Definition at line 108 of file Bitfields.h.


The documentation for this struct was generated from the following file: