GCC Middle and Back End API Reference
memmodel.h File Reference

Go to the source code of this file.

Macros

#define MEMMODEL_MASK   ((1<<16)-1)
 
#define MEMMODEL_SYNC   (1<<15)
 
#define MEMMODEL_BASE_MASK   (MEMMODEL_SYNC-1)
 

Enumerations

enum  memmodel {
  MEMMODEL_RELAXED = 0 , MEMMODEL_CONSUME = 1 , MEMMODEL_ACQUIRE = 2 , MEMMODEL_RELEASE = 3 ,
  MEMMODEL_ACQ_REL = 4 , MEMMODEL_SEQ_CST = 5 , MEMMODEL_LAST = 6 , MEMMODEL_SYNC_ACQUIRE = MEMMODEL_ACQUIRE | MEMMODEL_SYNC ,
  MEMMODEL_SYNC_RELEASE = MEMMODEL_RELEASE | MEMMODEL_SYNC , MEMMODEL_SYNC_SEQ_CST = MEMMODEL_SEQ_CST | MEMMODEL_SYNC , MEMMODEL_MAX = INTTYPE_MAXIMUM (int)
}
 

Functions

enum memmodel memmodel_from_int (unsigned HOST_WIDE_INT val)
 
enum memmodel memmodel_base (unsigned HOST_WIDE_INT val)
 
bool is_mm_relaxed (enum memmodel model)
 
bool is_mm_consume (enum memmodel model)
 
bool is_mm_acquire (enum memmodel model)
 
bool is_mm_release (enum memmodel model)
 
bool is_mm_acq_rel (enum memmodel model)
 
bool is_mm_seq_cst (enum memmodel model)
 
bool is_mm_sync (enum memmodel model)
 

Macro Definition Documentation

◆ MEMMODEL_BASE_MASK

#define MEMMODEL_BASE_MASK   (MEMMODEL_SYNC-1)
Memory model without SYNC bit for targets/operations that do not care.   

Referenced by is_mm_acq_rel(), is_mm_acquire(), is_mm_consume(), is_mm_relaxed(), is_mm_release(), is_mm_seq_cst(), memmodel_base(), and need_atomic_barrier_p().

◆ MEMMODEL_MASK

#define MEMMODEL_MASK   ((1<<16)-1)
Prototypes of memory model helper functions.
   Copyright (C) 2011-2024 Free Software Foundation, Inc.

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.   
Suppose that higher bits are target dependent.  

Referenced by get_memmodel(), and memmodel_from_int().

◆ MEMMODEL_SYNC

#define MEMMODEL_SYNC   (1<<15)
Legacy sync operations set this upper flag in the memory model.  This allows
targets that need to do something stronger for sync operations to
differentiate with their target patterns and issue a more appropriate insn
sequence.  See bugzilla 65697 for background.   

Referenced by is_mm_sync().

Enumeration Type Documentation

◆ memmodel

Memory model types for the __atomic* builtins.
This must match the order in libstdc++-v3/include/bits/atomic_base.h.   
Enumerator
MEMMODEL_RELAXED 
MEMMODEL_CONSUME 
MEMMODEL_ACQUIRE 
MEMMODEL_RELEASE 
MEMMODEL_ACQ_REL 
MEMMODEL_SEQ_CST 
MEMMODEL_LAST 
MEMMODEL_SYNC_ACQUIRE 
MEMMODEL_SYNC_RELEASE 
MEMMODEL_SYNC_SEQ_CST 
MEMMODEL_MAX 

Function Documentation

◆ is_mm_acq_rel()

◆ is_mm_acquire()

bool is_mm_acquire ( enum memmodel model)
inline
Return TRUE if the memory model is ACQUIRE.   

References ggc_alloc(), MEMMODEL_ACQUIRE, and MEMMODEL_BASE_MASK.

Referenced by expand_builtin_atomic_clear().

◆ is_mm_consume()

bool is_mm_consume ( enum memmodel model)
inline
Return TRUE if the memory model is CONSUME.   

References ggc_alloc(), MEMMODEL_BASE_MASK, and MEMMODEL_CONSUME.

Referenced by expand_builtin_atomic_clear().

◆ is_mm_relaxed()

bool is_mm_relaxed ( enum memmodel model)
inline

◆ is_mm_release()

◆ is_mm_seq_cst()

bool is_mm_seq_cst ( enum memmodel model)
inline

◆ is_mm_sync()

bool is_mm_sync ( enum memmodel model)
inline
Return TRUE if the memory model is a SYNC variant.   

References ggc_alloc(), and MEMMODEL_SYNC.

Referenced by expand_atomic_compare_and_swap(), expand_atomic_exchange(), expand_atomic_fetch_op(), and expand_atomic_store().

◆ memmodel_base()

enum memmodel memmodel_base ( unsigned HOST_WIDE_INT val)
inline
Return the base memory model from a host integer.   

References MEMMODEL_BASE_MASK.

Referenced by get_memmodel(), and instrument_builtin_call().

◆ memmodel_from_int()

enum memmodel memmodel_from_int ( unsigned HOST_WIDE_INT val)
inline
Return the memory model from a host integer.   

References MEMMODEL_MASK.