Intel® C++ Compiler Classic Developer Guide and Reference

ID 767249
Date 3/31/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

Miscellaneous Intrinsics

The following tables list and describe intrinsics that you can use across all Intel® architectures, except where noted. These intrinsics are available for both Intel® and non-Intel microprocessors but they may perform additional optimizations for Intel® microprocessors than they perform for non-Intel microprocessors.

NOTE:

Casting functions for various INT and FP types for use in intrinsic functions across Intel® architectures only change the type; they do not convert between integer and floating point values.

Intrinsic

Description

Intrinsics for all Supported Intel® Architectures

__cpuid

Queries the processor for information about processor type and supported features. The Intel® C++ Compiler Classic supports the Microsoft* implementation of this intrinsic. See the Microsoft documentation for details.

void *_alloca(int)

Allocates memory in the local stack frame. The memory is automatically freed upon return from the function.

int _bit_scan_forward(int x)

Returns the bit index of the least significant set bit of x. If x is 0, the result is undefined.

int _bit_scan_reverse(int)

Returns the bit index of the most significant set bit of x. If xis 0, the result is undefined.

unsigned char _BitScanForward(unsigned __int32 *p, unsigned __int32 b);

and for Intel® 64 architecture only:

unsigned char _BitScanForward64(unsigned __int32 *p, unsigned __int64 b);

Sets *p to the bit index of the least significant set bit of b or leaves it unchanged if b is zero. The function returns a non-zero result when b is non-zero and returns zero when b is zero.

unsigned char _BitScanReverse(unsigned __int32 *p, unsigned __int32 b);

and for Intel® 64 architecture only:

unsigned char _BitScanReverse64(unsigned __int32 *p, unsigned __int64 b);

Sets *p to the bit index of the most significant set bit of b or leaves it unchanged if b is zero. The function returns a non-zero result when b is non-zero and returns zero when b is zero.

unsigned char _bittest(__int32 *p, __int32 b);

and for Intel® 64 architecture only:

unsigned char _bittest64(__int64 *p, __int64 b);

Returns the bit in position b of the memory addressed by p.

unsigned char _bittestandcomplement(__int32 *p, __int32 b);

and for Intel® 64 architecture only:

unsigned char _bittestandcomplement64(__int64 *p, __int64 b);

Returns the bit in position b of the memory addressed by p, then compliments that bit.

unsigned char _bittestandreset(__int32 *p, __int32 b);

and for Intel® 64 architecture only:

unsigned char _bittestandreset64(__int64 *p, __int64 b);

Returns the bit in position b of the memory addressed by p, then resets that bit to 0.

unsigned char _bittestandset(__int32 *p, __int32 b);

and for Intel® 64 architecture only:

unsigned char _bittestandset64(__int64 *p, __int64 b);

Returns the bit in position b of the memory addressed by p, then sets the bit to 1.

int _bswap(int)

Reverses the byte order of x. Swaps 4 bytes; bits 0-7 are swapped with bits 24-31, bits 8-15 are swapped with bits 16-23.

__int64 _bswap64(__int64 x)

Reverses the byte order of x. Swaps 8 bytes; bits 0-7 are swapped with bits 56-63, bits 8-15 are swapped with bits 48-55, bits 16-23 are swapped with bits 40-47, and bits 24-31 are swapped with bits 32-39.

unsigned int __cacheSize(unsigned int cacheLevel)

__cacheSize(n) returns the size in kilobytes of the cache at level n. 1 represents the first-level cache. 0 is returned for a non-existent cache level. For example, an application may query the cache size and use it to select block sizes in algorithms that operate on matrices.

void _enable(void)

Enables the interrupt.

unsigned __int32 _castf32_u32(float)

Casts float value to unsigned 32-bit integer.

unsigned __int64 _castf64_u64(double)

Casts double value to unsigned 64-bit integer.

float _castu32_f32(unsigned __int32)

Casts unsigned 32-bit integer to float32.

double _castu64_f64(unsigned __int64)

Casts unsigned 32-bit integer to float64.

void _disable(void)

Disables the interrupt.

int _in_byte(int)

Intrinsic that maps to the IA-32 instruction IN. Transfer data byte from port specified by argument.

int _in_dword(int)

Intrinsic that maps to the IA-32 instruction IN. Transfer double word from port specified by argument.

int _in_word(int)

Intrinsic that maps to the IA-32 instruction IN. Transfer word from port specified by argument.

int _inp(int)

Same as _in_byte.

int _inpd(int)

Same as _in_dword.

int _inpw(int)

Same as _in_word.

int _out_byte(int, int)

Intrinsic that maps to the IA-32 instruction OUT. Transfer data byte in second argument to port specified by first argument.

int _out_dword(int, int)

Intrinsic that maps to the IA-32 instruction OUT. Transfer double word in second argument to port specified by first argument.

int _out_word(int, int)

Intrinsic that maps to the IA-32 instruction OUT. Transfer word in second argument to port specified by first argument.

int _outp(int, int)

Same as _out_byte.

int _outpw(int, int)

Same as _out_word.

int _outpd(int, int)

Same as _out_dword.

int _popcnt32(int x)

Returns the number of set bits in x.

int _popcnt64(__int64 x)

Returns the number of set bits in x.

__int64 _rdpmc(int p)

Returns the current value of the 40-bit performance monitoring counter specified by p.

Intrinsics for IA-32 and Intel® 64 Architectures

__int64 _rdtsc(void)

Returns the current value of the processor's 64-bit time stamp counter.

int _setjmp(jmp_buf)

A fast version of setjmp(), which bypasses the termination handling. Saves the callee-save registers, stack pointer and return address.

int __pin_value(char *annotation) Bypasses code that executes only in PIN mode. Especially useful with Intel® oneAPI Threading Building Blocks (oneTBB), which adds specified annotations to the object file so that code is executed in PIN mode.