lzcntintrin.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* Copyright (C) 2009-2019 Free Software Foundation, Inc.
  2. This file is part of GCC.
  3. GCC is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 3, or (at your option)
  6. any later version.
  7. GCC is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. Under Section 7 of GPL version 3, you are granted additional
  12. permissions described in the GCC Runtime Library Exception, version
  13. 3.1, as published by the Free Software Foundation.
  14. You should have received a copy of the GNU General Public License and
  15. a copy of the GCC Runtime Library Exception along with this program;
  16. see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  17. <http://www.gnu.org/licenses/>. */
  18. #if !defined _X86INTRIN_H_INCLUDED && !defined _IMMINTRIN_H_INCLUDED
  19. # error "Never use <lzcntintrin.h> directly; include <x86intrin.h> instead."
  20. #endif
  21. #ifndef _LZCNTINTRIN_H_INCLUDED
  22. #define _LZCNTINTRIN_H_INCLUDED
  23. #ifndef __LZCNT__
  24. #pragma GCC push_options
  25. #pragma GCC target("lzcnt")
  26. #define __DISABLE_LZCNT__
  27. #endif /* __LZCNT__ */
  28. extern __inline unsigned short __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  29. __lzcnt16 (unsigned short __X)
  30. {
  31. return __builtin_ia32_lzcnt_u16 (__X);
  32. }
  33. extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  34. __lzcnt32 (unsigned int __X)
  35. {
  36. return __builtin_ia32_lzcnt_u32 (__X);
  37. }
  38. extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  39. _lzcnt_u32 (unsigned int __X)
  40. {
  41. return __builtin_ia32_lzcnt_u32 (__X);
  42. }
  43. #ifdef __x86_64__
  44. extern __inline unsigned long long __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  45. __lzcnt64 (unsigned long long __X)
  46. {
  47. return __builtin_ia32_lzcnt_u64 (__X);
  48. }
  49. extern __inline unsigned long long __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  50. _lzcnt_u64 (unsigned long long __X)
  51. {
  52. return __builtin_ia32_lzcnt_u64 (__X);
  53. }
  54. #endif
  55. #ifdef __DISABLE_LZCNT__
  56. #undef __DISABLE_LZCNT__
  57. #pragma GCC pop_options
  58. #endif /* __DISABLE_LZCNT__ */
  59. #endif /* _LZCNTINTRIN_H_INCLUDED */