]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/rs6000/htmxlintrin.h
Update copyright years in gcc/
[thirdparty/gcc.git] / gcc / config / rs6000 / htmxlintrin.h
1 /* XL compiler Hardware Transactional Memory (HTM) execution intrinsics.
2 Copyright (C) 2013-2014 Free Software Foundation, Inc.
3 Contributed by Peter Bergner <bergner@vnet.ibm.com>.
4
5 This file is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License as published by the Free
7 Software Foundation; either version 3 of the License, or (at your option)
8 any later version.
9
10 This file is distributed in the hope that it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 for more details.
14
15 Under Section 7 of GPL version 3, you are granted additional
16 permissions described in the GCC Runtime Library Exception, version
17 3.1, as published by the Free Software Foundation.
18
19 You should have received a copy of the GNU General Public License and
20 a copy of the GCC Runtime Library Exception along with this program;
21 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
22 <http://www.gnu.org/licenses/>. */
23
24 #ifndef __HTM__
25 # error "HTM instruction set not enabled"
26 #endif /* __HTM__ */
27
28 #ifndef _HTMXLINTRIN_H
29 #define _HTMXLINTRIN_H
30
31 #include <stdint.h>
32 #include <htmintrin.h>
33
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37
38 #define _TEXASR_PTR(TM_BUF) \
39 ((texasr_t *)((TM_BUF)+0))
40 #define _TEXASRU_PTR(TM_BUF) \
41 ((texasru_t *)((TM_BUF)+0))
42 #define _TEXASRL_PTR(TM_BUF) \
43 ((texasrl_t *)((TM_BUF)+4))
44 #define _TFIAR_PTR(TM_BUF) \
45 ((tfiar_t *)((TM_BUF)+8))
46
47 typedef char TM_buff_type[16];
48
49 extern __inline long
50 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
51 __TM_simple_begin (void)
52 {
53 if (__builtin_expect (__builtin_tbegin (0), 1))
54 return 1;
55 return 0;
56 }
57
58 extern __inline long
59 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
60 __TM_begin (void* const TM_buff)
61 {
62 *_TEXASRL_PTR (TM_buff) = 0;
63 if (__builtin_expect (__builtin_tbegin (0), 1))
64 return 1;
65 #ifdef __powerpc64__
66 *_TEXASR_PTR (TM_buff) = __builtin_get_texasr ();
67 #else
68 *_TEXASRU_PTR (TM_buff) = __builtin_get_texasru ();
69 *_TEXASRL_PTR (TM_buff) = __builtin_get_texasr ();
70 #endif
71 *_TFIAR_PTR (TM_buff) = __builtin_get_tfiar ();
72 return 0;
73 }
74
75 extern __inline long
76 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
77 __TM_end (void)
78 {
79 if (__builtin_expect (__builtin_tend (0), 1))
80 return 1;
81 return 0;
82 }
83
84 extern __inline void
85 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
86 __TM_abort (void)
87 {
88 __builtin_tabort (0);
89 }
90
91 extern __inline void
92 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
93 __TM_named_abort (unsigned char const code)
94 {
95 __builtin_tabort (code);
96 }
97
98 extern __inline void
99 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
100 __TM_resume (void)
101 {
102 __builtin_tresume ();
103 }
104
105 extern __inline void
106 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
107 __TM_suspend (void)
108 {
109 __builtin_tsuspend ();
110 }
111
112 extern __inline long
113 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
114 __TM_is_user_abort (void* const TM_buff)
115 {
116 texasru_t texasru = *_TEXASRU_PTR (TM_buff);
117 return _TEXASRU_ABORT (texasru);
118 }
119
120 extern __inline long
121 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
122 __TM_is_named_user_abort (void* const TM_buff, unsigned char *code)
123 {
124 texasru_t texasru = *_TEXASRU_PTR (TM_buff);
125
126 *code = _TEXASRU_FAILURE_CODE (texasru);
127 return _TEXASRU_ABORT (texasru);
128 }
129
130 extern __inline long
131 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
132 __TM_is_illegal (void* const TM_buff)
133 {
134 texasru_t texasru = *_TEXASRU_PTR (TM_buff);
135 return _TEXASRU_DISALLOWED (texasru);
136 }
137
138 extern __inline long
139 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
140 __TM_is_footprint_exceeded (void* const TM_buff)
141 {
142 texasru_t texasru = *_TEXASRU_PTR (TM_buff);
143 return _TEXASRU_FOOTPRINT_OVERFLOW (texasru);
144 }
145
146 extern __inline long
147 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
148 __TM_nesting_depth (void* const TM_buff)
149 {
150 texasrl_t texasrl;
151
152 if (_HTM_STATE (__builtin_ttest ()) == _HTM_NONTRANSACTIONAL)
153 {
154 texasrl = *_TEXASRL_PTR (TM_buff);
155 if (!_TEXASR_FAILURE_SUMMARY (texasrl))
156 texasrl = 0;
157 }
158 else
159 texasrl = (texasrl_t) __builtin_get_texasr ();
160
161 return _TEXASR_TRANSACTION_LEVEL (texasrl);
162 }
163
164 extern __inline long
165 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
166 __TM_is_nested_too_deep(void* const TM_buff)
167 {
168 texasru_t texasru = *_TEXASRU_PTR (TM_buff);
169 return _TEXASRU_NESTING_OVERFLOW (texasru);
170 }
171
172 extern __inline long
173 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
174 __TM_is_conflict(void* const TM_buff)
175 {
176 texasru_t texasru = *_TEXASRU_PTR (TM_buff);
177 /* Return TEXASR bits 11 (Self-Induced Conflict) through
178 14 (Translation Invalidation Conflict). */
179 return (_TEXASRU_EXTRACT_BITS (texasru, 14, 4)) ? 1 : 0;
180 }
181
182 extern __inline long
183 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
184 __TM_is_failure_persistent(void* const TM_buff)
185 {
186 texasru_t texasru = *_TEXASRU_PTR (TM_buff);
187 return _TEXASRU_FAILURE_PERSISTENT (texasru);
188 }
189
190 extern __inline long
191 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
192 __TM_failure_address(void* const TM_buff)
193 {
194 return *_TFIAR_PTR (TM_buff);
195 }
196
197 extern __inline long long
198 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
199 __TM_failure_code(void* const TM_buff)
200 {
201 return *_TEXASR_PTR (TM_buff);
202 }
203
204 #ifdef __cplusplus
205 }
206 #endif
207
208 #endif /* _HTMXLINTRIN_H */