Yunzhong Gao | f4e0b10 | 2013-09-30 17:25:14 +0000 | [diff] [blame^] | 1 | /*===---- tbmintrin.h - TBM intrinsics -------------------------------------=== |
| 2 | * |
| 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 4 | * of this software and associated documentation files (the "Software"), to deal |
| 5 | * in the Software without restriction, including without limitation the rights |
| 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 7 | * copies of the Software, and to permit persons to whom the Software is |
| 8 | * furnished to do so, subject to the following conditions: |
| 9 | * |
| 10 | * The above copyright notice and this permission notice shall be included in |
| 11 | * all copies or substantial portions of the Software. |
| 12 | * |
| 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 19 | * THE SOFTWARE. |
| 20 | * |
| 21 | *===-----------------------------------------------------------------------=== |
| 22 | */ |
| 23 | |
| 24 | #ifndef __TBM__ |
| 25 | #error "TBM instruction set is not enabled" |
| 26 | #endif |
| 27 | |
| 28 | #ifndef __X86INTRIN_H |
| 29 | #error "Never use <tbmintrin.h> directly; include <x86intrin.h> instead." |
| 30 | #endif |
| 31 | |
| 32 | #ifndef __TBMINTRIN_H |
| 33 | #define __TBMINTRIN_H |
| 34 | |
| 35 | #define __bextri_u32(a, b) (__builtin_ia32_bextri_u32((a), (b))) |
| 36 | |
| 37 | #ifdef __x86_64__ |
| 38 | #define __bextri_u64(a, b) (__builtin_ia32_bextri_u64((a), (b))) |
| 39 | #endif |
| 40 | |
| 41 | static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__)) |
| 42 | __blcfill_u32(unsigned int a) |
| 43 | { |
| 44 | return __builtin_ia32_blcfill_u32(a); |
| 45 | } |
| 46 | |
| 47 | #ifdef __x86_64__ |
| 48 | static __inline__ unsigned long long __attribute__((__always_inline__, |
| 49 | __nodebug__)) |
| 50 | __blcfill_u64(unsigned long long a) |
| 51 | { |
| 52 | return __builtin_ia32_blcfill_u64(a); |
| 53 | } |
| 54 | #endif |
| 55 | |
| 56 | static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__)) |
| 57 | __blci_u32(unsigned int a) |
| 58 | { |
| 59 | return __builtin_ia32_blci_u32(a); |
| 60 | } |
| 61 | |
| 62 | #ifdef __x86_64__ |
| 63 | static __inline__ unsigned long long __attribute__((__always_inline__, |
| 64 | __nodebug__)) |
| 65 | __blci_u64(unsigned long long a) |
| 66 | { |
| 67 | return __builtin_ia32_blci_u64(a); |
| 68 | } |
| 69 | #endif |
| 70 | |
| 71 | static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__)) |
| 72 | __blcic_u32(unsigned int a) |
| 73 | { |
| 74 | return __builtin_ia32_blcic_u32(a); |
| 75 | } |
| 76 | |
| 77 | #ifdef __x86_64__ |
| 78 | static __inline__ unsigned long long __attribute__((__always_inline__, |
| 79 | __nodebug__)) |
| 80 | __blcic_u64(unsigned long long a) |
| 81 | { |
| 82 | return __builtin_ia32_blcic_u64(a); |
| 83 | } |
| 84 | #endif |
| 85 | |
| 86 | static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__)) |
| 87 | __blcmsk_u32(unsigned int a) |
| 88 | { |
| 89 | return __builtin_ia32_blcmsk_u32(a); |
| 90 | } |
| 91 | |
| 92 | #ifdef __x86_64__ |
| 93 | static __inline__ unsigned long long __attribute__((__always_inline__, |
| 94 | __nodebug__)) |
| 95 | __blcmsk_u64(unsigned long long a) |
| 96 | { |
| 97 | return __builtin_ia32_blcmsk_u64(a); |
| 98 | } |
| 99 | #endif |
| 100 | |
| 101 | static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__)) |
| 102 | __blcs_u32(unsigned int a) |
| 103 | { |
| 104 | return __builtin_ia32_blcs_u32(a); |
| 105 | } |
| 106 | |
| 107 | #ifdef __x86_64__ |
| 108 | static __inline__ unsigned long long __attribute__((__always_inline__, |
| 109 | __nodebug__)) |
| 110 | __blcs_u64(unsigned long long a) |
| 111 | { |
| 112 | return __builtin_ia32_blcs_u64(a); |
| 113 | } |
| 114 | #endif |
| 115 | |
| 116 | static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__)) |
| 117 | __blsfill_u32(unsigned int a) |
| 118 | { |
| 119 | return __builtin_ia32_blsfill_u32(a); |
| 120 | } |
| 121 | |
| 122 | #ifdef __x86_64__ |
| 123 | static __inline__ unsigned long long __attribute__((__always_inline__, |
| 124 | __nodebug__)) |
| 125 | __blsfill_u64(unsigned long long a) |
| 126 | { |
| 127 | return __builtin_ia32_blsfill_u64(a); |
| 128 | } |
| 129 | #endif |
| 130 | |
| 131 | static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__)) |
| 132 | __blsic_u32(unsigned int a) |
| 133 | { |
| 134 | return __builtin_ia32_blsic_u32(a); |
| 135 | } |
| 136 | |
| 137 | #ifdef __x86_64__ |
| 138 | static __inline__ unsigned long long __attribute__((__always_inline__, |
| 139 | __nodebug__)) |
| 140 | __blsic_u64(unsigned long long a) |
| 141 | { |
| 142 | return __builtin_ia32_blsic_u64(a); |
| 143 | } |
| 144 | #endif |
| 145 | |
| 146 | static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__)) |
| 147 | __t1mskc_u32(unsigned int a) |
| 148 | { |
| 149 | return __builtin_ia32_t1mskc_u32(a); |
| 150 | } |
| 151 | |
| 152 | #ifdef __x86_64__ |
| 153 | static __inline__ unsigned long long __attribute__((__always_inline__, |
| 154 | __nodebug__)) |
| 155 | __t1mskc_u64(unsigned long long a) |
| 156 | { |
| 157 | return __builtin_ia32_t1mskc_u64(a); |
| 158 | } |
| 159 | #endif |
| 160 | |
| 161 | static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__)) |
| 162 | __tzmsk_u32(unsigned int a) |
| 163 | { |
| 164 | return __builtin_ia32_tzmsk_u32(a); |
| 165 | } |
| 166 | |
| 167 | #ifdef __x86_64__ |
| 168 | static __inline__ unsigned long long __attribute__((__always_inline__, |
| 169 | __nodebug__)) |
| 170 | __tzmsk_u64(unsigned long long a) |
| 171 | { |
| 172 | return __builtin_ia32_tzmsk_u64(a); |
| 173 | } |
| 174 | #endif |
| 175 | |
| 176 | #endif /* __TBMINTRIN_H */ |