1 /* Copyright (C) 2010-2017 Free Software Foundation, Inc.
3 This file is part of GCC.
5 GCC is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3, or (at your option)
10 GCC is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 Under Section 7 of GPL version 3, you are granted additional
16 permissions described in the GCC Runtime Library Exception, version
17 3.1, as published by the Free Software Foundation.
19 You should have received a copy of the GNU General Public License and
20 a copy of the GCC Runtime Library Exception along with this program;
21 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
22 <http://www.gnu.org/licenses/>. */
24 /* This header is distributed to simplify porting x86_64 code that
25 makes explicit use of Intel intrinsics to powerpc64le.
26 It is the user's responsibility to determine if the results are
27 acceptable and make additional changes as necessary.
28 Note that much code that uses Intel intrinsics can be rewritten in
29 standard C or GNU C extensions, which are more portable and better
30 optimized across multiple targets. */
32 #if !defined _X86INTRIN_H_INCLUDED
33 # error "Never use <bmiintrin.h> directly; include <x86intrin.h> instead."
36 #ifndef _BMIINTRIN_H_INCLUDED
37 #define _BMIINTRIN_H_INCLUDED
39 extern __inline
unsigned short __attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
40 __tzcnt_u16 (unsigned short __X
)
42 return __builtin_ctz (__X
);
45 extern __inline
unsigned int __attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
46 __andn_u32 (unsigned int __X
, unsigned int __Y
)
51 extern __inline
unsigned int __attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
52 _bextr_u32 (unsigned int __X
, unsigned int __P
, unsigned int __L
)
54 return ((__X
<< (32 - (__L
+ __P
))) >> (32 - __L
));
57 extern __inline
unsigned int __attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
58 __bextr_u32 (unsigned int __X
, unsigned int __Y
)
60 unsigned int __P
, __L
;
62 __L
= (__Y
>> 8) & 0xFF;
63 return (_bextr_u32 (__X
, __P
, __L
));
66 extern __inline
unsigned int __attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
67 __blsi_u32 (unsigned int __X
)
72 extern __inline
unsigned int __attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
73 _blsi_u32 (unsigned int __X
)
75 return __blsi_u32 (__X
);
78 extern __inline
unsigned int __attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
79 __blsmsk_u32 (unsigned int __X
)
81 return (__X
^ (__X
- 1));
84 extern __inline
unsigned int __attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
85 _blsmsk_u32 (unsigned int __X
)
87 return __blsmsk_u32 (__X
);
90 extern __inline
unsigned int __attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
91 __blsr_u32 (unsigned int __X
)
93 return (__X
& (__X
- 1));
96 extern __inline
unsigned int __attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
97 _blsr_u32 (unsigned int __X
)
99 return __blsr_u32 (__X
);
102 extern __inline
unsigned int __attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
103 __tzcnt_u32 (unsigned int __X
)
105 return __builtin_ctz (__X
);
108 extern __inline
unsigned int __attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
109 _tzcnt_u32 (unsigned int __X
)
111 return __builtin_ctz (__X
);
114 /* use the 64-bit shift, rotate, and count leading zeros instructions
117 extern __inline
unsigned long long __attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
118 __andn_u64 (unsigned long long __X
, unsigned long long __Y
)
123 extern __inline
unsigned long long __attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
124 _bextr_u64 (unsigned long long __X
, unsigned int __P
, unsigned int __L
)
126 return ((__X
<< (64 - (__L
+ __P
))) >> (64 - __L
));
129 extern __inline
unsigned long long __attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
130 __bextr_u64 (unsigned long long __X
, unsigned long long __Y
)
132 unsigned int __P
, __L
;
134 __L
= (__Y
& 0xFF00) >> 8;
135 return (_bextr_u64 (__X
, __P
, __L
));
138 extern __inline
unsigned long long __attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
139 __blsi_u64 (unsigned long long __X
)
144 extern __inline
unsigned long long __attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
145 _blsi_u64 (unsigned long long __X
)
147 return __blsi_u64 (__X
);
150 extern __inline
unsigned long long __attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
151 __blsmsk_u64 (unsigned long long __X
)
153 return (__X
^ (__X
- 1));
156 extern __inline
unsigned long long __attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
157 _blsmsk_u64 (unsigned long long __X
)
159 return __blsmsk_u64 (__X
);
162 extern __inline
unsigned long long __attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
163 __blsr_u64 (unsigned long long __X
)
165 return (__X
& (__X
- 1));
168 extern __inline
unsigned long long __attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
169 _blsr_u64 (unsigned long long __X
)
171 return __blsr_u64 (__X
);
174 extern __inline
unsigned long long __attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
175 __tzcnt_u64 (unsigned long long __X
)
177 return __builtin_ctzll (__X
);
180 extern __inline
unsigned long long __attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
181 _tzcnt_u64 (unsigned long long __X
)
183 return __builtin_ctzll (__X
);
185 #endif /* __PPC64__ */
187 #endif /* _BMIINTRIN_H_INCLUDED */