]> git.ipfire.org Git - thirdparty/gcc.git/blame - libitm/config/x86/x86_avx.cc
Update copyright years.
[thirdparty/gcc.git] / libitm / config / x86 / x86_avx.cc
CommitLineData
a945c346 1/* Copyright (C) 2009-2024 Free Software Foundation, Inc.
0a35513e
AH
2 Contributed by Richard Henderson <rth@redhat.com>.
3
4 This file is part of the GNU Transactional Memory Library (libitm).
5
6 Libitm is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
10
11 Libitm is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 more details.
15
16 Under Section 7 of GPL version 3, you are granted additional
17 permissions described in the GCC Runtime Library Exception, version
18 3.1, as published by the Free Software Foundation.
19
20 You should have received a copy of the GNU General Public License and
21 a copy of the GCC Runtime Library Exception along with this program;
22 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 <http://www.gnu.org/licenses/>. */
24
430616e7
RH
25#include "config.h"
26
0a35513e
AH
27#include "libitm_i.h"
28#include "dispatch.h"
29
430616e7
RH
30extern "C" {
31
32#ifndef HAVE_AS_AVX
d4b17902
RH
33// If we don't have an AVX capable assembler, we didn't set -mavx on the
34// command-line either, which means that libitm.h defined neither this type
35// nor the functions in this file. Define the type and unconditionally
36// wrap the file in extern "C" to make up for the lack of pre-declaration.
430616e7
RH
37typedef float _ITM_TYPE_M256 __attribute__((vector_size(32), may_alias));
38#endif
39
d4b17902 40// Re-define the memcpy implementations so that we can frob the
430616e7
RH
41// interface to deal with possibly missing AVX instruction set support.
42
43#ifdef HAVE_AS_AVX
44#define RETURN(X) return X
45#define STORE(X,Y) X = Y
46#define OUTPUT(T) _ITM_TYPE_##T
47#define INPUT(T,X) , _ITM_TYPE_##T X
48#else
49/* Emit vmovaps (%rax),%ymm0. */
50#define RETURN(X) \
d4b17902 51 asm volatile(".byte 0xc5,0xfc,0x28,0x00" : "=m"(X) : "a"(&X))
430616e7
RH
52/* Emit vmovaps %ymm0,(%rax); vzeroupper. */
53#define STORE(X,Y) \
d4b17902 54 asm volatile(".byte 0xc5,0xfc,0x29,0x00,0xc5,0xf8,0x77" : "=m"(X) : "a"(&X))
430616e7
RH
55#define OUTPUT(T) void
56#define INPUT(T,X)
57#endif
58
59#undef ITM_READ_MEMCPY
60#define ITM_READ_MEMCPY(T, LSMOD, TARGET, M2) \
61OUTPUT(T) ITM_REGPARM _ITM_##LSMOD##T (const _ITM_TYPE_##T *ptr) \
62{ \
63 _ITM_TYPE_##T v; \
64 TARGET memtransfer##M2(&v, ptr, sizeof(_ITM_TYPE_##T), false, \
65 GTM::abi_dispatch::NONTXNAL, \
66 GTM::abi_dispatch::LSMOD); \
67 RETURN(v); \
68}
69
70#undef ITM_WRITE_MEMCPY
71#define ITM_WRITE_MEMCPY(T, LSMOD, TARGET, M2) \
72void ITM_REGPARM _ITM_##LSMOD##T (_ITM_TYPE_##T *ptr INPUT(T,in)) \
73{ \
74 _ITM_TYPE_##T v; \
75 STORE(v, in); \
76 TARGET memtransfer##M2(ptr, &v, sizeof(_ITM_TYPE_##T), false, \
77 GTM::abi_dispatch::LSMOD, \
78 GTM::abi_dispatch::NONTXNAL); \
79}
80
0a35513e
AH
81// ??? Use memcpy for now, until we have figured out how to best instantiate
82// these loads/stores.
83CREATE_DISPATCH_FUNCTIONS_T_MEMCPY(M256, GTM::abi_disp()->, )
84
85void ITM_REGPARM
86_ITM_LM256 (const _ITM_TYPE_M256 *ptr)
87{
88 GTM::GTM_LB (ptr, sizeof (*ptr));
89}
430616e7 90
d4b17902 91} // extern "C"