Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:36:48

0001 //===- AddressSpaces.h - Language-specific address spaces -------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 /// \file
0010 /// Provides definitions for the various language-specific address
0011 /// spaces.
0012 //
0013 //===----------------------------------------------------------------------===//
0014 
0015 #ifndef LLVM_CLANG_BASIC_ADDRESSSPACES_H
0016 #define LLVM_CLANG_BASIC_ADDRESSSPACES_H
0017 
0018 #include <cassert>
0019 
0020 namespace clang {
0021 
0022 /// Defines the address space values used by the address space qualifier
0023 /// of QualType.
0024 ///
0025 enum class LangAS : unsigned {
0026   // The default value 0 is the value used in QualType for the situation
0027   // where there is no address space qualifier.
0028   Default = 0,
0029 
0030   // OpenCL specific address spaces.
0031   // In OpenCL each l-value must have certain non-default address space, each
0032   // r-value must have no address space (i.e. the default address space). The
0033   // pointee of a pointer must have non-default address space.
0034   opencl_global,
0035   opencl_local,
0036   opencl_constant,
0037   opencl_private,
0038   opencl_generic,
0039   opencl_global_device,
0040   opencl_global_host,
0041 
0042   // CUDA specific address spaces.
0043   cuda_device,
0044   cuda_constant,
0045   cuda_shared,
0046 
0047   // SYCL specific address spaces.
0048   sycl_global,
0049   sycl_global_device,
0050   sycl_global_host,
0051   sycl_local,
0052   sycl_private,
0053 
0054   // Pointer size and extension address spaces.
0055   ptr32_sptr,
0056   ptr32_uptr,
0057   ptr64,
0058 
0059   // HLSL specific address spaces.
0060   hlsl_groupshared,
0061   hlsl_constant,
0062 
0063   // Wasm specific address spaces.
0064   wasm_funcref,
0065 
0066   // This denotes the count of language-specific address spaces and also
0067   // the offset added to the target-specific address spaces, which are usually
0068   // specified by address space attributes __attribute__(address_space(n))).
0069   FirstTargetAddressSpace
0070 };
0071 
0072 /// The type of a lookup table which maps from language-specific address spaces
0073 /// to target-specific ones.
0074 using LangASMap = unsigned[(unsigned)LangAS::FirstTargetAddressSpace];
0075 
0076 /// \return whether \p AS is a target-specific address space rather than a
0077 /// clang AST address space
0078 inline bool isTargetAddressSpace(LangAS AS) {
0079   return (unsigned)AS >= (unsigned)LangAS::FirstTargetAddressSpace;
0080 }
0081 
0082 inline unsigned toTargetAddressSpace(LangAS AS) {
0083   assert(isTargetAddressSpace(AS));
0084   return (unsigned)AS - (unsigned)LangAS::FirstTargetAddressSpace;
0085 }
0086 
0087 inline LangAS getLangASFromTargetAS(unsigned TargetAS) {
0088   return static_cast<LangAS>((TargetAS) +
0089                              (unsigned)LangAS::FirstTargetAddressSpace);
0090 }
0091 
0092 inline bool isPtrSizeAddressSpace(LangAS AS) {
0093   return (AS == LangAS::ptr32_sptr || AS == LangAS::ptr32_uptr ||
0094           AS == LangAS::ptr64);
0095 }
0096 
0097 } // namespace clang
0098 
0099 #endif // LLVM_CLANG_BASIC_ADDRESSSPACES_H