rtmintrin.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /* Copyright (C) 2012-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. #ifndef _IMMINTRIN_H_INCLUDED
  19. # error "Never use <rtmintrin.h> directly; include <immintrin.h> instead."
  20. #endif
  21. #ifndef _RTMINTRIN_H_INCLUDED
  22. #define _RTMINTRIN_H_INCLUDED
  23. #ifndef __RTM__
  24. #pragma GCC push_options
  25. #pragma GCC target("rtm")
  26. #define __DISABLE_RTM__
  27. #endif /* __RTM__ */
  28. #define _XBEGIN_STARTED (~0u)
  29. #define _XABORT_EXPLICIT (1 << 0)
  30. #define _XABORT_RETRY (1 << 1)
  31. #define _XABORT_CONFLICT (1 << 2)
  32. #define _XABORT_CAPACITY (1 << 3)
  33. #define _XABORT_DEBUG (1 << 4)
  34. #define _XABORT_NESTED (1 << 5)
  35. #define _XABORT_CODE(x) (((x) >> 24) & 0xFF)
  36. /* Start an RTM code region. Return _XBEGIN_STARTED on success and the
  37. abort condition otherwise. */
  38. extern __inline unsigned int
  39. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  40. _xbegin (void)
  41. {
  42. return __builtin_ia32_xbegin ();
  43. }
  44. /* Specify the end of an RTM code region. If it corresponds to the
  45. outermost transaction, then attempts the transaction commit. If the
  46. commit fails, then control is transferred to the outermost transaction
  47. fallback handler. */
  48. extern __inline void
  49. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  50. _xend (void)
  51. {
  52. __builtin_ia32_xend ();
  53. }
  54. /* Force an RTM abort condition. The control is transferred to the
  55. outermost transaction fallback handler with the abort condition IMM. */
  56. #ifdef __OPTIMIZE__
  57. extern __inline void
  58. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  59. _xabort (const unsigned int __imm)
  60. {
  61. __builtin_ia32_xabort (__imm);
  62. }
  63. #else
  64. #define _xabort(N) __builtin_ia32_xabort (N)
  65. #endif /* __OPTIMIZE__ */
  66. #ifdef __DISABLE_RTM__
  67. #undef __DISABLE_RTM__
  68. #pragma GCC pop_options
  69. #endif /* __DISABLE_RTM__ */
  70. #endif /* _RTMINTRIN_H_INCLUDED */