Coverage Report

Created: 2020-02-25 14:32

/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
    0, // cuda_device
32
    0, // cuda_constant
33
    0, // cuda_shared
34
    0, // ptr32_sptr
35
    0, // ptr32_uptr
36
    0  // ptr64
37
};
38
39
class LLVM_LIBRARY_VISIBILITY SPIRTargetInfo : public TargetInfo {
40
public:
41
  SPIRTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
42
180
      : TargetInfo(Triple) {
43
180
    assert(getTriple().getOS() == llvm::Triple::UnknownOS &&
44
180
           "SPIR target must use unknown OS");
45
180
    assert(getTriple().getEnvironment() == llvm::Triple::UnknownEnvironment &&
46
180
           "SPIR target must use unknown environment type");
47
180
    TLSSupported = false;
48
180
    VLASupported = false;
49
180
    LongWidth = LongAlign = 64;
50
180
    AddrSpaceMap = &SPIRAddrSpaceMap;
51
180
    UseAddrSpaceMapMangling = true;
52
180
    HasLegalHalfType = true;
53
180
    HasFloat16 = true;
54
180
    // Define available target features
55
180
    // These must be defined in sorted order!
56
180
    NoAsmVariants = true;
57
180
  }
58
59
  void getTargetDefines(const LangOptions &Opts,
60
                        MacroBuilder &Builder) const override;
61
62
105
  bool hasFeature(StringRef Feature) const override {
63
105
    return Feature == "spir";
64
105
  }
65
66
  // SPIR supports the half type and the only llvm intrinsic allowed in SPIR is
67
  // memcpy as per section 3 of the SPIR spec.
68
230
  bool useFP16ConversionIntrinsics() const override { return false; }
69
70
181
  ArrayRef<Builtin::Info> getTargetBuiltins() const override { return None; }
71
72
2
  const char *getClobbers() const override { return ""; }
73
74
0
  ArrayRef<const char *> getGCCRegNames() const override { return None; }
75
76
  bool validateAsmConstraint(const char *&Name,
77
0
                             TargetInfo::ConstraintInfo &info) const override {
78
0
    return true;
79
0
  }
80
81
0
  ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override {
82
0
    return None;
83
0
  }
84
85
177
  BuiltinVaListKind getBuiltinVaListKind() const override {
86
177
    return TargetInfo::VoidPtrBuiltinVaList;
87
177
  }
88
89
0
  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
90
0
    return (CC == CC_SpirFunction || CC == CC_OpenCLKernel) ? CCCR_OK
91
0
                                                            : CCCR_Warning;
92
0
  }
93
94
156k
  CallingConv getDefaultCallingConv() const override {
95
156k
    return CC_SpirFunction;
96
156k
  }
97
98
180
  void setSupportedOpenCLOpts() override {
99
180
    // Assume all OpenCL extensions and optional core features are supported
100
180
    // for SPIR since it is a generic target.
101
180
    getSupportedOpenCLOpts().supportAll();
102
180
  }
103
};
104
class LLVM_LIBRARY_VISIBILITY SPIR32TargetInfo : public SPIRTargetInfo {
105
public:
106
  SPIR32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
107
156
      : SPIRTargetInfo(Triple, Opts) {
108
156
    PointerWidth = PointerAlign = 32;
109
156
    SizeType = TargetInfo::UnsignedInt;
110
156
    PtrDiffType = IntPtrType = TargetInfo::SignedInt;
111
156
    resetDataLayout("e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-"
112
156
                    "v96:128-v192:256-v256:256-v512:512-v1024:1024");
113
156
  }
clang::targets::SPIR32TargetInfo::SPIR32TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
107
156
      : SPIRTargetInfo(Triple, Opts) {
108
156
    PointerWidth = PointerAlign = 32;
109
156
    SizeType = TargetInfo::UnsignedInt;
110
156
    PtrDiffType = IntPtrType = TargetInfo::SignedInt;
111
156
    resetDataLayout("e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-"
112
156
                    "v96:128-v192:256-v256:256-v512:512-v1024:1024");
113
156
  }
Unexecuted instantiation: clang::targets::SPIR32TargetInfo::SPIR32TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
114
115
  void getTargetDefines(const LangOptions &Opts,
116
                        MacroBuilder &Builder) const override;
117
};
118
119
class LLVM_LIBRARY_VISIBILITY SPIR64TargetInfo : public SPIRTargetInfo {
120
public:
121
  SPIR64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
122
24
      : SPIRTargetInfo(Triple, Opts) {
123
24
    PointerWidth = PointerAlign = 64;
124
24
    SizeType = TargetInfo::UnsignedLong;
125
24
    PtrDiffType = IntPtrType = TargetInfo::SignedLong;
126
24
    resetDataLayout("e-i64:64-v16:16-v24:32-v32:32-v48:64-"
127
24
                    "v96:128-v192:256-v256:256-v512:512-v1024:1024");
128
24
  }
clang::targets::SPIR64TargetInfo::SPIR64TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
122
24
      : SPIRTargetInfo(Triple, Opts) {
123
24
    PointerWidth = PointerAlign = 64;
124
24
    SizeType = TargetInfo::UnsignedLong;
125
24
    PtrDiffType = IntPtrType = TargetInfo::SignedLong;
126
24
    resetDataLayout("e-i64:64-v16:16-v24:32-v32:32-v48:64-"
127
24
                    "v96:128-v192:256-v256:256-v512:512-v1024:1024");
128
24
  }
Unexecuted instantiation: clang::targets::SPIR64TargetInfo::SPIR64TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
129
130
  void getTargetDefines(const LangOptions &Opts,
131
                        MacroBuilder &Builder) const override;
132
};
133
} // namespace targets
134
} // namespace clang
135
#endif // LLVM_CLANG_LIB_BASIC_TARGETS_SPIR_H