Coverage Report

Created: 2020-11-24 06:42

/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
195
      : TargetInfo(Triple) {
45
195
    assert(getTriple().getOS() == llvm::Triple::UnknownOS &&
46
195
           "SPIR target must use unknown OS");
47
195
    assert(getTriple().getEnvironment() == llvm::Triple::UnknownEnvironment &&
48
195
           "SPIR target must use unknown environment type");
49
195
    TLSSupported = false;
50
195
    VLASupported = false;
51
195
    LongWidth = LongAlign = 64;
52
195
    AddrSpaceMap = &SPIRAddrSpaceMap;
53
195
    UseAddrSpaceMapMangling = true;
54
195
    HasLegalHalfType = true;
55
195
    HasFloat16 = true;
56
    // Define available target features
57
    // These must be defined in sorted order!
58
195
    NoAsmVariants = true;
59
195
  }
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
233
  bool useFP16ConversionIntrinsics() const override { return false; }
71
72
196
  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
191
  BuiltinVaListKind getBuiltinVaListKind() const override {
88
191
    return TargetInfo::VoidPtrBuiltinVaList;
89
191
  }
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
196k
  CallingConv getDefaultCallingConv() const override {
97
196k
    return CC_SpirFunction;
98
196k
  }
99
100
195
  void setSupportedOpenCLOpts() override {
101
    // Assume all OpenCL extensions and optional core features are supported
102
    // for SPIR since it is a generic target.
103
195
    getSupportedOpenCLOpts().supportAll();
104
195
  }
105
106
30
  bool hasExtIntType() const override { return true; }
107
};
108
class LLVM_LIBRARY_VISIBILITY SPIR32TargetInfo : public SPIRTargetInfo {
109
public:
110
  SPIR32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
111
164
      : SPIRTargetInfo(Triple, Opts) {
112
164
    PointerWidth = PointerAlign = 32;
113
164
    SizeType = TargetInfo::UnsignedInt;
114
164
    PtrDiffType = IntPtrType = TargetInfo::SignedInt;
115
164
    resetDataLayout("e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-"
116
164
                    "v96:128-v192:256-v256:256-v512:512-v1024:1024");
117
164
  }
clang::targets::SPIR32TargetInfo::SPIR32TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
111
164
      : SPIRTargetInfo(Triple, Opts) {
112
164
    PointerWidth = PointerAlign = 32;
113
164
    SizeType = TargetInfo::UnsignedInt;
114
164
    PtrDiffType = IntPtrType = TargetInfo::SignedInt;
115
164
    resetDataLayout("e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-"
116
164
                    "v96:128-v192:256-v256:256-v512:512-v1024:1024");
117
164
  }
Unexecuted instantiation: clang::targets::SPIR32TargetInfo::SPIR32TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
118
119
  void getTargetDefines(const LangOptions &Opts,
120
                        MacroBuilder &Builder) const override;
121
};
122
123
class LLVM_LIBRARY_VISIBILITY SPIR64TargetInfo : public SPIRTargetInfo {
124
public:
125
  SPIR64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
126
31
      : SPIRTargetInfo(Triple, Opts) {
127
31
    PointerWidth = PointerAlign = 64;
128
31
    SizeType = TargetInfo::UnsignedLong;
129
31
    PtrDiffType = IntPtrType = TargetInfo::SignedLong;
130
31
    resetDataLayout("e-i64:64-v16:16-v24:32-v32:32-v48:64-"
131
31
                    "v96:128-v192:256-v256:256-v512:512-v1024:1024");
132
31
  }
clang::targets::SPIR64TargetInfo::SPIR64TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
126
31
      : SPIRTargetInfo(Triple, Opts) {
127
31
    PointerWidth = PointerAlign = 64;
128
31
    SizeType = TargetInfo::UnsignedLong;
129
31
    PtrDiffType = IntPtrType = TargetInfo::SignedLong;
130
31
    resetDataLayout("e-i64:64-v16:16-v24:32-v32:32-v48:64-"
131
31
                    "v96:128-v192:256-v256:256-v512:512-v1024:1024");
132
31
  }
Unexecuted instantiation: clang::targets::SPIR64TargetInfo::SPIR64TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
133
134
  void getTargetDefines(const LangOptions &Opts,
135
                        MacroBuilder &Builder) const override;
136
};
137
} // namespace targets
138
} // namespace clang
139
#endif // LLVM_CLANG_LIB_BASIC_TARGETS_SPIR_H