]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/config/s390/htmxlintrin.h
Fix.
[thirdparty/gcc.git] / gcc / config / s390 / htmxlintrin.h
CommitLineData
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
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify it under
8the terms of the GNU General Public License as published by the Free
9Software Foundation; either version 3, or (at your option) any later
10version.
11
12GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13WARRANTY; without even the implied warranty of MERCHANTABILITY or
14FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15for more details.
16
17You should have received a copy of the GNU General Public License
18along 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
29extern "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
36extern __inline long __attribute__((__gnu_inline__, __always_inline__, __artificial__))
37__TM_simple_begin ()
38{
39 return __builtin_tbegin_nofloat (0);
40}
41
42extern __inline long __attribute__((__gnu_inline__, __always_inline__, __artificial__))
43__TM_begin (void* const tdb)
44{
45 return __builtin_tbegin_nofloat (tdb);
46}
47
48extern __inline long __attribute__((__gnu_inline__, __always_inline__, __artificial__))
49__TM_end ()
50{
51 return __builtin_tend ();
52}
53
54extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
55__TM_abort ()
56{
57 return __builtin_tabort (_HTM_FIRST_USER_ABORT_CODE);
58}
59
60extern __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
66extern __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
72extern __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
88extern __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
99extern __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
115extern __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
125extern __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
135extern __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
143extern __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
153extern __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
159extern __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
170extern __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 */