Coverage Report

Created: 2019-02-20 07:29

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/CodeGen/MIRYamlMapping.h
Line
Count
Source (jump to first uncovered line)
1
//===- MIRYamlMapping.h - Describes the mapping between MIR and YAML ------===//
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 implements the mapping between various MIR data structures and
10
// their corresponding YAML representation.
11
//
12
//===----------------------------------------------------------------------===//
13
14
#ifndef LLVM_CODEGEN_MIRYAMLMAPPING_H
15
#define LLVM_CODEGEN_MIRYAMLMAPPING_H
16
17
#include "llvm/ADT/Optional.h"
18
#include "llvm/ADT/StringRef.h"
19
#include "llvm/CodeGen/MachineJumpTableInfo.h"
20
#include "llvm/Support/SMLoc.h"
21
#include "llvm/Support/YAMLTraits.h"
22
#include "llvm/Support/raw_ostream.h"
23
#include <algorithm>
24
#include <cstdint>
25
#include <string>
26
#include <vector>
27
28
namespace llvm {
29
namespace yaml {
30
31
/// A wrapper around std::string which contains a source range that's being
32
/// set during parsing.
33
0
struct StringValue {
34
  std::string Value;
35
  SMRange SourceRange;
36
37
334k
  StringValue() = default;
38
255
  StringValue(std::string Value) : Value(std::move(Value)) {}
39
40
93.8k
  bool operator==(const StringValue &Other) const {
41
93.8k
    return Value == Other.Value;
42
93.8k
  }
43
};
44
45
template <> struct ScalarTraits<StringValue> {
46
119k
  static void output(const StringValue &S, void *, raw_ostream &OS) {
47
119k
    OS << S.Value;
48
119k
  }
49
50
32.8k
  static StringRef input(StringRef Scalar, void *Ctx, StringValue &S) {
51
32.8k
    S.Value = Scalar.str();
52
32.8k
    if (const auto *Node =
53
32.8k
            reinterpret_cast<yaml::Input *>(Ctx)->getCurrentNode())
54
32.8k
      S.SourceRange = Node->getSourceRange();
55
32.8k
    return "";
56
32.8k
  }
57
58
137k
  static QuotingType mustQuote(StringRef S) { return needsQuotes(S); }
59
};
60
61
0
struct FlowStringValue : StringValue {
62
1.25k
  FlowStringValue() = default;
63
94
  FlowStringValue(std::string Value) : StringValue(std::move(Value)) {}
64
};
65
66
template <> struct ScalarTraits<FlowStringValue> {
67
507
  static void output(const FlowStringValue &S, void *, raw_ostream &OS) {
68
507
    return ScalarTraits<StringValue>::output(S, nullptr, OS);
69
507
  }
70
71
839
  static StringRef input(StringRef Scalar, void *Ctx, FlowStringValue &S) {
72
839
    return ScalarTraits<StringValue>::input(Scalar, Ctx, S);
73
839
  }
74
75
1.34k
  static QuotingType mustQuote(StringRef S) { return needsQuotes(S); }
76
};
77
78
0
struct BlockStringValue {
79
  StringValue Value;
80
81
7.25k
  bool operator==(const BlockStringValue &Other) const {
82
7.25k
    return Value == Other.Value;
83
7.25k
  }
84
};
85
86
template <> struct BlockScalarTraits<BlockStringValue> {
87
7.25k
  static void output(const BlockStringValue &S, void *Ctx, raw_ostream &OS) {
88
7.25k
    return ScalarTraits<StringValue>::output(S.Value, Ctx, OS);
89
7.25k
  }
90
91
6.89k
  static StringRef input(StringRef Scalar, void *Ctx, BlockStringValue &S) {
92
6.89k
    return ScalarTraits<StringValue>::input(Scalar, Ctx, S.Value);
93
6.89k
  }
94
};
95
96
/// A wrapper around unsigned which contains a source range that's being set
97
/// during parsing.
98
0
struct UnsignedValue {
99
  unsigned Value = 0;
100
  SMRange SourceRange;
101
102
57.5k
  UnsignedValue() = default;
103
42.4k
  UnsignedValue(unsigned Value) : Value(Value) {}
104
105
0
  bool operator==(const UnsignedValue &Other) const {
106
0
    return Value == Other.Value;
107
0
  }
108
};
109
110
template <> struct ScalarTraits<UnsignedValue> {
111
42.3k
  static void output(const UnsignedValue &Value, void *Ctx, raw_ostream &OS) {
112
42.3k
    return ScalarTraits<unsigned>::output(Value.Value, Ctx, OS);
113
42.3k
  }
114
115
15.1k
  static StringRef input(StringRef Scalar, void *Ctx, UnsignedValue &Value) {
116
15.1k
    if (const auto *Node =
117
15.1k
            reinterpret_cast<yaml::Input *>(Ctx)->getCurrentNode())
118
15.1k
      Value.SourceRange = Node->getSourceRange();
119
15.1k
    return ScalarTraits<unsigned>::input(Scalar, Ctx, Value.Value);
120
15.1k
  }
121
122
57.5k
  static QuotingType mustQuote(StringRef Scalar) {
123
57.5k
    return ScalarTraits<unsigned>::mustQuote(Scalar);
124
57.5k
  }
125
};
126
127
template <> struct ScalarEnumerationTraits<MachineJumpTableInfo::JTEntryKind> {
128
  static void enumeration(yaml::IO &IO,
129
24
                          MachineJumpTableInfo::JTEntryKind &EntryKind) {
130
24
    IO.enumCase(EntryKind, "block-address",
131
24
                MachineJumpTableInfo::EK_BlockAddress);
132
24
    IO.enumCase(EntryKind, "gp-rel64-block-address",
133
24
                MachineJumpTableInfo::EK_GPRel64BlockAddress);
134
24
    IO.enumCase(EntryKind, "gp-rel32-block-address",
135
24
                MachineJumpTableInfo::EK_GPRel32BlockAddress);
136
24
    IO.enumCase(EntryKind, "label-difference32",
137
24
                MachineJumpTableInfo::EK_LabelDifference32);
138
24
    IO.enumCase(EntryKind, "inline", MachineJumpTableInfo::EK_Inline);
139
24
    IO.enumCase(EntryKind, "custom32", MachineJumpTableInfo::EK_Custom32);
140
24
  }
141
};
142
143
} // end namespace yaml
144
} // end namespace llvm
145
146
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::StringValue)
147
LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(llvm::yaml::FlowStringValue)
148
LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(llvm::yaml::UnsignedValue)
149
150
namespace llvm {
151
namespace yaml {
152
153
0
struct VirtualRegisterDefinition {
154
  UnsignedValue ID;
155
  StringValue Class;
156
  StringValue PreferredRegister;
157
158
  // TODO: Serialize the target specific register hints.
159
160
0
  bool operator==(const VirtualRegisterDefinition &Other) const {
161
0
    return ID == Other.ID && Class == Other.Class &&
162
0
           PreferredRegister == Other.PreferredRegister;
163
0
  }
164
};
165
166
template <> struct MappingTraits<VirtualRegisterDefinition> {
167
55.5k
  static void mapping(IO &YamlIO, VirtualRegisterDefinition &Reg) {
168
55.5k
    YamlIO.mapRequired("id", Reg.ID);
169
55.5k
    YamlIO.mapRequired("class", Reg.Class);
170
55.5k
    YamlIO.mapOptional("preferred-register", Reg.PreferredRegister,
171
55.5k
                       StringValue()); // Don't print out when it's empty.
172
55.5k
  }
173
174
  static const bool flow = true;
175
};
176
177
0
struct MachineFunctionLiveIn {
178
  StringValue Register;
179
  StringValue VirtualRegister;
180
181
0
  bool operator==(const MachineFunctionLiveIn &Other) const {
182
0
    return Register == Other.Register &&
183
0
           VirtualRegister == Other.VirtualRegister;
184
0
  }
185
};
186
187
template <> struct MappingTraits<MachineFunctionLiveIn> {
188
3.68k
  static void mapping(IO &YamlIO, MachineFunctionLiveIn &LiveIn) {
189
3.68k
    YamlIO.mapRequired("reg", LiveIn.Register);
190
3.68k
    YamlIO.mapOptional(
191
3.68k
        "virtual-reg", LiveIn.VirtualRegister,
192
3.68k
        StringValue()); // Don't print the virtual register when it's empty.
193
3.68k
  }
194
195
  static const bool flow = true;
196
};
197
198
/// Serializable representation of stack object from the MachineFrameInfo class.
199
///
200
/// The flags 'isImmutable' and 'isAliased' aren't serialized, as they are
201
/// determined by the object's type and frame information flags.
202
/// Dead stack objects aren't serialized.
203
///
204
/// The 'isPreallocated' flag is determined by the local offset.
205
0
struct MachineStackObject {
206
  enum ObjectType { DefaultType, SpillSlot, VariableSized };
207
  UnsignedValue ID;
208
  StringValue Name;
209
  // TODO: Serialize unnamed LLVM alloca reference.
210
  ObjectType Type = DefaultType;
211
  int64_t Offset = 0;
212
  uint64_t Size = 0;
213
  unsigned Alignment = 0;
214
  uint8_t StackID = 0;
215
  StringValue CalleeSavedRegister;
216
  bool CalleeSavedRestored = true;
217
  Optional<int64_t> LocalOffset;
218
  StringValue DebugVar;
219
  StringValue DebugExpr;
220
  StringValue DebugLoc;
221
222
0
  bool operator==(const MachineStackObject &Other) const {
223
0
    return ID == Other.ID && Name == Other.Name && Type == Other.Type &&
224
0
           Offset == Other.Offset && Size == Other.Size &&
225
0
           Alignment == Other.Alignment &&
226
0
           StackID == Other.StackID &&
227
0
           CalleeSavedRegister == Other.CalleeSavedRegister &&
228
0
           CalleeSavedRestored == Other.CalleeSavedRestored &&
229
0
           LocalOffset == Other.LocalOffset && DebugVar == Other.DebugVar &&
230
0
           DebugExpr == Other.DebugExpr && DebugLoc == Other.DebugLoc;
231
0
  }
232
};
233
234
template <> struct ScalarEnumerationTraits<MachineStackObject::ObjectType> {
235
1.09k
  static void enumeration(yaml::IO &IO, MachineStackObject::ObjectType &Type) {
236
1.09k
    IO.enumCase(Type, "default", MachineStackObject::DefaultType);
237
1.09k
    IO.enumCase(Type, "spill-slot", MachineStackObject::SpillSlot);
238
1.09k
    IO.enumCase(Type, "variable-sized", MachineStackObject::VariableSized);
239
1.09k
  }
240
};
241
242
template <> struct MappingTraits<MachineStackObject> {
243
1.20k
  static void mapping(yaml::IO &YamlIO, MachineStackObject &Object) {
244
1.20k
    YamlIO.mapRequired("id", Object.ID);
245
1.20k
    YamlIO.mapOptional("name", Object.Name,
246
1.20k
                       StringValue()); // Don't print out an empty name.
247
1.20k
    YamlIO.mapOptional(
248
1.20k
        "type", Object.Type,
249
1.20k
        MachineStackObject::DefaultType); // Don't print the default type.
250
1.20k
    YamlIO.mapOptional("offset", Object.Offset, (int64_t)0);
251
1.20k
    if (Object.Type != MachineStackObject::VariableSized)
252
1.18k
      YamlIO.mapRequired("size", Object.Size);
253
1.20k
    YamlIO.mapOptional("alignment", Object.Alignment, (unsigned)0);
254
1.20k
    YamlIO.mapOptional("stack-id", Object.StackID);
255
1.20k
    YamlIO.mapOptional("callee-saved-register", Object.CalleeSavedRegister,
256
1.20k
                       StringValue()); // Don't print it out when it's empty.
257
1.20k
    YamlIO.mapOptional("callee-saved-restored", Object.CalleeSavedRestored,
258
1.20k
                       true);
259
1.20k
    YamlIO.mapOptional("local-offset", Object.LocalOffset, Optional<int64_t>());
260
1.20k
    YamlIO.mapOptional("debug-info-variable", Object.DebugVar,
261
1.20k
                       StringValue()); // Don't print it out when it's empty.
262
1.20k
    YamlIO.mapOptional("debug-info-expression", Object.DebugExpr,
263
1.20k
                       StringValue()); // Don't print it out when it's empty.
264
1.20k
    YamlIO.mapOptional("debug-info-location", Object.DebugLoc,
265
1.20k
                       StringValue()); // Don't print it out when it's empty.
266
1.20k
  }
267
268
  static const bool flow = true;
269
};
270
271
/// Serializable representation of the fixed stack object from the
272
/// MachineFrameInfo class.
273
0
struct FixedMachineStackObject {
274
  enum ObjectType { DefaultType, SpillSlot };
275
  UnsignedValue ID;
276
  ObjectType Type = DefaultType;
277
  int64_t Offset = 0;
278
  uint64_t Size = 0;
279
  unsigned Alignment = 0;
280
  uint8_t StackID = 0;
281
  bool IsImmutable = false;
282
  bool IsAliased = false;
283
  StringValue CalleeSavedRegister;
284
  bool CalleeSavedRestored = true;
285
  StringValue DebugVar;
286
  StringValue DebugExpr;
287
  StringValue DebugLoc;
288
289
0
  bool operator==(const FixedMachineStackObject &Other) const {
290
0
    return ID == Other.ID && Type == Other.Type && Offset == Other.Offset &&
291
0
           Size == Other.Size && Alignment == Other.Alignment &&
292
0
           StackID == Other.StackID &&
293
0
           IsImmutable == Other.IsImmutable && IsAliased == Other.IsAliased &&
294
0
           CalleeSavedRegister == Other.CalleeSavedRegister &&
295
0
           CalleeSavedRestored == Other.CalleeSavedRestored &&
296
0
           DebugVar == Other.DebugVar && DebugExpr == Other.DebugExpr
297
0
           && DebugLoc == Other.DebugLoc;
298
0
  }
299
};
300
301
template <>
302
struct ScalarEnumerationTraits<FixedMachineStackObject::ObjectType> {
303
  static void enumeration(yaml::IO &IO,
304
560
                          FixedMachineStackObject::ObjectType &Type) {
305
560
    IO.enumCase(Type, "default", FixedMachineStackObject::DefaultType);
306
560
    IO.enumCase(Type, "spill-slot", FixedMachineStackObject::SpillSlot);
307
560
  }
308
};
309
310
template <> struct MappingTraits<FixedMachineStackObject> {
311
626
  static void mapping(yaml::IO &YamlIO, FixedMachineStackObject &Object) {
312
626
    YamlIO.mapRequired("id", Object.ID);
313
626
    YamlIO.mapOptional(
314
626
        "type", Object.Type,
315
626
        FixedMachineStackObject::DefaultType); // Don't print the default type.
316
626
    YamlIO.mapOptional("offset", Object.Offset, (int64_t)0);
317
626
    YamlIO.mapOptional("size", Object.Size, (uint64_t)0);
318
626
    YamlIO.mapOptional("alignment", Object.Alignment, (unsigned)0);
319
626
    YamlIO.mapOptional("stack-id", Object.StackID);
320
626
    if (Object.Type != FixedMachineStackObject::SpillSlot) {
321
482
      YamlIO.mapOptional("isImmutable", Object.IsImmutable, false);
322
482
      YamlIO.mapOptional("isAliased", Object.IsAliased, false);
323
482
    }
324
626
    YamlIO.mapOptional("callee-saved-register", Object.CalleeSavedRegister,
325
626
                       StringValue()); // Don't print it out when it's empty.
326
626
    YamlIO.mapOptional("callee-saved-restored", Object.CalleeSavedRestored,
327
626
                     true);
328
626
    YamlIO.mapOptional("debug-info-variable", Object.DebugVar,
329
626
                       StringValue()); // Don't print it out when it's empty.
330
626
    YamlIO.mapOptional("debug-info-expression", Object.DebugExpr,
331
626
                       StringValue()); // Don't print it out when it's empty.
332
626
    YamlIO.mapOptional("debug-info-location", Object.DebugLoc,
333
626
                       StringValue()); // Don't print it out when it's empty.
334
626
  }
335
336
  static const bool flow = true;
337
};
338
339
0
struct MachineConstantPoolValue {
340
  UnsignedValue ID;
341
  StringValue Value;
342
  unsigned Alignment = 0;
343
  bool IsTargetSpecific = false;
344
345
0
  bool operator==(const MachineConstantPoolValue &Other) const {
346
0
    return ID == Other.ID && Value == Other.Value &&
347
0
           Alignment == Other.Alignment &&
348
0
           IsTargetSpecific == Other.IsTargetSpecific;
349
0
  }
350
};
351
352
template <> struct MappingTraits<MachineConstantPoolValue> {
353
89
  static void mapping(IO &YamlIO, MachineConstantPoolValue &Constant) {
354
89
    YamlIO.mapRequired("id", Constant.ID);
355
89
    YamlIO.mapOptional("value", Constant.Value, StringValue());
356
89
    YamlIO.mapOptional("alignment", Constant.Alignment, (unsigned)0);
357
89
    YamlIO.mapOptional("isTargetSpecific", Constant.IsTargetSpecific, false);
358
89
  }
359
};
360
361
0
struct MachineJumpTable {
362
0
  struct Entry {
363
    UnsignedValue ID;
364
    std::vector<FlowStringValue> Blocks;
365
366
0
    bool operator==(const Entry &Other) const {
367
0
      return ID == Other.ID && Blocks == Other.Blocks;
368
0
    }
369
  };
370
371
  MachineJumpTableInfo::JTEntryKind Kind = MachineJumpTableInfo::EK_Custom32;
372
  std::vector<Entry> Entries;
373
374
11
  bool operator==(const MachineJumpTable &Other) const {
375
11
    return Kind == Other.Kind && 
Entries == Other.Entries0
;
376
11
  }
377
};
378
379
template <> struct MappingTraits<MachineJumpTable::Entry> {
380
34
  static void mapping(IO &YamlIO, MachineJumpTable::Entry &Entry) {
381
34
    YamlIO.mapRequired("id", Entry.ID);
382
34
    YamlIO.mapOptional("blocks", Entry.Blocks, std::vector<FlowStringValue>());
383
34
  }
384
};
385
386
} // end namespace yaml
387
} // end namespace llvm
388
389
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::MachineFunctionLiveIn)
390
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::VirtualRegisterDefinition)
391
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::MachineStackObject)
392
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::FixedMachineStackObject)
393
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::MachineConstantPoolValue)
394
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::MachineJumpTable::Entry)
395
396
namespace llvm {
397
namespace yaml {
398
399
template <> struct MappingTraits<MachineJumpTable> {
400
24
  static void mapping(IO &YamlIO, MachineJumpTable &JT) {
401
24
    YamlIO.mapRequired("kind", JT.Kind);
402
24
    YamlIO.mapOptional("entries", JT.Entries,
403
24
                       std::vector<MachineJumpTable::Entry>());
404
24
  }
405
};
406
407
/// Serializable representation of MachineFrameInfo.
408
///
409
/// Doesn't serialize attributes like 'StackAlignment', 'IsStackRealignable' and
410
/// 'RealignOption' as they are determined by the target and LLVM function
411
/// attributes.
412
/// It also doesn't serialize attributes like 'NumFixedObject' and
413
/// 'HasVarSizedObjects' as they are determined by the frame objects themselves.
414
0
struct MachineFrameInfo {
415
  bool IsFrameAddressTaken = false;
416
  bool IsReturnAddressTaken = false;
417
  bool HasStackMap = false;
418
  bool HasPatchPoint = false;
419
  uint64_t StackSize = 0;
420
  int OffsetAdjustment = 0;
421
  unsigned MaxAlignment = 0;
422
  bool AdjustsStack = false;
423
  bool HasCalls = false;
424
  StringValue StackProtector;
425
  // TODO: Serialize FunctionContextIdx
426
  unsigned MaxCallFrameSize = ~0u; ///< ~0u means: not computed yet.
427
  unsigned CVBytesOfCalleeSavedRegisters = 0;
428
  bool HasOpaqueSPAdjustment = false;
429
  bool HasVAStart = false;
430
  bool HasMustTailInVarArgFunc = false;
431
  unsigned LocalFrameSize = 0;
432
  StringValue SavePoint;
433
  StringValue RestorePoint;
434
435
7.25k
  bool operator==(const MachineFrameInfo &Other) const {
436
7.25k
    return IsFrameAddressTaken == Other.IsFrameAddressTaken &&
437
7.25k
           
IsReturnAddressTaken == Other.IsReturnAddressTaken7.25k
&&
438
7.25k
           
HasStackMap == Other.HasStackMap7.25k
&&
439
7.25k
           
HasPatchPoint == Other.HasPatchPoint7.25k
&&
440
7.25k
           
StackSize == Other.StackSize7.24k
&&
441
7.25k
           
OffsetAdjustment == Other.OffsetAdjustment7.12k
&&
442
7.25k
           
MaxAlignment == Other.MaxAlignment7.12k
&&
443
7.25k
           
AdjustsStack == Other.AdjustsStack6.63k
&&
HasCalls == Other.HasCalls6.63k
&&
444
7.25k
           
StackProtector == Other.StackProtector6.34k
&&
445
7.25k
           
MaxCallFrameSize == Other.MaxCallFrameSize6.34k
&&
446
7.25k
           CVBytesOfCalleeSavedRegisters ==
447
5.04k
               Other.CVBytesOfCalleeSavedRegisters &&
448
7.25k
           
HasOpaqueSPAdjustment == Other.HasOpaqueSPAdjustment5.04k
&&
449
7.25k
           
HasVAStart == Other.HasVAStart5.04k
&&
450
7.25k
           
HasMustTailInVarArgFunc == Other.HasMustTailInVarArgFunc5.04k
&&
451
7.25k
           
LocalFrameSize == Other.LocalFrameSize5.04k
&&
452
7.25k
           
SavePoint == Other.SavePoint5.04k
&&
RestorePoint == Other.RestorePoint5.04k
;
453
7.25k
  }
454
};
455
456
template <> struct MappingTraits<MachineFrameInfo> {
457
8.06k
  static void mapping(IO &YamlIO, MachineFrameInfo &MFI) {
458
8.06k
    YamlIO.mapOptional("isFrameAddressTaken", MFI.IsFrameAddressTaken, false);
459
8.06k
    YamlIO.mapOptional("isReturnAddressTaken", MFI.IsReturnAddressTaken, false);
460
8.06k
    YamlIO.mapOptional("hasStackMap", MFI.HasStackMap, false);
461
8.06k
    YamlIO.mapOptional("hasPatchPoint", MFI.HasPatchPoint, false);
462
8.06k
    YamlIO.mapOptional("stackSize", MFI.StackSize, (uint64_t)0);
463
8.06k
    YamlIO.mapOptional("offsetAdjustment", MFI.OffsetAdjustment, (int)0);
464
8.06k
    YamlIO.mapOptional("maxAlignment", MFI.MaxAlignment, (unsigned)0);
465
8.06k
    YamlIO.mapOptional("adjustsStack", MFI.AdjustsStack, false);
466
8.06k
    YamlIO.mapOptional("hasCalls", MFI.HasCalls, false);
467
8.06k
    YamlIO.mapOptional("stackProtector", MFI.StackProtector,
468
8.06k
                       StringValue()); // Don't print it out when it's empty.
469
8.06k
    YamlIO.mapOptional("maxCallFrameSize", MFI.MaxCallFrameSize, (unsigned)~0);
470
8.06k
    YamlIO.mapOptional("cvBytesOfCalleeSavedRegisters",
471
8.06k
                       MFI.CVBytesOfCalleeSavedRegisters, 0U);
472
8.06k
    YamlIO.mapOptional("hasOpaqueSPAdjustment", MFI.HasOpaqueSPAdjustment,
473
8.06k
                       false);
474
8.06k
    YamlIO.mapOptional("hasVAStart", MFI.HasVAStart, false);
475
8.06k
    YamlIO.mapOptional("hasMustTailInVarArgFunc", MFI.HasMustTailInVarArgFunc,
476
8.06k
                       false);
477
8.06k
    YamlIO.mapOptional("localFrameSize", MFI.LocalFrameSize, (unsigned)0);
478
8.06k
    YamlIO.mapOptional("savePoint", MFI.SavePoint,
479
8.06k
                       StringValue()); // Don't print it out when it's empty.
480
8.06k
    YamlIO.mapOptional("restorePoint", MFI.RestorePoint,
481
8.06k
                       StringValue()); // Don't print it out when it's empty.
482
8.06k
  }
483
};
484
485
struct MachineFunction {
486
  StringRef Name;
487
  unsigned Alignment = 0;
488
  bool ExposesReturnsTwice = false;
489
  // GISel MachineFunctionProperties.
490
  bool Legalized = false;
491
  bool RegBankSelected = false;
492
  bool Selected = false;
493
  bool FailedISel = false;
494
  // Register information
495
  bool TracksRegLiveness = false;
496
  bool HasWinCFI = false;
497
  std::vector<VirtualRegisterDefinition> VirtualRegisters;
498
  std::vector<MachineFunctionLiveIn> LiveIns;
499
  Optional<std::vector<FlowStringValue>> CalleeSavedRegisters;
500
  // TODO: Serialize the various register masks.
501
  // Frame information
502
  MachineFrameInfo FrameInfo;
503
  std::vector<FixedMachineStackObject> FixedStackObjects;
504
  std::vector<MachineStackObject> StackObjects;
505
  std::vector<MachineConstantPoolValue> Constants; /// Constant pool.
506
  MachineJumpTable JumpTableInfo;
507
  BlockStringValue Body;
508
};
509
510
template <> struct MappingTraits<MachineFunction> {
511
14.1k
  static void mapping(IO &YamlIO, MachineFunction &MF) {
512
14.1k
    YamlIO.mapRequired("name", MF.Name);
513
14.1k
    YamlIO.mapOptional("alignment", MF.Alignment, (unsigned)0);
514
14.1k
    YamlIO.mapOptional("exposesReturnsTwice", MF.ExposesReturnsTwice, false);
515
14.1k
    YamlIO.mapOptional("legalized", MF.Legalized, false);
516
14.1k
    YamlIO.mapOptional("regBankSelected", MF.RegBankSelected, false);
517
14.1k
    YamlIO.mapOptional("selected", MF.Selected, false);
518
14.1k
    YamlIO.mapOptional("failedISel", MF.FailedISel, false);
519
14.1k
    YamlIO.mapOptional("tracksRegLiveness", MF.TracksRegLiveness, false);
520
14.1k
    YamlIO.mapOptional("hasWinCFI", MF.HasWinCFI, false);
521
14.1k
    YamlIO.mapOptional("registers", MF.VirtualRegisters,
522
14.1k
                       std::vector<VirtualRegisterDefinition>());
523
14.1k
    YamlIO.mapOptional("liveins", MF.LiveIns,
524
14.1k
                       std::vector<MachineFunctionLiveIn>());
525
14.1k
    YamlIO.mapOptional("calleeSavedRegisters", MF.CalleeSavedRegisters,
526
14.1k
                       Optional<std::vector<FlowStringValue>>());
527
14.1k
    YamlIO.mapOptional("frameInfo", MF.FrameInfo, MachineFrameInfo());
528
14.1k
    YamlIO.mapOptional("fixedStack", MF.FixedStackObjects,
529
14.1k
                       std::vector<FixedMachineStackObject>());
530
14.1k
    YamlIO.mapOptional("stack", MF.StackObjects,
531
14.1k
                       std::vector<MachineStackObject>());
532
14.1k
    YamlIO.mapOptional("constants", MF.Constants,
533
14.1k
                       std::vector<MachineConstantPoolValue>());
534
14.1k
    if (!YamlIO.outputting() || 
!MF.JumpTableInfo.Entries.empty()7.25k
)
535
6.92k
      YamlIO.mapOptional("jumpTable", MF.JumpTableInfo, MachineJumpTable());
536
14.1k
    YamlIO.mapOptional("body", MF.Body, BlockStringValue());
537
14.1k
  }
538
};
539
540
} // end namespace yaml
541
} // end namespace llvm
542
543
#endif // LLVM_CODEGEN_MIRYAMLMAPPING_H