annotate gcc/memmodel.h @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 1830386684a0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* Prototypes of memory model helper functions.
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
2 Copyright (C) 2011-2020 Free Software Foundation, Inc.
111
kono
parents:
diff changeset
3
kono
parents:
diff changeset
4 This file is part of GCC.
kono
parents:
diff changeset
5
kono
parents:
diff changeset
6 GCC is free software; you can redistribute it and/or modify it under
kono
parents:
diff changeset
7 the terms of the GNU General Public License as published by the Free
kono
parents:
diff changeset
8 Software Foundation; either version 3, or (at your option) any later
kono
parents:
diff changeset
9 version.
kono
parents:
diff changeset
10
kono
parents:
diff changeset
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
kono
parents:
diff changeset
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
kono
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
kono
parents:
diff changeset
14 for more details.
kono
parents:
diff changeset
15
kono
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
kono
parents:
diff changeset
17 along with GCC; see the file COPYING3. If not see
kono
parents:
diff changeset
18 <http://www.gnu.org/licenses/>. */
kono
parents:
diff changeset
19
kono
parents:
diff changeset
20 #ifndef GCC_MEMMODEL_H
kono
parents:
diff changeset
21 #define GCC_MEMMODEL_H
kono
parents:
diff changeset
22
kono
parents:
diff changeset
23 /* Suppose that higher bits are target dependent. */
kono
parents:
diff changeset
24 #define MEMMODEL_MASK ((1<<16)-1)
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 /* Legacy sync operations set this upper flag in the memory model. This allows
kono
parents:
diff changeset
27 targets that need to do something stronger for sync operations to
kono
parents:
diff changeset
28 differentiate with their target patterns and issue a more appropriate insn
kono
parents:
diff changeset
29 sequence. See bugzilla 65697 for background. */
kono
parents:
diff changeset
30 #define MEMMODEL_SYNC (1<<15)
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 /* Memory model without SYNC bit for targets/operations that do not care. */
kono
parents:
diff changeset
33 #define MEMMODEL_BASE_MASK (MEMMODEL_SYNC-1)
kono
parents:
diff changeset
34
kono
parents:
diff changeset
35 /* Memory model types for the __atomic* builtins.
kono
parents:
diff changeset
36 This must match the order in libstdc++-v3/include/bits/atomic_base.h. */
kono
parents:
diff changeset
37 enum memmodel
kono
parents:
diff changeset
38 {
kono
parents:
diff changeset
39 MEMMODEL_RELAXED = 0,
kono
parents:
diff changeset
40 MEMMODEL_CONSUME = 1,
kono
parents:
diff changeset
41 MEMMODEL_ACQUIRE = 2,
kono
parents:
diff changeset
42 MEMMODEL_RELEASE = 3,
kono
parents:
diff changeset
43 MEMMODEL_ACQ_REL = 4,
kono
parents:
diff changeset
44 MEMMODEL_SEQ_CST = 5,
kono
parents:
diff changeset
45 MEMMODEL_LAST = 6,
kono
parents:
diff changeset
46 MEMMODEL_SYNC_ACQUIRE = MEMMODEL_ACQUIRE | MEMMODEL_SYNC,
kono
parents:
diff changeset
47 MEMMODEL_SYNC_RELEASE = MEMMODEL_RELEASE | MEMMODEL_SYNC,
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
48 MEMMODEL_SYNC_SEQ_CST = MEMMODEL_SEQ_CST | MEMMODEL_SYNC,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
49 /* Say that all the higher bits are valid target extensions. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
50 MEMMODEL_MAX = INTTYPE_MAXIMUM (int)
111
kono
parents:
diff changeset
51 };
kono
parents:
diff changeset
52
kono
parents:
diff changeset
53 /* Return the memory model from a host integer. */
kono
parents:
diff changeset
54 static inline enum memmodel
kono
parents:
diff changeset
55 memmodel_from_int (unsigned HOST_WIDE_INT val)
kono
parents:
diff changeset
56 {
kono
parents:
diff changeset
57 return (enum memmodel) (val & MEMMODEL_MASK);
kono
parents:
diff changeset
58 }
kono
parents:
diff changeset
59
kono
parents:
diff changeset
60 /* Return the base memory model from a host integer. */
kono
parents:
diff changeset
61 static inline enum memmodel
kono
parents:
diff changeset
62 memmodel_base (unsigned HOST_WIDE_INT val)
kono
parents:
diff changeset
63 {
kono
parents:
diff changeset
64 return (enum memmodel) (val & MEMMODEL_BASE_MASK);
kono
parents:
diff changeset
65 }
kono
parents:
diff changeset
66
kono
parents:
diff changeset
67 /* Return TRUE if the memory model is RELAXED. */
kono
parents:
diff changeset
68 static inline bool
kono
parents:
diff changeset
69 is_mm_relaxed (enum memmodel model)
kono
parents:
diff changeset
70 {
kono
parents:
diff changeset
71 return (model & MEMMODEL_BASE_MASK) == MEMMODEL_RELAXED;
kono
parents:
diff changeset
72 }
kono
parents:
diff changeset
73
kono
parents:
diff changeset
74 /* Return TRUE if the memory model is CONSUME. */
kono
parents:
diff changeset
75 static inline bool
kono
parents:
diff changeset
76 is_mm_consume (enum memmodel model)
kono
parents:
diff changeset
77 {
kono
parents:
diff changeset
78 return (model & MEMMODEL_BASE_MASK) == MEMMODEL_CONSUME;
kono
parents:
diff changeset
79 }
kono
parents:
diff changeset
80
kono
parents:
diff changeset
81 /* Return TRUE if the memory model is ACQUIRE. */
kono
parents:
diff changeset
82 static inline bool
kono
parents:
diff changeset
83 is_mm_acquire (enum memmodel model)
kono
parents:
diff changeset
84 {
kono
parents:
diff changeset
85 return (model & MEMMODEL_BASE_MASK) == MEMMODEL_ACQUIRE;
kono
parents:
diff changeset
86 }
kono
parents:
diff changeset
87
kono
parents:
diff changeset
88 /* Return TRUE if the memory model is RELEASE. */
kono
parents:
diff changeset
89 static inline bool
kono
parents:
diff changeset
90 is_mm_release (enum memmodel model)
kono
parents:
diff changeset
91 {
kono
parents:
diff changeset
92 return (model & MEMMODEL_BASE_MASK) == MEMMODEL_RELEASE;
kono
parents:
diff changeset
93 }
kono
parents:
diff changeset
94
kono
parents:
diff changeset
95 /* Return TRUE if the memory model is ACQ_REL. */
kono
parents:
diff changeset
96 static inline bool
kono
parents:
diff changeset
97 is_mm_acq_rel (enum memmodel model)
kono
parents:
diff changeset
98 {
kono
parents:
diff changeset
99 return (model & MEMMODEL_BASE_MASK) == MEMMODEL_ACQ_REL;
kono
parents:
diff changeset
100 }
kono
parents:
diff changeset
101
kono
parents:
diff changeset
102 /* Return TRUE if the memory model is SEQ_CST. */
kono
parents:
diff changeset
103 static inline bool
kono
parents:
diff changeset
104 is_mm_seq_cst (enum memmodel model)
kono
parents:
diff changeset
105 {
kono
parents:
diff changeset
106 return (model & MEMMODEL_BASE_MASK) == MEMMODEL_SEQ_CST;
kono
parents:
diff changeset
107 }
kono
parents:
diff changeset
108
kono
parents:
diff changeset
109 /* Return TRUE if the memory model is a SYNC variant. */
kono
parents:
diff changeset
110 static inline bool
kono
parents:
diff changeset
111 is_mm_sync (enum memmodel model)
kono
parents:
diff changeset
112 {
kono
parents:
diff changeset
113 return (model & MEMMODEL_SYNC);
kono
parents:
diff changeset
114 }
kono
parents:
diff changeset
115
kono
parents:
diff changeset
116 #endif /* GCC_MEMMODEL_H */