Coverage Report

Created: 2020-09-19 12:23

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/Basic/Targets/SystemZ.h
Line
Count
Source (jump to first uncovered line)
1
//===--- SystemZ.h - Declare SystemZ 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 SystemZ TargetInfo objects.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#ifndef LLVM_CLANG_LIB_BASIC_TARGETS_SYSTEMZ_H
14
#define LLVM_CLANG_LIB_BASIC_TARGETS_SYSTEMZ_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
class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo {
25
26
  static const Builtin::Info BuiltinInfo[];
27
  static const char *const GCCRegNames[];
28
  std::string CPU;
29
  int ISARevision;
30
  bool HasTransactionalExecution;
31
  bool HasVector;
32
  bool SoftFloat;
33
34
public:
35
  SystemZTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
36
      : TargetInfo(Triple), CPU("z10"), ISARevision(8),
37
121
        HasTransactionalExecution(false), HasVector(false), SoftFloat(false) {
38
121
    IntMaxType = SignedLong;
39
121
    Int64Type = SignedLong;
40
121
    TLSSupported = true;
41
121
    IntWidth = IntAlign = 32;
42
121
    LongWidth = LongLongWidth = LongAlign = LongLongAlign = 64;
43
121
    PointerWidth = PointerAlign = 64;
44
121
    LongDoubleWidth = 128;
45
121
    LongDoubleAlign = 64;
46
121
    LongDoubleFormat = &llvm::APFloat::IEEEquad();
47
121
    DefaultAlignForAttributeAligned = 64;
48
121
    MinGlobalAlign = 16;
49
121
    resetDataLayout("E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64");
50
121
    MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
51
121
    HasStrictFP = true;
52
121
  }
clang::targets::SystemZTargetInfo::SystemZTargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
37
27
        HasTransactionalExecution(false), HasVector(false), SoftFloat(false) {
38
27
    IntMaxType = SignedLong;
39
27
    Int64Type = SignedLong;
40
27
    TLSSupported = true;
41
27
    IntWidth = IntAlign = 32;
42
27
    LongWidth = LongLongWidth = LongAlign = LongLongAlign = 64;
43
27
    PointerWidth = PointerAlign = 64;
44
27
    LongDoubleWidth = 128;
45
27
    LongDoubleAlign = 64;
46
27
    LongDoubleFormat = &llvm::APFloat::IEEEquad();
47
27
    DefaultAlignForAttributeAligned = 64;
48
27
    MinGlobalAlign = 16;
49
27
    resetDataLayout("E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64");
50
27
    MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
51
27
    HasStrictFP = true;
52
27
  }
clang::targets::SystemZTargetInfo::SystemZTargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
37
94
        HasTransactionalExecution(false), HasVector(false), SoftFloat(false) {
38
94
    IntMaxType = SignedLong;
39
94
    Int64Type = SignedLong;
40
94
    TLSSupported = true;
41
94
    IntWidth = IntAlign = 32;
42
94
    LongWidth = LongLongWidth = LongAlign = LongLongAlign = 64;
43
94
    PointerWidth = PointerAlign = 64;
44
94
    LongDoubleWidth = 128;
45
94
    LongDoubleAlign = 64;
46
94
    LongDoubleFormat = &llvm::APFloat::IEEEquad();
47
94
    DefaultAlignForAttributeAligned = 64;
48
94
    MinGlobalAlign = 16;
49
94
    resetDataLayout("E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64");
50
94
    MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
51
94
    HasStrictFP = true;
52
94
  }
53
54
  void getTargetDefines(const LangOptions &Opts,
55
                        MacroBuilder &Builder) const override;
56
57
  ArrayRef<Builtin::Info> getTargetBuiltins() const override;
58
59
  ArrayRef<const char *> getGCCRegNames() const override;
60
61
2
  ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override {
62
    // No aliases.
63
2
    return None;
64
2
  }
65
66
  ArrayRef<TargetInfo::AddlRegName> getGCCAddlRegNames() const override;
67
68
1
  bool isSPRegName(StringRef RegName) const override {
69
1
    return RegName.equals("r15");
70
1
  }
71
72
  bool validateAsmConstraint(const char *&Name,
73
                             TargetInfo::ConstraintInfo &info) const override;
74
75
59
  const char *getClobbers() const override {
76
    // FIXME: Is this really right?
77
59
    return "";
78
59
  }
79
80
97
  BuiltinVaListKind getBuiltinVaListKind() const override {
81
97
    return TargetInfo::SystemZBuiltinVaList;
82
97
  }
83
84
  int getISARevision(StringRef Name) const;
85
86
0
  bool isValidCPUName(StringRef Name) const override {
87
0
    return getISARevision(Name) != -1;
88
0
  }
89
90
  void fillValidCPUList(SmallVectorImpl<StringRef> &Values) const override;
91
92
79
  bool setCPU(const std::string &Name) override {
93
79
    CPU = Name;
94
79
    ISARevision = getISARevision(CPU);
95
79
    return ISARevision != -1;
96
79
  }
97
98
  bool
99
  initFeatureMap(llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags,
100
                 StringRef CPU,
101
119
                 const std::vector<std::string> &FeaturesVec) const override {
102
119
    int ISARevision = getISARevision(CPU);
103
119
    if (ISARevision >= 10)
104
62
      Features["transactional-execution"] = true;
105
119
    if (ISARevision >= 11)
106
55
      Features["vector"] = true;
107
119
    if (ISARevision >= 12)
108
34
      Features["vector-enhancements-1"] = true;
109
119
    if (ISARevision >= 13)
110
16
      Features["vector-enhancements-2"] = true;
111
119
    return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
112
119
  }
113
114
  bool handleTargetFeatures(std::vector<std::string> &Features,
115
119
                            DiagnosticsEngine &Diags) override {
116
119
    HasTransactionalExecution = false;
117
119
    HasVector = false;
118
119
    SoftFloat = false;
119
173
    for (const auto &Feature : Features) {
120
173
      if (Feature == "+transactional-execution")
121
63
        HasTransactionalExecution = true;
122
110
      else if (Feature == "+vector")
123
58
        HasVector = true;
124
52
      else if (Feature == "+soft-float")
125
2
        SoftFloat = true;
126
173
    }
127
119
    HasVector &= !SoftFloat;
128
119
129
    // If we use the vector ABI, vector types are 64-bit aligned.
130
119
    if (HasVector) {
131
56
      MaxVectorAlign = 64;
132
56
      resetDataLayout("E-m:e-i1:8:16-i8:8:16-i64:64-f128:64"
133
56
                      "-v128:64-a:8:16-n32:64");
134
56
    }
135
119
    return true;
136
119
  }
137
138
  bool hasFeature(StringRef Feature) const override;
139
140
0
  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
141
0
    switch (CC) {
142
0
    case CC_C:
143
0
    case CC_Swift:
144
0
    case CC_OpenCLKernel:
145
0
      return CCCR_OK;
146
0
    default:
147
0
      return CCCR_Warning;
148
0
    }
149
0
  }
150
151
77
  StringRef getABI() const override {
152
77
    if (HasVector)
153
41
      return "vector";
154
36
    return "";
155
36
  }
156
157
1
  const char *getLongDoubleMangling() const override { return "g"; }
158
159
15
  bool hasExtIntType() const override { return true; }
160
161
16
  int getEHDataRegisterNumber(unsigned RegNo) const override {
162
16
    return RegNo < 4 ? 6 + RegNo : 
-10
;
163
16
  }
164
};
165
} // namespace targets
166
} // namespace clang
167
#endif // LLVM_CLANG_LIB_BASIC_TARGETS_SYSTEMZ_H