Coverage Report

Created: 2019-07-24 05:18

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