asmjit::Support Namespace Reference

Contains support classes and functions that may be used by AsmJit source and header files.

Anything defined here is considered internal and should not be used outside of AsmJit and related projects like AsmTK.

Classes

Typedefs

Enumerations

Functions

Variables

Typedef Documentation

typedef Internal::StdInt<sizeof(uintptr_t), 1>::Type Support::BitWord◆ 

Storage used to store a pack of bits (should by compatible with a machine word).

Enumeration Type Documentation

class Support::SortOrder : uint32_tenumstrong◆ 

Sort order.

ConstantDescription
kAscending 

Ascending order.

Descending order.

Function Documentation

template<typename T>
Internal::Int32Or64<T, 0>::Type Support::asInt(const T& x)constexprstaticconstexprnoexcept◆ 

Casts an integer x to either int32_t or int64_t depending on T.

template<typename T>
Internal::Int32Or64<T, 1>::Type Support::asUInt(const T& x)constexprstaticconstexprnoexcept◆ 

Casts an integer x to either uint32_t or uint64_t depending on T.

template<typename T>
Internal::Int32Or64<T>::Type Support::asNormalized(const T& x)constexprstaticconstexprnoexcept◆ 

Casts an integer x to either int32_t, uint32_t,int64_t, oruint64_tdepending onT`.

template<typename T>
Internal::StdInt<sizeof(T), isUnsigned<T> ()>::Type Support::asStdInt(const T& x)constexprstaticconstexprnoexcept◆ 

Casts an integer x to the same type as defined by <stdint.h>.

template<typename Dst, typename Src>
Dst Support::bitCast(const Src& x)staticnoexcept◆ 

Bit-casts from Src type to Dst type.

Useful to bit-cast between integers and floating points.

template<typename T>
T Support::neg(const T& x)constexprstaticconstexprnoexcept◆ 

Returns 0 - x in a safe way (no undefined behavior), works for unsigned numbers as well.

template<typename X, typename Y>
X Support::shl(const X& x, const Y& y)constexprstaticconstexprnoexcept◆ 

Returns x << y (shift left logical) by explicitly casting x to an unsigned type and back.

template<typename X, typename Y>
X Support::shr(const X& x, const Y& y)constexprstaticconstexprnoexcept◆ 

Returns x >> y (shift right logical) by explicitly casting x to an unsigned type and back.

template<typename X, typename Y>
X Support::sar(const X& x, const Y& y)constexprstaticconstexprnoexcept◆ 

Returns x >> y (shift right arithmetic) by explicitly casting x to a signed type and back.

template<typename X, typename Y>
X Support::or_shr(const X& x, const Y& y)constexprstaticconstexprnoexcept◆ 

Returns x | (x >> y) - helper used by some bit manipulation helpers.

template<typename T>
T Support::blsi(T x)constexprstaticconstexprnoexcept◆ 

Returns x & -x - extracts lowest set isolated bit (like BLSI instruction).

template<typename T, typename IndexT>
bool Support::bitTest(T x, IndexT n)constexprstaticconstexprnoexcept◆ 

Tests whether the given value x has nth bit set.

template<typename T, typename CountT>
T Support::lsbMask(const CountT& n)constexprstaticconstexprnoexcept◆ 

Generates a trailing bit-mask that has n least significant (trailing) bits set.

template<typename T, typename CountT>
T Support::msbMask(const CountT& n)constexprstaticconstexprnoexcept◆ 

Generates a leading bit-mask that has n most significant (leading) bits set.

template<typename Index>
uint32_t Support::bitMask(const Index& x)constexprstaticconstexprnoexcept[1/2]◆ 

Returns a bit-mask that has x bit set.

template<typename Index, typename... Args>
uint32_t Support::bitMask(const Index& x, Args... args)constexprstaticconstexprnoexcept[2/2]◆ 

Returns a bit-mask that has x bit set (multiple arguments).

template<typename DstT, typename SrcT>
DstT Support::bitMaskFromBool(SrcT b)constexprstaticconstexprnoexcept◆ 

Converts a boolean value b to zero or full mask (all bits set).

template<typename A, typename B>
bool Support::test(A a, B b)constexprstaticconstexprnoexcept◆ 

Tests whether a & b is non-zero.

template<typename T>
uint32_t Support::clz(T x)staticnoexcept◆ 

Count leading zeros in x (returns a position of a first bit set in x).

Note
The input MUST NOT be zero, otherwise the result is undefined.

template<typename T>
uint32_t Support::ctz(T x)staticnoexcept◆ 

Count trailing zeros in x (returns a position of a first bit set in x).

Note
The input MUST NOT be zero, otherwise the result is undefined.

template<typename T>
uint32_t Support::popcnt(T x)staticnoexcept◆ 

Calculates count of bits in x.

template<typename T>
uint32_t Support::constPopcnt(T x)staticnoexcept◆ 

Calculates count of bits in x (useful in constant expressions).

template<typename T>
bool Support::isPowerOf2(T x)constexprstaticconstexprnoexcept◆ 

Tests whether the x is a power of two (only one bit is set).

template<typename X, typename Y>
Internal::StdInt<sizeof(X), 1>::Type Support::alignUpDiff(X base, Y alignment)constexprstaticconstexprnoexcept◆ 

Returns either zero or a positive difference between base and base when aligned to alignment.

template<typename X, typename Y>
X Support::numGranularized(X base, Y granularity)constexprstaticconstexprnoexcept◆ 

Calculates the number of elements that would be required if base is granularized by granularity.

This function can be used to calculate the number of BitWords to represent N bits, for example.

template<typename T>
bool Support::isBetween(const T& x, const T& a, const T& b)constexprstaticconstexprnoexcept◆ 

Checks whether x is greater than or equal to a and lesser than or equal to b.

template<typename T>
bool Support::isInt4(T x)constexprstaticconstexprnoexcept◆ 

Checks whether the given integer x can be casted to a 4-bit signed integer.

template<typename T>
bool Support::isInt7(T x)constexprstaticconstexprnoexcept◆ 

Checks whether the given integer x can be casted to a 7-bit signed integer.

template<typename T>
bool Support::isInt8(T x)constexprstaticconstexprnoexcept◆ 

Checks whether the given integer x can be casted to an 8-bit signed integer.

template<typename T>
bool Support::isInt9(T x)constexprstaticconstexprnoexcept◆ 

Checks whether the given integer x can be casted to a 9-bit signed integer.

template<typename T>
bool Support::isInt10(T x)constexprstaticconstexprnoexcept◆ 

Checks whether the given integer x can be casted to a 10-bit signed integer.

template<typename T>
bool Support::isInt16(T x)constexprstaticconstexprnoexcept◆ 

Checks whether the given integer x can be casted to a 16-bit signed integer.

template<typename T>
bool Support::isInt32(T x)constexprstaticconstexprnoexcept◆ 

Checks whether the given integer x can be casted to a 32-bit signed integer.

template<typename T>
bool Support::isUInt4(T x)constexprstaticconstexprnoexcept◆ 

Checks whether the given integer x can be casted to a 4-bit unsigned integer.

template<typename T>
bool Support::isUInt8(T x)constexprstaticconstexprnoexcept◆ 

Checks whether the given integer x can be casted to an 8-bit unsigned integer.

template<typename T>
bool Support::isUInt12(T x)constexprstaticconstexprnoexcept◆ 

Checks whether the given integer x can be casted to a 12-bit unsigned integer (ARM specific).

template<typename T>
bool Support::isUInt16(T x)constexprstaticconstexprnoexcept◆ 

Checks whether the given integer x can be casted to a 16-bit unsigned integer.

template<typename T>
bool Support::isUInt32(T x)constexprstaticconstexprnoexcept◆ 

Checks whether the given integer x can be casted to a 32-bit unsigned integer.

template<typename T>
bool Support::isIntOrUInt32(T x)constexprstaticconstexprnoexcept◆ 

Checks whether the given integer x can be casted to a 32-bit unsigned integer.

uint32_t Support::bytepack32_4x8(uint32_t a, uint32_t b, uint32_t c, uint32_t d)constexprstaticconstexprnoexcept◆ 

Pack four 8-bit integer into a 32-bit integer as it is an array of {b0,b1,b2,b3}.

int Support::compareStringViews(const char* aData, size_t aSize, const char* bData, size_t bSize)staticnoexcept◆ 

Compares two string views.

template<typename T>
bool Support::bitVectorGetBit(T* buf, size_t index)staticnoexcept◆ 

Sets bit in a bit-vector buf at index.

template<typename T>
void Support::bitVectorSetBit(T* buf, size_t index, bool value)staticnoexcept◆ 

Sets bit in a bit-vector buf at index to value.

template<typename T>
void Support::bitVectorFlipBit(T* buf, size_t index)staticnoexcept◆ 

Sets bit in a bit-vector buf at index to value.

template<typename T>
void Support::bitVectorFill(T* buf, size_t index, size_t count)staticnoexcept◆ 

Fills count bits in bit-vector buf starting at bit-index index.

template<typename T>
void Support::bitVectorClear(T* buf, size_t index, size_t count)staticnoexcept◆ 

Clears count bits in bit-vector buf starting at bit-index index.

template<typename T, typename CompareT = Compare<SortOrder::kAscending>>
void Support::iSort(T* base, size_t size, const CompareT& cmp = CompareT())staticnoexcept◆ 

Insertion sort.

template<typename T, class CompareT = Compare<SortOrder::kAscending>>
void Support::qSort(T* base, size_t size, const CompareT& cmp = CompareT())staticnoexcept◆ 

Quick sort implementation.

The main reason to provide a custom qsort implementation is that we needed something that will never throw bad_alloc exception. This implementation doesn't use dynamic memory allocation.

Variable Documentation

uint32_t Support::kBitWordSizeInBits = bitSizeOf<BitWord>()constexprstaticconstexpr◆ 

Number of bits stored in a single BitWord.