amxtileintrin.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /* Copyright (C) 2020-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 <amxtileintrin.h> directly; include <immintrin.h> instead."
  20. #endif
  21. #ifndef _AMXTILEINTRIN_H_INCLUDED
  22. #define _AMXTILEINTRIN_H_INCLUDED
  23. #if !defined(__AMX_TILE__)
  24. #pragma GCC push_options
  25. #pragma GCC target("amx-tile")
  26. #define __DISABLE_AMX_TILE__
  27. #endif /* __AMX_TILE__ */
  28. #if defined(__x86_64__)
  29. extern __inline void
  30. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  31. _tile_loadconfig (const void *__config)
  32. {
  33. __asm__ volatile ("ldtilecfg\t%X0" :: "m" (*((const void **)__config)));
  34. }
  35. extern __inline void
  36. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  37. _tile_storeconfig (void *__config)
  38. {
  39. __asm__ volatile ("sttilecfg\t%X0" : "=m" (*((void **)__config)));
  40. }
  41. extern __inline void
  42. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  43. _tile_release (void)
  44. {
  45. __asm__ volatile ("tilerelease" ::);
  46. }
  47. #define _tile_loadd(dst,base,stride) \
  48. _tile_loadd_internal (dst, base, stride)
  49. #define _tile_loadd_internal(dst,base,stride) \
  50. __asm__ volatile \
  51. ("{tileloadd\t(%0,%1,1), %%tmm"#dst"|tileloadd\t%%tmm"#dst", [%0+%1*1]}" \
  52. :: "r" ((const void*) (base)), "r" ((long) (stride)))
  53. #define _tile_stream_loadd(dst,base,stride) \
  54. _tile_stream_loadd_internal (dst, base, stride)
  55. #define _tile_stream_loadd_internal(dst,base,stride) \
  56. __asm__ volatile \
  57. ("{tileloaddt1\t(%0,%1,1), %%tmm"#dst"|tileloaddt1\t%%tmm"#dst", [%0+%1*1]}" \
  58. :: "r" ((const void*) (base)), "r" ((long) (stride)))
  59. #define _tile_stored(dst,base,stride) \
  60. _tile_stored_internal (dst, base, stride)
  61. #define _tile_stored_internal(src,base,stride) \
  62. __asm__ volatile \
  63. ("{tilestored\t%%tmm"#src", (%0,%1,1)|tilestored\t[%0+%1*1], %%tmm"#src"}" \
  64. :: "r" ((void*) (base)), "r" ((long) (stride)) \
  65. : "memory")
  66. #define _tile_zero(dst) \
  67. _tile_zero_internal (dst)
  68. #define _tile_zero_internal(dst) \
  69. __asm__ volatile \
  70. ("tilezero\t%%tmm"#dst ::)
  71. #endif
  72. #ifdef __DISABLE_AMX_TILE__
  73. #undef __DISABLE_AMX_TILE__
  74. #pragma GCC pop_options
  75. #endif /* __DISABLE_AMX_TILE__ */
  76. #endif /* _AMXTILEINTRIN_H_INCLUDED */