Coverage Report

Created: 2018-09-23 22:08

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/clang/include/clang/Basic/AddressSpaces.h
Line
Count
Source
1
//===- AddressSpaces.h - Language-specific address spaces -------*- C++ -*-===//
2
//
3
//                     The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
//
10
/// \file
11
/// Provides definitions for the various language-specific address
12
/// spaces.
13
//
14
//===----------------------------------------------------------------------===//
15
16
#ifndef LLVM_CLANG_BASIC_ADDRESSSPACES_H
17
#define LLVM_CLANG_BASIC_ADDRESSSPACES_H
18
19
#include <cassert>
20
21
namespace clang {
22
23
/// Defines the address space values used by the address space qualifier
24
/// of QualType.
25
///
26
enum class LangAS : unsigned {
27
  // The default value 0 is the value used in QualType for the situation
28
  // where there is no address space qualifier.
29
  Default = 0,
30
31
  // OpenCL specific address spaces.
32
  // In OpenCL each l-value must have certain non-default address space, each
33
  // r-value must have no address space (i.e. the default address space). The
34
  // pointee of a pointer must have non-default address space.
35
  opencl_global,
36
  opencl_local,
37
  opencl_constant,
38
  opencl_private,
39
  opencl_generic,
40
41
  // CUDA specific address spaces.
42
  cuda_device,
43
  cuda_constant,
44
  cuda_shared,
45
46
  // This denotes the count of language-specific address spaces and also
47
  // the offset added to the target-specific address spaces, which are usually
48
  // specified by address space attributes __attribute__(address_space(n))).
49
  FirstTargetAddressSpace
50
};
51
52
/// The type of a lookup table which maps from language-specific address spaces
53
/// to target-specific ones.
54
using LangASMap = unsigned[(unsigned)LangAS::FirstTargetAddressSpace];
55
56
/// \return whether \p AS is a target-specific address space rather than a
57
/// clang AST address space
58
1.09M
inline bool isTargetAddressSpace(LangAS AS) {
59
1.09M
  return (unsigned)AS >= (unsigned)LangAS::FirstTargetAddressSpace;
60
1.09M
}
61
62
596
inline unsigned toTargetAddressSpace(LangAS AS) {
63
596
  assert(isTargetAddressSpace(AS));
64
596
  return (unsigned)AS - (unsigned)LangAS::FirstTargetAddressSpace;
65
596
}
66
67
473
inline LangAS getLangASFromTargetAS(unsigned TargetAS) {
68
473
  return static_cast<LangAS>((TargetAS) +
69
473
                             (unsigned)LangAS::FirstTargetAddressSpace);
70
473
}
71
72
} // namespace clang
73
74
#endif // LLVM_CLANG_BASIC_ADDRESSSPACES_H