Coverage Report

Created: 2018-11-16 02:38

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