37
37
// / \param __A
38
38
// / A 32-bit integer operand.
39
39
// / \returns A 32-bit integer containing the bit number.
40
+ // / \see _bit_scan_forward
40
41
static __inline__ int __DEFAULT_FN_ATTRS_CONSTEXPR
41
42
__bsfd (int __A) {
42
43
return __builtin_ctz ((unsigned int )__A);
@@ -53,6 +54,7 @@ __bsfd(int __A) {
53
54
// / \param __A
54
55
// / A 32-bit integer operand.
55
56
// / \returns A 32-bit integer containing the bit number.
57
+ // / \see _bit_scan_reverse
56
58
static __inline__ int __DEFAULT_FN_ATTRS_CONSTEXPR
57
59
__bsrd (int __A) {
58
60
return 31 - __builtin_clz ((unsigned int )__A);
@@ -88,7 +90,40 @@ _bswap(int __A) {
88
90
return (int )__builtin_bswap32 ((unsigned int )__A);
89
91
}
90
92
93
+ // / Find the first set bit starting from the lsb. Result is undefined if
94
+ // / input is 0.
95
+ // /
96
+ // / \headerfile <x86intrin.h>
97
+ // /
98
+ // / \code
99
+ // / int _bit_scan_forward(int A);
100
+ // / \endcode
101
+ // /
102
+ // / This intrinsic corresponds to the \c BSF instruction or the
103
+ // / \c TZCNT instruction.
104
+ // /
105
+ // / \param A
106
+ // / A 32-bit integer operand.
107
+ // / \returns A 32-bit integer containing the bit number.
108
+ // / \see __bsfd
91
109
#define _bit_scan_forward (A ) __bsfd((A))
110
+
111
+ // / Find the first set bit starting from the msb. Result is undefined if
112
+ // / input is 0.
113
+ // /
114
+ // / \headerfile <x86intrin.h>
115
+ // /
116
+ // / \code
117
+ // / int _bit_scan_reverse(int A);
118
+ // / \endcode
119
+ // /
120
+ // / This intrinsic corresponds to the \c BSR instruction or the
121
+ // / \c LZCNT instruction and an \c XOR.
122
+ // /
123
+ // / \param A
124
+ // / A 32-bit integer operand.
125
+ // / \returns A 32-bit integer containing the bit number.
126
+ // / \see __bsrd
92
127
#define _bit_scan_reverse (A ) __bsrd((A))
93
128
94
129
#ifdef __x86_64__
@@ -134,13 +169,29 @@ __bsrq(long long __A) {
134
169
// / \param __A
135
170
// / A 64-bit integer operand.
136
171
// / \returns A 64-bit integer containing the swapped bytes.
172
+ // / \see _bswap64
137
173
static __inline__ long long __DEFAULT_FN_ATTRS_CONSTEXPR
138
174
__bswapq (long long __A) {
139
175
return (long long )__builtin_bswap64 ((unsigned long long )__A);
140
176
}
141
177
178
+ // / Swaps the bytes in the input. Converting little endian to big endian or
179
+ // / vice versa.
180
+ // /
181
+ // / \headerfile <x86intrin.h>
182
+ // /
183
+ // / \code
184
+ // / long long _bswap64(long long A);
185
+ // / \endcode
186
+ // /
187
+ // / This intrinsic corresponds to the \c BSWAP instruction.
188
+ // /
189
+ // / \param A
190
+ // / A 64-bit integer operand.
191
+ // / \returns A 64-bit integer containing the swapped bytes.
192
+ // / \see __bswapq
142
193
#define _bswap64 (A ) __bswapq((A))
143
- #endif
194
+ #endif /* __x86_64__ */
144
195
145
196
// / Counts the number of bits in the source operand having a value of 1.
146
197
// /
@@ -153,12 +204,29 @@ __bswapq(long long __A) {
153
204
// / An unsigned 32-bit integer operand.
154
205
// / \returns A 32-bit integer containing the number of bits with value 1 in the
155
206
// / source operand.
207
+ // / \see _popcnt32
156
208
static __inline__ int __DEFAULT_FN_ATTRS_CONSTEXPR
157
209
__popcntd (unsigned int __A)
158
210
{
159
211
return __builtin_popcount (__A);
160
212
}
161
213
214
+ // / Counts the number of bits in the source operand having a value of 1.
215
+ // /
216
+ // / \headerfile <x86intrin.h>
217
+ // /
218
+ // / \code
219
+ // / int _popcnt32(int A);
220
+ // / \endcode
221
+ // /
222
+ // / This intrinsic corresponds to the \c POPCNT instruction or a
223
+ // / a sequence of arithmetic and logic ops to calculate it.
224
+ // /
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
162
230
#define _popcnt32 (A ) __popcntd((A))
163
231
164
232
#ifdef __x86_64__
@@ -173,12 +241,29 @@ __popcntd(unsigned int __A)
173
241
// / An unsigned 64-bit integer operand.
174
242
// / \returns A 64-bit integer containing the number of bits with value 1 in the
175
243
// / source operand.
244
+ // / \see _popcnt64
176
245
static __inline__ long long __DEFAULT_FN_ATTRS_CONSTEXPR
177
246
__popcntq (unsigned long long __A)
178
247
{
179
248
return __builtin_popcountll (__A);
180
249
}
181
250
251
+ // / Counts the number of bits in the source operand having a value of 1.
252
+ // /
253
+ // / \headerfile <x86intrin.h>
254
+ // /
255
+ // / \code
256
+ // / long long _popcnt64(unsigned long long A);
257
+ // / \endcode
258
+ // /
259
+ // / This intrinsic corresponds to the \c POPCNT instruction or a
260
+ // / a sequence of arithmetic and logic ops to calculate it.
261
+ // /
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
182
267
#define _popcnt64 (A ) __popcntq((A))
183
268
#endif /* __x86_64__ */
184
269
@@ -396,6 +481,7 @@ __crc32q(unsigned long long __C, unsigned long long __D)
396
481
// / \param __A
397
482
// / The performance counter to read.
398
483
// / \returns The 64-bit value read from the performance counter.
484
+ // / \see _rdpmc
399
485
static __inline__ unsigned long long __DEFAULT_FN_ATTRS
400
486
__rdpmc (int __A) {
401
487
return __builtin_ia32_rdpmc (__A);
@@ -416,8 +502,35 @@ __rdtscp(unsigned int *__A) {
416
502
return __builtin_ia32_rdtscp (__A);
417
503
}
418
504
505
+ // / Reads the processor's time stamp counter.
506
+ // /
507
+ // / \headerfile <x86intrin.h>
508
+ // /
509
+ // / \code
510
+ // / unsigned long long _rdtsc();
511
+ // / \endcode
512
+ // /
513
+ // / This intrinsic corresponds to the \c RDTSC instruction.
514
+ // /
515
+ // / \returns The 64-bit value of the time stamp counter.
419
516
#define _rdtsc () __rdtsc()
420
517
518
+ // / Reads the specified performance monitoring counter. Refer to your
519
+ // / processor's documentation to determine which performance counters are
520
+ // / supported.
521
+ // /
522
+ // / \headerfile <x86intrin.h>
523
+ // /
524
+ // / \code
525
+ // / unsigned long long _rdpmc(int A);
526
+ // / \endcode
527
+ // /
528
+ // / This intrinsic corresponds to the \c RDPMC instruction.
529
+ // /
530
+ // / \param A
531
+ // / The performance counter to read.
532
+ // / \returns The 64-bit value read from the performance counter.
533
+ // / \see __rdpmc
421
534
#define _rdpmc (A ) __rdpmc(A)
422
535
423
536
static __inline__ void __DEFAULT_FN_ATTRS
@@ -474,6 +587,7 @@ __rorb(unsigned char __X, int __C) {
474
587
// / \param __C
475
588
// / The number of bits to rotate the value.
476
589
// / \returns The rotated value.
590
+ // / \see _rotwl
477
591
static __inline__ unsigned short __DEFAULT_FN_ATTRS_CONSTEXPR
478
592
__rolw (unsigned short __X, int __C) {
479
593
return __builtin_rotateleft16 (__X, __C);
@@ -492,6 +606,7 @@ __rolw(unsigned short __X, int __C) {
492
606
// / \param __C
493
607
// / The number of bits to rotate the value.
494
608
// / \returns The rotated value.
609
+ // / \see _rotwr
495
610
static __inline__ unsigned short __DEFAULT_FN_ATTRS_CONSTEXPR
496
611
__rorw (unsigned short __X, int __C) {
497
612
return __builtin_rotateright16 (__X, __C);
@@ -510,6 +625,7 @@ __rorw(unsigned short __X, int __C) {
510
625
// / \param __C
511
626
// / The number of bits to rotate the value.
512
627
// / \returns The rotated value.
628
+ // / \see _rotl
513
629
static __inline__ unsigned int __DEFAULT_FN_ATTRS_CONSTEXPR
514
630
__rold (unsigned int __X, int __C) {
515
631
return __builtin_rotateleft32 (__X, (unsigned int )__C);
@@ -528,6 +644,7 @@ __rold(unsigned int __X, int __C) {
528
644
// / \param __C
529
645
// / The number of bits to rotate the value.
530
646
// / \returns The rotated value.
647
+ // / \see _rotr
531
648
static __inline__ unsigned int __DEFAULT_FN_ATTRS_CONSTEXPR
532
649
__rord (unsigned int __X, int __C) {
533
650
return __builtin_rotateright32 (__X, (unsigned int )__C);
@@ -575,18 +692,167 @@ __rorq(unsigned long long __X, int __C) {
575
692
/* These are already provided as builtins for MSVC. */
576
693
/* Select the correct function based on the size of long. */
577
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.
698
+ // /
699
+ // / \headerfile <x86intrin.h>
700
+ // /
701
+ // / \code
702
+ // / unsigned long long _lrotl(unsigned long long a, int b);
703
+ // / \endcode
704
+ // /
705
+ // / This intrinsic corresponds to the \c ROL instruction.
706
+ // /
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
578
713
#define _lrotl (a,b ) __rolq((a), (b))
714
+
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.
718
+ // /
719
+ // / \headerfile <x86intrin.h>
720
+ // /
721
+ // / \code
722
+ // / unsigned long long _lrotr(unsigned long long a, int b);
723
+ // / \endcode
724
+ // /
725
+ // / This intrinsic corresponds to the \c ROR instruction.
726
+ // /
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
579
733
#define _lrotr (a,b ) __rorq((a), (b))
580
- #else
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.
738
+ // /
739
+ // / \headerfile <x86intrin.h>
740
+ // /
741
+ // / \code
742
+ // / unsigned int _lrotl(unsigned int a, int b);
743
+ // / \endcode
744
+ // /
745
+ // / This intrinsic corresponds to the \c ROL instruction.
746
+ // /
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
581
753
#define _lrotl (a,b ) __rold((a), (b))
754
+
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.
758
+ // /
759
+ // / \headerfile <x86intrin.h>
760
+ // /
761
+ // / \code
762
+ // / unsigned int _lrotr(unsigned int a, int b);
763
+ // / \endcode
764
+ // /
765
+ // / This intrinsic corresponds to the \c ROR instruction.
766
+ // /
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
582
773
#define _lrotr (a,b ) __rord((a), (b))
583
- #endif
774
+ #endif // __LP64__
775
+
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.
779
+ // /
780
+ // / \headerfile <x86intrin.h>
781
+ // /
782
+ // / \code
783
+ // / unsigned int _rotl(unsigned int a, int b);
784
+ // / \endcode
785
+ // /
786
+ // / This intrinsic corresponds to the \c ROL instruction.
787
+ // /
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
584
794
#define _rotl (a,b ) __rold((a), (b))
795
+
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.
799
+ // /
800
+ // / \headerfile <x86intrin.h>
801
+ // /
802
+ // / \code
803
+ // / unsigned int _rotr(unsigned int a, int b);
804
+ // / \endcode
805
+ // /
806
+ // / This intrinsic corresponds to the \c ROR instruction.
807
+ // /
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
585
814
#define _rotr (a,b ) __rord((a), (b))
586
815
#endif // _MSC_VER
587
816
588
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.
821
+ // /
822
+ // / \headerfile <x86intrin.h>
823
+ // /
824
+ // / \code
825
+ // / unsigned short _rotwl(unsigned short a, int b);
826
+ // / \endcode
827
+ // /
828
+ // / This intrinsic corresponds to the \c ROL instruction.
829
+ // /
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
589
836
#define _rotwl (a,b ) __rolw((a), (b))
837
+
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.
841
+ // /
842
+ // / \headerfile <x86intrin.h>
843
+ // /
844
+ // / \code
845
+ // / unsigned short _rotwr(unsigned short a, int b);
846
+ // / \endcode
847
+ // /
848
+ // / This intrinsic corresponds to the \c ROR instruction.
849
+ // /
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
590
856
#define _rotwr (a,b ) __rorw((a), (b))
591
857
592
858
#undef __DEFAULT_FN_ATTRS
0 commit comments