1 /* XL compiler hardware transactional execution intrinsics
2 Copyright (C) 2013-2017 Free Software Foundation, Inc.
3 Contributed by Andreas Krebbel (Andreas.Krebbel@de.ibm.com)
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #ifndef _HTMXLINTRIN_H
22 #define _HTMXLINTRIN_H
26 #include <htmintrin.h>
32 /* These intrinsics are being made available for compatibility with
33 the IBM XL compiler. For documentation please see the "z/OS XL
34 C/C++ Programming Guide" publicly available on the web. */
36 /* FIXME: __TM_simple_begin and __TM_begin should be marked
37 __always_inline__ as well but this currently produces an error
38 since the tbegin builtins are "returns_twice" and setjmp_call_p
39 (calls.c) therefore identifies the functions as calling setjmp.
40 The tree inliner currently refuses to inline functions calling
46 return __builtin_tbegin_nofloat (0);
50 __TM_begin (void* const tdb
)
52 return __builtin_tbegin_nofloat (tdb
);
55 extern __inline
long __attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
58 return __builtin_tend ();
61 extern __inline
void __attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
64 return __builtin_tabort (_HTM_FIRST_USER_ABORT_CODE
);
67 extern __inline
void __attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
68 __TM_named_abort (unsigned char const code
)
70 return __builtin_tabort ((int)_HTM_FIRST_USER_ABORT_CODE
+ code
);
73 extern __inline
void __attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
74 __TM_non_transactional_store (void* const addr
, long long const value
)
76 __builtin_non_tx_store ((uint64_t*)addr
, (uint64_t)value
);
79 extern __inline
long __attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
80 __TM_nesting_depth (void* const tdb_ptr
)
82 int depth
= __builtin_tx_nesting_depth ();
83 struct __htm_tdb
*tdb
= (struct __htm_tdb
*)tdb_ptr
;
90 return tdb
->nesting_depth
;
93 /* Transaction failure diagnostics */
95 extern __inline
long __attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
96 __TM_is_user_abort (void* const tdb_ptr
)
98 struct __htm_tdb
*tdb
= (struct __htm_tdb
*)tdb_ptr
;
100 if (tdb
->format
!= 1)
103 return !!(tdb
->abort_code
>= _HTM_FIRST_USER_ABORT_CODE
);
106 extern __inline
long __attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
107 __TM_is_named_user_abort (void* const tdb_ptr
, unsigned char* code
)
109 struct __htm_tdb
*tdb
= (struct __htm_tdb
*)tdb_ptr
;
111 if (tdb
->format
!= 1)
114 if (tdb
->abort_code
>= _HTM_FIRST_USER_ABORT_CODE
)
116 *code
= tdb
->abort_code
- _HTM_FIRST_USER_ABORT_CODE
;
122 extern __inline
long __attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
123 __TM_is_illegal (void* const tdb_ptr
)
125 struct __htm_tdb
*tdb
= (struct __htm_tdb
*)tdb_ptr
;
127 return (tdb
->format
== 1
128 && (tdb
->abort_code
== 4 /* unfiltered program interruption */
129 || tdb
->abort_code
== 11 /* restricted instruction */));
132 extern __inline
long __attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
133 __TM_is_footprint_exceeded (void* const tdb_ptr
)
135 struct __htm_tdb
*tdb
= (struct __htm_tdb
*)tdb_ptr
;
137 return (tdb
->format
== 1
138 && (tdb
->abort_code
== 7 /* fetch overflow */
139 || tdb
->abort_code
== 8 /* store overflow */));
142 extern __inline
long __attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
143 __TM_is_nested_too_deep (void* const tdb_ptr
)
145 struct __htm_tdb
*tdb
= (struct __htm_tdb
*)tdb_ptr
;
147 return tdb
->format
== 1 && tdb
->abort_code
== 13; /* depth exceeded */
150 extern __inline
long __attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
151 __TM_is_conflict (void* const tdb_ptr
)
153 struct __htm_tdb
*tdb
= (struct __htm_tdb
*)tdb_ptr
;
155 return (tdb
->format
== 1
156 && (tdb
->abort_code
== 9 /* fetch conflict */
157 || tdb
->abort_code
== 10 /* store conflict */));
160 extern __inline
long __attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
161 __TM_is_failure_persistent (long const result
)
163 return result
== _HTM_TBEGIN_PERSISTENT
;
166 extern __inline
long __attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
167 __TM_failure_address (void* const tdb_ptr
)
169 struct __htm_tdb
*tdb
= (struct __htm_tdb
*)tdb_ptr
;
173 return tdb
->atia
& 0xffffffff;
177 extern __inline
long __attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
178 __TM_failure_code (void* const tdb_ptr
)
180 struct __htm_tdb
*tdb
= (struct __htm_tdb
*)tdb_ptr
;
182 return tdb
->abort_code
;
189 #endif /* _HTMXLINTRIN_H */