llvm/llvm/include/llvm/Support/AtomicOrdering.h

//===-- llvm/Support/AtomicOrdering.h ---Atomic Ordering---------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
///
/// \file
/// Atomic ordering constants.
///
/// These values are used by LLVM to represent atomic ordering for C++11's
/// memory model and more, as detailed in docs/Atomics.rst.
///
//===----------------------------------------------------------------------===//

#ifndef LLVM_SUPPORT_ATOMICORDERING_H
#define LLVM_SUPPORT_ATOMICORDERING_H

#include <cstddef>

namespace llvm {

/// Atomic ordering for C11 / C++11's memory models.
///
/// These values cannot change because they are shared with standard library
/// implementations as well as with other compilers.
enum class AtomicOrderingCABI {};

bool operator<(AtomicOrderingCABI, AtomicOrderingCABI) = delete;
bool operator>(AtomicOrderingCABI, AtomicOrderingCABI) = delete;
bool operator<=(AtomicOrderingCABI, AtomicOrderingCABI) = delete;
bool operator>=(AtomicOrderingCABI, AtomicOrderingCABI) = delete;

// Validate an integral value which isn't known to fit within the enum's range
// is a valid AtomicOrderingCABI.
template <typename Int> inline bool isValidAtomicOrderingCABI(Int I) {}

/// Atomic ordering for LLVM's memory model.
///
/// C++ defines ordering as a lattice. LLVM supplements this with NotAtomic and
/// Unordered, which are both below the C++ orders.
///
/// not_atomic-->unordered-->relaxed-->release--------------->acq_rel-->seq_cst
///                                   \-->consume-->acquire--/
enum class AtomicOrdering : unsigned {};

bool operator<(AtomicOrdering, AtomicOrdering) = delete;
bool operator>(AtomicOrdering, AtomicOrdering) = delete;
bool operator<=(AtomicOrdering, AtomicOrdering) = delete;
bool operator>=(AtomicOrdering, AtomicOrdering) = delete;

// Validate an integral value which isn't known to fit within the enum's range
// is a valid AtomicOrdering.
template <typename Int> inline bool isValidAtomicOrdering(Int I) {}

/// String used by LLVM IR to represent atomic ordering.
inline const char *toIRString(AtomicOrdering ao) {}

/// Returns true if ao is stronger than other as defined by the AtomicOrdering
/// lattice, which is based on C++'s definition.
inline bool isStrongerThan(AtomicOrdering AO, AtomicOrdering Other) {}

inline bool isAtLeastOrStrongerThan(AtomicOrdering AO, AtomicOrdering Other) {}

inline bool isStrongerThanUnordered(AtomicOrdering AO) {}

inline bool isStrongerThanMonotonic(AtomicOrdering AO) {}

inline bool isAcquireOrStronger(AtomicOrdering AO) {}

inline bool isReleaseOrStronger(AtomicOrdering AO) {}

/// Return a single atomic ordering that is at least as strong as both the \p AO
/// and \p Other orderings for an atomic operation.
inline AtomicOrdering getMergedAtomicOrdering(AtomicOrdering AO,
                                              AtomicOrdering Other) {}

inline AtomicOrderingCABI toCABI(AtomicOrdering AO) {}

} // end namespace llvm

#endif // LLVM_SUPPORT_ATOMICORDERING_H