]>
Commit | Line | Data |
---|---|---|
5a3fe9b6 AK |
1 | /* XL compiler hardware transactional execution intrinsics |
2 | Copyright (C) 2013 Free Software Foundation, Inc. | |
3 | Contributed by Andreas Krebbel (Andreas.Krebbel@de.ibm.com) | |
4 | ||
5 | This file is part of GCC. | |
6 | ||
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 | |
10 | version. | |
11 | ||
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 | |
15 | for more details. | |
16 | ||
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/>. */ | |
20 | ||
21 | #ifndef _HTMXLINTRIN_H | |
22 | #define _HTMXLINTRIN_H | |
23 | ||
24 | #include <stdint.h> | |
25 | ||
26 | #include <htmintrin.h> | |
27 | ||
28 | #ifdef __cplusplus | |
29 | extern "C" { | |
30 | #endif | |
31 | ||
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" publically available on the web. */ | |
35 | ||
36 | extern __inline long __attribute__((__gnu_inline__, __always_inline__, __artificial__)) | |
37 | __TM_simple_begin () | |
38 | { | |
39 | return __builtin_tbegin_nofloat (0); | |
40 | } | |
41 | ||
42 | extern __inline long __attribute__((__gnu_inline__, __always_inline__, __artificial__)) | |
43 | __TM_begin (void* const tdb) | |
44 | { | |
45 | return __builtin_tbegin_nofloat (tdb); | |
46 | } | |
47 | ||
48 | extern __inline long __attribute__((__gnu_inline__, __always_inline__, __artificial__)) | |
49 | __TM_end () | |
50 | { | |
51 | return __builtin_tend (); | |
52 | } | |
53 | ||
54 | extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__)) | |
55 | __TM_abort () | |
56 | { | |
57 | return __builtin_tabort (_HTM_FIRST_USER_ABORT_CODE); | |
58 | } | |
59 | ||
60 | extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__)) | |
61 | __TM_named_abort (unsigned char const code) | |
62 | { | |
63 | return __builtin_tabort ((int)_HTM_FIRST_USER_ABORT_CODE + code); | |
64 | } | |
65 | ||
66 | extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__)) | |
67 | __TM_non_transactional_store (void* const addr, long long const value) | |
68 | { | |
69 | __builtin_non_tx_store ((uint64_t*)addr, (uint64_t)value); | |
70 | } | |
71 | ||
72 | extern __inline long __attribute__((__gnu_inline__, __always_inline__, __artificial__)) | |
73 | __TM_nesting_depth (void* const tdb_ptr) | |
74 | { | |
75 | int depth = __builtin_tx_nesting_depth (); | |
76 | struct __htm_tdb *tdb = (struct __htm_tdb*)tdb_ptr; | |
77 | ||
78 | if (depth != 0) | |
79 | return depth; | |
80 | ||
81 | if (tdb->format == 0) | |
82 | return 0; | |
83 | return tdb->nesting_depth; | |
84 | } | |
85 | ||
86 | /* Transaction failure diagnostics */ | |
87 | ||
88 | extern __inline long __attribute__((__gnu_inline__, __always_inline__, __artificial__)) | |
89 | __TM_is_user_abort (void* const tdb_ptr) | |
90 | { | |
91 | struct __htm_tdb *tdb = (struct __htm_tdb*)tdb_ptr; | |
92 | ||
93 | if (tdb->format == 0) | |
94 | return 0; | |
95 | ||
96 | return !!(tdb->abort_code >= _HTM_FIRST_USER_ABORT_CODE); | |
97 | } | |
98 | ||
99 | extern __inline long __attribute__((__gnu_inline__, __always_inline__, __artificial__)) | |
100 | __TM_is_named_user_abort (void* const tdb_ptr, unsigned char* code) | |
101 | { | |
102 | struct __htm_tdb *tdb = (struct __htm_tdb*)tdb_ptr; | |
103 | ||
104 | if (tdb->format == 0) | |
105 | return 0; | |
106 | ||
107 | if (tdb->abort_code >= _HTM_FIRST_USER_ABORT_CODE) | |
108 | { | |
109 | *code = tdb->abort_code - _HTM_FIRST_USER_ABORT_CODE; | |
110 | return 1; | |
111 | } | |
112 | return 0; | |
113 | } | |
114 | ||
115 | extern __inline long __attribute__((__gnu_inline__, __always_inline__, __artificial__)) | |
116 | __TM_is_illegal (void* const tdb_ptr) | |
117 | { | |
118 | struct __htm_tdb *tdb = (struct __htm_tdb*)tdb_ptr; | |
119 | ||
120 | return (tdb->format == 0 | |
121 | && (tdb->abort_code == 4 /* unfiltered program interruption */ | |
122 | || tdb->abort_code == 11 /* restricted instruction */)); | |
123 | } | |
124 | ||
125 | extern __inline long __attribute__((__gnu_inline__, __always_inline__, __artificial__)) | |
126 | __TM_is_footprint_exceeded (void* const tdb_ptr) | |
127 | { | |
128 | struct __htm_tdb *tdb = (struct __htm_tdb*)tdb_ptr; | |
129 | ||
130 | return (tdb->format == 0 | |
131 | && (tdb->abort_code == 7 /* fetch overflow */ | |
132 | || tdb->abort_code == 8 /* store overflow */)); | |
133 | } | |
134 | ||
135 | extern __inline long __attribute__((__gnu_inline__, __always_inline__, __artificial__)) | |
136 | __TM_is_nested_too_deep (void* const tdb_ptr) | |
137 | { | |
138 | struct __htm_tdb *tdb = (struct __htm_tdb*)tdb_ptr; | |
139 | ||
140 | return tdb->format == 0 && tdb->abort_code == 13; /* depth exceeded */ | |
141 | } | |
142 | ||
143 | extern __inline long __attribute__((__gnu_inline__, __always_inline__, __artificial__)) | |
144 | __TM_is_conflict (void* const tdb_ptr) | |
145 | { | |
146 | struct __htm_tdb *tdb = (struct __htm_tdb*)tdb_ptr; | |
147 | ||
148 | return (tdb->format == 0 | |
149 | && (tdb->abort_code == 9 /* fetch conflict */ | |
150 | || tdb->abort_code == 10 /* store conflict */)); | |
151 | } | |
152 | ||
153 | extern __inline long __attribute__((__gnu_inline__, __always_inline__, __artificial__)) | |
154 | __TM_is_failure_persistent (long const result) | |
155 | { | |
156 | return result == _HTM_TBEGIN_PERSISTENT; | |
157 | } | |
158 | ||
159 | extern __inline long __attribute__((__gnu_inline__, __always_inline__, __artificial__)) | |
160 | __TM_failure_address (void* const tdb_ptr) | |
161 | { | |
162 | struct __htm_tdb *tdb = (struct __htm_tdb*)tdb_ptr; | |
163 | #ifdef __s390x__ | |
164 | return tdb->atia; | |
165 | #else | |
166 | return tdb->atia & 0xffffffff; | |
167 | #endif | |
168 | } | |
169 | ||
170 | extern __inline long __attribute__((__gnu_inline__, __always_inline__, __artificial__)) | |
171 | __TM_failure_code (void* const tdb_ptr) | |
172 | { | |
173 | struct __htm_tdb *tdb = (struct __htm_tdb*)tdb_ptr; | |
174 | ||
175 | return tdb->abort_code; | |
176 | } | |
177 | ||
178 | #ifdef __cplusplus | |
179 | } | |
180 | #endif | |
181 | ||
182 | #endif /* _HTMXLINTRIN_H */ |