Coverage Report

Created: 2017-10-03 07:32

/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/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
struct StringValue {
35
  std::string Value;
36
  SMRange SourceRange;
37
38
112k
  StringValue() = default;
39
11.5k
  StringValue(std::string Value) : Value(std::move(Value)) {}
40
41
29.3k
  bool operator==(const StringValue &Other) const {
42
29.3k
    return Value == Other.Value;
43
29.3k
  }
44
};
45
46
template <> struct ScalarTraits<StringValue> {
47
35.6k
  static void output(const StringValue &S, void *, raw_ostream &OS) {
48
35.6k
    OS << S.Value;
49
35.6k
  }
50
51
12.3k
  static StringRef input(StringRef Scalar, void *Ctx, StringValue &S) {
52
12.3k
    S.Value = Scalar.str();
53
12.3k
    if (const auto *Node =
54
12.3k
            reinterpret_cast<yaml::Input *>(Ctx)->getCurrentNode())
55
12.3k
      S.SourceRange = Node->getSourceRange();
56
12.3k
    return "";
57
12.3k
  }
58
59
41.8k
  static bool mustQuote(StringRef Scalar) { return needsQuotes(Scalar); }
60
};
61
62
struct FlowStringValue : StringValue {
63
1.23k
  FlowStringValue() = default;
64
73
  FlowStringValue(std::string Value) : StringValue(std::move(Value)) {}
65
};
66
67
template <> struct ScalarTraits<FlowStringValue> {
68
486
  static void output(const FlowStringValue &S, void *, raw_ostream &OS) {
69
486
    return ScalarTraits<StringValue>::output(S, nullptr, OS);
70
486
  }
71
72
822
  static StringRef input(StringRef Scalar, void *Ctx, FlowStringValue &S) {
73
822
    return ScalarTraits<StringValue>::input(Scalar, Ctx, S);
74
822
  }
75
76
1.30k
  static bool mustQuote(StringRef Scalar) { return needsQuotes(Scalar); }
77
};
78
79
struct BlockStringValue {
80
  StringValue Value;
81
82
2.51k
  bool operator==(const BlockStringValue &Other) const {
83
2.51k
    return Value == Other.Value;
84
2.51k
  }
85
};
86
87
template <> struct BlockScalarTraits<BlockStringValue> {
88
2.51k
  static void output(const BlockStringValue &S, void *Ctx, raw_ostream &OS) {
89
2.51k
    return ScalarTraits<StringValue>::output(S.Value, Ctx, OS);
90
2.51k
  }
91
92
2.31k
  static StringRef input(StringRef Scalar, void *Ctx, BlockStringValue &S) {
93
2.31k
    return ScalarTraits<StringValue>::input(Scalar, Ctx, S.Value);
94
2.31k
  }
95
};
96
97
/// A wrapper around unsigned which contains a source range that's being set
98
/// during parsing.
99
struct UnsignedValue {
100
  unsigned Value = 0;
101
  SMRange SourceRange;
102
103
19.4k
  UnsignedValue() = default;
104
11.8k
  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
11.8k
  static void output(const UnsignedValue &Value, void *Ctx, raw_ostream &OS) {
113
11.8k
    return ScalarTraits<unsigned>::output(Value.Value, Ctx, OS);
114
11.8k
  }
115
116
7.59k
  static StringRef input(StringRef Scalar, void *Ctx, UnsignedValue &Value) {
117
7.59k
    if (const auto *Node =
118
7.59k
            reinterpret_cast<yaml::Input *>(Ctx)->getCurrentNode())
119
7.59k
      Value.SourceRange = Node->getSourceRange();
120
7.59k
    return ScalarTraits<unsigned>::input(Scalar, Ctx, Value.Value);
121
7.59k
  }
122
123
19.4k
  static bool mustQuote(StringRef Scalar) {
124
19.4k
    return ScalarTraits<unsigned>::mustQuote(Scalar);
125
19.4k
  }
126
};
127
128
template <> struct ScalarEnumerationTraits<MachineJumpTableInfo::JTEntryKind> {
129
  static void enumeration(yaml::IO &IO,
130
17
                          MachineJumpTableInfo::JTEntryKind &EntryKind) {
131
17
    IO.enumCase(EntryKind, "block-address",
132
17
                MachineJumpTableInfo::EK_BlockAddress);
133
17
    IO.enumCase(EntryKind, "gp-rel64-block-address",
134
17
                MachineJumpTableInfo::EK_GPRel64BlockAddress);
135
17
    IO.enumCase(EntryKind, "gp-rel32-block-address",
136
17
                MachineJumpTableInfo::EK_GPRel32BlockAddress);
137
17
    IO.enumCase(EntryKind, "label-difference32",
138
17
                MachineJumpTableInfo::EK_LabelDifference32);
139
17
    IO.enumCase(EntryKind, "inline", MachineJumpTableInfo::EK_Inline);
140
17
    IO.enumCase(EntryKind, "custom32", MachineJumpTableInfo::EK_Custom32);
141
17
  }
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
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
18.6k
  static void mapping(IO &YamlIO, VirtualRegisterDefinition &Reg) {
169
18.6k
    YamlIO.mapRequired("id", Reg.ID);
170
18.6k
    YamlIO.mapRequired("class", Reg.Class);
171
18.6k
    YamlIO.mapOptional("preferred-register", Reg.PreferredRegister,
172
18.6k
                       StringValue()); // Don't print out when it's empty.
173
18.6k
  }
174
175
  static const bool flow = true;
176
};
177
178
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
1.06k
  static void mapping(IO &YamlIO, MachineFunctionLiveIn &LiveIn) {
190
1.06k
    YamlIO.mapRequired("reg", LiveIn.Register);
191
1.06k
    YamlIO.mapOptional(
192
1.06k
        "virtual-reg", LiveIn.VirtualRegister,
193
1.06k
        StringValue()); // Don't print the virtual register when it's empty.
194
1.06k
  }
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
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.Name0
&&
Type == Other.Type0
&&
225
0
           
