]>
Commit | Line | Data |
---|---|---|
a5544970 | 1 | /* Copyright (C) 2010-2019 Free Software Foundation, Inc. |
91afcfa3 QN |
2 | |
3 | This file is part of GCC. | |
4 | ||
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) | |
8 | any later version. | |
9 | ||
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. | |
14 | ||
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. | |
18 | ||
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/>. */ | |
23 | ||
f13677ba | 24 | #if !defined _X86INTRIN_H_INCLUDED && !defined _IMMINTRIN_H_INCLUDED |
91afcfa3 QN |
25 | # error "Never use <bmiintrin.h> directly; include <x86intrin.h> instead." |
26 | #endif | |
27 | ||
91afcfa3 QN |
28 | #ifndef _BMIINTRIN_H_INCLUDED |
29 | #define _BMIINTRIN_H_INCLUDED | |
30 | ||
97db2bf7 ST |
31 | #ifndef __BMI__ |
32 | #pragma GCC push_options | |
33 | #pragma GCC target("bmi") | |
34 | #define __DISABLE_BMI__ | |
35 | #endif /* __BMI__ */ | |
36 | ||
91afcfa3 QN |
37 | extern __inline unsigned short __attribute__((__gnu_inline__, __always_inline__, __artificial__)) |
38 | __tzcnt_u16 (unsigned short __X) | |
39 | { | |
f56ea76e | 40 | return __builtin_ia32_tzcnt_u16 (__X); |
91afcfa3 QN |
41 | } |
42 | ||
91afcfa3 QN |
43 | extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__)) |
44 | __andn_u32 (unsigned int __X, unsigned int __Y) | |
45 | { | |
e0cdd8d4 | 46 | return ~__X & __Y; |
91afcfa3 QN |
47 | } |
48 | ||
49 | extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__)) | |
50 | __bextr_u32 (unsigned int __X, unsigned int __Y) | |
51 | { | |
52 | return __builtin_ia32_bextr_u32 (__X, __Y); | |
53 | } | |
54 | ||
ebf8f0ea KY |
55 | extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__)) |
56 | _bextr_u32 (unsigned int __X, unsigned int __Y, unsigned __Z) | |
57 | { | |
58 | return __builtin_ia32_bextr_u32 (__X, ((__Y & 0xff) | ((__Z & 0xff) << 8))); | |
59 | } | |
60 | ||
91afcfa3 QN |
61 | extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__)) |
62 | __blsi_u32 (unsigned int __X) | |
63 | { | |
e0cdd8d4 | 64 | return __X & -__X; |
91afcfa3 QN |
65 | } |
66 | ||
5a65129e JJ |
67 | extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__)) |
68 | _blsi_u32 (unsigned int __X) | |
69 | { | |
70 | return __blsi_u32 (__X); | |
71 | } | |
72 | ||
91afcfa3 QN |
73 | extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__)) |
74 | __blsmsk_u32 (unsigned int __X) | |
75 | { | |
e0cdd8d4 | 76 | return __X ^ (__X - 1); |
91afcfa3 QN |
77 | } |
78 | ||
5a65129e JJ |
79 | extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__)) |
80 | _blsmsk_u32 (unsigned int __X) | |
81 | { | |
82 | return __blsmsk_u32 (__X); | |
83 | } | |
84 | ||
91afcfa3 QN |
85 | extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__)) |
86 | __blsr_u32 (unsigned int __X) | |
87 | { | |
e0cdd8d4 | 88 | return __X & (__X - 1); |
91afcfa3 QN |
89 | } |
90 | ||
5a65129e JJ |
91 | extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__)) |
92 | _blsr_u32 (unsigned int __X) | |
93 | { | |
94 | return __blsr_u32 (__X); | |
95 | } | |
91afcfa3 QN |
96 | |
97 | extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__)) | |
98 | __tzcnt_u32 (unsigned int __X) | |
99 | { | |
f56ea76e | 100 | return __builtin_ia32_tzcnt_u32 (__X); |
91afcfa3 QN |
101 | } |
102 | ||
5a65129e JJ |
103 | extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__)) |
104 | _tzcnt_u32 (unsigned int __X) | |
105 | { | |
f56ea76e | 106 | return __builtin_ia32_tzcnt_u32 (__X); |
5a65129e JJ |
107 | } |
108 | ||
91afcfa3 QN |
109 | |
110 | #ifdef __x86_64__ | |
111 | extern __inline unsigned long long __attribute__((__gnu_inline__, __always_inline__, __artificial__)) | |
112 | __andn_u64 (unsigned long long __X, unsigned long long __Y) | |
113 | { | |
e0cdd8d4 | 114 | return ~__X & __Y; |
91afcfa3 QN |
115 | } |
116 | ||
117 | extern __inline unsigned long long __attribute__((__gnu_inline__, __always_inline__, __artificial__)) | |
118 | __bextr_u64 (unsigned long long __X, unsigned long long __Y) | |
119 | { | |
120 | return __builtin_ia32_bextr_u64 (__X, __Y); | |
121 | } | |
122 | ||
ebf8f0ea KY |
123 | extern __inline unsigned long long __attribute__((__gnu_inline__, __always_inline__, __artificial__)) |
124 | _bextr_u64 (unsigned long long __X, unsigned int __Y, unsigned int __Z) | |
125 | { | |
126 | return __builtin_ia32_bextr_u64 (__X, ((__Y & 0xff) | ((__Z & 0xff) << 8))); | |
127 | } | |
128 | ||
91afcfa3 QN |
129 | extern __inline unsigned long long __attribute__((__gnu_inline__, __always_inline__, __artificial__)) |
130 | __blsi_u64 (unsigned long long __X) | |
131 | { | |
e0cdd8d4 | 132 | return __X & -__X; |
91afcfa3 QN |
133 | } |
134 | ||
5a65129e JJ |
135 | extern __inline unsigned long long __attribute__((__gnu_inline__, __always_inline__, __artificial__)) |
136 | _blsi_u64 (unsigned long long __X) | |
137 | { | |
138 | return __blsi_u64 (__X); | |
139 | } | |
140 | ||
91afcfa3 QN |
141 | extern __inline unsigned long long __attribute__((__gnu_inline__, __always_inline__, __artificial__)) |
142 | __blsmsk_u64 (unsigned long long __X) | |
143 | { | |
e0cdd8d4 | 144 | return __X ^ (__X - 1); |
91afcfa3 QN |
145 | } |
146 | ||
5a65129e JJ |
147 | extern __inline unsigned long long __attribute__((__gnu_inline__, __always_inline__, __artificial__)) |
148 | _blsmsk_u64 (unsigned long long __X) | |
149 | { | |
150 | return __blsmsk_u64 (__X); | |
151 | } | |
152 | ||
91afcfa3 QN |
153 | extern __inline unsigned long long __attribute__((__gnu_inline__, __always_inline__, __artificial__)) |
154 | __blsr_u64 (unsigned long long __X) | |
155 | { | |
e0cdd8d4 | 156 | return __X & (__X - 1); |
91afcfa3 QN |
157 | } |
158 | ||
5a65129e JJ |
159 | extern __inline unsigned long long __attribute__((__gnu_inline__, __always_inline__, __artificial__)) |
160 | _blsr_u64 (unsigned long long __X) | |
161 | { | |
162 | return __blsr_u64 (__X); | |
163 | } | |
164 | ||
91afcfa3 QN |
165 | extern __inline unsigned long long __attribute__((__gnu_inline__, __always_inline__, __artificial__)) |
166 | __tzcnt_u64 (unsigned long long __X) | |
167 | { | |
f56ea76e | 168 | return __builtin_ia32_tzcnt_u64 (__X); |
91afcfa3 QN |
169 | } |
170 | ||
5a65129e JJ |
171 | extern __inline unsigned long long __attribute__((__gnu_inline__, __always_inline__, __artificial__)) |
172 | _tzcnt_u64 (unsigned long long __X) | |
173 | { | |
f56ea76e | 174 | return __builtin_ia32_tzcnt_u64 (__X); |
5a65129e JJ |
175 | } |
176 | ||
91afcfa3 QN |
177 | #endif /* __x86_64__ */ |
178 | ||
97db2bf7 ST |
179 | #ifdef __DISABLE_BMI__ |
180 | #undef __DISABLE_BMI__ | |
181 | #pragma GCC pop_options | |
182 | #endif /* __DISABLE_BMI__ */ | |
183 | ||
91afcfa3 | 184 | #endif /* _BMIINTRIN_H_INCLUDED */ |