]>
git.ipfire.org Git - thirdparty/gcc.git/blob - 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>.
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)
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
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.
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/>. */
25 # error "HTM instruction set not enabled"
28 #ifndef _HTMXLINTRIN_H
29 #define _HTMXLINTRIN_H
32 #include <htmintrin.h>
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))
47 typedef char TM_buff_type
[16];
50 __attribute__ ((__gnu_inline__
, __always_inline__
, __artificial__
))
51 __TM_simple_begin (void)
53 if (__builtin_expect (__builtin_tbegin (0), 1))
59 __attribute__ ((__gnu_inline__
, __always_inline__
, __artificial__
))
60 __TM_begin (void* const TM_buff
)
62 *_TEXASRL_PTR (TM_buff
) = 0;
63 if (__builtin_expect (__builtin_tbegin (0), 1))
66 *_TEXASR_PTR (TM_buff
) = __builtin_get_texasr ();
68 *_TEXASRU_PTR (TM_buff
) = __builtin_get_texasru ();
69 *_TEXASRL_PTR (TM_buff
) = __builtin_get_texasr ();
71 *_TFIAR_PTR (TM_buff
) = __builtin_get_tfiar ();
76 __attribute__ ((__gnu_inline__
, __always_inline__
, __artificial__
))
79 if (__builtin_expect (__builtin_tend (0), 1))
85 __attribute__ ((__gnu_inline__
, __always_inline__
, __artificial__
))
92 __attribute__ ((__gnu_inline__
, __always_inline__
, __artificial__
))
93 __TM_named_abort (unsigned char const code
)
95 __builtin_tabort (code
);
99 __attribute__ ((__gnu_inline__
, __always_inline__
, __artificial__
))
102 __builtin_tresume ();
106 __attribute__ ((__gnu_inline__
, __always_inline__
, __artificial__
))
109 __builtin_tsuspend ();
113 __attribute__ ((__gnu_inline__
, __always_inline__
, __artificial__
))
114 __TM_is_user_abort (void* const TM_buff
)
116 texasru_t texasru
= *_TEXASRU_PTR (TM_buff
);
117 return _TEXASRU_ABORT (texasru
);
121 __attribute__ ((__gnu_inline__
, __always_inline__
, __artificial__
))
122 __TM_is_named_user_abort (void* const TM_buff
, unsigned char *code
)
124 texasru_t texasru
= *_TEXASRU_PTR (TM_buff
);
126 *code
= _TEXASRU_FAILURE_CODE (texasru
);
127 return _TEXASRU_ABORT (texasru
);
131 __attribute__ ((__gnu_inline__
, __always_inline__
, __artificial__
))
132 __TM_is_illegal (void* const TM_buff
)
134 texasru_t texasru
= *_TEXASRU_PTR (TM_buff
);
135 return _TEXASRU_DISALLOWED (texasru
);
139 __attribute__ ((__gnu_inline__
, __always_inline__
, __artificial__
))
140 __TM_is_footprint_exceeded (void* const TM_buff
)
142 texasru_t texasru
= *_TEXASRU_PTR (TM_buff
);
143 return _TEXASRU_FOOTPRINT_OVERFLOW (texasru
);
147 __attribute__ ((__gnu_inline__
, __always_inline__
, __artificial__
))
148 __TM_nesting_depth (void* const TM_buff
)
152 if (_HTM_STATE (__builtin_ttest ()) == _HTM_NONTRANSACTIONAL
)
154 texasrl
= *_TEXASRL_PTR (TM_buff
);
155 if (!_TEXASR_FAILURE_SUMMARY (texasrl
))
159 texasrl
= (texasrl_t
) __builtin_get_texasr ();
161 return _TEXASR_TRANSACTION_LEVEL (texasrl
);
165 __attribute__ ((__gnu_inline__
, __always_inline__
, __artificial__
))
166 __TM_is_nested_too_deep(void* const TM_buff
)
168 texasru_t texasru
= *_TEXASRU_PTR (TM_buff
);
169 return _TEXASRU_NESTING_OVERFLOW (texasru
);
173 __attribute__ ((__gnu_inline__
, __always_inline__
, __artificial__
))
174 __TM_is_conflict(void* const TM_buff
)
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;
183 __attribute__ ((__gnu_inline__
, __always_inline__
, __artificial__
))
184 __TM_is_failure_persistent(void* const TM_buff
)
186 texasru_t texasru
= *_TEXASRU_PTR (TM_buff
);
187 return _TEXASRU_FAILURE_PERSISTENT (texasru
);
191 __attribute__ ((__gnu_inline__
, __always_inline__
, __artificial__
))
192 __TM_failure_address(void* const TM_buff
)
194 return *_TFIAR_PTR (TM_buff
);
197 extern __inline
long long
198 __attribute__ ((__gnu_inline__
, __always_inline__
, __artificial__
))
199 __TM_failure_code(void* const TM_buff
)
201 return *_TEXASR_PTR (TM_buff
);
208 #endif /* _HTMXLINTRIN_H */