Offset == Other.Offset0
&&
Size == Other.Size0
&&
226
0
           Alignment == Other.Alignment &&
227
0
           StackID == Other.StackID &&
228
0
           CalleeSavedRegister == Other.CalleeSavedRegister &&
229
0
           CalleeSavedRestored == Other.CalleeSavedRestored &&
230
0
           
LocalOffset == Other.LocalOffset0
&&
DebugVar == Other.DebugVar0
&&
231
0
           
DebugExpr == Other.DebugExpr0
&&
DebugLoc == Other.DebugLoc0
;
232
0
  }
233
};
234
235
template <> struct ScalarEnumerationTraits<MachineStackObject::ObjectType> {
236
289
  static void enumeration(yaml::IO &IO, MachineStackObject::ObjectType &Type) {
237
289
    IO.enumCase(Type, "default", MachineStackObject::DefaultType);
238
289
    IO.enumCase(Type, "spill-slot", MachineStackObject::SpillSlot);
239
289
    IO.enumCase(Type, "variable-sized", MachineStackObject::VariableSized);
240
289
  }
241
};
242
243
template <> struct MappingTraits<MachineStackObject> {
244
366
  static void mapping(yaml::IO &YamlIO, MachineStackObject &Object) {
245
366
    YamlIO.mapRequired("id", Object.ID);
246
366
    YamlIO.mapOptional("name", Object.Name,
247
366
                       StringValue()); // Don't print out an empty name.
248
366
    YamlIO.mapOptional(
249
366
        "type", Object.Type,
250
366
        MachineStackObject::DefaultType); // Don't print the default type.
251
366
    YamlIO.mapOptional("offset", Object.Offset, (int64_t)0);
252
366
    if (Object.Type != MachineStackObject::VariableSized)
253
355
      YamlIO.mapRequired("size", Object.Size);
254
366
    YamlIO.mapOptional("alignment", Object.Alignment, (unsigned)0);
255
366
    YamlIO.mapOptional("stack-id", Object.StackID);
256
366
    YamlIO.mapOptional("callee-saved-register", Object.CalleeSavedRegister,
257
366
                       StringValue()); // Don't print it out when it's empty.
258
366
    YamlIO.mapOptional("callee-saved-restored", Object.CalleeSavedRestored,
259
366
                       true);
260
366
    YamlIO.mapOptional("local-offset", Object.LocalOffset, Optional<int64_t>());
261
366
    YamlIO.mapOptional("di-variable", Object.DebugVar,
262
366
                       StringValue()); // Don't print it out when it's empty.
263
366
    YamlIO.mapOptional("di-expression", Object.DebugExpr,
264
366
                       StringValue()); // Don't print it out when it's empty.
265
366
    YamlIO.mapOptional("di-location", Object.DebugLoc,
266
366
                       StringValue()); // Don't print it out when it's empty.
267
366
  }
268
269
  static const bool flow = true;
270
};
271
272
/// Serializable representation of the fixed stack object from the
273
/// MachineFrameInfo class.
274
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
287
0
  bool operator==(const FixedMachineStackObject &Other) const {
288
0
    return ID == Other.ID && 
Type == Other.Type0
&&
Offset == Other.Offset0
&&
289
0
           
Size == Other.Size0
&&
Alignment == Other.Alignment0
&&
290
0
           StackID == Other.StackID &&
291
0
           
IsImmutable == Other.IsImmutable0
&&
IsAliased == Other.IsAliased0
&&
292
0
           CalleeSavedRegister == Other.CalleeSavedRegister &&
293
0
           CalleeSavedRestored == Other.CalleeSavedRestored;
294
0
  }
