Coverage Report

Created: 2020-02-25 14:32

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