annotate gcc/memmodel.h @ 127:4c56639505ff

fix function.c and add CbC-example Makefile
author mir3636
date Wed, 11 Apr 2018 18:46:58 +0900
parents 04ced10e8804
children 84e7813d76e9
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.
kono
parents:
diff changeset
2 Copyright (C) 2011-2017 Free Software Foundation, Inc.
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,
kono
parents:
diff changeset
48 MEMMODEL_SYNC_SEQ_CST = MEMMODEL_SEQ_CST | MEMMODEL_SYNC
kono
parents:
diff changeset
49 };
kono
parents:
diff changeset
50
kono
parents:
diff changeset
51 /* Return the memory model from a host integer. */
kono
parents:
diff changeset
52 static inline enum memmodel
kono
parents:
diff changeset
53 memmodel_from_int (unsigned HOST_WIDE_INT val)
kono
parents:
diff changeset
54 {
kono
parents:
diff changeset
55 return (enum memmodel) (val & MEMMODEL_MASK);
kono
parents:
diff changeset
56 }
kono
parents:
diff changeset
57
kono
parents:
diff changeset
58 /* Return the base memory model from a host integer. */
kono
parents:
diff changeset
59 static inline enum memmodel
kono
parents:
diff changeset
60 memmodel_base (unsigned HOST_WIDE_INT val)
kono
parents:
diff changeset
61 {
kono
parents:
diff changeset
62 return (enum memmodel) (val & MEMMODEL_BASE_MASK);
kono
parents:
diff changeset
63 }
kono
parents:
diff changeset
64
kono
parents:
diff changeset
65 /* Return TRUE if the memory model is RELAXED. */
kono
parents:
diff changeset
66 static inline bool
kono
parents:
diff changeset
67 is_mm_relaxed (enum memmodel model)
kono
parents:
diff changeset
68 {
kono
parents:
diff changeset
69 return (model & MEMMODEL_BASE_MASK) == MEMMODEL_RELAXED;
kono
parents:
diff changeset
70 }
kono
parents:
diff changeset
71
kono
parents:
diff changeset
72 /* Return TRUE if the memory model is CONSUME. */
kono
parents:
diff changeset
73 static inline bool
kono
parents:
diff changeset
74 is_mm_consume (enum memmodel model)
kono
parents:
diff changeset
75 {
kono
parents:
diff changeset
76 return (model & MEMMODEL_BASE_MASK) == MEMMODEL_CONSUME;
kono
parents:
diff changeset
77 }
kono
parents:
diff changeset
78
kono
parents:
diff changeset
79 /* Return TRUE if the memory model is ACQUIRE. */
kono
parents:
diff changeset
80 static inline bool
kono
parents:
diff changeset
81 is_mm_acquire (enum memmodel model)
kono
parents:
diff changeset
82 {
kono
parents:
diff changeset
83 return (model & MEMMODEL_BASE_MASK) == MEMMODEL_ACQUIRE;
kono
parents:
diff changeset
84 }
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86 /* Return TRUE if the memory model is RELEASE. */
kono
parents:
diff changeset
87 static inline bool
kono
parents:
diff changeset
88 is_mm_release (enum memmodel model)
kono
parents:
diff changeset
89 {
kono
parents:
diff changeset
90 return (model & MEMMODEL_BASE_MASK) == MEMMODEL_RELEASE;
kono
parents:
diff changeset
91 }
kono
parents:
diff changeset
92
kono
parents:
diff changeset
93 /* Return TRUE if the memory model is ACQ_REL. */
kono
parents:
diff changeset
94 static inline bool
kono
parents:
diff changeset
95 is_mm_acq_rel (enum memmodel model)
kono
parents:
diff changeset
96 {
kono
parents:
diff changeset
97 return (model & MEMMODEL_BASE_MASK) == MEMMODEL_ACQ_REL;
kono
parents:
diff changeset
98 }
kono
parents:
diff changeset
99
kono
parents:
diff changeset
100 /* Return TRUE if the memory model is SEQ_CST. */
kono
parents:
diff changeset
101 static inline bool
kono
parents:
diff changeset
102 is_mm_seq_cst (enum memmodel model)
kono
parents:
diff changeset
103 {
kono
parents:
diff changeset
104 return (model & MEMMODEL_BASE_MASK) == MEMMODEL_SEQ_CST;
kono
parents:
diff changeset
105 }
kono
parents:
diff changeset
106
kono
parents:
diff changeset
107 /* Return TRUE if the memory model is a SYNC variant. */
kono
parents:
diff changeset
108 static inline bool
kono
parents:
diff changeset
109 is_mm_sync (enum memmodel model)
kono
parents:
diff changeset
110 {
kono
parents:
diff changeset
111 return (model & MEMMODEL_SYNC);
kono
parents:
diff changeset
112 }
kono
parents:
diff changeset
113
kono
parents:
diff changeset
114 #endif /* GCC_MEMMODEL_H */