Coverage Report

Created: 2022-01-18 06:27

/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
90
        HasTransactionalExecution(false), HasVector(false), SoftFloat(false) {
38
90
    IntMaxType = SignedLong;
39
90
    Int64Type = SignedLong;
40
90
    TLSSupported = true;
41
90
    IntWidth = IntAlign = 32;
42
90
    LongWidth = LongLongWidth = LongAlign = LongLongAlign = 64;
43
90
    PointerWidth = PointerAlign = 64;
44
90
    LongDoubleWidth = 128;
45
90
    LongDoubleAlign = 64;
46
90
    LongDoubleFormat = &llvm::APFloat::IEEEquad();
47
90
    DefaultAlignForAttributeAligned = 64;
48
90
    MinGlobalAlign = 16;
49
90
    if (Triple.isOSzOS()) {
50
      // All vector types are default aligned on an 8-byte boundary, even if the
51
      // vector facility is not available. That is different from Linux.
52
28
      MaxVectorAlign = 64;
53
      // Compared to Linux/ELF, the data layout differs only in some details:
54
      // - name mangling is GOFF
55
      // - 128 bit vector types are 64 bit aligned
56
28
      resetDataLayout(
57
28
          "E-m:l-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64");
58
28
    } else
59
62
      resetDataLayout("E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64");
60
90
    MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
61
90
    HasStrictFP = true;
62
90
  }
clang::targets::SystemZTargetInfo::SystemZTargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
37
13
        HasTransactionalExecution(false), HasVector(false), SoftFloat(false) {
38
13
    IntMaxType = SignedLong;
39
13
    Int64Type = SignedLong;
40
13
    TLSSupported = true;
41
13
    IntWidth = IntAlign = 32;
42
13
    LongWidth = LongLongWidth = LongAlign = LongLongAlign = 64;
43
13
    PointerWidth = PointerAlign = 64;
44
13
    LongDoubleWidth = 128;
45
13
    LongDoubleAlign = 64;
46
13
    LongDoubleFormat = &llvm::APFloat::IEEEquad();
47
13
    DefaultAlignForAttributeAligned = 64;
48
13
    MinGlobalAlign = 16;
49
13
    if (Triple.isOSzOS()) {
50
      // All vector types are default aligned on an 8-byte boundary, even if the
51
      // vector facility is not available. That is different from Linux.
52
0
      MaxVectorAlign = 64;
53
      // Compared to Linux/ELF, the data layout differs only in some details:
54
      // - name mangling is GOFF
55
      // - 128 bit vector types are 64 bit aligned
56
0
      resetDataLayout(
57
0
          "E-m:l-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64");
58
0
    } else
59
13
      resetDataLayout("E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64");
60
13
    MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
61
13
    HasStrictFP = true;
62
13
  }
clang::targets::SystemZTargetInfo::SystemZTargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
37
77
        HasTransactionalExecution(false), HasVector(false), SoftFloat(false) {
38
77
    IntMaxType = SignedLong;
39
77
    Int64Type = SignedLong;
40
77
    TLSSupported = true;
41
77
    IntWidth = IntAlign = 32;
42
77
    LongWidth = LongLongWidth = LongAlign = LongLongAlign = 64;
43
77
    PointerWidth = PointerAlign = 64;
44
77
    LongDoubleWidth = 128;
45
77
    LongDoubleAlign = 64;
46
77
    LongDoubleFormat = &llvm::APFloat::IEEEquad();
47
77
    DefaultAlignForAttributeAligned = 64;
48
77
    MinGlobalAlign = 16;
49
77
    if (Triple.isOSzOS()) {
50
      // All vector types are default aligned on an 8-byte boundary, even if the
51
      // vector facility is not available. That is different from Linux.
52
28
      MaxVectorAlign = 64;
53
      // Compared to Linux/ELF, the data layout differs only in some details:
54
      // - name mangling is GOFF
55
      // - 128 bit vector types are 64 bit aligned
56
28
      resetDataLayout(
57
28
          "E-m:l-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64");
58
28
    } else
59
49
      resetDataLayout("E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64");
60
77
    MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
61
77
    HasStrictFP = true;
62
77
  }
63
64
  void getTargetDefines(const LangOptions &Opts,
65
                        MacroBuilder &Builder) const override;
