proxygen
folly::compression::instructions::Haswell Struct Reference

#include <Instructions.h>

Inheritance diagram for folly::compression::instructions::Haswell:
folly::compression::instructions::Nehalem folly::compression::instructions::Default

Static Public Member Functions

static bool supported (const folly::CpuId &cpuId={})
 
static FOLLY_ALWAYS_INLINE uint64_t blsr (uint64_t value)
 
static FOLLY_ALWAYS_INLINE uint64_t bextr (uint64_t value, uint32_t start, uint32_t length)
 
static FOLLY_ALWAYS_INLINE uint64_t bzhi (uint64_t value, uint32_t index)
 
- Static Public Member Functions inherited from folly::compression::instructions::Nehalem
static bool supported (const folly::CpuId &cpuId={})
 
static FOLLY_ALWAYS_INLINE uint64_t popcount (uint64_t value)
 
- Static Public Member Functions inherited from folly::compression::instructions::Default
static bool supported (const folly::CpuId &={})
 
static FOLLY_ALWAYS_INLINE uint64_t popcount (uint64_t value)
 
static FOLLY_ALWAYS_INLINE int ctz (uint64_t value)
 
static FOLLY_ALWAYS_INLINE int clz (uint64_t value)
 
static FOLLY_ALWAYS_INLINE uint64_t blsr (uint64_t value)
 
static FOLLY_ALWAYS_INLINE uint64_t bextr (uint64_t value, uint32_t start, uint32_t length)
 
static FOLLY_ALWAYS_INLINE uint64_t bzhi (uint64_t value, uint32_t index)
 

Detailed Description

Definition at line 104 of file Instructions.h.

Member Function Documentation

static FOLLY_ALWAYS_INLINE uint64_t folly::compression::instructions::Haswell::bextr ( uint64_t  value,
uint32_t  start,
uint32_t  length 
)
inlinestatic

Definition at line 123 of file Instructions.h.

References uint64_t.

Referenced by TEST().

123  {
124 #if defined(__GNUC__) || defined(__clang__)
125  // GCC and Clang won't inline the intrinsics.
126  // Encode parameters in `pattern` where `pattern[0:7]` is `start` and
127  // `pattern[8:15]` is `length`.
128  // Ref: Intel Advanced Vector Extensions Programming Reference
129  uint64_t pattern = start & 0xFF;
130  pattern = pattern | ((length & 0xFF) << 8);
131  uint64_t result;
132  asm("bextrq %2, %1, %0" : "=r"(result) : "r"(value), "r"(pattern));
133  return result;
134 #else
135  return _bextr_u64(value, start, length);
136 #endif
137  }
auto start
uint64_t value(const typename LockFreeRingBuffer< T, Atom >::Cursor &rbcursor)
static FOLLY_ALWAYS_INLINE uint64_t folly::compression::instructions::Haswell::blsr ( uint64_t  value)
inlinestatic

Definition at line 109 of file Instructions.h.

References FOLLY_ALWAYS_INLINE, and uint64_t.

109  {
110 // BMI1 is supported starting with Intel Haswell, AMD Piledriver.
111 // BLSR combines two instructions into one and reduces register pressure.
112 #if defined(__GNUC__) || defined(__clang__)
113  // GCC and Clang won't inline the intrinsics.
114  uint64_t result;
115  asm("blsrq %1, %0" : "=r"(result) : "r"(value));
116  return result;
117 #else
118  return _blsr_u64(value);
119 #endif
120  }
uint64_t value(const typename LockFreeRingBuffer< T, Atom >::Cursor &rbcursor)
static FOLLY_ALWAYS_INLINE uint64_t folly::compression::instructions::Haswell::bzhi ( uint64_t  value,
uint32_t  index 
)
inlinestatic

Definition at line 139 of file Instructions.h.

References uint64_t.

139  {
140 #if defined(__GNUC__) || defined(__clang__)
141  // GCC and Clang won't inline the intrinsics.
142  const uint64_t index64 = index;
143  uint64_t result;
144  asm("bzhiq %2, %1, %0" : "=r"(result) : "r"(value), "r"(index64));
145  return result;
146 #else
147  return _bzhi_u64(value, index);
148 #endif
149  }
uint64_t value(const typename LockFreeRingBuffer< T, Atom >::Cursor &rbcursor)
static bool folly::compression::instructions::Haswell::supported ( const folly::CpuId cpuId = {})
inlinestatic

Definition at line 105 of file Instructions.h.

References folly::compression::instructions::Nehalem::supported().

Referenced by folly::compression::instructions::detect().

105  {}) {
106  return Nehalem::supported(cpuId) && cpuId.bmi1() && cpuId.bmi2();
107  }
FOLLY_ALWAYS_INLINE bool bmi2() const
Definition: CpuId.h:183
FOLLY_ALWAYS_INLINE bool bmi1() const
Definition: CpuId.h:179
static bool supported(const folly::CpuId &cpuId={})
Definition: Instructions.h:87

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