1 /* Copyright (C) 2009-2015 Free Software Foundation, Inc.
2 Contributed by Richard Henderson <rth@redhat.com>.
4 This file is part of the GNU Transactional Memory Library (libitm).
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.
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
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.
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/>. */
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.
37 typedef float _ITM_TYPE_M256
__attribute__((vector_size(32), may_alias
));
40 // Re-define the memcpy implementations so that we can frob the
41 // interface to deal with possibly missing AVX instruction set support.
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
49 /* Emit vmovaps (%rax),%ymm0. */
51 asm volatile(".byte 0xc5,0xfc,0x28,0x00" : "=m"(X) : "a"(&X))
52 /* Emit vmovaps %ymm0,(%rax); vzeroupper. */
54 asm volatile(".byte 0xc5,0xfc,0x29,0x00,0xc5,0xf8,0x77" : "=m"(X) : "a"(&X))
55 #define OUTPUT(T) void
59 #undef ITM_READ_MEMCPY
60 #define ITM_READ_MEMCPY(T, LSMOD, TARGET, M2) \
61 OUTPUT(T) ITM_REGPARM _ITM_##LSMOD##T (const _ITM_TYPE_##T *ptr) \
64 TARGET memtransfer##M2(&v, ptr, sizeof(_ITM_TYPE_##T), false, \
65 GTM::abi_dispatch::NONTXNAL, \
66 GTM::abi_dispatch::LSMOD); \
70 #undef ITM_WRITE_MEMCPY
71 #define ITM_WRITE_MEMCPY(T, LSMOD, TARGET, M2) \
72 void ITM_REGPARM _ITM_##LSMOD##T (_ITM_TYPE_##T *ptr INPUT(T,in)) \
76 TARGET memtransfer##M2(ptr, &v, sizeof(_ITM_TYPE_##T), false, \
77 GTM::abi_dispatch::LSMOD, \
78 GTM::abi_dispatch::NONTXNAL); \
81 // ??? Use memcpy for now, until we have figured out how to best instantiate
82 // these loads/stores.
83 CREATE_DISPATCH_FUNCTIONS_T_MEMCPY(M256
, GTM::abi_disp()->, )
86 _ITM_LM256 (const _ITM_TYPE_M256
*ptr
)
88 GTM::GTM_LB (ptr
, sizeof (*ptr
));