]> git.ipfire.org Git - thirdparty/gcc.git/blob - libitm/config/alpha/unaligned.h
Merge from transactional-memory branch.
[thirdparty/gcc.git] / libitm / config / alpha / unaligned.h
1 /* Copyright (C) 2009, 2011 Free Software Foundation, Inc.
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
25 #ifndef LIBITM_ALPHA_UNALIGNED_H
26 #define LIBITM_ALPHA_UNALIGNED_H 1
27
28 #define HAVE_ARCH_UNALIGNED_LOAD2_U2 1
29 #define HAVE_ARCH_UNALIGNED_LOAD2_U4 1
30 #define HAVE_ARCH_UNALIGNED_LOAD2_U8 1
31
32 #ifndef __alpha_bwx__
33 #define HAVE_ARCH_UNALIGNED_STORE2_U2 1
34 #endif
35 #define HAVE_ARCH_UNALIGNED_STORE2_U4 1
36 #define HAVE_ARCH_UNALIGNED_STORE2_U8 1
37
38 #include "config/generic/unaligned.h"
39
40 namespace GTM HIDDEN {
41
42 template<>
43 inline uint16_t ALWAYS_INLINE
44 unaligned_load2<uint16_t>(const gtm_cacheline *c1,
45 const gtm_cacheline *c2, size_t ofs)
46 {
47 uint64_t v1 = c1->u64[CACHELINE_SIZE / sizeof(uint64_t) - 1];
48 uint64_t v2 = c2->u64[0];
49
50 return __builtin_alpha_extwl (v1, ofs) | __builtin_alpha_extwh (v2, ofs);
51 }
52
53 template<>
54 inline uint32_t ALWAYS_INLINE
55 unaligned_load2<uint32_t>(const gtm_cacheline *c1,
56 const gtm_cacheline *c2, size_t ofs)
57 {
58 uint64_t v1 = c1->u64[CACHELINE_SIZE / sizeof(uint64_t) - 1];
59 uint64_t v2 = c2->u64[0];
60
61 return __builtin_alpha_extll (v1, ofs) + __builtin_alpha_extlh (v2, ofs);
62 }
63
64 template<>
65 inline uint64_t ALWAYS_INLINE
66 unaligned_load2<uint64_t>(const gtm_cacheline *c1,
67 const gtm_cacheline *c2, size_t ofs)
68 {
69 uint64_t v1 = c1->u64[CACHELINE_SIZE / sizeof(uint64_t) - 1];
70 uint64_t v2 = c2->u64[0];
71
72 return __builtin_alpha_extql (v1, ofs) | __builtin_alpha_extqh (v2, ofs);
73 }
74
75 #ifndef __alpha_bwx__
76 template<>
77 inline void
78 unaligned_store2<uint16_t>(gtm_cacheline *c1, gtm_cacheline *c2,
79 size_t ofs, uint16_t val)
80 {
81 uint32_t vl = (uint32_t)val << 24, vh = val >> 8;
82
83 gtm_cacheline::store_mask (&c1->u32[CACHELINE_SIZE / 4 - 1], vl, 4);
84 gtm_cacheline::store_mask (&c2->u32[0], vh, 1);
85 }
86 #endif
87
88 template<>
89 inline void
90 unaligned_store2<uint32_t>(gtm_cacheline *c1, gtm_cacheline *c2,
91 size_t ofs, uint32_t val)
92 {
93 uint64_t vl = __builtin_alpha_insll (val, ofs);
94 uint64_t ml = __builtin_alpha_insll (~0u, ofs);
95 uint64_t vh = __builtin_alpha_inslh (val, ofs);
96 uint64_t mh = __builtin_alpha_inslh (~0u, ofs);
97
98 gtm_cacheline::store_mask (&c1->u64[CACHELINE_SIZE / 8 - 1], vl, ml);
99 gtm_cacheline::store_mask (&c2->u64[0], vh, mh);
100 }
101
102 template<>
103 inline void
104 unaligned_store2<uint64_t>(gtm_cacheline *c1, gtm_cacheline *c2,
105 size_t ofs, uint64_t val)
106 {
107 uint64_t vl = __builtin_alpha_insql (val, ofs);
108 uint64_t ml = __builtin_alpha_insql (~0u, ofs);
109 uint64_t vh = __builtin_alpha_insqh (val, ofs);
110 uint64_t mh = __builtin_alpha_insqh (~0u, ofs);
111
112 gtm_cacheline::store_mask (&c1->u64[CACHELINE_SIZE / 8 - 1], vl, ml);
113 gtm_cacheline::store_mask (&c2->u64[0], vh, mh);
114 }
115
116 } // namespace GTM
117
118 #endif // LIBITM_ALPHA_UNALIGNED_H