]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/config/rs6000/htmxlintrin.h
Daily bump.
[thirdparty/gcc.git] / gcc / config / rs6000 / htmxlintrin.h
CommitLineData
0258b6e4 1/* XL compiler Hardware Transactional Memory (HTM) execution intrinsics.
23a5b65a 2 Copyright (C) 2013-2014 Free Software Foundation, Inc.
0258b6e4
PB
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
35extern "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
47typedef char TM_buff_type[16];
48
49extern __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
58extern __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
75extern __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
84extern __inline void
85__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
86__TM_abort (void)
87{
88 __builtin_tabort (0);
89}
90
91extern __inline void
92__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
93__TM_named_abort (unsigned char const code)
94{
95 __builtin_tabort (code);
96}
97
98extern __inline void
99__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
100__TM_resume (void)
101{
102 __builtin_tresume ();
103}
104
105extern __inline void
106__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
107__TM_suspend (void)
108{
109 __builtin_tsuspend ();
110}
111
112extern __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
120extern __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
130extern __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
138extern __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
146extern __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
164extern __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
172extern __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
182extern __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
190extern __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
197extern __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 */