]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/memmodel.h
tree.h (memmodel_from_int, [...]): Move to ...
[thirdparty/gcc.git] / gcc / memmodel.h
CommitLineData
e73cf9a2
TP
1/* Prototypes of memory model helper functions.
2 Copyright (C) 2015-2016 Free Software Foundation, Inc.
3
4This file is part of GCC.
5
6GCC is free software; you can redistribute it and/or modify it under
7the terms of the GNU General Public License as published by the Free
8Software Foundation; either version 3, or (at your option) any later
9version.
10
11GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12WARRANTY; without even the implied warranty of MERCHANTABILITY or
13FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14for more details.
15
16You should have received a copy of the GNU General Public License
17along with GCC; see the file COPYING3. If not see
18<http://www.gnu.org/licenses/>. */
19
20#ifndef GCC_MEMMODEL_H
21#define GCC_MEMMODEL_H
22
23/* Return the memory model from a host integer. */
24static inline enum memmodel
25memmodel_from_int (unsigned HOST_WIDE_INT val)
26{
27 return (enum memmodel) (val & MEMMODEL_MASK);
28}
29
30/* Return the base memory model from a host integer. */
31static inline enum memmodel
32memmodel_base (unsigned HOST_WIDE_INT val)
33{
34 return (enum memmodel) (val & MEMMODEL_BASE_MASK);
35}
36
37/* Return TRUE if the memory model is RELAXED. */
38static inline bool
39is_mm_relaxed (enum memmodel model)
40{
41 return (model & MEMMODEL_BASE_MASK) == MEMMODEL_RELAXED;
42}
43
44/* Return TRUE if the memory model is CONSUME. */
45static inline bool
46is_mm_consume (enum memmodel model)
47{
48 return (model & MEMMODEL_BASE_MASK) == MEMMODEL_CONSUME;
49}
50
51/* Return TRUE if the memory model is ACQUIRE. */
52static inline bool
53is_mm_acquire (enum memmodel model)
54{
55 return (model & MEMMODEL_BASE_MASK) == MEMMODEL_ACQUIRE;
56}
57
58/* Return TRUE if the memory model is RELEASE. */
59static inline bool
60is_mm_release (enum memmodel model)
61{
62 return (model & MEMMODEL_BASE_MASK) == MEMMODEL_RELEASE;
63}
64
65/* Return TRUE if the memory model is ACQ_REL. */
66static inline bool
67is_mm_acq_rel (enum memmodel model)
68{
69 return (model & MEMMODEL_BASE_MASK) == MEMMODEL_ACQ_REL;
70}
71
72/* Return TRUE if the memory model is SEQ_CST. */
73static inline bool
74is_mm_seq_cst (enum memmodel model)
75{
76 return (model & MEMMODEL_BASE_MASK) == MEMMODEL_SEQ_CST;
77}
78
79/* Return TRUE if the memory model is a SYNC variant. */
80static inline bool
81is_mm_sync (enum memmodel model)
82{
83 return (model & MEMMODEL_SYNC);
84}
85
86#endif /* GCC_MEMMODEL_H */