pconfigintrin.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /* Copyright (C) 2018-2022 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. #ifndef _X86GPRINTRIN_H_INCLUDED
  19. # error "Never use <pconfigintrin.h> directly; include <x86gprintrin.h> instead."
  20. #endif
  21. #ifndef _PCONFIGINTRIN_H_INCLUDED
  22. #define _PCONFIGINTRIN_H_INCLUDED
  23. #ifndef __PCONFIG__
  24. #pragma GCC push_options
  25. #pragma GCC target("pconfig")
  26. #define __DISABLE_PCONFIG__
  27. #endif /* __PCONFIG__ */
  28. #define __pconfig_b(leaf, b, retval) \
  29. __asm__ __volatile__ ("pconfig\n\t" \
  30. : "=a" (retval) \
  31. : "a" (leaf), "b" (b) \
  32. : "cc")
  33. #define __pconfig_generic(leaf, b, c, d, retval) \
  34. __asm__ __volatile__ ("pconfig\n\t" \
  35. : "=a" (retval), "=b" (b), "=c" (c), "=d" (d) \
  36. : "a" (leaf), "b" (b), "c" (c), "d" (d) \
  37. : "cc")
  38. extern __inline unsigned int
  39. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  40. _pconfig_u32 (const unsigned int __L, size_t __D[])
  41. {
  42. enum __pconfig_type
  43. {
  44. __PCONFIG_KEY_PROGRAM = 0x01,
  45. };
  46. unsigned int __R = 0;
  47. if (!__builtin_constant_p (__L))
  48. __pconfig_generic (__L, __D[0], __D[1], __D[2], __R);
  49. else switch (__L)
  50. {
  51. case __PCONFIG_KEY_PROGRAM:
  52. __pconfig_b (__L, __D[0], __R);
  53. break;
  54. default:
  55. __pconfig_generic (__L, __D[0], __D[1], __D[2], __R);
  56. }
  57. return __R;
  58. }
  59. #ifdef __DISABLE_PCONFIG__
  60. #undef __DISABLE_PCONFIG__
  61. #pragma GCC pop_options
  62. #endif /* __DISABLE_PCONFIG__ */
  63. #endif /* _PCONFIGINTRIN_H_INCLUDED */