66
67
  ArrayRef<Builtin::Info> getTargetBuiltins() const override;
68
69
  ArrayRef<const char *> getGCCRegNames() const override;
70
71
8
  ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override {
72
    // No aliases.
73
8
    return None;
74
8
  }
75
76
  ArrayRef<TargetInfo::AddlRegName> getGCCAddlRegNames() const override;
77
78
1
  bool isSPRegName(StringRef RegName) const override {
79
1
    return RegName.equals("r15");
80
1
  }
81
82
  bool validateAsmConstraint(const char *&Name,
83
                             TargetInfo::ConstraintInfo &info) const override;
84
85
61
  const char *getClobbers() const override {
86
    // FIXME: Is this really right?
87
61
    return "";
88
61
  }
89
90
81
  BuiltinVaListKind getBuiltinVaListKind() const override {
91
81
    return TargetInfo::SystemZBuiltinVaList;
92
81
  }
93
94
  int getISARevision(StringRef Name) const;
95
96
0
  bool isValidCPUName(StringRef Name) const override {
97
0
    return getISARevision(Name) != -1;
98
0
  }
99
100
  void fillValidCPUList(SmallVectorImpl<StringRef> &Values) const override;
101
102
42
  bool setCPU(const std::string &Name) override {
103
42
    CPU = Name;
104
42
    ISARevision = getISARevision(CPU);
105
42
    return ISARevision != -1;
106
42
  }
107
108
  bool
109
  initFeatureMap(llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags,
110
                 StringRef CPU,
111
88
                 const std::vector<std::string> &FeaturesVec) const override {
112
88
    int ISARevision = getISARevision(CPU);
113
88
    if (ISARevision >= 10)
114
26
      Features["transactional-execution"] = true;
115
88
    if (ISARevision >= 11)
116
26
      Features["vector"] = true;
117
88
    if (ISARevision >= 12)
118
14
      Features["vector-enhancements-1"] = true;
119
88
    if (ISARevision >= 13)
120
8
      Features["vector-enhancements-2"] = true;
121
88
    if (ISARevision >= 14)
122
3
      Features["nnp-assist"] = true;
123
88
    return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
124
88
  }
125
126
  bool handleTargetFeatures(std::vector<std::string> &Features,
127
88
                            DiagnosticsEngine &Diags) override {
128
88
    HasTransactionalExecution = false;
129
88
    HasVector = false;
130
88
    SoftFloat = false;
131
88
    for (const auto &Feature : Features) {
132
81
      if (Feature == "+transactional-execution")
133
26
        HasTransactionalExecution = true;
134
55
      else if (Feature == "+vector")
135
28
        HasVector = true;
136
27
      else if (Feature == "+soft-float")
137
2
        SoftFloat = true;
138
81
    }
139
88
    HasVector &= !SoftFloat;
140
141
    // If we use the vector ABI, vector types are 64-bit aligned.
142
88
    if (HasVector && 
!getTriple().isOSzOS()26
) {
143
24
      MaxVectorAlign = 64;
144
24
      resetDataLayout("E-m:e-i1:8:16-i8:8:16-i64:64-f128:64"
145
24
                      "-v128:64-a:8:16-n32:64");
146
24
    }
147
88
    return true;
148
88
  }
149
150
  bool hasFeature(StringRef Feature) const override;
151
152
6
  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
153
6
    switch (CC) {
154
0
    case CC_C:
155
0
    case CC_Swift:
156
0
    case CC_OpenCLKernel:
157
0
      return CCCR_OK;
158
6
    case CC_SwiftAsync:
159
6
      return CCCR_Error;
160
0
    default:
161
0
      return CCCR_Warning;
162
6
    }
163
6
  }
164
165
441
  StringRef getABI() const override {
166
441
    if (HasVector)
167
312
      return "vector";
168
129
    return "";
169
441
  }
170
171
1
  const char *getLongDoubleMangling() const override { return "g"; }
172
173
15
  bool hasBitIntType() const override { return true; }
174
175
0
  int getEHDataRegisterNumber(unsigned RegNo) const override {
176
0
    return RegNo < 4 ? 6 + RegNo : -1;
177
0
  }
178
};
179
} // namespace targets
180
} // namespace clang
181
#endif // LLVM_CLANG_LIB_BASIC_TARGETS_SYSTEMZ_H