1/* Copyright (C) 2010-2020 Free Software Foundation, Inc. 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 24#ifndef _X86INTRIN_H_INCLUDED 25# error "Never use <tbmintrin.h> directly; include <x86intrin.h> instead." 26#endif 27 28#ifndef _TBMINTRIN_H_INCLUDED 29#define _TBMINTRIN_H_INCLUDED 30 31#ifndef __TBM__ 32#pragma GCC push_options 33#pragma GCC target("tbm") 34#define __DISABLE_TBM__ 35#endif /* __TBM__ */ 36 37#ifdef __OPTIMIZE__ 38extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 39__bextri_u32 (unsigned int __X, const unsigned int __I) 40{ 41 return __builtin_ia32_bextri_u32 (__X, __I); 42} 43#else 44#define __bextri_u32(X, I) \ 45 ((unsigned int)__builtin_ia32_bextri_u32 ((unsigned int)(X), \ 46 (unsigned int)(I))) 47#endif /*__OPTIMIZE__ */ 48 49extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 50__blcfill_u32 (unsigned int __X) 51{ 52 return __X & (__X + 1); 53} 54 55extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 56__blci_u32 (unsigned int __X) 57{ 58 return __X | ~(__X + 1); 59} 60 61extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 62__blcic_u32 (unsigned int __X) 63{ 64 return ~__X & (__X + 1); 65} 66 67extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 68__blcmsk_u32 (unsigned int __X) 69{ 70 return __X ^ (__X + 1); 71} 72 73extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 74__blcs_u32 (unsigned int __X) 75{ 76 return __X | (__X + 1); 77} 78 79extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 80__blsfill_u32 (unsigned int __X) 81{ 82 return __X | (__X - 1); 83} 84 85extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 86__blsic_u32 (unsigned int __X) 87{ 88 return ~__X | (__X - 1); 89} 90 91extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 92__t1mskc_u32 (unsigned int __X) 93{ 94 return ~__X | (__X + 1); 95} 96 97extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 98__tzmsk_u32 (unsigned int __X) 99{ 100 return ~__X & (__X - 1); 101} 102 103 104 105#ifdef __x86_64__ 106#ifdef __OPTIMIZE__ 107extern __inline unsigned long long __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 108__bextri_u64 (unsigned long long __X, const unsigned int __I) 109{ 110 return __builtin_ia32_bextri_u64 (__X, __I); 111} 112#else 113#define __bextri_u64(X, I) \ 114 ((unsigned long long)__builtin_ia32_bextri_u64 ((unsigned long long)(X), \ 115 (unsigned long long)(I))) 116#endif /*__OPTIMIZE__ */ 117 118extern __inline unsigned long long __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 119__blcfill_u64 (unsigned long long __X) 120{ 121 return __X & (__X + 1); 122} 123 124extern __inline unsigned long long __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 125__blci_u64 (unsigned long long __X) 126{ 127 return __X | ~(__X + 1); 128} 129 130extern __inline unsigned long long __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 131__blcic_u64 (unsigned long long __X) 132{ 133 return ~__X & (__X + 1); 134} 135 136extern __inline unsigned long long __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 137__blcmsk_u64 (unsigned long long __X) 138{ 139 return __X ^ (__X + 1); 140} 141 142extern __inline unsigned long long __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 143__blcs_u64 (unsigned long long __X) 144{ 145 return __X | (__X + 1); 146} 147 148extern __inline unsigned long long __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 149__blsfill_u64 (unsigned long long __X) 150{ 151 return __X | (__X - 1); 152} 153 154extern __inline unsigned long long __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 155__blsic_u64 (unsigned long long __X) 156{ 157 return ~__X | (__X - 1); 158} 159 160extern __inline unsigned long long __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 161__t1mskc_u64 (unsigned long long __X) 162{ 163 return ~__X | (__X + 1); 164} 165 166extern __inline unsigned long long __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 167__tzmsk_u64 (unsigned long long __X) 168{ 169 return ~__X & (__X - 1); 170} 171 172 173#endif /* __x86_64__ */ 174 175#ifdef __DISABLE_TBM__ 176#undef __DISABLE_TBM__ 177#pragma GCC pop_options 178#endif /* __DISABLE_TBM__ */ 179 180#endif /* _TBMINTRIN_H_INCLUDED */ 181