Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/Support/AMDGPUMetadata.cpp
Line
Count
Source (jump to first uncovered line)
1
//===--- AMDGPUMetadata.cpp -------------------------------------*- 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
/// \file
10
/// AMDGPU metadata definitions and in-memory representations.
11
///
12
//
13
//===----------------------------------------------------------------------===//
14
15
#include "llvm/ADT/Twine.h"
16
#include "llvm/Support/AMDGPUMetadata.h"
17
#include "llvm/Support/YAMLTraits.h"
18
19
using namespace llvm::AMDGPU;
20
using namespace llvm::AMDGPU::HSAMD;
21
22
LLVM_YAML_IS_SEQUENCE_VECTOR(Kernel::Arg::Metadata)
23
LLVM_YAML_IS_SEQUENCE_VECTOR(Kernel::Metadata)
24
25
namespace llvm {
26
namespace yaml {
27
28
template <>
29
struct ScalarEnumerationTraits<AccessQualifier> {
30
1.00k
  static void enumeration(IO &YIO, AccessQualifier &EN) {
31
1.00k
    YIO.enumCase(EN, "Default", AccessQualifier::Default);
32
1.00k
    YIO.enumCase(EN, "ReadOnly", AccessQualifier::ReadOnly);
33
1.00k
    YIO.enumCase(EN, "WriteOnly", AccessQualifier::WriteOnly);
34
1.00k
    YIO.enumCase(EN, "ReadWrite", AccessQualifier::ReadWrite);
35
1.00k
  }
36
};
37
38
template <>
39
struct ScalarEnumerationTraits<AddressSpaceQualifier> {
40
4.38k
  static void enumeration(IO &YIO, AddressSpaceQualifier &EN) {
41
4.38k
    YIO.enumCase(EN, "Private", AddressSpaceQualifier::Private);
42
4.38k
    YIO.enumCase(EN, "Global", AddressSpaceQualifier::Global);
43
4.38k
    YIO.enumCase(EN, "Constant", AddressSpaceQualifier::Constant);
44
4.38k
    YIO.enumCase(EN, "Local", AddressSpaceQualifier::Local);
45
4.38k
    YIO.enumCase(EN, "Generic", AddressSpaceQualifier::Generic);
46
4.38k
    YIO.enumCase(EN, "Region", AddressSpaceQualifier::Region);
47
4.38k
  }
48
};
49
50
template <>
51
struct ScalarEnumerationTraits<ValueKind> {
52
7.63k
  static void enumeration(IO &YIO, ValueKind &EN) {
53
7.63k
    YIO.enumCase(EN, "ByValue", ValueKind::ByValue);
54
7.63k
    YIO.enumCase(EN, "GlobalBuffer", ValueKind::GlobalBuffer);
55
7.63k
    YIO.enumCase(EN, "DynamicSharedPointer", ValueKind::DynamicSharedPointer);
56
7.63k
    YIO.enumCase(EN, "Sampler", ValueKind::Sampler);
57
7.63k
    YIO.enumCase(EN, "Image", ValueKind::Image);
58
7.63k
    YIO.enumCase(EN, "Pipe", ValueKind::Pipe);
59
7.63k
    YIO.enumCase(EN, "Queue", ValueKind::Queue);
60
7.63k
    YIO.enumCase(EN, "HiddenGlobalOffsetX", ValueKind::HiddenGlobalOffsetX);
61
7.63k
    YIO.enumCase(EN, "HiddenGlobalOffsetY", ValueKind::HiddenGlobalOffsetY);
62
7.63k
    YIO.enumCase(EN, "HiddenGlobalOffsetZ", ValueKind::HiddenGlobalOffsetZ);
63
7.63k
    YIO.enumCase(EN, "HiddenNone", ValueKind::HiddenNone);
64
7.63k
    YIO.enumCase(EN, "HiddenPrintfBuffer", ValueKind::HiddenPrintfBuffer);
65
7.63k
    YIO.enumCase(EN, "HiddenDefaultQueue", ValueKind::HiddenDefaultQueue);
66
7.63k
    YIO.enumCase(EN, "HiddenCompletionAction",
67
7.63k
                 ValueKind::HiddenCompletionAction);
68
7.63k
    YIO.enumCase(EN, "HiddenMultiGridSyncArg",
69
7.63k
     ValueKind::HiddenMultiGridSyncArg);
70
7.63k
  }
71
};
72
73
template <>
74
struct ScalarEnumerationTraits<ValueType> {
75
7.63k
  static void enumeration(IO &YIO, ValueType &EN) {
76
7.63k
    YIO.enumCase(EN, "Struct", ValueType::Struct);
77
7.63k
    YIO.enumCase(EN, "I8", ValueType::I8);
78
7.63k
    YIO.enumCase(EN, "U8", ValueType::U8);
79
7.63k
    YIO.enumCase(EN, "I16", ValueType::I16);
80
7.63k
    YIO.enumCase(EN, "U16", ValueType::U16);
81
7.63k
    YIO.enumCase(EN, "F16", ValueType::F16);
82
7.63k
    YIO.enumCase(EN, "I32", ValueType::I32);
83
7.63k
    YIO.enumCase(EN, "U32", ValueType::U32);
84
7.63k
    YIO.enumCase(EN, "F32", ValueType::F32);
85
7.63k
    YIO.enumCase(EN, "I64", ValueType::I64);
86
7.63k
    YIO.enumCase(EN, "U64", ValueType::U64);
87
7.63k
    YIO.enumCase(EN, "F64", ValueType::F64);
88
7.63k
  }
89
};
90
91
template <>
92
struct MappingTraits<Kernel::Attrs::Metadata> {
93
186
  static void mapping(IO &YIO, Kernel::Attrs::Metadata &MD) {
94
186
    YIO.mapOptional(Kernel::Attrs::Key::ReqdWorkGroupSize,
95
186
                    MD.mReqdWorkGroupSize, std::vector<uint32_t>());
96
186
    YIO.mapOptional(Kernel::Attrs::Key::WorkGroupSizeHint,
97
186
                    MD.mWorkGroupSizeHint, std::vector<uint32_t>());
98
186
    YIO.mapOptional(Kernel::Attrs::Key::VecTypeHint,
99
186
                    MD.mVecTypeHint, std::string());
100
186
    YIO.mapOptional(Kernel::Attrs::Key::RuntimeHandle, MD.mRuntimeHandle,
101
186
                    std::string());
102
186
  }
103
};
104
105
template <>
106
struct MappingTraits<Kernel::Arg::Metadata> {
107
7.63k
  static void mapping(IO &YIO, Kernel::Arg::Metadata &MD) {
108
7.63k
    YIO.mapOptional(Kernel::Arg::Key::Name, MD.mName, std::string());
109
7.63k
    YIO.mapOptional(Kernel::Arg::Key::TypeName, MD.mTypeName, std::string());
110
7.63k
    YIO.mapRequired(Kernel::Arg::Key::Size, MD.mSize);
111
7.63k
    YIO.mapRequired(Kernel::Arg::Key::Align, MD.mAlign);
112
7.63k
    YIO.mapRequired(Kernel::Arg::Key::ValueKind, MD.mValueKind);
113
7.63k
    YIO.mapRequired(Kernel::Arg::Key::ValueType, MD.mValueType);
114
7.63k
    YIO.mapOptional(Kernel::Arg::Key::PointeeAlign, MD.mPointeeAlign,
115
7.63k
                    uint32_t(0));
116
7.63k
    YIO.mapOptional(Kernel::Arg::Key::AddrSpaceQual, MD.mAddrSpaceQual,
117
7.63k
                    AddressSpaceQualifier::Unknown);
118
7.63k
    YIO.mapOptional(Kernel::Arg::Key::AccQual, MD.mAccQual,
119
7.63k
                    AccessQualifier::Unknown);
120
7.63k
    YIO.mapOptional(Kernel::Arg::Key::ActualAccQual, MD.mActualAccQual,
121
7.63k
                    AccessQualifier::Unknown);
122
7.63k
    YIO.mapOptional(Kernel::Arg::Key::IsConst, MD.mIsConst, false);
123
7.63k
    YIO.mapOptional(Kernel::Arg::Key::IsRestrict, MD.mIsRestrict, false);
124
7.63k
    YIO.mapOptional(Kernel::Arg::Key::IsVolatile, MD.mIsVolatile, false);
125
7.63k
    YIO.mapOptional(Kernel::Arg::Key::IsPipe, MD.mIsPipe, false);
126
7.63k
  }
127
};
128
129
template <>
130
struct MappingTraits<Kernel::CodeProps::Metadata> {
131
1.77k
  static void mapping(IO &YIO, Kernel::CodeProps::Metadata &MD) {
132
1.77k
    YIO.mapRequired(Kernel::CodeProps::Key::KernargSegmentSize,
133
1.77k
                    MD.mKernargSegmentSize);
134
1.77k
    YIO.mapRequired(Kernel::CodeProps::Key::GroupSegmentFixedSize,
135
1.77k
                    MD.mGroupSegmentFixedSize);
136
1.77k
    YIO.mapRequired(Kernel::CodeProps::Key::PrivateSegmentFixedSize,
137
1.77k
                    MD.mPrivateSegmentFixedSize);
138
1.77k
    YIO.mapRequired(Kernel::CodeProps::Key::KernargSegmentAlign,
139
1.77k
                    MD.mKernargSegmentAlign);
140
1.77k
    YIO.mapRequired(Kernel::CodeProps::Key::WavefrontSize,
141
1.77k
                    MD.mWavefrontSize);
142
1.77k
    YIO.mapOptional(Kernel::CodeProps::Key::NumSGPRs,
143
1.77k
                    MD.mNumSGPRs, uint16_t(0));
144
1.77k
    YIO.mapOptional(Kernel::CodeProps::Key::NumVGPRs,
145
1.77k
                    MD.mNumVGPRs, uint16_t(0));
146
1.77k
    YIO.mapOptional(Kernel::CodeProps::Key::MaxFlatWorkGroupSize,
147
1.77k
                    MD.mMaxFlatWorkGroupSize, uint32_t(0));
148
1.77k
    YIO.mapOptional(Kernel::CodeProps::Key::IsDynamicCallStack,
149
1.77k
                    MD.mIsDynamicCallStack, false);
150
1.77k
    YIO.mapOptional(Kernel::CodeProps::Key::IsXNACKEnabled,
151
1.77k
                    MD.mIsXNACKEnabled, false);
152
1.77k
    YIO.mapOptional(Kernel::CodeProps::Key::NumSpilledSGPRs,
153
1.77k
                    MD.mNumSpilledSGPRs, uint16_t(0));
154
1.77k
    YIO.mapOptional(Kernel::CodeProps::Key::NumSpilledVGPRs,
155
1.77k
                    MD.mNumSpilledVGPRs, uint16_t(0));
156
1.77k
  }
157
};
158
159
template <>
160
struct MappingTraits<Kernel::DebugProps::Metadata> {
161
6
  static void mapping(IO &YIO, Kernel::DebugProps::Metadata &MD) {
162
6
    YIO.mapOptional(Kernel::DebugProps::Key::DebuggerABIVersion,
163
6
                    MD.mDebuggerABIVersion, std::vector<uint32_t>());
164
6
    YIO.mapOptional(Kernel::DebugProps::Key::ReservedNumVGPRs,
165
6
                    MD.mReservedNumVGPRs, uint16_t(0));
166
6
    YIO.mapOptional(Kernel::DebugProps::Key::ReservedFirstVGPR,
167
6
                    MD.mReservedFirstVGPR, uint16_t(-1));
168
6
    YIO.mapOptional(Kernel::DebugProps::Key::PrivateSegmentBufferSGPR,
169
6
                    MD.mPrivateSegmentBufferSGPR, uint16_t(-1));
170
6
    YIO.mapOptional(Kernel::DebugProps::Key::WavefrontPrivateSegmentOffsetSGPR,
171
6
                    MD.mWavefrontPrivateSegmentOffsetSGPR, uint16_t(-1));
172
6
  }
173
};
174
175
template <>
176
struct MappingTraits<Kernel::Metadata> {
177
1.79k
  static void mapping(IO &YIO, Kernel::Metadata &MD) {
178
1.79k
    YIO.mapRequired(Kernel::Key::Name, MD.mName);
179
1.79k
    YIO.mapRequired(Kernel::Key::SymbolName, MD.mSymbolName);
180
1.79k
    YIO.mapOptional(Kernel::Key::Language, MD.mLanguage, std::string());
181
1.79k
    YIO.mapOptional(Kernel::Key::LanguageVersion, MD.mLanguageVersion,
182
1.79k
                    std::vector<uint32_t>());
183
1.79k
    if (!MD.mAttrs.empty() || 
!YIO.outputting()1.64k
)
184
288
      YIO.mapOptional(Kernel::Key::Attrs, MD.mAttrs);
185
1.79k
    if (!MD.mArgs.empty() || 
!YIO.outputting()437
)
186
1.49k
      YIO.mapOptional(Kernel::Key::Args, MD.mArgs);
187
1.79k
    if (!MD.mCodeProps.empty() || 
!YIO.outputting()0
)
188
1.79k
      YIO.mapOptional(Kernel::Key::CodeProps, MD.mCodeProps);
189
1.79k
    if (!MD.mDebugProps.empty() || 
!YIO.outputting()1.79k
)
190
138
      YIO.mapOptional(Kernel::Key::DebugProps, MD.mDebugProps);
191
1.79k
  }
192
};
193
194
template <>
195
struct MappingTraits<HSAMD::Metadata> {
196
380
  static void mapping(IO &YIO, HSAMD::Metadata &MD) {
197
380
    YIO.mapRequired(Key::Version, MD.mVersion);
198
380
    YIO.mapOptional(Key::Printf, MD.mPrintf, std::vector<std::string>());
199
380
    if (!MD.mKernels.empty() || 
!YIO.outputting()121
)
200
287
      YIO.mapOptional(Key::Kernels, MD.mKernels);
201
380
  }
202
};
203
204
} // end namespace yaml
205
206
namespace AMDGPU {
207
namespace HSAMD {
208
209
28
std::error_code fromString(std::string String, Metadata &HSAMetadata) {
210
28
  yaml::Input YamlInput(String);
211
28
  YamlInput >> HSAMetadata;
212
28
  return YamlInput.error();
213
28
}
214
215
352
std::error_code toString(Metadata HSAMetadata, std::string &String) {
216
352
  raw_string_ostream YamlStream(String);
217
352
  yaml::Output YamlOutput(YamlStream, nullptr, std::numeric_limits<int>::max());
218
352
  YamlOutput << HSAMetadata;
219
352
  return std::error_code();
220
352
}
221
222
} // end namespace HSAMD
223
} // end namespace AMDGPU
224
} // end namespace llvm