keylockerintrin.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. #if !defined _IMMINTRIN_H_INCLUDED
  19. # error "Never use <keylockerintrin.h> directly; include <x86intrin.h> instead."
  20. #endif
  21. #ifndef _KEYLOCKERINTRIN_H_INCLUDED
  22. #define _KEYLOCKERINTRIN_H_INCLUDED
  23. #ifndef __KL__
  24. #pragma GCC push_options
  25. #pragma GCC target("kl")
  26. #define __DISABLE_KL__
  27. #endif /* __KL__ */
  28. extern __inline
  29. void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  30. _mm_loadiwkey (unsigned int __I, __m128i __A, __m128i __B, __m128i __C)
  31. {
  32. __builtin_ia32_loadiwkey ((__v2di) __B, (__v2di) __C, (__v2di) __A, __I);
  33. }
  34. extern __inline
  35. unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  36. _mm_encodekey128_u32 (unsigned int __I, __m128i __A, void * __P)
  37. {
  38. return __builtin_ia32_encodekey128_u32 (__I, (__v2di)__A, __P);
  39. }
  40. extern __inline
  41. unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  42. _mm_encodekey256_u32 (unsigned int __I, __m128i __A, __m128i __B, void * __P)
  43. {
  44. return __builtin_ia32_encodekey256_u32 (__I, (__v2di)__A, (__v2di)__B, __P);
  45. }
  46. extern __inline
  47. unsigned char __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  48. _mm_aesdec128kl_u8 (__m128i * __A, __m128i __B, const void * __P)
  49. {
  50. return __builtin_ia32_aesdec128kl_u8 ((__v2di *) __A, (__v2di) __B, __P);
  51. }
  52. extern __inline
  53. unsigned char __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  54. _mm_aesdec256kl_u8 (__m128i * __A, __m128i __B, const void * __P)
  55. {
  56. return __builtin_ia32_aesdec256kl_u8 ((__v2di *) __A, (__v2di) __B, __P);
  57. }
  58. extern __inline
  59. unsigned char __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  60. _mm_aesenc128kl_u8 (__m128i * __A, __m128i __B, const void * __P)
  61. {
  62. return __builtin_ia32_aesenc128kl_u8 ((__v2di *) __A, (__v2di) __B, __P);
  63. }
  64. extern __inline
  65. unsigned char __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  66. _mm_aesenc256kl_u8 (__m128i * __A, __m128i __B, const void * __P)
  67. {
  68. return __builtin_ia32_aesenc256kl_u8 ((__v2di *) __A, (__v2di) __B, __P);
  69. }
  70. #ifdef __DISABLE_KL__
  71. #undef __DISABLE_KL__
  72. #pragma GCC pop_options
  73. #endif /* __DISABLE_KL__ */
  74. #ifndef __WIDEKL__
  75. #pragma GCC push_options
  76. #pragma GCC target("widekl")
  77. #define __DISABLE_WIDEKL__
  78. #endif /* __WIDEKL__ */
  79. extern __inline
  80. unsigned char __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  81. _mm_aesdecwide128kl_u8(__m128i __A[8], const __m128i __B[8], const void * __P)
  82. {
  83. return __builtin_ia32_aesdecwide128kl_u8 ((__v2di *) __A, (__v2di *) __B, __P);
  84. }
  85. extern __inline
  86. unsigned char __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  87. _mm_aesdecwide256kl_u8(__m128i __A[8], const __m128i __B[8], const void * __P)
  88. {
  89. return __builtin_ia32_aesdecwide256kl_u8 ((__v2di *) __A, (__v2di *) __B, __P);
  90. }
  91. extern __inline
  92. unsigned char __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  93. _mm_aesencwide128kl_u8(__m128i __A[8], const __m128i __B[8], const void * __P)
  94. {
  95. return __builtin_ia32_aesencwide128kl_u8 ((__v2di *) __A, (__v2di *) __B, __P);
  96. }
  97. extern __inline
  98. unsigned char __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  99. _mm_aesencwide256kl_u8(__m128i __A[8], const __m128i __B[8], const void * __P)
  100. {
  101. return __builtin_ia32_aesencwide256kl_u8 ((__v2di *) __A, (__v2di *) __B, __P);
  102. }
  103. #ifdef __DISABLE_WIDEKL__
  104. #undef __DISABLE_WIDEKL__
  105. #pragma GCC pop_options
  106. #endif /* __DISABLE_WIDEKL__ */
  107. #endif /* _KEYLOCKERINTRIN_H_INCLUDED */