Home | History | Annotate | Line # | Download | only in Headers
      1      1.1  joerg /* ===-------- ia32intrin.h ---------------------------------------------------===
      2      1.1  joerg  *
      3      1.1  joerg  * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
      4      1.1  joerg  * See https://llvm.org/LICENSE.txt for license information.
      5      1.1  joerg  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
      6      1.1  joerg  *
      7      1.1  joerg  *===-----------------------------------------------------------------------===
      8      1.1  joerg  */
      9      1.1  joerg 
     10      1.1  joerg #ifndef __X86INTRIN_H
     11      1.1  joerg #error "Never use <ia32intrin.h> directly; include <x86intrin.h> instead."
     12      1.1  joerg #endif
     13      1.1  joerg 
     14      1.1  joerg #ifndef __IA32INTRIN_H
     15      1.1  joerg #define __IA32INTRIN_H
     16      1.1  joerg 
     17  1.1.1.2  joerg /* Define the default attributes for the functions in this file. */
     18  1.1.1.2  joerg #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
     19  1.1.1.2  joerg #define __DEFAULT_FN_ATTRS_SSE42 __attribute__((__always_inline__, __nodebug__, __target__("sse4.2")))
     20  1.1.1.2  joerg 
     21  1.1.1.2  joerg #if defined(__cplusplus) && (__cplusplus >= 201103L)
     22  1.1.1.2  joerg #define __DEFAULT_FN_ATTRS_CAST __attribute__((__always_inline__)) constexpr
     23  1.1.1.2  joerg #define __DEFAULT_FN_ATTRS_CONSTEXPR __DEFAULT_FN_ATTRS constexpr
     24  1.1.1.2  joerg #else
     25  1.1.1.2  joerg #define __DEFAULT_FN_ATTRS_CAST __attribute__((__always_inline__))
     26  1.1.1.2  joerg #define __DEFAULT_FN_ATTRS_CONSTEXPR __DEFAULT_FN_ATTRS
     27  1.1.1.2  joerg #endif
     28  1.1.1.2  joerg 
     29      1.1  joerg /** Find the first set bit starting from the lsb. Result is undefined if
     30      1.1  joerg  *  input is 0.
     31      1.1  joerg  *
     32      1.1  joerg  *  \headerfile <x86intrin.h>
     33      1.1  joerg  *
     34      1.1  joerg  *  This intrinsic corresponds to the <c> BSF </c> instruction or the
     35      1.1  joerg  *  <c> TZCNT </c> instruction.
     36      1.1  joerg  *
     37      1.1  joerg  *  \param __A
     38      1.1  joerg  *     A 32-bit integer operand.
     39      1.1  joerg  *  \returns A 32-bit integer containing the bit number.
     40      1.1  joerg  */
     41  1.1.1.2  joerg static __inline__ int __DEFAULT_FN_ATTRS_CONSTEXPR
     42      1.1  joerg __bsfd(int __A) {
     43      1.1  joerg   return __builtin_ctz(__A);
     44      1.1  joerg }
     45      1.1  joerg 
     46      1.1  joerg /** Find the first set bit starting from the msb. Result is undefined if
     47      1.1  joerg  *  input is 0.
     48      1.1  joerg  *
     49      1.1  joerg  *  \headerfile <x86intrin.h>
     50      1.1  joerg  *
     51      1.1  joerg  *  This intrinsic corresponds to the <c> BSR </c> instruction or the
     52      1.1  joerg  *  <c> LZCNT </c> instruction and an <c> XOR </c>.
     53      1.1  joerg  *
     54      1.1  joerg  *  \param __A
     55      1.1  joerg  *     A 32-bit integer operand.
     56      1.1  joerg  *  \returns A 32-bit integer containing the bit number.
     57      1.1  joerg  */
     58  1.1.1.2  joerg static __inline__ int __DEFAULT_FN_ATTRS_CONSTEXPR
     59      1.1  joerg __bsrd(int __A) {
     60      1.1  joerg   return 31 - __builtin_clz(__A);
     61      1.1  joerg }
     62      1.1  joerg 
     63      1.1  joerg /** Swaps the bytes in the input. Converting little endian to big endian or
     64      1.1  joerg  *  vice versa.
     65      1.1  joerg  *
     66      1.1  joerg  *  \headerfile <x86intrin.h>
     67      1.1  joerg  *
     68      1.1  joerg  *  This intrinsic corresponds to the <c> BSWAP </c> instruction.
     69      1.1  joerg  *
     70      1.1  joerg  *  \param __A
     71      1.1  joerg  *     A 32-bit integer operand.
     72      1.1  joerg  *  \returns A 32-bit integer containing the swapped bytes.
     73      1.1  joerg  */
     74  1.1.1.2  joerg static __inline__ int __DEFAULT_FN_ATTRS_CONSTEXPR
     75      1.1  joerg __bswapd(int __A) {
     76      1.1  joerg   return __builtin_bswap32(__A);
     77      1.1  joerg }
     78      1.1  joerg 
     79  1.1.1.2  joerg static __inline__ int __DEFAULT_FN_ATTRS_CONSTEXPR
     80      1.1  joerg _bswap(int __A) {
     81      1.1  joerg   return __builtin_bswap32(__A);
     82      1.1  joerg }
     83      1.1  joerg 
     84      1.1  joerg #define _bit_scan_forward(A) __bsfd((A))
     85      1.1  joerg #define _bit_scan_reverse(A) __bsrd((A))
     86      1.1  joerg 
     87      1.1  joerg #ifdef __x86_64__
     88      1.1  joerg /** Find the first set bit starting from the lsb. Result is undefined if
     89      1.1  joerg  *  input is 0.
     90      1.1  joerg  *
     91      1.1  joerg  *  \headerfile <x86intrin.h>
     92      1.1  joerg  *
     93      1.1  joerg  *  This intrinsic corresponds to the <c> BSF </c> instruction or the
     94      1.1  joerg  *  <c> TZCNT </c> instruction.
     95      1.1  joerg  *
     96      1.1  joerg  *  \param __A
     97      1.1  joerg  *     A 64-bit integer operand.
     98      1.1  joerg  *  \returns A 32-bit integer containing the bit number.
     99      1.1  joerg  */
    100  1.1.1.2  joerg static __inline__ int __DEFAULT_FN_ATTRS_CONSTEXPR
    101      1.1  joerg __bsfq(long long __A) {
    102      1.1  joerg   return __builtin_ctzll(__A);
    103      1.1  joerg }
    104      1.1  joerg 
    105      1.1  joerg /** Find the first set bit starting from the msb. Result is undefined if
    106      1.1  joerg  *  input is 0.
    107      1.1  joerg  *
    108      1.1  joerg  *  \headerfile <x86intrin.h>
    109      1.1  joerg  *
    110      1.1  joerg  *  This intrinsic corresponds to the <c> BSR </c> instruction or the
    111      1.1  joerg  *  <c> LZCNT </c> instruction and an <c> XOR </c>.
    112      1.1  joerg  *
    113      1.1  joerg  *  \param __A
    114      1.1  joerg  *     A 64-bit integer operand.
    115      1.1  joerg  *  \returns A 32-bit integer containing the bit number.
    116      1.1  joerg  */
    117  1.1.1.2  joerg static __inline__ int __DEFAULT_FN_ATTRS_CONSTEXPR
    118      1.1  joerg __bsrq(long long __A) {
    119      1.1  joerg   return 63 - __builtin_clzll(__A);
    120      1.1  joerg }
    121      1.1  joerg 
    122      1.1  joerg /** Swaps the bytes in the input. Converting little endian to big endian or
    123      1.1  joerg  *  vice versa.
    124      1.1  joerg  *
    125      1.1  joerg  *  \headerfile <x86intrin.h>
    126      1.1  joerg  *
    127      1.1  joerg  *  This intrinsic corresponds to the <c> BSWAP </c> instruction.
    128      1.1  joerg  *
    129      1.1  joerg  *  \param __A
    130      1.1  joerg  *     A 64-bit integer operand.
    131      1.1  joerg  *  \returns A 64-bit integer containing the swapped bytes.
    132      1.1  joerg  */
    133  1.1.1.2  joerg static __inline__ long long __DEFAULT_FN_ATTRS_CONSTEXPR
    134      1.1  joerg __bswapq(long long __A) {
    135      1.1  joerg   return __builtin_bswap64(__A);
    136      1.1  joerg }
    137      1.1  joerg 
    138      1.1  joerg #define _bswap64(A) __bswapq((A))
    139      1.1  joerg #endif
    140      1.1  joerg 
    141      1.1  joerg /** Counts the number of bits in the source operand having a value of 1.
    142      1.1  joerg  *
    143      1.1  joerg  *  \headerfile <x86intrin.h>
    144      1.1  joerg  *
    145      1.1  joerg  *  This intrinsic corresponds to the <c> POPCNT </c> instruction or a
    146      1.1  joerg  *  a sequence of arithmetic and logic ops to calculate it.
    147      1.1  joerg  *
    148      1.1  joerg  *  \param __A
    149      1.1  joerg  *     An unsigned 32-bit integer operand.
    150      1.1  joerg  *  \returns A 32-bit integer containing the number of bits with value 1 in the
    151      1.1  joerg  *     source operand.
    152      1.1  joerg  */
    153  1.1.1.2  joerg static __inline__ int __DEFAULT_FN_ATTRS_CONSTEXPR
    154      1.1  joerg __popcntd(unsigned int __A)
    155      1.1  joerg {
    156      1.1  joerg   return __builtin_popcount(__A);
    157      1.1  joerg }
    158      1.1  joerg 
    159      1.1  joerg #define _popcnt32(A) __popcntd((A))
    160      1.1  joerg 
    161      1.1  joerg #ifdef __x86_64__
    162      1.1  joerg /** Counts the number of bits in the source operand having a value of 1.
    163      1.1  joerg  *
    164      1.1  joerg  *  \headerfile <x86intrin.h>
    165      1.1  joerg  *
    166      1.1  joerg  *  This intrinsic corresponds to the <c> POPCNT </c> instruction or a
    167      1.1  joerg  *  a sequence of arithmetic and logic ops to calculate it.
    168      1.1  joerg  *
    169      1.1  joerg  *  \param __A
    170      1.1  joerg  *     An unsigned 64-bit integer operand.
    171      1.1  joerg  *  \returns A 64-bit integer containing the number of bits with value 1 in the
    172      1.1  joerg  *     source operand.
    173      1.1  joerg  */
    174  1.1.1.2  joerg static __inline__ long long __DEFAULT_FN_ATTRS_CONSTEXPR
    175      1.1  joerg __popcntq(unsigned long long __A)
    176      1.1  joerg {
    177      1.1  joerg   return __builtin_popcountll(__A);
    178      1.1  joerg }
    179      1.1  joerg 
    180      1.1  joerg #define _popcnt64(A) __popcntq((A))
    181      1.1  joerg #endif /* __x86_64__ */
    182      1.1  joerg 
    183      1.1  joerg #ifdef __x86_64__
    184  1.1.1.2  joerg static __inline__ unsigned long long __DEFAULT_FN_ATTRS
    185      1.1  joerg __readeflags(void)
    186      1.1  joerg {
    187      1.1  joerg   return __builtin_ia32_readeflags_u64();
    188      1.1  joerg }
    189      1.1  joerg 
    190  1.1.1.2  joerg static __inline__ void __DEFAULT_FN_ATTRS
    191      1.1  joerg __writeeflags(unsigned long long __f)
    192      1.1  joerg {
    193      1.1  joerg   __builtin_ia32_writeeflags_u64(__f);
    194      1.1  joerg }
    195      1.1  joerg 
    196      1.1  joerg #else /* !__x86_64__ */
    197  1.1.1.2  joerg static __inline__ unsigned int __DEFAULT_FN_ATTRS
    198      1.1  joerg __readeflags(void)
    199      1.1  joerg {
    200      1.1  joerg   return __builtin_ia32_readeflags_u32();
    201      1.1  joerg }
    202      1.1  joerg 
    203  1.1.1.2  joerg static __inline__ void __DEFAULT_FN_ATTRS
    204      1.1  joerg __writeeflags(unsigned int __f)
    205      1.1  joerg {
    206      1.1  joerg   __builtin_ia32_writeeflags_u32(__f);
    207      1.1  joerg }
    208      1.1  joerg #endif /* !__x86_64__ */
    209      1.1  joerg 
    210      1.1  joerg /** Cast a 32-bit float value to a 32-bit unsigned integer value
    211      1.1  joerg  *
    212      1.1  joerg  *  \headerfile <x86intrin.h>
    213      1.1  joerg  *  This intrinsic corresponds to the <c> VMOVD / MOVD </c> instruction in x86_64,
    214      1.1  joerg  *  and corresponds to the <c> VMOVL / MOVL </c> instruction in ia32.
    215      1.1  joerg  *
    216      1.1  joerg  *  \param __A
    217      1.1  joerg  *     A 32-bit float value.
    218      1.1  joerg  *  \returns a 32-bit unsigned integer containing the converted value.
    219      1.1  joerg  */
    220  1.1.1.2  joerg static __inline__ unsigned int __DEFAULT_FN_ATTRS_CAST
    221      1.1  joerg _castf32_u32(float __A) {
    222  1.1.1.2  joerg   return __builtin_bit_cast(unsigned int, __A);
    223      1.1  joerg }
    224      1.1  joerg 
    225      1.1  joerg /** Cast a 64-bit float value to a 64-bit unsigned integer value
    226      1.1  joerg  *
    227      1.1  joerg  *  \headerfile <x86intrin.h>
    228      1.1  joerg  *  This intrinsic corresponds to the <c> VMOVQ / MOVQ </c> instruction in x86_64,
    229      1.1  joerg  *  and corresponds to the <c> VMOVL / MOVL </c> instruction in ia32.
    230      1.1  joerg  *
    231      1.1  joerg  *  \param __A
    232      1.1  joerg  *     A 64-bit float value.
    233      1.1  joerg  *  \returns a 64-bit unsigned integer containing the converted value.
    234      1.1  joerg  */
    235  1.1.1.2  joerg static __inline__ unsigned long long __DEFAULT_FN_ATTRS_CAST
    236      1.1  joerg _castf64_u64(double __A) {
    237  1.1.1.2  joerg   return __builtin_bit_cast(unsigned long long, __A);
    238      1.1  joerg }
    239      1.1  joerg 
    240      1.1  joerg /** Cast a 32-bit unsigned integer value to a 32-bit float value
    241      1.1  joerg  *
    242      1.1  joerg  *  \headerfile <x86intrin.h>
    243      1.1  joerg  *  This intrinsic corresponds to the <c> VMOVQ / MOVQ </c> instruction in x86_64,
    244      1.1  joerg  *  and corresponds to the <c> FLDS </c> instruction in ia32.
    245      1.1  joerg  *
    246      1.1  joerg  *  \param __A
    247      1.1  joerg  *     A 32-bit unsigned integer value.
    248      1.1  joerg  *  \returns a 32-bit float value containing the converted value.
    249      1.1  joerg  */
    250  1.1.1.2  joerg static __inline__ float __DEFAULT_FN_ATTRS_CAST
    251      1.1  joerg _castu32_f32(unsigned int __A) {
    252  1.1.1.2  joerg   return __builtin_bit_cast(float, __A);
    253      1.1  joerg }
    254      1.1  joerg 
    255      1.1  joerg /** Cast a 64-bit unsigned integer value to a 64-bit float value
    256      1.1  joerg  *
    257      1.1  joerg  *  \headerfile <x86intrin.h>
    258      1.1  joerg  *  This intrinsic corresponds to the <c> VMOVQ / MOVQ </c> instruction in x86_64,
    259      1.1  joerg  *  and corresponds to the <c> FLDL </c> instruction in ia32.
    260      1.1  joerg  *
    261      1.1  joerg  *  \param __A
    262      1.1  joerg  *     A 64-bit unsigned integer value.
    263      1.1  joerg  *  \returns a 64-bit float value containing the converted value.
    264      1.1  joerg  */
    265  1.1.1.2  joerg static __inline__ double __DEFAULT_FN_ATTRS_CAST
    266      1.1  joerg _castu64_f64(unsigned long long __A) {
    267  1.1.1.2  joerg   return __builtin_bit_cast(double, __A);
    268      1.1  joerg }
    269      1.1  joerg 
    270      1.1  joerg /** Adds the unsigned integer operand to the CRC-32C checksum of the
    271      1.1  joerg  *     unsigned char operand.
    272      1.1  joerg  *
    273      1.1  joerg  *  \headerfile <x86intrin.h>
    274      1.1  joerg  *
    275      1.1  joerg  *  This intrinsic corresponds to the <c> CRC32B </c> instruction.
    276      1.1  joerg  *
    277      1.1  joerg  *  \param __C
    278      1.1  joerg  *     An unsigned integer operand to add to the CRC-32C checksum of operand
    279      1.1  joerg  *     \a  __D.
    280      1.1  joerg  *  \param __D
    281      1.1  joerg  *     An unsigned 8-bit integer operand used to compute the CRC-32C checksum.
    282      1.1  joerg  *  \returns The result of adding operand \a __C to the CRC-32C checksum of
    283      1.1  joerg  *     operand \a __D.
    284      1.1  joerg  */
    285  1.1.1.2  joerg static __inline__ unsigned int __DEFAULT_FN_ATTRS_SSE42
    286      1.1  joerg __crc32b(unsigned int __C, unsigned char __D)
    287      1.1  joerg {
    288      1.1  joerg   return __builtin_ia32_crc32qi(__C, __D);
    289      1.1  joerg }
    290      1.1  joerg 
    291      1.1  joerg /** Adds the unsigned integer operand to the CRC-32C checksum of the
    292      1.1  joerg  *     unsigned short operand.
    293      1.1  joerg  *
    294      1.1  joerg  *  \headerfile <x86intrin.h>
    295      1.1  joerg  *
    296      1.1  joerg  *  This intrinsic corresponds to the <c> CRC32W </c> instruction.
    297      1.1  joerg  *
    298      1.1  joerg  *  \param __C
    299      1.1  joerg  *     An unsigned integer operand to add to the CRC-32C checksum of operand
    300      1.1  joerg  *     \a  __D.
    301      1.1  joerg  *  \param __D
    302      1.1  joerg  *     An unsigned 16-bit integer operand used to compute the CRC-32C checksum.
    303      1.1  joerg  *  \returns The result of adding operand \a __C to the CRC-32C checksum of
    304      1.1  joerg  *     operand \a __D.
    305      1.1  joerg  */
    306  1.1.1.2  joerg static __inline__ unsigned int __DEFAULT_FN_ATTRS_SSE42
    307      1.1  joerg __crc32w(unsigned int __C, unsigned short __D)
    308      1.1  joerg {
    309      1.1  joerg   return __builtin_ia32_crc32hi(__C, __D);
    310      1.1  joerg }
    311      1.1  joerg 
    312      1.1  joerg /** Adds the unsigned integer operand to the CRC-32C checksum of the
    313      1.1  joerg  *     second unsigned integer operand.
    314      1.1  joerg  *
    315      1.1  joerg  *  \headerfile <x86intrin.h>
    316      1.1  joerg  *
    317      1.1  joerg  *  This intrinsic corresponds to the <c> CRC32D </c> instruction.
    318      1.1  joerg  *
    319      1.1  joerg  *  \param __C
    320      1.1  joerg  *     An unsigned integer operand to add to the CRC-32C checksum of operand
    321      1.1  joerg  *     \a  __D.
    322      1.1  joerg  *  \param __D
    323      1.1  joerg  *     An unsigned 32-bit integer operand used to compute the CRC-32C checksum.
    324      1.1  joerg  *  \returns The result of adding operand \a __C to the CRC-32C checksum of
    325      1.1  joerg  *     operand \a __D.
    326      1.1  joerg  */
    327  1.1.1.2  joerg static __inline__ unsigned int __DEFAULT_FN_ATTRS_SSE42
    328      1.1  joerg __crc32d(unsigned int __C, unsigned int __D)
    329      1.1  joerg {
    330      1.1  joerg   return __builtin_ia32_crc32si(__C, __D);
    331      1.1  joerg }
    332      1.1  joerg 
    333      1.1  joerg #ifdef __x86_64__
    334      1.1  joerg /** Adds the unsigned integer operand to the CRC-32C checksum of the
    335      1.1  joerg  *     unsigned 64-bit integer operand.
    336      1.1  joerg  *
    337      1.1  joerg  *  \headerfile <x86intrin.h>
    338      1.1  joerg  *
    339      1.1  joerg  *  This intrinsic corresponds to the <c> CRC32Q </c> instruction.
    340      1.1  joerg  *
    341      1.1  joerg  *  \param __C
    342      1.1  joerg  *     An unsigned integer operand to add to the CRC-32C checksum of operand
    343      1.1  joerg  *     \a  __D.
    344      1.1  joerg  *  \param __D
    345      1.1  joerg  *     An unsigned 64-bit integer operand used to compute the CRC-32C checksum.
    346      1.1  joerg  *  \returns The result of adding operand \a __C to the CRC-32C checksum of
    347      1.1  joerg  *     operand \a __D.
    348      1.1  joerg  */
    349  1.1.1.2  joerg static __inline__ unsigned long long __DEFAULT_FN_ATTRS_SSE42
    350      1.1  joerg __crc32q(unsigned long long __C, unsigned long long __D)
    351      1.1  joerg {
    352      1.1  joerg   return __builtin_ia32_crc32di(__C, __D);
    353      1.1  joerg }
    354      1.1  joerg #endif /* __x86_64__ */
    355      1.1  joerg 
    356  1.1.1.2  joerg static __inline__ unsigned long long __DEFAULT_FN_ATTRS
    357      1.1  joerg __rdpmc(int __A) {
    358      1.1  joerg   return __builtin_ia32_rdpmc(__A);
    359      1.1  joerg }
    360      1.1  joerg 
    361      1.1  joerg /* __rdtscp */
    362  1.1.1.2  joerg static __inline__ unsigned long long __DEFAULT_FN_ATTRS
    363      1.1  joerg __rdtscp(unsigned int *__A) {
    364      1.1  joerg   return __builtin_ia32_rdtscp(__A);
    365      1.1  joerg }
    366      1.1  joerg 
    367      1.1  joerg #define _rdtsc() __rdtsc()
    368      1.1  joerg 
    369      1.1  joerg #define _rdpmc(A) __rdpmc(A)
    370      1.1  joerg 
    371  1.1.1.2  joerg static __inline__ void __DEFAULT_FN_ATTRS
    372      1.1  joerg _wbinvd(void) {
    373      1.1  joerg   __builtin_ia32_wbinvd();
    374      1.1  joerg }
    375      1.1  joerg 
    376  1.1.1.2  joerg static __inline__ unsigned char __DEFAULT_FN_ATTRS_CONSTEXPR
    377      1.1  joerg __rolb(unsigned char __X, int __C) {
    378      1.1  joerg   return __builtin_rotateleft8(__X, __C);
    379      1.1  joerg }
    380      1.1  joerg 
    381  1.1.1.2  joerg static __inline__ unsigned char __DEFAULT_FN_ATTRS_CONSTEXPR
    382      1.1  joerg __rorb(unsigned char __X, int __C) {
    383      1.1  joerg   return __builtin_rotateright8(__X, __C);
    384      1.1  joerg }
    385      1.1  joerg 
    386  1.1.1.2  joerg static __inline__ unsigned short __DEFAULT_FN_ATTRS_CONSTEXPR
    387      1.1  joerg __rolw(unsigned short __X, int __C) {
    388      1.1  joerg   return __builtin_rotateleft16(__X, __C);
    389      1.1  joerg }
    390      1.1  joerg 
    391  1.1.1.2  joerg static __inline__ unsigned short __DEFAULT_FN_ATTRS_CONSTEXPR
    392      1.1  joerg __rorw(unsigned short __X, int __C) {
    393      1.1  joerg   return __builtin_rotateright16(__X, __C);
    394      1.1  joerg }
    395      1.1  joerg 
    396  1.1.1.2  joerg static __inline__ unsigned int __DEFAULT_FN_ATTRS_CONSTEXPR
    397      1.1  joerg __rold(unsigned int __X, int __C) {
    398      1.1  joerg   return __builtin_rotateleft32(__X, __C);
    399      1.1  joerg }
    400      1.1  joerg 
    401  1.1.1.2  joerg static __inline__ unsigned int __DEFAULT_FN_ATTRS_CONSTEXPR
    402      1.1  joerg __rord(unsigned int __X, int __C) {
    403      1.1  joerg   return __builtin_rotateright32(__X, __C);
    404      1.1  joerg }
    405      1.1  joerg 
    406      1.1  joerg #ifdef __x86_64__
    407  1.1.1.2  joerg static __inline__ unsigned long long __DEFAULT_FN_ATTRS_CONSTEXPR
    408      1.1  joerg __rolq(unsigned long long __X, int __C) {
    409      1.1  joerg   return __builtin_rotateleft64(__X, __C);
    410      1.1  joerg }
    411      1.1  joerg 
    412  1.1.1.2  joerg static __inline__ unsigned long long __DEFAULT_FN_ATTRS_CONSTEXPR
    413      1.1  joerg __rorq(unsigned long long __X, int __C) {
    414      1.1  joerg   return __builtin_rotateright64(__X, __C);
    415      1.1  joerg }
    416      1.1  joerg #endif /* __x86_64__ */
    417      1.1  joerg 
    418      1.1  joerg #ifndef _MSC_VER
    419      1.1  joerg /* These are already provided as builtins for MSVC. */
    420      1.1  joerg /* Select the correct function based on the size of long. */
    421      1.1  joerg #ifdef __LP64__
    422      1.1  joerg #define _lrotl(a,b) __rolq((a), (b))
    423      1.1  joerg #define _lrotr(a,b) __rorq((a), (b))
    424      1.1  joerg #else
    425      1.1  joerg #define _lrotl(a,b) __rold((a), (b))
    426      1.1  joerg #define _lrotr(a,b) __rord((a), (b))
    427      1.1  joerg #endif
    428      1.1  joerg #define _rotl(a,b) __rold((a), (b))
    429      1.1  joerg #define _rotr(a,b) __rord((a), (b))
    430      1.1  joerg #endif // _MSC_VER
    431      1.1  joerg 
    432      1.1  joerg /* These are not builtins so need to be provided in all modes. */
    433      1.1  joerg #define _rotwl(a,b) __rolw((a), (b))
    434      1.1  joerg #define _rotwr(a,b) __rorw((a), (b))
    435      1.1  joerg 
    436  1.1.1.2  joerg #undef __DEFAULT_FN_ATTRS
    437  1.1.1.2  joerg #undef __DEFAULT_FN_ATTRS_CAST
    438  1.1.1.2  joerg #undef __DEFAULT_FN_ATTRS_SSE42
    439  1.1.1.2  joerg #undef __DEFAULT_FN_ATTRS_CONSTEXPR
    440  1.1.1.2  joerg 
    441      1.1  joerg #endif /* __IA32INTRIN_H */
    442