[HLSL] Implement RWBuffer::operator[] via __builtin_hlsl_resource_getpointer (#117017)
[llvm-project.git] / clang / lib / Headers / ia32intrin.h
blob8e65f232a0def8b0b7b80f9bdb5d80c68beded6d
1 /* ===-------- ia32intrin.h ---------------------------------------------------===
3 * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 * See https://llvm.org/LICENSE.txt for license information.
5 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 *===-----------------------------------------------------------------------===
8 */
10 #ifndef __X86INTRIN_H
11 #error "Never use <ia32intrin.h> directly; include <x86intrin.h> instead."
12 #endif
14 #ifndef __IA32INTRIN_H
15 #define __IA32INTRIN_H
17 /* Define the default attributes for the functions in this file. */
18 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
19 #define __DEFAULT_FN_ATTRS_CRC32 __attribute__((__always_inline__, __nodebug__, __target__("crc32")))
21 #if defined(__cplusplus) && (__cplusplus >= 201103L)
22 #define __DEFAULT_FN_ATTRS_CAST __attribute__((__always_inline__)) constexpr
23 #define __DEFAULT_FN_ATTRS_CONSTEXPR __DEFAULT_FN_ATTRS constexpr
24 #else
25 #define __DEFAULT_FN_ATTRS_CAST __attribute__((__always_inline__))
26 #define __DEFAULT_FN_ATTRS_CONSTEXPR __DEFAULT_FN_ATTRS
27 #endif
29 /// Finds the first set bit starting from the least significant bit. The result
30 /// is undefined if the input is 0.
31 ///
32 /// \headerfile <x86intrin.h>
33 ///
34 /// This intrinsic corresponds to the \c BSF instruction or the
35 /// \c TZCNT instruction.
36 ///
37 /// \param __A
38 /// A 32-bit integer operand.
39 /// \returns A 32-bit integer containing the bit number.
40 /// \see _bit_scan_forward
41 static __inline__ int __DEFAULT_FN_ATTRS_CONSTEXPR
42 __bsfd(int __A) {
43 return __builtin_ctz((unsigned int)__A);
46 /// Finds the first set bit starting from the most significant bit. The result
47 /// is undefined if the input is 0.
48 ///
49 /// \headerfile <x86intrin.h>
50 ///
51 /// This intrinsic corresponds to the \c BSR instruction or the
52 /// \c LZCNT instruction and an \c XOR.
53 ///
54 /// \param __A
55 /// A 32-bit integer operand.
56 /// \returns A 32-bit integer containing the bit number.
57 /// \see _bit_scan_reverse
58 static __inline__ int __DEFAULT_FN_ATTRS_CONSTEXPR
59 __bsrd(int __A) {
60 return 31 - __builtin_clz((unsigned int)__A);
63 /// Swaps the bytes in the input, converting little endian to big endian or
64 /// vice versa.
65 ///
66 /// \headerfile <x86intrin.h>
67 ///
68 /// This intrinsic corresponds to the \c BSWAP instruction.
69 ///
70 /// \param __A
71 /// A 32-bit integer operand.
72 /// \returns A 32-bit integer containing the swapped bytes.
73 static __inline__ int __DEFAULT_FN_ATTRS_CONSTEXPR
74 __bswapd(int __A) {
75 return (int)__builtin_bswap32((unsigned int)__A);
78 /// Swaps the bytes in the input, converting little endian to big endian or
79 /// vice versa.
80 ///
81 /// \headerfile <x86intrin.h>
82 ///
83 /// This intrinsic corresponds to the \c BSWAP instruction.
84 ///
85 /// \param __A
86 /// A 32-bit integer operand.
87 /// \returns A 32-bit integer containing the swapped bytes.
88 static __inline__ int __DEFAULT_FN_ATTRS_CONSTEXPR
89 _bswap(int __A) {
90 return (int)__builtin_bswap32((unsigned int)__A);
93 /// Finds the first set bit starting from the least significant bit. The result
94 /// is undefined if the input is 0.
95 ///
96 /// \headerfile <x86intrin.h>
97 ///
98 /// \code
99 /// int _bit_scan_forward(int A);
100 /// \endcode
102 /// This intrinsic corresponds to the \c BSF instruction or the
103 /// \c TZCNT instruction.
105 /// \param A
106 /// A 32-bit integer operand.
107 /// \returns A 32-bit integer containing the bit number.
108 /// \see __bsfd
109 #define _bit_scan_forward(A) __bsfd((A))
111 /// Finds the first set bit starting from the most significant bit. The result
112 /// is undefined if the input is 0.
114 /// \headerfile <x86intrin.h>
116 /// \code
117 /// int _bit_scan_reverse(int A);
118 /// \endcode
120 /// This intrinsic corresponds to the \c BSR instruction or the
121 /// \c LZCNT instruction and an \c XOR.
123 /// \param A
124 /// A 32-bit integer operand.
125 /// \returns A 32-bit integer containing the bit number.
126 /// \see __bsrd
127 #define _bit_scan_reverse(A) __bsrd((A))
129 #ifdef __x86_64__
130 /// Finds the first set bit starting from the least significant bit. The result
131 /// is undefined if the input is 0.
133 /// \headerfile <x86intrin.h>
135 /// This intrinsic corresponds to the \c BSF instruction or the
136 /// \c TZCNT instruction.
138 /// \param __A
139 /// A 64-bit integer operand.
140 /// \returns A 32-bit integer containing the bit number.
141 static __inline__ int __DEFAULT_FN_ATTRS_CONSTEXPR
142 __bsfq(long long __A) {
143 return (long long)__builtin_ctzll((unsigned long long)__A);
146 /// Finds the first set bit starting from the most significant bit. The result
147 /// is undefined if input is 0.
149 /// \headerfile <x86intrin.h>
151 /// This intrinsic corresponds to the \c BSR instruction or the
152 /// \c LZCNT instruction and an \c XOR.
154 /// \param __A
155 /// A 64-bit integer operand.
156 /// \returns A 32-bit integer containing the bit number.
157 static __inline__ int __DEFAULT_FN_ATTRS_CONSTEXPR
158 __bsrq(long long __A) {
159 return 63 - __builtin_clzll((unsigned long long)__A);
162 /// Swaps the bytes in the input, converting little endian to big endian or
163 /// vice versa.
165 /// \headerfile <x86intrin.h>
167 /// This intrinsic corresponds to the \c BSWAP instruction.
169 /// \param __A
170 /// A 64-bit integer operand.
171 /// \returns A 64-bit integer containing the swapped bytes.
172 /// \see _bswap64
173 static __inline__ long long __DEFAULT_FN_ATTRS_CONSTEXPR
174 __bswapq(long long __A) {
175 return (long long)__builtin_bswap64((unsigned long long)__A);
178 /// Swaps the bytes in the input, converting little endian to big endian or
179 /// vice versa.
181 /// \headerfile <x86intrin.h>
183 /// \code
184 /// long long _bswap64(long long A);
185 /// \endcode
187 /// This intrinsic corresponds to the \c BSWAP instruction.
189 /// \param A
190 /// A 64-bit integer operand.
191 /// \returns A 64-bit integer containing the swapped bytes.
192 /// \see __bswapq
193 #define _bswap64(A) __bswapq((A))
194 #endif /* __x86_64__ */
196 /// Counts the number of bits in the source operand having a value of 1.
198 /// \headerfile <x86intrin.h>
200 /// This intrinsic corresponds to the \c POPCNT instruction or a
201 /// sequence of arithmetic and logic operations to calculate it.
203 /// \param __A
204 /// An unsigned 32-bit integer operand.
205 /// \returns A 32-bit integer containing the number of bits with value 1 in the
206 /// source operand.
207 /// \see _popcnt32
208 static __inline__ int __DEFAULT_FN_ATTRS_CONSTEXPR
209 __popcntd(unsigned int __A)
211 return __builtin_popcount(__A);
214 /// Counts the number of bits in the source operand having a value of 1.
216 /// \headerfile <x86intrin.h>
218 /// \code
219 /// int _popcnt32(int A);
220 /// \endcode
222 /// This intrinsic corresponds to the \c POPCNT instruction or a
223 /// sequence of arithmetic and logic operations to calculate it.
225 /// \param A
226 /// An unsigned 32-bit integer operand.
227 /// \returns A 32-bit integer containing the number of bits with value 1 in the
228 /// source operand.
229 /// \see __popcntd
230 #define _popcnt32(A) __popcntd((A))
232 #ifdef __x86_64__
233 /// Counts the number of bits in the source operand having a value of 1.
235 /// \headerfile <x86intrin.h>
237 /// This intrinsic corresponds to the \c POPCNT instruction or a
238 /// sequence of arithmetic and logic operations to calculate it.
240 /// \param __A
241 /// An unsigned 64-bit integer operand.
242 /// \returns A 64-bit integer containing the number of bits with value 1 in the
243 /// source operand.
244 /// \see _popcnt64
245 static __inline__ long long __DEFAULT_FN_ATTRS_CONSTEXPR
246 __popcntq(unsigned long long __A)
248 return __builtin_popcountll(__A);
251 /// Counts the number of bits in the source operand having a value of 1.
253 /// \headerfile <x86intrin.h>
255 /// \code
256 /// long long _popcnt64(unsigned long long A);
257 /// \endcode
259 /// This intrinsic corresponds to the \c POPCNT instruction or a
260 /// sequence of arithmetic and logic operations to calculate it.
262 /// \param A
263 /// An unsigned 64-bit integer operand.
264 /// \returns A 64-bit integer containing the number of bits with value 1 in the
265 /// source operand.
266 /// \see __popcntq
267 #define _popcnt64(A) __popcntq((A))
268 #endif /* __x86_64__ */
270 #ifdef __x86_64__
271 /// Returns the program status-and-control \c RFLAGS register with the \c VM
272 /// and \c RF flags cleared.
274 /// \headerfile <x86intrin.h>
276 /// This intrinsic corresponds to the \c PUSHFQ + \c POP instruction sequence.
278 /// \returns The 64-bit value of the RFLAGS register.
279 static __inline__ unsigned long long __DEFAULT_FN_ATTRS
280 __readeflags(void)
282 return __builtin_ia32_readeflags_u64();
285 /// Writes the specified value to the program status-and-control \c RFLAGS
286 /// register. Reserved bits are not affected.
288 /// \headerfile <x86intrin.h>
290 /// This intrinsic corresponds to the \c PUSH + \c POPFQ instruction sequence.
292 /// \param __f
293 /// The 64-bit value to write to \c RFLAGS.
294 static __inline__ void __DEFAULT_FN_ATTRS
295 __writeeflags(unsigned long long __f)
297 __builtin_ia32_writeeflags_u64(__f);
300 #else /* !__x86_64__ */
301 /// Returns the program status-and-control \c EFLAGS register with the \c VM
302 /// and \c RF flags cleared.
304 /// \headerfile <x86intrin.h>
306 /// This intrinsic corresponds to the \c PUSHFD + \c POP instruction sequence.
308 /// \returns The 32-bit value of the EFLAGS register.
309 static __inline__ unsigned int __DEFAULT_FN_ATTRS
310 __readeflags(void)
312 return __builtin_ia32_readeflags_u32();
315 /// Writes the specified value to the program status-and-control \c EFLAGS
316 /// register. Reserved bits are not affected.
318 /// \headerfile <x86intrin.h>
320 /// This intrinsic corresponds to the \c PUSH + \c POPFD instruction sequence.
322 /// \param __f
323 /// The 32-bit value to write to \c EFLAGS.
324 static __inline__ void __DEFAULT_FN_ATTRS
325 __writeeflags(unsigned int __f)
327 __builtin_ia32_writeeflags_u32(__f);
329 #endif /* !__x86_64__ */
331 /// Casts a 32-bit float value to a 32-bit unsigned integer value.
333 /// \headerfile <x86intrin.h>
335 /// This intrinsic corresponds to the \c VMOVD / \c MOVD instruction in x86_64,
336 /// and corresponds to the \c VMOVL / \c MOVL instruction in ia32.
338 /// \param __A
339 /// A 32-bit float value.
340 /// \returns A 32-bit unsigned integer containing the converted value.
341 static __inline__ unsigned int __DEFAULT_FN_ATTRS_CAST
342 _castf32_u32(float __A) {
343 return __builtin_bit_cast(unsigned int, __A);
346 /// Casts a 64-bit float value to a 64-bit unsigned integer value.
348 /// \headerfile <x86intrin.h>
350 /// This intrinsic corresponds to the \c VMOVQ / \c MOVQ instruction in x86_64,
351 /// and corresponds to the \c VMOVL / \c MOVL instruction in ia32.
353 /// \param __A
354 /// A 64-bit float value.
355 /// \returns A 64-bit unsigned integer containing the converted value.
356 static __inline__ unsigned long long __DEFAULT_FN_ATTRS_CAST
357 _castf64_u64(double __A) {
358 return __builtin_bit_cast(unsigned long long, __A);
361 /// Casts a 32-bit unsigned integer value to a 32-bit float value.
363 /// \headerfile <x86intrin.h>
365 /// This intrinsic corresponds to the \c VMOVQ / \c MOVQ instruction in x86_64,
366 /// and corresponds to the \c FLDS instruction in ia32.
368 /// \param __A
369 /// A 32-bit unsigned integer value.
370 /// \returns A 32-bit float value containing the converted value.
371 static __inline__ float __DEFAULT_FN_ATTRS_CAST
372 _castu32_f32(unsigned int __A) {
373 return __builtin_bit_cast(float, __A);
376 /// Casts a 64-bit unsigned integer value to a 64-bit float value.
378 /// \headerfile <x86intrin.h>
380 /// This intrinsic corresponds to the \c VMOVQ / \c MOVQ instruction in x86_64,
381 /// and corresponds to the \c FLDL instruction in ia32.
383 /// \param __A
384 /// A 64-bit unsigned integer value.
385 /// \returns A 64-bit float value containing the converted value.
386 static __inline__ double __DEFAULT_FN_ATTRS_CAST
387 _castu64_f64(unsigned long long __A) {
388 return __builtin_bit_cast(double, __A);
391 /// Adds the unsigned integer operand to the CRC-32C checksum of the
392 /// unsigned char operand.
394 /// \headerfile <x86intrin.h>
396 /// This intrinsic corresponds to the \c CRC32B instruction.
398 /// \param __C
399 /// An unsigned integer operand to add to the CRC-32C checksum of operand
400 /// \a __D.
401 /// \param __D
402 /// An unsigned 8-bit integer operand used to compute the CRC-32C checksum.
403 /// \returns The result of adding operand \a __C to the CRC-32C checksum of
404 /// operand \a __D.
405 static __inline__ unsigned int __DEFAULT_FN_ATTRS_CRC32
406 __crc32b(unsigned int __C, unsigned char __D)
408 return __builtin_ia32_crc32qi(__C, __D);
411 /// Adds the unsigned integer operand to the CRC-32C checksum of the
412 /// unsigned short operand.
414 /// \headerfile <x86intrin.h>
416 /// This intrinsic corresponds to the \c CRC32W instruction.
418 /// \param __C
419 /// An unsigned integer operand to add to the CRC-32C checksum of operand
420 /// \a __D.
421 /// \param __D
422 /// An unsigned 16-bit integer operand used to compute the CRC-32C checksum.
423 /// \returns The result of adding operand \a __C to the CRC-32C checksum of
424 /// operand \a __D.
425 static __inline__ unsigned int __DEFAULT_FN_ATTRS_CRC32
426 __crc32w(unsigned int __C, unsigned short __D)
428 return __builtin_ia32_crc32hi(__C, __D);
431 /// Adds the unsigned integer operand to the CRC-32C checksum of the
432 /// second unsigned integer operand.
434 /// \headerfile <x86intrin.h>
436 /// This intrinsic corresponds to the \c CRC32D instruction.
438 /// \param __C
439 /// An unsigned integer operand to add to the CRC-32C checksum of operand
440 /// \a __D.
441 /// \param __D
442 /// An unsigned 32-bit integer operand used to compute the CRC-32C checksum.
443 /// \returns The result of adding operand \a __C to the CRC-32C checksum of
444 /// operand \a __D.
445 static __inline__ unsigned int __DEFAULT_FN_ATTRS_CRC32
446 __crc32d(unsigned int __C, unsigned int __D)
448 return __builtin_ia32_crc32si(__C, __D);
451 #ifdef __x86_64__
452 /// Adds the unsigned integer operand to the CRC-32C checksum of the
453 /// unsigned 64-bit integer operand.
455 /// \headerfile <x86intrin.h>
457 /// This intrinsic corresponds to the \c CRC32Q instruction.
459 /// \param __C
460 /// An unsigned integer operand to add to the CRC-32C checksum of operand
461 /// \a __D.
462 /// \param __D
463 /// An unsigned 64-bit integer operand used to compute the CRC-32C checksum.
464 /// \returns The result of adding operand \a __C to the CRC-32C checksum of
465 /// operand \a __D.
466 static __inline__ unsigned long long __DEFAULT_FN_ATTRS_CRC32
467 __crc32q(unsigned long long __C, unsigned long long __D)
469 return __builtin_ia32_crc32di(__C, __D);
471 #endif /* __x86_64__ */
473 /// Reads the specified performance-monitoring counter. Refer to your
474 /// processor's documentation to determine which performance counters are
475 /// supported.
477 /// \headerfile <x86intrin.h>
479 /// This intrinsic corresponds to the \c RDPMC instruction.
481 /// \param __A
482 /// The performance counter to read.
483 /// \returns The 64-bit value read from the performance counter.
484 /// \see _rdpmc
485 static __inline__ unsigned long long __DEFAULT_FN_ATTRS
486 __rdpmc(int __A) {
487 return __builtin_ia32_rdpmc(__A);
490 /// Reads the processor's time-stamp counter and the \c IA32_TSC_AUX MSR
491 /// \c (0xc0000103).
493 /// \headerfile <x86intrin.h>
495 /// This intrinsic corresponds to the \c RDTSCP instruction.
497 /// \param __A
498 /// The address of where to store the 32-bit \c IA32_TSC_AUX value.
499 /// \returns The 64-bit value of the time-stamp counter.
500 static __inline__ unsigned long long __DEFAULT_FN_ATTRS
501 __rdtscp(unsigned int *__A) {
502 return __builtin_ia32_rdtscp(__A);
505 /// Reads the processor's time-stamp counter.
507 /// \headerfile <x86intrin.h>
509 /// \code
510 /// unsigned long long _rdtsc();
511 /// \endcode
513 /// This intrinsic corresponds to the \c RDTSC instruction.
515 /// \returns The 64-bit value of the time-stamp counter.
516 #define _rdtsc() __rdtsc()
518 /// Reads the specified performance monitoring counter. Refer to your
519 /// processor's documentation to determine which performance counters are
520 /// supported.
522 /// \headerfile <x86intrin.h>
524 /// \code
525 /// unsigned long long _rdpmc(int A);
526 /// \endcode
528 /// This intrinsic corresponds to the \c RDPMC instruction.
530 /// \param A
531 /// The performance counter to read.
532 /// \returns The 64-bit value read from the performance counter.
533 /// \see __rdpmc
534 #define _rdpmc(A) __rdpmc(A)
536 static __inline__ void __DEFAULT_FN_ATTRS
537 _wbinvd(void) {
538 __builtin_ia32_wbinvd();
541 /// Rotates an 8-bit value to the left by the specified number of bits.
542 /// This operation is undefined if the number of bits exceeds the size of
543 /// the value.
545 /// \headerfile <x86intrin.h>
547 /// This intrinsic corresponds to the \c ROL instruction.
549 /// \param __X
550 /// The unsigned 8-bit value to be rotated.
551 /// \param __C
552 /// The number of bits to rotate the value.
553 /// \returns The rotated value.
554 static __inline__ unsigned char __DEFAULT_FN_ATTRS_CONSTEXPR
555 __rolb(unsigned char __X, int __C) {
556 return __builtin_rotateleft8(__X, __C);
559 /// Rotates an 8-bit value to the right by the specified number of bits.
560 /// This operation is undefined if the number of bits exceeds the size of
561 /// the value.
563 /// \headerfile <x86intrin.h>
565 /// This intrinsic corresponds to the \c ROR instruction.
567 /// \param __X
568 /// The unsigned 8-bit value to be rotated.
569 /// \param __C
570 /// The number of bits to rotate the value.
571 /// \returns The rotated value.
572 static __inline__ unsigned char __DEFAULT_FN_ATTRS_CONSTEXPR
573 __rorb(unsigned char __X, int __C) {
574 return __builtin_rotateright8(__X, __C);
577 /// Rotates a 16-bit value to the left by the specified number of bits.
578 /// This operation is undefined if the number of bits exceeds the size of
579 /// the value.
581 /// \headerfile <x86intrin.h>
583 /// This intrinsic corresponds to the \c ROL instruction.
585 /// \param __X
586 /// The unsigned 16-bit value to be rotated.
587 /// \param __C
588 /// The number of bits to rotate the value.
589 /// \returns The rotated value.
590 /// \see _rotwl
591 static __inline__ unsigned short __DEFAULT_FN_ATTRS_CONSTEXPR
592 __rolw(unsigned short __X, int __C) {
593 return __builtin_rotateleft16(__X, __C);
596 /// Rotates a 16-bit value to the right by the specified number of bits.
597 /// This operation is undefined if the number of bits exceeds the size of
598 /// the value.
600 /// \headerfile <x86intrin.h>
602 /// This intrinsic corresponds to the \c ROR instruction.
604 /// \param __X
605 /// The unsigned 16-bit value to be rotated.
606 /// \param __C
607 /// The number of bits to rotate the value.
608 /// \returns The rotated value.
609 /// \see _rotwr
610 static __inline__ unsigned short __DEFAULT_FN_ATTRS_CONSTEXPR
611 __rorw(unsigned short __X, int __C) {
612 return __builtin_rotateright16(__X, __C);
615 /// Rotates a 32-bit value to the left by the specified number of bits.
616 /// This operation is undefined if the number of bits exceeds the size of
617 /// the value.
619 /// \headerfile <x86intrin.h>
621 /// This intrinsic corresponds to the \c ROL instruction.
623 /// \param __X
624 /// The unsigned 32-bit value to be rotated.
625 /// \param __C
626 /// The number of bits to rotate the value.
627 /// \returns The rotated value.
628 /// \see _rotl
629 static __inline__ unsigned int __DEFAULT_FN_ATTRS_CONSTEXPR
630 __rold(unsigned int __X, int __C) {
631 return __builtin_rotateleft32(__X, (unsigned int)__C);
634 /// Rotates a 32-bit value to the right by the specified number of bits.
635 /// This operation is undefined if the number of bits exceeds the size of
636 /// the value.
638 /// \headerfile <x86intrin.h>
640 /// This intrinsic corresponds to the \c ROR instruction.
642 /// \param __X
643 /// The unsigned 32-bit value to be rotated.
644 /// \param __C
645 /// The number of bits to rotate the value.
646 /// \returns The rotated value.
647 /// \see _rotr
648 static __inline__ unsigned int __DEFAULT_FN_ATTRS_CONSTEXPR
649 __rord(unsigned int __X, int __C) {
650 return __builtin_rotateright32(__X, (unsigned int)__C);
653 #ifdef __x86_64__
654 /// Rotates a 64-bit value to the left by the specified number of bits.
655 /// This operation is undefined if the number of bits exceeds the size of
656 /// the value.
658 /// \headerfile <x86intrin.h>
660 /// This intrinsic corresponds to the \c ROL instruction.
662 /// \param __X
663 /// The unsigned 64-bit value to be rotated.
664 /// \param __C
665 /// The number of bits to rotate the value.
666 /// \returns The rotated value.
667 static __inline__ unsigned long long __DEFAULT_FN_ATTRS_CONSTEXPR
668 __rolq(unsigned long long __X, int __C) {
669 return __builtin_rotateleft64(__X, (unsigned long long)__C);
672 /// Rotates a 64-bit value to the right by the specified number of bits.
673 /// This operation is undefined if the number of bits exceeds the size of
674 /// the value.
676 /// \headerfile <x86intrin.h>
678 /// This intrinsic corresponds to the \c ROR instruction.
680 /// \param __X
681 /// The unsigned 64-bit value to be rotated.
682 /// \param __C
683 /// The number of bits to rotate the value.
684 /// \returns The rotated value.
685 static __inline__ unsigned long long __DEFAULT_FN_ATTRS_CONSTEXPR
686 __rorq(unsigned long long __X, int __C) {
687 return __builtin_rotateright64(__X, (unsigned long long)__C);
689 #endif /* __x86_64__ */
691 #ifndef _MSC_VER
692 /* These are already provided as builtins for MSVC. */
693 /* Select the correct function based on the size of long. */
694 #ifdef __LP64__
695 /// Rotates a 64-bit value to the left by the specified number of bits.
696 /// This operation is undefined if the number of bits exceeds the size of
697 /// the value.
699 /// \headerfile <x86intrin.h>
701 /// \code
702 /// unsigned long long _lrotl(unsigned long long a, int b);
703 /// \endcode
705 /// This intrinsic corresponds to the \c ROL instruction.
707 /// \param a
708 /// The unsigned 64-bit value to be rotated.
709 /// \param b
710 /// The number of bits to rotate the value.
711 /// \returns The rotated value.
712 /// \see __rolq
713 #define _lrotl(a,b) __rolq((a), (b))
715 /// Rotates a 64-bit value to the right by the specified number of bits.
716 /// This operation is undefined if the number of bits exceeds the size of
717 /// the value.
719 /// \headerfile <x86intrin.h>
721 /// \code
722 /// unsigned long long _lrotr(unsigned long long a, int b);
723 /// \endcode
725 /// This intrinsic corresponds to the \c ROR instruction.
727 /// \param a
728 /// The unsigned 64-bit value to be rotated.
729 /// \param b
730 /// The number of bits to rotate the value.
731 /// \returns The rotated value.
732 /// \see __rorq
733 #define _lrotr(a,b) __rorq((a), (b))
734 #else // __LP64__
735 /// Rotates a 32-bit value to the left by the specified number of bits.
736 /// This operation is undefined if the number of bits exceeds the size of
737 /// the value.
739 /// \headerfile <x86intrin.h>
741 /// \code
742 /// unsigned int _lrotl(unsigned int a, int b);
743 /// \endcode
745 /// This intrinsic corresponds to the \c ROL instruction.
747 /// \param a
748 /// The unsigned 32-bit value to be rotated.
749 /// \param b
750 /// The number of bits to rotate the value.
751 /// \returns The rotated value.
752 /// \see __rold
753 #define _lrotl(a,b) __rold((a), (b))
755 /// Rotates a 32-bit value to the right by the specified number of bits.
756 /// This operation is undefined if the number of bits exceeds the size of
757 /// the value.
759 /// \headerfile <x86intrin.h>
761 /// \code
762 /// unsigned int _lrotr(unsigned int a, int b);
763 /// \endcode
765 /// This intrinsic corresponds to the \c ROR instruction.
767 /// \param a
768 /// The unsigned 32-bit value to be rotated.
769 /// \param b
770 /// The number of bits to rotate the value.
771 /// \returns The rotated value.
772 /// \see __rord
773 #define _lrotr(a,b) __rord((a), (b))
774 #endif // __LP64__
776 /// Rotates a 32-bit value to the left by the specified number of bits.
777 /// This operation is undefined if the number of bits exceeds the size of
778 /// the value.
780 /// \headerfile <x86intrin.h>
782 /// \code
783 /// unsigned int _rotl(unsigned int a, int b);
784 /// \endcode
786 /// This intrinsic corresponds to the \c ROL instruction.
788 /// \param a
789 /// The unsigned 32-bit value to be rotated.
790 /// \param b
791 /// The number of bits to rotate the value.
792 /// \returns The rotated value.
793 /// \see __rold
794 #define _rotl(a,b) __rold((a), (b))
796 /// Rotates a 32-bit value to the right by the specified number of bits.
797 /// This operation is undefined if the number of bits exceeds the size of
798 /// the value.
800 /// \headerfile <x86intrin.h>
802 /// \code
803 /// unsigned int _rotr(unsigned int a, int b);
804 /// \endcode
806 /// This intrinsic corresponds to the \c ROR instruction.
808 /// \param a
809 /// The unsigned 32-bit value to be rotated.
810 /// \param b
811 /// The number of bits to rotate the value.
812 /// \returns The rotated value.
813 /// \see __rord
814 #define _rotr(a,b) __rord((a), (b))
815 #endif // _MSC_VER
817 /* These are not builtins so need to be provided in all modes. */
818 /// Rotates a 16-bit value to the left by the specified number of bits.
819 /// This operation is undefined if the number of bits exceeds the size of
820 /// the value.
822 /// \headerfile <x86intrin.h>
824 /// \code
825 /// unsigned short _rotwl(unsigned short a, int b);
826 /// \endcode
828 /// This intrinsic corresponds to the \c ROL instruction.
830 /// \param a
831 /// The unsigned 16-bit value to be rotated.
832 /// \param b
833 /// The number of bits to rotate the value.
834 /// \returns The rotated value.
835 /// \see __rolw
836 #define _rotwl(a,b) __rolw((a), (b))
838 /// Rotates a 16-bit value to the right by the specified number of bits.
839 /// This operation is undefined if the number of bits exceeds the size of
840 /// the value.
842 /// \headerfile <x86intrin.h>
844 /// \code
845 /// unsigned short _rotwr(unsigned short a, int b);
846 /// \endcode
848 /// This intrinsic corresponds to the \c ROR instruction.
850 /// \param a
851 /// The unsigned 16-bit value to be rotated.
852 /// \param b
853 /// The number of bits to rotate the value.
854 /// \returns The rotated value.
855 /// \see __rorw
856 #define _rotwr(a,b) __rorw((a), (b))
858 #undef __DEFAULT_FN_ATTRS
859 #undef __DEFAULT_FN_ATTRS_CAST
860 #undef __DEFAULT_FN_ATTRS_CRC32
861 #undef __DEFAULT_FN_ATTRS_CONSTEXPR
863 #endif /* __IA32INTRIN_H */