Coverage Report

Created: 2021-01-26 06:56

/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
129
        HasTransactionalExecution(false), HasVector(false), SoftFloat(false) {
38
129
    IntMaxType = SignedLong;
39
129
    Int64Type = SignedLong;
40
129
    TLSSupported = true;
41
129
    IntWidth = IntAlign = 32;
42
129
    LongWidth = LongLongWidth = LongAlign = LongLongAlign = 64;
43
129
    PointerWidth = PointerAlign = 64;
44
129
    LongDoubleWidth = 128;
45
129
    LongDoubleAlign = 64;
46
129
    LongDoubleFormat = &llvm::APFloat::IEEEquad();
47
129
    DefaultAlignForAttributeAligned = 64;
48
129
    MinGlobalAlign = 16;
49
129
    resetDataLayout("E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64");
50
129
    MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
51
129
    HasStrictFP = true;
52
129
  }
clang::targets::SystemZTargetInfo::SystemZTargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
37
28
        HasTransactionalExecution(false), HasVector(false), SoftFloat(false) {
38
28
    IntMaxType = SignedLong;
39
28
    Int64Type = SignedLong;
40
28
    TLSSupported = true;
41
28
    IntWidth = IntAlign = 32;
42
28
    LongWidth = LongLongWidth = LongAlign = LongLongAlign = 64;
43
28
    PointerWidth = PointerAlign = 64;
44
28
    LongDoubleWidth = 128;
45
28
    LongDoubleAlign = 64;
46
28
    LongDoubleFormat = &llvm::APFloat::IEEEquad();
47
28
    DefaultAlignForAttributeAligned = 64;
48
28
    MinGlobalAlign = 16;
49
28
    resetDataLayout("E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64");
50
28
    MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
51
28
    HasStrictFP = true;
52
28
  }
clang::targets::SystemZTargetInfo::SystemZTargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
37
101
        HasTransactionalExecution(false), HasVector(false), SoftFloat(false) {
38
101
    IntMaxType = SignedLong;
39
101
    Int64Type = SignedLong;
40
101
    TLSSupported = true;
41
101
    IntWidth = IntAlign = 32;
42
101
    LongWidth = LongLongWidth = LongAlign = LongLongAlign = 64;
43
101
    PointerWidth = PointerAlign = 64;
44
101
    LongDoubleWidth = 128;
45
101
    LongDoubleAlign = 64;
46
101
    LongDoubleFormat = &llvm::APFloat::IEEEquad();
47
101
    DefaultAlignForAttributeAligned = 64;
48
101
    MinGlobalAlign = 16;
49
101
    resetDataLayout("E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64");
50
101
    MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
51
101
    HasStrictFP = true;
52
101
  }
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
12
  ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override {
62
    // No aliases.
63
12
    return None;
64
12
  }
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
62
  const char *getClobbers() const override {
76
    // FIXME: Is this really right?
77
62
    return "";
78
62
  }
79
80
103
  BuiltinVaListKind getBuiltinVaListKind() const override {
81
103
    return TargetInfo::SystemZBuiltinVaList;
82
103
  }
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
127
                 const std::vector<std::string> &FeaturesVec) const override {
102
127
    int ISARevision = getISARevision(CPU);
103
127
    if (ISARevision >= 10)
104
62
      Features["transactional-execution"] = true;
105
127
    if (ISARevision >= 11)
106
55
      Features["vector"] = true;
107
127
    if (ISARevision >= 12)
108
34
      Features["vector-enhancements-1"] = true;
109
127
    if (ISARevision >= 13)
110
16
      Features["vector-enhancements-2"] = true;
111
127
    return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
112
127
  }
113
114
  bool handleTargetFeatures(std::vector<std::string> &Features,
115
127
                            DiagnosticsEngine &Diags) override {
116
127
    HasTransactionalExecution = false;
117
127
    HasVector = false;
118
127
    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
127
    HasVector &= !SoftFloat;
128
129
    // If we use the vector ABI, vector types are 64-bit aligned.
130
127
    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
127
    return true;
136
127
  }
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
396
  StringRef getABI() const override {
152
396
    if (HasVector)
153
281
      return "vector";
154
115
    return "";
155
115
  }
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