blob: b600ec92e18d6a4ee866cfb8a70bbaff7f501911 [file] [log] [blame]
Andrew Walbran16937d02019-10-22 13:54:20 +01001//===- MIRYamlMapping.h - Describes the mapping between MIR and YAML ------===//
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002//
Andrew Walbran16937d02019-10-22 13:54:20 +01003// 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
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006//
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
28namespace llvm {
29namespace yaml {
30
31/// A wrapper around std::string which contains a source range that's being
32/// set during parsing.
33struct StringValue {
34 std::string Value;
35 SMRange SourceRange;
36
37 StringValue() = default;
38 StringValue(std::string Value) : Value(std::move(Value)) {}
39
40 bool operator==(const StringValue &Other) const {
41 return Value == Other.Value;
42 }
43};
44
45template <> struct ScalarTraits<StringValue> {
46 static void output(const StringValue &S, void *, raw_ostream &OS) {
47 OS << S.Value;
48 }
49
50 static StringRef input(StringRef Scalar, void *Ctx, StringValue &S) {
51 S.Value = Scalar.str();
52 if (const auto *Node =
53 reinterpret_cast<yaml::Input *>(Ctx)->getCurrentNode())
54 S.SourceRange = Node->getSourceRange();
55 return "";
56 }
57
58 static QuotingType mustQuote(StringRef S) { return needsQuotes(S); }
59};
60
61struct FlowStringValue : StringValue {
62 FlowStringValue() = default;
63 FlowStringValue(std::string Value) : StringValue(std::move(Value)) {}
64};
65
66template <> struct ScalarTraits<FlowStringValue> {
67 static void output(const FlowStringValue &S, void *, raw_ostream &OS) {
68 return ScalarTraits<StringValue>::output(S, nullptr, OS);
69 }
70
71 static StringRef input(StringRef Scalar, void *Ctx, FlowStringValue &S) {
72 return ScalarTraits<StringValue>::input(Scalar, Ctx, S);
73 }
74
75 static QuotingType mustQuote(StringRef S) { return needsQuotes(S); }
76};
77
78struct BlockStringValue {
79 StringValue Value;
80
81 bool operator==(const BlockStringValue &Other) const {
82 return Value == Other.Value;
83 }
84};
85
86template <> struct BlockScalarTraits<BlockStringValue> {
87 static void output(const BlockStringValue &S, void *Ctx, raw_ostream &OS) {
88 return ScalarTraits<StringValue>::output(S.Value, Ctx, OS);
89 }
90
91 static StringRef input(StringRef Scalar, void *Ctx, BlockStringValue &S) {
92 return ScalarTraits<StringValue>::input(Scalar, Ctx, S.Value);
93 }
94};
95
96/// A wrapper around unsigned which contains a source range that's being set
97/// during parsing.
98struct UnsignedValue {
99 unsigned Value = 0;
100 SMRange SourceRange;
101
102 UnsignedValue() = default;
103 UnsignedValue(unsigned Value) : Value(Value) {}
104
105 bool operator==(const UnsignedValue &Other) const {
106 return Value == Other.Value;
107 }
108};
109
110template <> struct ScalarTraits<UnsignedValue> {
111 static void output(const UnsignedValue &Value, void *Ctx, raw_ostream &OS) {
112 return ScalarTraits<unsigned>::output(Value.Value, Ctx, OS);
113 }
114
115 static StringRef input(StringRef Scalar, void *Ctx, UnsignedValue &Value) {
116 if (const auto *Node =
117 reinterpret_cast<yaml::Input *>(Ctx)->getCurrentNode())
118 Value.SourceRange = Node->getSourceRange();
119 return ScalarTraits<unsigned>::input(Scalar, Ctx, Value.Value);
120 }
121
122 static QuotingType mustQuote(StringRef Scalar) {
123 return ScalarTraits<unsigned>::mustQuote(Scalar);
124 }
125};
126
127template <> struct ScalarEnumerationTraits<MachineJumpTableInfo::JTEntryKind> {
128 static void enumeration(yaml::IO &IO,
129 MachineJumpTableInfo::JTEntryKind &EntryKind) {
130 IO.enumCase(EntryKind, "block-address",
131 MachineJumpTableInfo::EK_BlockAddress);
132 IO.enumCase(EntryKind, "gp-rel64-block-address",
133 MachineJumpTableInfo::EK_GPRel64BlockAddress);
134 IO.enumCase(EntryKind, "gp-rel32-block-address",
135 MachineJumpTableInfo::EK_GPRel32BlockAddress);
136 IO.enumCase(EntryKind, "label-difference32",
137 MachineJumpTableInfo::EK_LabelDifference32);
138 IO.enumCase(EntryKind, "inline", MachineJumpTableInfo::EK_Inline);
139 IO.enumCase(EntryKind, "custom32", MachineJumpTableInfo::EK_Custom32);
140 }
141};
142
143} // end namespace yaml
144} // end namespace llvm
145
146LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::StringValue)
147LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(llvm::yaml::FlowStringValue)
148LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(llvm::yaml::UnsignedValue)
149
150namespace llvm {
151namespace yaml {
152
153struct VirtualRegisterDefinition {
154 UnsignedValue ID;
155 StringValue Class;
156 StringValue PreferredRegister;
157
158 // TODO: Serialize the target specific register hints.
159
160 bool operator==(const VirtualRegisterDefinition &Other) const {
161 return ID == Other.ID && Class == Other.Class &&
162 PreferredRegister == Other.PreferredRegister;
163 }
164};
165
166template <> struct MappingTraits<VirtualRegisterDefinition> {
167 static void mapping(IO &YamlIO, VirtualRegisterDefinition &Reg) {
168 YamlIO.mapRequired("id", Reg.ID);
169 YamlIO.mapRequired("class", Reg.Class);
170 YamlIO.mapOptional("preferred-register", Reg.PreferredRegister,
171 StringValue()); // Don't print out when it's empty.
172 }
173
174 static const bool flow = true;
175};
176
177struct MachineFunctionLiveIn {
178 StringValue Register;
179 StringValue VirtualRegister;
180
181 bool operator==(const MachineFunctionLiveIn &Other) const {
182 return Register == Other.Register &&
183 VirtualRegister == Other.VirtualRegister;
184 }
185};
186
187template <> struct MappingTraits<MachineFunctionLiveIn> {
188 static void mapping(IO &YamlIO, MachineFunctionLiveIn &LiveIn) {
189 YamlIO.mapRequired("reg", LiveIn.Register);
190 YamlIO.mapOptional(
191 "virtual-reg", LiveIn.VirtualRegister,
192 StringValue()); // Don't print the virtual register when it's empty.
193 }
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.
205struct 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 bool operator==(const MachineStackObject &Other) const {
223 return ID == Other.ID && Name == Other.Name && Type == Other.Type &&
224 Offset == Other.Offset && Size == Other.Size &&
225 Alignment == Other.Alignment &&
226 StackID == Other.StackID &&
227 CalleeSavedRegister == Other.CalleeSavedRegister &&
228 CalleeSavedRestored == Other.CalleeSavedRestored &&
229 LocalOffset == Other.LocalOffset && DebugVar == Other.DebugVar &&
230 DebugExpr == Other.DebugExpr && DebugLoc == Other.DebugLoc;
231 }
232};
233
234template <> struct ScalarEnumerationTraits<MachineStackObject::ObjectType> {
235 static void enumeration(yaml::IO &IO, MachineStackObject::ObjectType &Type) {
236 IO.enumCase(Type, "default", MachineStackObject::DefaultType);
237 IO.enumCase(Type, "spill-slot", MachineStackObject::SpillSlot);
238 IO.enumCase(Type, "variable-sized", MachineStackObject::VariableSized);
239 }
240};
241
242template <> struct MappingTraits<MachineStackObject> {
243 static void mapping(yaml::IO &YamlIO, MachineStackObject &Object) {
244 YamlIO.mapRequired("id", Object.ID);
245 YamlIO.mapOptional("name", Object.Name,
246 StringValue()); // Don't print out an empty name.
247 YamlIO.mapOptional(
248 "type", Object.Type,
249 MachineStackObject::DefaultType); // Don't print the default type.
250 YamlIO.mapOptional("offset", Object.Offset, (int64_t)0);
251 if (Object.Type != MachineStackObject::VariableSized)
252 YamlIO.mapRequired("size", Object.Size);
253 YamlIO.mapOptional("alignment", Object.Alignment, (unsigned)0);
254 YamlIO.mapOptional("stack-id", Object.StackID);
255 YamlIO.mapOptional("callee-saved-register", Object.CalleeSavedRegister,
256 StringValue()); // Don't print it out when it's empty.
257 YamlIO.mapOptional("callee-saved-restored", Object.CalleeSavedRestored,
258 true);
259 YamlIO.mapOptional("local-offset", Object.LocalOffset, Optional<int64_t>());
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100260 YamlIO.mapOptional("debug-info-variable", Object.DebugVar,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100261 StringValue()); // Don't print it out when it's empty.
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100262 YamlIO.mapOptional("debug-info-expression", Object.DebugExpr,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100263 StringValue()); // Don't print it out when it's empty.
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100264 YamlIO.mapOptional("debug-info-location", Object.DebugLoc,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100265 StringValue()); // Don't print it out when it's empty.
266 }
267
268 static const bool flow = true;
269};
270
271/// Serializable representation of the fixed stack object from the
272/// MachineFrameInfo class.
273struct 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;
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100285 StringValue DebugVar;
286 StringValue DebugExpr;
287 StringValue DebugLoc;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100288
289 bool operator==(const FixedMachineStackObject &Other) const {
290 return ID == Other.ID && Type == Other.Type && Offset == Other.Offset &&
291 Size == Other.Size && Alignment == Other.Alignment &&
292 StackID == Other.StackID &&
293 IsImmutable == Other.IsImmutable && IsAliased == Other.IsAliased &&
294 CalleeSavedRegister == Other.CalleeSavedRegister &&
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100295 CalleeSavedRestored == Other.CalleeSavedRestored &&
296 DebugVar == Other.DebugVar && DebugExpr == Other.DebugExpr
297 && DebugLoc == Other.DebugLoc;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100298 }
299};
300
301template <>
302struct ScalarEnumerationTraits<FixedMachineStackObject::ObjectType> {
303 static void enumeration(yaml::IO &IO,
304 FixedMachineStackObject::ObjectType &Type) {
305 IO.enumCase(Type, "default", FixedMachineStackObject::DefaultType);
306 IO.enumCase(Type, "spill-slot", FixedMachineStackObject::SpillSlot);
307 }
308};
309
310template <> struct MappingTraits<FixedMachineStackObject> {
311 static void mapping(yaml::IO &YamlIO, FixedMachineStackObject &Object) {
312 YamlIO.mapRequired("id", Object.ID);
313 YamlIO.mapOptional(
314 "type", Object.Type,
315 FixedMachineStackObject::DefaultType); // Don't print the default type.
316 YamlIO.mapOptional("offset", Object.Offset, (int64_t)0);
317 YamlIO.mapOptional("size", Object.Size, (uint64_t)0);
318 YamlIO.mapOptional("alignment", Object.Alignment, (unsigned)0);
319 YamlIO.mapOptional("stack-id", Object.StackID);
320 if (Object.Type != FixedMachineStackObject::SpillSlot) {
321 YamlIO.mapOptional("isImmutable", Object.IsImmutable, false);
322 YamlIO.mapOptional("isAliased", Object.IsAliased, false);
323 }
324 YamlIO.mapOptional("callee-saved-register", Object.CalleeSavedRegister,
325 StringValue()); // Don't print it out when it's empty.
326 YamlIO.mapOptional("callee-saved-restored", Object.CalleeSavedRestored,
327 true);
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100328 YamlIO.mapOptional("debug-info-variable", Object.DebugVar,
329 StringValue()); // Don't print it out when it's empty.
330 YamlIO.mapOptional("debug-info-expression", Object.DebugExpr,
331 StringValue()); // Don't print it out when it's empty.
332 YamlIO.mapOptional("debug-info-location", Object.DebugLoc,
333 StringValue()); // Don't print it out when it's empty.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100334 }
335
336 static const bool flow = true;
337};
338
339struct MachineConstantPoolValue {
340 UnsignedValue ID;
341 StringValue Value;
342 unsigned Alignment = 0;
343 bool IsTargetSpecific = false;
344
345 bool operator==(const MachineConstantPoolValue &Other) const {
346 return ID == Other.ID && Value == Other.Value &&
347 Alignment == Other.Alignment &&
348 IsTargetSpecific == Other.IsTargetSpecific;
349 }
350};
351
352template <> struct MappingTraits<MachineConstantPoolValue> {
353 static void mapping(IO &YamlIO, MachineConstantPoolValue &Constant) {
354 YamlIO.mapRequired("id", Constant.ID);
355 YamlIO.mapOptional("value", Constant.Value, StringValue());
356 YamlIO.mapOptional("alignment", Constant.Alignment, (unsigned)0);
357 YamlIO.mapOptional("isTargetSpecific", Constant.IsTargetSpecific, false);
358 }
359};
360
361struct MachineJumpTable {
362 struct Entry {
363 UnsignedValue ID;
364 std::vector<FlowStringValue> Blocks;
365
366 bool operator==(const Entry &Other) const {
367 return ID == Other.ID && Blocks == Other.Blocks;
368 }
369 };
370
371 MachineJumpTableInfo::JTEntryKind Kind = MachineJumpTableInfo::EK_Custom32;
372 std::vector<Entry> Entries;
373
374 bool operator==(const MachineJumpTable &Other) const {
375 return Kind == Other.Kind && Entries == Other.Entries;
376 }
377};
378
379template <> struct MappingTraits<MachineJumpTable::Entry> {
380 static void mapping(IO &YamlIO, MachineJumpTable::Entry &Entry) {
381 YamlIO.mapRequired("id", Entry.ID);
382 YamlIO.mapOptional("blocks", Entry.Blocks, std::vector<FlowStringValue>());
383 }
384};
385
386} // end namespace yaml
387} // end namespace llvm
388
389LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::MachineFunctionLiveIn)
390LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::VirtualRegisterDefinition)
391LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::MachineStackObject)
392LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::FixedMachineStackObject)
393LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::MachineConstantPoolValue)
394LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::MachineJumpTable::Entry)
395
396namespace llvm {
397namespace yaml {
398
399template <> struct MappingTraits<MachineJumpTable> {
400 static void mapping(IO &YamlIO, MachineJumpTable &JT) {
401 YamlIO.mapRequired("kind", JT.Kind);
402 YamlIO.mapOptional("entries", JT.Entries,
403 std::vector<MachineJumpTable::Entry>());
404 }
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.
414struct 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.
Andrew Scull0372a572018-11-16 15:47:06 +0000427 unsigned CVBytesOfCalleeSavedRegisters = 0;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100428 bool HasOpaqueSPAdjustment = false;
429 bool HasVAStart = false;
430 bool HasMustTailInVarArgFunc = false;
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100431 unsigned LocalFrameSize = 0;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100432 StringValue SavePoint;
433 StringValue RestorePoint;
434
435 bool operator==(const MachineFrameInfo &Other) const {
436 return IsFrameAddressTaken == Other.IsFrameAddressTaken &&
437 IsReturnAddressTaken == Other.IsReturnAddressTaken &&
438 HasStackMap == Other.HasStackMap &&
439 HasPatchPoint == Other.HasPatchPoint &&
440 StackSize == Other.StackSize &&
441 OffsetAdjustment == Other.OffsetAdjustment &&
442 MaxAlignment == Other.MaxAlignment &&
443 AdjustsStack == Other.AdjustsStack && HasCalls == Other.HasCalls &&
444 StackProtector == Other.StackProtector &&
445 MaxCallFrameSize == Other.MaxCallFrameSize &&
Andrew Scull0372a572018-11-16 15:47:06 +0000446 CVBytesOfCalleeSavedRegisters ==
447 Other.CVBytesOfCalleeSavedRegisters &&
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100448 HasOpaqueSPAdjustment == Other.HasOpaqueSPAdjustment &&
449 HasVAStart == Other.HasVAStart &&
450 HasMustTailInVarArgFunc == Other.HasMustTailInVarArgFunc &&
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100451 LocalFrameSize == Other.LocalFrameSize &&
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100452 SavePoint == Other.SavePoint && RestorePoint == Other.RestorePoint;
453 }
454};
455
456template <> struct MappingTraits<MachineFrameInfo> {
457 static void mapping(IO &YamlIO, MachineFrameInfo &MFI) {
458 YamlIO.mapOptional("isFrameAddressTaken", MFI.IsFrameAddressTaken, false);
459 YamlIO.mapOptional("isReturnAddressTaken", MFI.IsReturnAddressTaken, false);
460 YamlIO.mapOptional("hasStackMap", MFI.HasStackMap, false);
461 YamlIO.mapOptional("hasPatchPoint", MFI.HasPatchPoint, false);
462 YamlIO.mapOptional("stackSize", MFI.StackSize, (uint64_t)0);
463 YamlIO.mapOptional("offsetAdjustment", MFI.OffsetAdjustment, (int)0);
464 YamlIO.mapOptional("maxAlignment", MFI.MaxAlignment, (unsigned)0);
465 YamlIO.mapOptional("adjustsStack", MFI.AdjustsStack, false);
466 YamlIO.mapOptional("hasCalls", MFI.HasCalls, false);
467 YamlIO.mapOptional("stackProtector", MFI.StackProtector,
468 StringValue()); // Don't print it out when it's empty.
469 YamlIO.mapOptional("maxCallFrameSize", MFI.MaxCallFrameSize, (unsigned)~0);
Andrew Scull0372a572018-11-16 15:47:06 +0000470 YamlIO.mapOptional("cvBytesOfCalleeSavedRegisters",
471 MFI.CVBytesOfCalleeSavedRegisters, 0U);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100472 YamlIO.mapOptional("hasOpaqueSPAdjustment", MFI.HasOpaqueSPAdjustment,
473 false);
474 YamlIO.mapOptional("hasVAStart", MFI.HasVAStart, false);
475 YamlIO.mapOptional("hasMustTailInVarArgFunc", MFI.HasMustTailInVarArgFunc,
476 false);
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100477 YamlIO.mapOptional("localFrameSize", MFI.LocalFrameSize, (unsigned)0);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100478 YamlIO.mapOptional("savePoint", MFI.SavePoint,
479 StringValue()); // Don't print it out when it's empty.
480 YamlIO.mapOptional("restorePoint", MFI.RestorePoint,
481 StringValue()); // Don't print it out when it's empty.
482 }
483};
484
485struct 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;
Andrew Walbran16937d02019-10-22 13:54:20 +0100496 bool HasWinCFI = false;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100497 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
510template <> struct MappingTraits<MachineFunction> {
511 static void mapping(IO &YamlIO, MachineFunction &MF) {
512 YamlIO.mapRequired("name", MF.Name);
513 YamlIO.mapOptional("alignment", MF.Alignment, (unsigned)0);
514 YamlIO.mapOptional("exposesReturnsTwice", MF.ExposesReturnsTwice, false);
515 YamlIO.mapOptional("legalized", MF.Legalized, false);
516 YamlIO.mapOptional("regBankSelected", MF.RegBankSelected, false);
517 YamlIO.mapOptional("selected", MF.Selected, false);
518 YamlIO.mapOptional("failedISel", MF.FailedISel, false);
519 YamlIO.mapOptional("tracksRegLiveness", MF.TracksRegLiveness, false);
Andrew Walbran16937d02019-10-22 13:54:20 +0100520 YamlIO.mapOptional("hasWinCFI", MF.HasWinCFI, false);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100521 YamlIO.mapOptional("registers", MF.VirtualRegisters,
522 std::vector<VirtualRegisterDefinition>());
523 YamlIO.mapOptional("liveins", MF.LiveIns,
524 std::vector<MachineFunctionLiveIn>());
525 YamlIO.mapOptional("calleeSavedRegisters", MF.CalleeSavedRegisters,
526 Optional<std::vector<FlowStringValue>>());
527 YamlIO.mapOptional("frameInfo", MF.FrameInfo, MachineFrameInfo());
528 YamlIO.mapOptional("fixedStack", MF.FixedStackObjects,
529 std::vector<FixedMachineStackObject>());
530 YamlIO.mapOptional("stack", MF.StackObjects,
531 std::vector<MachineStackObject>());
532 YamlIO.mapOptional("constants", MF.Constants,
533 std::vector<MachineConstantPoolValue>());
534 if (!YamlIO.outputting() || !MF.JumpTableInfo.Entries.empty())
535 YamlIO.mapOptional("jumpTable", MF.JumpTableInfo, MachineJumpTable());
536 YamlIO.mapOptional("body", MF.Body, BlockStringValue());
537 }
538};
539
540} // end namespace yaml
541} // end namespace llvm
542
543#endif // LLVM_CODEGEN_MIRYAMLMAPPING_H