//===--- SyncScope.h - Atomic synchronization scopes ------------*- 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 /// Provides definitions for the atomic synchronization scopes. /// //===----------------------------------------------------------------------===// #ifndef LLVM_CLANG_BASIC_SYNCSCOPE_H #define LLVM_CLANG_BASIC_SYNCSCOPE_H #include "clang/Basic/LangOptions.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/StringRef.h" #include <memory> namespace clang { /// Defines synch scope values used internally by clang. /// /// The enum values start from 0 and are contiguous. They are mainly used for /// enumerating all supported synch scope values and mapping them to LLVM /// synch scopes. Their numerical values may be different from the corresponding /// synch scope enums used in source languages. /// /// In atomic builtin and expressions, language-specific synch scope enums are /// used. Currently only OpenCL memory scope enums are supported and assumed /// to be used by all languages. However, in the future, other languages may /// define their own set of synch scope enums. The language-specific synch scope /// values are represented by class AtomicScopeModel and its derived classes. /// /// To add a new enum value: /// Add the enum value to enum class SyncScope. /// Update enum value Last if necessary. /// Update getAsString. /// enum class SyncScope { … }; inline llvm::StringRef getAsString(SyncScope S) { … } /// Defines the kind of atomic scope models. enum class AtomicScopeModelKind { … }; /// Defines the interface for synch scope model. class AtomicScopeModel { … }; /// Defines the synch scope model for OpenCL. class AtomicScopeOpenCLModel : public AtomicScopeModel { … }; /// Defines the synch scope model for HIP. class AtomicScopeHIPModel : public AtomicScopeModel { … }; /// Defines the generic atomic scope model. class AtomicScopeGenericModel : public AtomicScopeModel { … }; inline std::unique_ptr<AtomicScopeModel> AtomicScopeModel::create(AtomicScopeModelKind K) { … } } // namespace clang #endif