295
};
296
297
template <>
298
struct ScalarEnumerationTraits<FixedMachineStackObject::ObjectType> {
299
  static void enumeration(yaml::IO &IO,
300
349
                          FixedMachineStackObject::ObjectType &Type) {
301
349
    IO.enumCase(Type, "default", FixedMachineStackObject::DefaultType);
302
349
    IO.enumCase(Type, "spill-slot", FixedMachineStackObject::SpillSlot);
303
349
  }
304
};
305
306
template <> struct MappingTraits<FixedMachineStackObject> {
307
384
  static void mapping(yaml::IO &YamlIO, FixedMachineStackObject &Object) {
308
384
    YamlIO.mapRequired("id", Object.ID);
309
384
    YamlIO.mapOptional(
310
384
        "type", Object.Type,
311
384
        FixedMachineStackObject::DefaultType); // Don't print the default type.
312
384
    YamlIO.mapOptional("offset", Object.Offset, (int64_t)0);
313
384
    YamlIO.mapOptional("size", Object.Size, (uint64_t)0);
314
384
    YamlIO.mapOptional("alignment", Object.Alignment, (unsigned)0);
315
384
    YamlIO.mapOptional("stack-id", Object.StackID);
316
384
    if (
Object.Type != FixedMachineStackObject::SpillSlot384
) {
317
289
      YamlIO.mapOptional("isImmutable", Object.IsImmutable, false);
318
289
      YamlIO.mapOptional("isAliased", Object.IsAliased, false);
319
289
    }
320
384
    YamlIO.mapOptional("callee-saved-register", Object.CalleeSavedRegister,
321
384
                       StringValue()); // Don't print it out when it's empty.
322
384
    YamlIO.mapOptional("callee-saved-restored", Object.CalleeSavedRestored,
323
384
                     true);
324
384
  }
325
326
  static const bool flow = true;
327
};
328
329
struct MachineConstantPoolValue {
330
  UnsignedValue ID;
331
  StringValue Value;
332
  unsigned Alignment = 0;
333
  bool IsTargetSpecific = false;
334
335
0
  bool operator==(const MachineConstantPoolValue &Other) const {
336
0
    return ID == Other.ID && Value == Other.Value &&
337
0
           Alignment == Other.Alignment &&
338
0
           IsTargetSpecific == Other.IsTargetSpecific;
339
0
  }
340
};
341
342
template <> struct MappingTraits<MachineConstantPoolValue> {
343
56
  static void mapping(IO &YamlIO, MachineConstantPoolValue &Constant) {
344
56
    YamlIO.mapRequired("id", Constant.ID);
345
56
    YamlIO.mapOptional("value", Constant.Value, StringValue());
346
56
    YamlIO.mapOptional("alignment", Constant.Alignment, (unsigned)0);
347
56
    YamlIO.mapOptional("isTargetSpecific", Constant.IsTargetSpecific, false);
348
56
  }
349
};
350
351
struct MachineJumpTable {
352
  struct Entry {
353
    UnsignedValue ID;
354
    std::vector<FlowStringValue> Blocks;
355
356
0
    bool operator==(const Entry &Other) const {
357
0
      return ID == Other.ID && Blocks == Other.Blocks;
358
0
    }
359
  };
360
361
  MachineJumpTableInfo::JTEntryKind Kind = MachineJumpTableInfo::EK_Custom32;
362
  std::vector<Entry> Entries;
363
364
7
  bool operator==(const MachineJumpTable &Other) const {
365
0
    return Kind == Other.Kind && Entries == Other.Entries;
366
7
  }
367
};
368
369
template <> struct MappingTraits<MachineJumpTable::Entry> {
370
17
  static void mapping(IO &YamlIO, MachineJumpTable::Entry &Entry) {
371
17
    YamlIO.mapRequired("id", Entry.ID);
372
17
    YamlIO.mapOptional("blocks", Entry.Blocks, std::vector<FlowStringValue>());
373
17
  }
374
};
375
376
} // end namespace yaml
377
} // end namespace llvm
378
379
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::MachineFunctionLiveIn)
380
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::VirtualRegisterDefinition)
381
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::MachineStackObject)
382
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::FixedMachineStackObject)
383
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::MachineConstantPoolValue)
384
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::MachineJumpTable::Entry)
385
386
namespace llvm {
387
namespace yaml {
388
389
template <> struct MappingTraits<MachineJumpTable> {
390
17
  static void mapping(IO &YamlIO, MachineJumpTable &JT) {
391
17
    YamlIO.mapRequired("kind", JT.Kind);
392
17
    YamlIO.mapOptional("entries", JT.Entries,
393
17
                       std::vector<MachineJumpTable::Entry>());
394
17
  }
395
};
396
397
/// Serializable representation of MachineFrameInfo.
398
///
399
/// Doesn't serialize attributes like 'StackAlignment', 'IsStackRealignable' and
400
/// 'RealignOption' as they are determined by the target and LLVM function
401
/// attributes.
402
/// It also doesn't serialize attributes like 'NumFixedObject' and
403
/// 'HasVarSizedObjects' as they are determined by the frame objects themselves.
404
struct MachineFrameInfo {
405
  bool IsFrameAddressTaken = false;
406
  bool IsReturnAddressTaken = false;
407
  bool HasStackMap = false;
408
  bool HasPatchPoint = false;
409
  uint64_t StackSize = 0;
410
  int OffsetAdjustment = 0;
411
  unsigned MaxAlignment = 0;
412
  bool AdjustsStack = false;
413
  bool HasCalls = false;
414
  StringValue StackProtector;
415
  // TODO: Serialize FunctionContextIdx
416
  unsigned MaxCallFrameSize = ~0u; ///< ~0u means: not computed yet.
417
  bool HasOpaqueSPAdjustment = false;
418
  bool HasVAStart = false;
419
  bool HasMustTailInVarArgFunc = false;
420
  StringValue SavePoint;
421
  StringValue RestorePoint;
422
423
2.51k
  bool operator==(const MachineFrameInfo &Other) const {
424
2.51k
    return IsFrameAddressTaken == Other.IsFrameAddressTaken &&
425
2.51k
           IsReturnAddressTaken == Other.IsReturnAddressTaken &&
426
2.51k
           HasStackMap == Other.HasStackMap &&
427
2.50k
           HasPatchPoint == Other.HasPatchPoint &&
428
2.50k
           StackSize == Other.StackSize &&
429
2.46k
           OffsetAdjustment == Other.OffsetAdjustment &&
430
2.46k
           MaxAlignment == Other.MaxAlignment &&
431
2.51k
           
AdjustsStack == Other.AdjustsStack2.30k
&&
HasCalls == Other.HasCalls2.30k
&&
432
2.16k
           StackProtector == Other.StackProtector &&
433
2.16k
           MaxCallFrameSize == Other.MaxCallFrameSize &&
434
1.92k
           HasOpaqueSPAdjustment == Other.HasOpaqueSPAdjustment &&
435
1.92k
           HasVAStart == Other.HasVAStart &&
436
1.92k
           HasMustTailInVarArgFunc == Other.HasMustTailInVarArgFunc &&
437
2.51k
           
SavePoint == Other.SavePoint1.92k
&&
RestorePoint == Other.RestorePoint1.92k
;
438
2.51k
  }
439
};
440
441
template <> struct MappingTraits<MachineFrameInfo> {
442
2.74k
  static void mapping(IO &YamlIO, MachineFrameInfo &MFI) {
443
2.74k
    YamlIO.mapOptional("isFrameAddressTaken", MFI.IsFrameAddressTaken, false);
444
2.74k
    YamlIO.mapOptional("isReturnAddressTaken", MFI.IsReturnAddressTaken, false);
445
2.74k
    YamlIO.mapOptional("hasStackMap", MFI.HasStackMap, false);
446
2.74k
    YamlIO.mapOptional("hasPatchPoint", MFI.HasPatchPoint, false);
447
2.74k
    YamlIO.mapOptional("stackSize", MFI.StackSize, (uint64_t)0);
448
2.74k
    YamlIO.mapOptional("offsetAdjustment", MFI.OffsetAdjustment, (int)0);
449
2.74k
    YamlIO.mapOptional("maxAlignment", MFI.MaxAlignment, (unsigned)0);
450
2.74k
    YamlIO.mapOptional("adjustsStack", MFI.AdjustsStack, false);
451
2.74k
    YamlIO.mapOptional("hasCalls", MFI.HasCalls, false);
452
2.74k
    YamlIO.mapOptional("stackProtector", MFI.StackProtector,
453
2.74k
                       StringValue()); // Don't print it out when it's empty.
454
2.74k
    YamlIO.mapOptional("maxCallFrameSize", MFI.MaxCallFrameSize, (unsigned)~0);
455
2.74k
    YamlIO.mapOptional("hasOpaqueSPAdjustment", MFI.HasOpaqueSPAdjustment,
456
2.74k
                       false);
457
2.74k
    YamlIO.mapOptional("hasVAStart", MFI.HasVAStart, false);
458
2.74k
    YamlIO.mapOptional("hasMustTailInVarArgFunc", MFI.HasMustTailInVarArgFunc,
459
2.74k
                       false);
460
2.74k
    YamlIO.mapOptional("savePoint", MFI.SavePoint,
461
2.74k
                       StringValue()); // Don't print it out when it's empty.
462
2.74k
    YamlIO.mapOptional("restorePoint", MFI.RestorePoint,
463
2.74k
                       StringValue()); // Don't print it out when it's empty.
464
2.74k
  }
465
};
466
467
struct MachineFunction {
468
  StringRef Name;
469
  unsigned Alignment = 0;
470
  bool ExposesReturnsTwice = false;
471
  // GISel MachineFunctionProperties.
472
  bool Legalized = false;
473
  bool RegBankSelected = false;
474
  bool Selected = false;
475
  // Register information
476
  bool TracksRegLiveness = false;
477
  std::vector<VirtualRegisterDefinition> VirtualRegisters;
478
  std::vector<MachineFunctionLiveIn> LiveIns;
479
  Optional<std::vector<FlowStringValue>> CalleeSavedRegisters;
480
  // TODO: Serialize the various register masks.
481
  // Frame information
482
  MachineFrameInfo FrameInfo;
483
  std::vector<FixedMachineStackObject> FixedStackObjects;
484
  std::vector<MachineStackObject> StackObjects;
485
  std::vector<MachineConstantPoolValue> Constants; /// Constant pool.
486
  MachineJumpTable JumpTableInfo;
487
  BlockStringValue Body;
488
};
489
490
template <> struct MappingTraits<MachineFunction> {
491
4.85k
  static void mapping(IO &YamlIO, MachineFunction &MF) {
492
4.85k
    YamlIO.mapRequired("name", MF.Name);
493
4.85k
    YamlIO.mapOptional("alignment", MF.Alignment, (unsigned)0);
494
4.85k
    YamlIO.mapOptional("exposesReturnsTwice", MF.ExposesReturnsTwice, false);
495
4.85k
    YamlIO.mapOptional("legalized", MF.Legalized, false);
496
4.85k
    YamlIO.mapOptional("regBankSelected", MF.RegBankSelected, false);
497
4.85k
    YamlIO.mapOptional("selected", MF.Selected, false);
498
4.85k
    YamlIO.mapOptional("tracksRegLiveness", MF.TracksRegLiveness, false);
499
4.85k
    YamlIO.mapOptional("registers", MF.VirtualRegisters,
500
4.85k
                       std::vector<VirtualRegisterDefinition>());
501
4.85k
    YamlIO.mapOptional("liveins", MF.LiveIns,
502
4.85k
                       std::vector<MachineFunctionLiveIn>());
503
4.85k
    YamlIO.mapOptional("calleeSavedRegisters", MF.CalleeSavedRegisters,
504
4.85k
                       Optional<std::vector<FlowStringValue>>());
505
4.85k
    YamlIO.mapOptional("frameInfo", MF.FrameInfo, MachineFrameInfo());
506
4.85k
    YamlIO.mapOptional("fixedStack", MF.FixedStackObjects,
507
4.85k
                       std::vector<FixedMachineStackObject>());
508
4.85k
    YamlIO.mapOptional("stack", MF.StackObjects,
509
4.85k
                       std::vector<MachineStackObject>());
510
4.85k
    YamlIO.mapOptional("constants", MF.Constants,
511
4.85k
                       std::vector<MachineConstantPoolValue>());
512
4.85k
    if (
!YamlIO.outputting() || 4.85k
!MF.JumpTableInfo.Entries.empty()2.51k
)
513
2.34k
      YamlIO.mapOptional("jumpTable", MF.JumpTableInfo, MachineJumpTable());
514
4.85k
    YamlIO.mapOptional("body", MF.Body, BlockStringValue());
515
4.85k
  }
516
};
517
518
} // end namespace yaml
519
} // end namespace llvm
520
521
#endif // LLVM_CODEGEN_MIRYAMLMAPPING_H