pconfigintrin.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #ifndef _IMMINTRIN_H_INCLUDED
  2. #error "Never use <pconfigintrin.h> directly; include <immintrin.h> instead."
  3. #endif
  4. #ifndef _PCONFIGINTRIN_H_INCLUDED
  5. #define _PCONFIGINTRIN_H_INCLUDED
  6. #ifndef __PCONFIG__
  7. #pragma GCC push_options
  8. #pragma GCC target("pconfig")
  9. #define __DISABLE_PCONFIG__
  10. #endif /* __PCONFIG__ */
  11. #define __pconfig_b(leaf, b, retval) \
  12. __asm__ __volatile__ ("pconfig\n\t" \
  13. : "=a" (retval) \
  14. : "a" (leaf), "b" (b) \
  15. : "cc")
  16. #define __pconfig_generic(leaf, b, c, d, retval) \
  17. __asm__ __volatile__ ("pconfig\n\t" \
  18. : "=a" (retval), "=b" (b), "=c" (c), "=d" (d) \
  19. : "a" (leaf), "b" (b), "c" (c), "d" (d) \
  20. : "cc")
  21. extern __inline unsigned int
  22. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  23. _pconfig_u32 (const unsigned int __L, size_t __D[])
  24. {
  25. enum __pconfig_type
  26. {
  27. __PCONFIG_KEY_PROGRAM = 0x01,
  28. };
  29. unsigned int __R = 0;
  30. if (!__builtin_constant_p (__L))
  31. __pconfig_generic (__L, __D[0], __D[1], __D[2], __R);
  32. else switch (__L)
  33. {
  34. case __PCONFIG_KEY_PROGRAM:
  35. __pconfig_b (__L, __D[0], __R);
  36. break;
  37. default:
  38. __pconfig_generic (__L, __D[0], __D[1], __D[2], __R);
  39. }
  40. return __R;
  41. }
  42. #ifdef __DISABLE_PCONFIG__
  43. #undef __DISABLE_PCONFIG__
  44. #pragma GCC pop_options
  45. #endif /* __DISABLE_PCONFIG__ */
  46. #endif /* _PCONFIGINTRIN_H_INCLUDED */