Coverage Report

Created: 2021-04-24 07:00

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/Basic/Targets/SPIR.h
Line
Count
Source (jump to first uncovered line)
1
//===--- SPIR.h - Declare SPIR target feature support -----------*- C++ -*-===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
// This file declares SPIR TargetInfo objects.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#ifndef LLVM_CLANG_LIB_BASIC_TARGETS_SPIR_H
14
#define LLVM_CLANG_LIB_BASIC_TARGETS_SPIR_H
15
16
#include "clang/Basic/TargetInfo.h"
17
#include "clang/Basic/TargetOptions.h"
18
#include "llvm/ADT/Triple.h"
19
#include "llvm/Support/Compiler.h"
20
21
namespace clang {
22
namespace targets {
23
24
static const unsigned SPIRAddrSpaceMap[] = {
25
    0, // Default
26
    1, // opencl_global
27
    3, // opencl_local
28
    2, // opencl_constant
29
    0, // opencl_private
30
    4, // opencl_generic
31
    5, // opencl_global_device
32
    6, // opencl_global_host
33
    0, // cuda_device
34
    0, // cuda_constant
35
    0, // cuda_shared
36
    0, // ptr32_sptr
37
    0, // ptr32_uptr
38
    0  // ptr64
39
};
40
41
class LLVM_LIBRARY_VISIBILITY SPIRTargetInfo : public TargetInfo {
42
public:
43
  SPIRTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
44
223
      : TargetInfo(Triple) {
45
223
    assert(getTriple().getOS() == llvm::Triple::UnknownOS &&
46
223
           "SPIR target must use unknown OS");
47
0
    assert(getTriple().getEnvironment() == llvm::Triple::UnknownEnvironment &&
48
223
           "SPIR target must use unknown environment type");
49
0
    TLSSupported = false;
50
223
    VLASupported = false;
51
223
    LongWidth = LongAlign = 64;
52
223
    AddrSpaceMap = &SPIRAddrSpaceMap;
53
223
    UseAddrSpaceMapMangling = true;
54
223
    HasLegalHalfType = true;
55
223
    HasFloat16 = true;
56
    // Define available target features
57
    // These must be defined in sorted order!
58
223
    NoAsmVariants = true;
59
223
  }
60
61
  void getTargetDefines(const LangOptions &Opts,
62
                        MacroBuilder &Builder) const override;
63
64
114
  bool hasFeature(StringRef Feature) const override {
65
114
    return Feature == "spir";
66
114
  }
67
68
  // SPIR supports the half type and the only llvm intrinsic allowed in SPIR is
69
  // memcpy as per section 3 of the SPIR spec.
70
293
  bool useFP16ConversionIntrinsics() const override { return false; }
71
72
225
  ArrayRef<Builtin::Info> getTargetBuiltins() const override { return None; }
73
74
2
  const char *getClobbers() const override { return ""; }
75
76
0
  ArrayRef<const char *> getGCCRegNames() const override { return None; }
77
78
  bool validateAsmConstraint(const char *&Name,
79
0
                             TargetInfo::ConstraintInfo &info) const override {
80
0
    return true;
81
0
  }
82
83
0
  ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override {
84
0
    return None;
85
0
  }
86
87
214
  BuiltinVaListKind getBuiltinVaListKind() const override {
88
214
    return TargetInfo::VoidPtrBuiltinVaList;
89
214
  }
90
91
0
  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
92
0
    return (CC == CC_SpirFunction || CC == CC_OpenCLKernel) ? CCCR_OK
93
0
                                                            : CCCR_Warning;
94
0
  }
95
96
151k
  CallingConv getDefaultCallingConv() const override {
97
151k
    return CC_SpirFunction;
98
151k
  }
99
100
223
  void setSupportedOpenCLOpts() override {
101
    // Assume all OpenCL extensions and optional core features are supported
102
    // for SPIR since it is a generic target.
103
223
    supportAllOpenCLOpts();
104
223
  }
105
106
30
  bool hasExtIntType() const override { return true; }
107
108
760
  bool hasInt128Type() const override { return false; }
109
};
110
class LLVM_LIBRARY_VISIBILITY SPIR32TargetInfo : public SPIRTargetInfo {
111
public:
112
  SPIR32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
113
188
      : SPIRTargetInfo(Triple, Opts) {
114
188
    PointerWidth = PointerAlign = 32;
115
188
    SizeType = TargetInfo::UnsignedInt;
116
188
    PtrDiffType = IntPtrType = TargetInfo::SignedInt;
117
188
    resetDataLayout("e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-"
118
188
                    "v96:128-v192:256-v256:256-v512:512-v1024:1024");
119
188
  }
clang::targets::SPIR32TargetInfo::SPIR32TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
113
188
      : SPIRTargetInfo(Triple, Opts) {
114
188
    PointerWidth = PointerAlign = 32;
115
188
    SizeType = TargetInfo::UnsignedInt;
116
188
    PtrDiffType = IntPtrType = TargetInfo::SignedInt;
117
188
    resetDataLayout("e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-"
118
188
                    "v96:128-v192:256-v256:256-v512:512-v1024:1024");
119
188
  }
Unexecuted instantiation: clang::targets::SPIR32TargetInfo::SPIR32TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
120
121
  void getTargetDefines(const LangOptions &Opts,
122
                        MacroBuilder &Builder) const override;
123
};
124
125
class LLVM_LIBRARY_VISIBILITY SPIR64TargetInfo : public SPIRTargetInfo {
126
public:
127
  SPIR64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
128
35
      : SPIRTargetInfo(Triple, Opts) {
129
35
    PointerWidth = PointerAlign = 64;
130
35
    SizeType = TargetInfo::UnsignedLong;
131
35
    PtrDiffType = IntPtrType = TargetInfo::SignedLong;
132
35
    resetDataLayout("e-i64:64-v16:16-v24:32-v32:32-v48:64-"
133
35
                    "v96:128-v192:256-v256:256-v512:512-v1024:1024");
134
35
  }
clang::targets::SPIR64TargetInfo::SPIR64TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
128
35
      : SPIRTargetInfo(Triple, Opts) {
129
35
    PointerWidth = PointerAlign = 64;
130
35
    SizeType = TargetInfo::UnsignedLong;
131
35
    PtrDiffType = IntPtrType = TargetInfo::SignedLong;
132
35
    resetDataLayout("e-i64:64-v16:16-v24:32-v32:32-v48:64-"
133
35
                    "v96:128-v192:256-v256:256-v512:512-v1024:1024");
134
35
  }
Unexecuted instantiation: clang::targets::SPIR64TargetInfo::SPIR64TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
135
136
  void getTargetDefines(const LangOptions &Opts,
137
                        MacroBuilder &Builder) const override;
138
};
139
} // namespace targets
140
} // namespace clang
141
#endif // LLVM_CLANG_LIB_BASIC_TARGETS_SPIR_H