clang API Documentation

tbmintrin.h
Go to the documentation of this file.
00001 /*===---- tbmintrin.h - TBM intrinsics -------------------------------------===
00002  *
00003  * Permission is hereby granted, free of charge, to any person obtaining a copy
00004  * of this software and associated documentation files (the "Software"), to deal
00005  * in the Software without restriction, including without limitation the rights
00006  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00007  * copies of the Software, and to permit persons to whom the Software is
00008  * furnished to do so, subject to the following conditions:
00009  *
00010  * The above copyright notice and this permission notice shall be included in
00011  * all copies or substantial portions of the Software.
00012  *
00013  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00014  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00015  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00016  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00017  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00018  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00019  * THE SOFTWARE.
00020  *
00021  *===-----------------------------------------------------------------------===
00022  */
00023 
00024 #ifndef __TBM__
00025 #error "TBM instruction set is not enabled"
00026 #endif
00027 
00028 #ifndef __X86INTRIN_H
00029 #error "Never use <tbmintrin.h> directly; include <x86intrin.h> instead."
00030 #endif
00031 
00032 #ifndef __TBMINTRIN_H
00033 #define __TBMINTRIN_H
00034 
00035 #define __bextri_u32(a, b) (__builtin_ia32_bextri_u32((a), (b)))
00036 
00037 static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
00038 __blcfill_u32(unsigned int a)
00039 {
00040   return a & (a + 1);
00041 }
00042 
00043 static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
00044 __blci_u32(unsigned int a)
00045 {
00046   return a | ~(a + 1);
00047 }
00048 
00049 static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
00050 __blcic_u32(unsigned int a)
00051 {
00052   return ~a & (a + 1);
00053 }
00054 
00055 static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
00056 __blcmsk_u32(unsigned int a)
00057 {
00058   return a ^ (a + 1);
00059 }
00060 
00061 static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
00062 __blcs_u32(unsigned int a)
00063 {
00064   return a | (a + 1);
00065 }
00066 
00067 static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
00068 __blsfill_u32(unsigned int a)
00069 {
00070   return a | (a - 1);
00071 }
00072 
00073 static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
00074 __blsic_u32(unsigned int a)
00075 {
00076   return ~a | (a - 1);
00077 }
00078 
00079 static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
00080 __t1mskc_u32(unsigned int a)
00081 {
00082   return ~a | (a + 1);
00083 }
00084 
00085 static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
00086 __tzmsk_u32(unsigned int a)
00087 {
00088   return ~a & (a - 1);
00089 }
00090 
00091 #ifdef __x86_64__
00092 #define __bextri_u64(a, b) (__builtin_ia32_bextri_u64((a), (int)(b)))
00093 
00094 static __inline__ unsigned long long __attribute__((__always_inline__,
00095                                                     __nodebug__))
00096 __blcfill_u64(unsigned long long a)
00097 {
00098   return a & (a + 1);
00099 }
00100 
00101 static __inline__ unsigned long long __attribute__((__always_inline__,
00102                                                     __nodebug__))
00103 __blci_u64(unsigned long long a)
00104 {
00105   return a | ~(a + 1);
00106 }
00107 
00108 static __inline__ unsigned long long __attribute__((__always_inline__,
00109                                                     __nodebug__))
00110 __blcic_u64(unsigned long long a)
00111 {
00112   return ~a & (a + 1);
00113 }
00114 
00115 static __inline__ unsigned long long __attribute__((__always_inline__,
00116                                                     __nodebug__))
00117 __blcmsk_u64(unsigned long long a)
00118 {
00119   return a ^ (a + 1);
00120 }
00121 
00122 static __inline__ unsigned long long __attribute__((__always_inline__,
00123                                                     __nodebug__))
00124 __blcs_u64(unsigned long long a)
00125 {
00126   return a | (a + 1);
00127 }
00128 
00129 static __inline__ unsigned long long __attribute__((__always_inline__,
00130                                                     __nodebug__))
00131 __blsfill_u64(unsigned long long a)
00132 {
00133   return a | (a - 1);
00134 }
00135 
00136 static __inline__ unsigned long long __attribute__((__always_inline__,
00137                                                     __nodebug__))
00138 __blsic_u64(unsigned long long a)
00139 {
00140   return ~a | (a - 1);
00141 }
00142 
00143 static __inline__ unsigned long long __attribute__((__always_inline__,
00144                                                     __nodebug__))
00145 __t1mskc_u64(unsigned long long a)
00146 {
00147   return ~a | (a + 1);
00148 }
00149 
00150 static __inline__ unsigned long long __attribute__((__always_inline__,
00151                                                     __nodebug__))
00152 __tzmsk_u64(unsigned long long a)
00153 {
00154   return ~a & (a - 1);
00155 }
00156 #endif
00157 
00158 #endif /* __TBMINTRIN_H */