LLVM  10.0.0svn
MIRYamlMapping.h
Go to the documentation of this file.
1 //===- MIRYamlMapping.h - Describe mapping between MIR and YAML--*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // 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"
21 #include "llvm/Support/SMLoc.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;
37 
38  StringValue() = default;
39  StringValue(std::string Value) : Value(std::move(Value)) {}
40  StringValue(const char Val[]) : Value(Val) {}
41 
42  bool operator==(const StringValue &Other) const {
43  return Value == Other.Value;
44  }
45 };
46 
47 template <> struct ScalarTraits<StringValue> {
48  static void output(const StringValue &S, void *, raw_ostream &OS) {
49  OS << S.Value;
50  }
51 
52  static StringRef input(StringRef Scalar, void *Ctx, StringValue &S) {
53  S.Value = Scalar.str();
54  if (const auto *Node =
55  reinterpret_cast<yaml::Input *>(Ctx)->getCurrentNode())
57  return "";
58  }
59 
60  static QuotingType mustQuote(StringRef S) { return needsQuotes(S); }
61 };
62 
64  FlowStringValue() = default;
65  FlowStringValue(std::string Value) : StringValue(std::move(Value)) {}
66 };
67 
68 template <> struct ScalarTraits<FlowStringValue> {
69  static void output(const FlowStringValue &S, void *, raw_ostream &OS) {
70  return ScalarTraits<StringValue>::output(S, nullptr, OS);
71  }
72 
73  static StringRef input(StringRef Scalar, void *Ctx, FlowStringValue &S) {
74  return ScalarTraits<StringValue>::input(Scalar, Ctx, S);
75  }
76 
77  static QuotingType mustQuote(StringRef S) { return needsQuotes(S); }
78 };
79 
82 
83  bool operator==(const BlockStringValue &Other) const {
84  return Value == Other.Value;
85  }
86 };
87 
88 template <> struct BlockScalarTraits<BlockStringValue> {
89  static void output(const BlockStringValue &S, void *Ctx, raw_ostream &OS) {
90  return ScalarTraits<StringValue>::output(S.Value, Ctx, OS);
91  }
92 
93  static StringRef input(StringRef Scalar, void *Ctx, BlockStringValue &S) {
94  return ScalarTraits<StringValue>::input(Scalar, Ctx, S.Value);
95  }
96 };
97 
98 /// A wrapper around unsigned which contains a source range that's being set
99 /// during parsing.
101  unsigned Value = 0;
103 
104  UnsignedValue() = default;
105  UnsignedValue(unsigned Value) : Value(Value) {}
106 
107  bool operator==(const UnsignedValue &Other) const {
108  return Value == Other.Value;
109  }
110 };
111 
112 template <> struct ScalarTraits<UnsignedValue> {
113  static void output(const UnsignedValue &Value, void *Ctx, raw_ostream &OS) {
114  return ScalarTraits<unsigned>::output(Value.Value, Ctx, OS);
115  }
116 
118  if (const auto *Node =
119  reinterpret_cast<yaml::Input *>(Ctx)->getCurrentNode())
120  Value.SourceRange = Node->getSourceRange();
121  return ScalarTraits<unsigned>::input(Scalar, Ctx, Value.Value);
122  }
123 
124  static QuotingType mustQuote(StringRef Scalar) {
125  return ScalarTraits<unsigned>::mustQuote(Scalar);
126  }
127 };
128 
129 template <> struct ScalarEnumerationTraits<MachineJumpTableInfo::JTEntryKind> {
130  static void enumeration(yaml::IO &IO,
132  IO.enumCase(EntryKind, "block-address",
134  IO.enumCase(EntryKind, "gp-rel64-block-address",
136  IO.enumCase(EntryKind, "gp-rel32-block-address",
138  IO.enumCase(EntryKind, "label-difference32",
140  IO.enumCase(EntryKind, "inline", MachineJumpTableInfo::EK_Inline);
141  IO.enumCase(EntryKind, "custom32", MachineJumpTableInfo::EK_Custom32);
142  }
143 };
144 
145 } // end namespace yaml
146 } // end namespace llvm
147 
148 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::StringValue)
149 LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(llvm::yaml::FlowStringValue)
150 LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(llvm::yaml::UnsignedValue)
151 
152 namespace llvm {
153 namespace yaml {
154 
159 
160  // TODO: Serialize the target specific register hints.
161 
162  bool operator==(const VirtualRegisterDefinition &Other) const {
163  return ID == Other.ID && Class == Other.Class &&
164  PreferredRegister == Other.PreferredRegister;
165  }
166 };
167 
169  static void mapping(IO &YamlIO, VirtualRegisterDefinition &Reg) {
170  YamlIO.mapRequired("id", Reg.ID);
171  YamlIO.mapRequired("class", Reg.Class);
172  YamlIO.mapOptional("preferred-register", Reg.PreferredRegister,
173  StringValue()); // Don't print out when it's empty.
174  }
175 
176  static const bool flow = true;
177 };
178 
182 
183  bool operator==(const MachineFunctionLiveIn &Other) const {
184  return Register == Other.Register &&
185  VirtualRegister == Other.VirtualRegister;
186  }
187 };
188 
190  static void mapping(IO &YamlIO, MachineFunctionLiveIn &LiveIn) {
191  YamlIO.mapRequired("reg", LiveIn.Register);
192  YamlIO.mapOptional(
193  "virtual-reg", LiveIn.VirtualRegister,
194  StringValue()); // Don't print the virtual register when it's empty.
195  }
196 
197  static const bool flow = true;
198 };
199 
200 /// Serializable representation of stack object from the MachineFrameInfo class.
201 ///
202 /// The flags 'isImmutable' and 'isAliased' aren't serialized, as they are
203 /// determined by the object's type and frame information flags.
204 /// Dead stack objects aren't serialized.
205 ///
206 /// The 'isPreallocated' flag is determined by the local offset.
208  enum ObjectType { DefaultType, SpillSlot, VariableSized };
211  // TODO: Serialize unnamed LLVM alloca reference.
212  ObjectType Type = DefaultType;
213  int64_t Offset = 0;
214  uint64_t Size = 0;
215  unsigned Alignment = 0;
218  bool CalleeSavedRestored = true;
223 
224  bool operator==(const MachineStackObject &Other) const {
225  return ID == Other.ID && Name == Other.Name && Type == Other.Type &&
226  Offset == Other.Offset && Size == Other.Size &&
227  Alignment == Other.Alignment &&
228  StackID == Other.StackID &&
229  CalleeSavedRegister == Other.CalleeSavedRegister &&
230  CalleeSavedRestored == Other.CalleeSavedRestored &&
231  LocalOffset == Other.LocalOffset && DebugVar == Other.DebugVar &&
232  DebugExpr == Other.DebugExpr && DebugLoc == Other.DebugLoc;
233  }
234 };
235 
236 template <> struct ScalarEnumerationTraits<MachineStackObject::ObjectType> {
237  static void enumeration(yaml::IO &IO, MachineStackObject::ObjectType &Type) {
238  IO.enumCase(Type, "default", MachineStackObject::DefaultType);
239  IO.enumCase(Type, "spill-slot", MachineStackObject::SpillSlot);
240  IO.enumCase(Type, "variable-sized", MachineStackObject::VariableSized);
241  }
242 };
243 
244 template <> struct MappingTraits<MachineStackObject> {
245  static void mapping(yaml::IO &YamlIO, MachineStackObject &Object) {
246  YamlIO.mapRequired("id", Object.ID);
247  YamlIO.mapOptional("name", Object.Name,
248  StringValue()); // Don't print out an empty name.
249  YamlIO.mapOptional(
250  "type", Object.Type,
251  MachineStackObject::DefaultType); // Don't print the default type.
252  YamlIO.mapOptional("offset", Object.Offset, (int64_t)0);
254  YamlIO.mapRequired("size", Object.Size);
255  YamlIO.mapOptional("alignment", Object.Alignment, (unsigned)0);
256  YamlIO.mapOptional("stack-id", Object.StackID, TargetStackID::Default);
257  YamlIO.mapOptional("callee-saved-register", Object.CalleeSavedRegister,
258  StringValue()); // Don't print it out when it's empty.
259  YamlIO.mapOptional("callee-saved-restored", Object.CalleeSavedRestored,
260  true);
261  YamlIO.mapOptional("local-offset", Object.LocalOffset, Optional<int64_t>());
262  YamlIO.mapOptional("debug-info-variable", Object.DebugVar,
263  StringValue()); // Don't print it out when it's empty.
264  YamlIO.mapOptional("debug-info-expression", Object.DebugExpr,
265  StringValue()); // Don't print it out when it's empty.
266  YamlIO.mapOptional("debug-info-location", Object.DebugLoc,
267  StringValue()); // Don't print it out when it's empty.
268  }
269 
270  static const bool flow = true;
271 };
272 
273 /// Serializable representation of the fixed stack object from the
274 /// MachineFrameInfo class.
276  enum ObjectType { DefaultType, SpillSlot };
278  ObjectType Type = DefaultType;
279  int64_t Offset = 0;
280  uint64_t Size = 0;
281  unsigned Alignment = 0;
283  bool IsImmutable = false;
284  bool IsAliased = false;
286  bool CalleeSavedRestored = true;
290 
291  bool operator==(const FixedMachineStackObject &Other) const {
292  return ID == Other.ID && Type == Other.Type && Offset == Other.Offset &&
293  Size == Other.Size && Alignment == Other.Alignment &&
294  StackID == Other.StackID &&
295  IsImmutable == Other.IsImmutable && IsAliased == Other.IsAliased &&
296  CalleeSavedRegister == Other.CalleeSavedRegister &&
297  CalleeSavedRestored == Other.CalleeSavedRestored &&
298  DebugVar == Other.DebugVar && DebugExpr == Other.DebugExpr
299  && DebugLoc == Other.DebugLoc;
300  }
301 };
302 
303 template <>
304 struct ScalarEnumerationTraits<FixedMachineStackObject::ObjectType> {
305  static void enumeration(yaml::IO &IO,
307  IO.enumCase(Type, "default", FixedMachineStackObject::DefaultType);
308  IO.enumCase(Type, "spill-slot", FixedMachineStackObject::SpillSlot);
309  }
310 };
311 
312 template <>
313 struct ScalarEnumerationTraits<TargetStackID::Value> {
314  static void enumeration(yaml::IO &IO, TargetStackID::Value &ID) {
315  IO.enumCase(ID, "default", TargetStackID::Default);
316  IO.enumCase(ID, "sgpr-spill", TargetStackID::SGPRSpill);
317  IO.enumCase(ID, "noalloc", TargetStackID::NoAlloc);
318  }
319 };
320 
322  static void mapping(yaml::IO &YamlIO, FixedMachineStackObject &Object) {
323  YamlIO.mapRequired("id", Object.ID);
324  YamlIO.mapOptional(
325  "type", Object.Type,
326  FixedMachineStackObject::DefaultType); // Don't print the default type.
327  YamlIO.mapOptional("offset", Object.Offset, (int64_t)0);
328  YamlIO.mapOptional("size", Object.Size, (uint64_t)0);
329  YamlIO.mapOptional("alignment", Object.Alignment, (unsigned)0);
330  YamlIO.mapOptional("stack-id", Object.StackID, TargetStackID::Default);
332  YamlIO.mapOptional("isImmutable", Object.IsImmutable, false);
333  YamlIO.mapOptional("isAliased", Object.IsAliased, false);
334  }
335  YamlIO.mapOptional("callee-saved-register", Object.CalleeSavedRegister,
336  StringValue()); // Don't print it out when it's empty.
337  YamlIO.mapOptional("callee-saved-restored", Object.CalleeSavedRestored,
338  true);
339  YamlIO.mapOptional("debug-info-variable", Object.DebugVar,
340  StringValue()); // Don't print it out when it's empty.
341  YamlIO.mapOptional("debug-info-expression", Object.DebugExpr,
342  StringValue()); // Don't print it out when it's empty.
343  YamlIO.mapOptional("debug-info-location", Object.DebugLoc,
344  StringValue()); // Don't print it out when it's empty.
345  }
346 
347  static const bool flow = true;
348 };
349 
350 
351 /// Serializable representation of CallSiteInfo.
352 struct CallSiteInfo {
353  // Representation of call argument and register which is used to
354  // transfer it.
355  struct ArgRegPair {
357  uint16_t ArgNo;
358 
359  bool operator==(const ArgRegPair &Other) const {
360  return Reg == Other.Reg && ArgNo == Other.ArgNo;
361  }
362  };
363 
364  /// Identifies call instruction location in machine function.
366  unsigned BlockNum;
367  unsigned Offset;
368 
369  bool operator==(const MachineInstrLoc &Other) const {
370  return BlockNum == Other.BlockNum && Offset == Other.Offset;
371  }
372  };
373 
375  std::vector<ArgRegPair> ArgForwardingRegs;
376 
377  bool operator==(const CallSiteInfo &Other) const {
378  return CallLocation.BlockNum == Other.CallLocation.BlockNum &&
379  CallLocation.Offset == Other.CallLocation.Offset;
380  }
381 };
382 
383 template <> struct MappingTraits<CallSiteInfo::ArgRegPair> {
384  static void mapping(IO &YamlIO, CallSiteInfo::ArgRegPair &ArgReg) {
385  YamlIO.mapRequired("arg", ArgReg.ArgNo);
386  YamlIO.mapRequired("reg", ArgReg.Reg);
387  }
388 
389  static const bool flow = true;
390 };
391 }
392 }
393 
394 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::CallSiteInfo::ArgRegPair)
395 
396 namespace llvm {
397 namespace yaml {
398 
399 template <> struct MappingTraits<CallSiteInfo> {
400  static void mapping(IO &YamlIO, CallSiteInfo &CSInfo) {
401  YamlIO.mapRequired("bb", CSInfo.CallLocation.BlockNum);
402  YamlIO.mapRequired("offset", CSInfo.CallLocation.Offset);
403  YamlIO.mapOptional("fwdArgRegs", CSInfo.ArgForwardingRegs,
404  std::vector<CallSiteInfo::ArgRegPair>());
405  }
406 
407  static const bool flow = true;
408 };
409 
413  unsigned Alignment = 0;
414  bool IsTargetSpecific = false;
415 
416  bool operator==(const MachineConstantPoolValue &Other) const {
417  return ID == Other.ID && Value == Other.Value &&
418  Alignment == Other.Alignment &&
419  IsTargetSpecific == Other.IsTargetSpecific;
420  }
421 };
422 
424  static void mapping(IO &YamlIO, MachineConstantPoolValue &Constant) {
425  YamlIO.mapRequired("id", Constant.ID);
426  YamlIO.mapOptional("value", Constant.Value, StringValue());
427  YamlIO.mapOptional("alignment", Constant.Alignment, (unsigned)0);
428  YamlIO.mapOptional("isTargetSpecific", Constant.IsTargetSpecific, false);
429  }
430 };
431 
433  struct Entry {
435  std::vector<FlowStringValue> Blocks;
436 
437  bool operator==(const Entry &Other) const {
438  return ID == Other.ID && Blocks == Other.Blocks;
439  }
440  };
441 
443  std::vector<Entry> Entries;
444 
445  bool operator==(const MachineJumpTable &Other) const {
446  return Kind == Other.Kind && Entries == Other.Entries;
447  }
448 };
449 
450 template <> struct MappingTraits<MachineJumpTable::Entry> {
451  static void mapping(IO &YamlIO, MachineJumpTable::Entry &Entry) {
452  YamlIO.mapRequired("id", Entry.ID);
453  YamlIO.mapOptional("blocks", Entry.Blocks, std::vector<FlowStringValue>());
454  }
455 };
456 
457 } // end namespace yaml
458 } // end namespace llvm
459 
460 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::MachineFunctionLiveIn)
461 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::VirtualRegisterDefinition)
462 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::MachineStackObject)
463 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::FixedMachineStackObject)
464 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::CallSiteInfo)
465 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::MachineConstantPoolValue)
466 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::MachineJumpTable::Entry)
467 
468 namespace llvm {
469 namespace yaml {
470 
471 template <> struct MappingTraits<MachineJumpTable> {
472  static void mapping(IO &YamlIO, MachineJumpTable &JT) {
473  YamlIO.mapRequired("kind", JT.Kind);
474  YamlIO.mapOptional("entries", JT.Entries,
475  std::vector<MachineJumpTable::Entry>());
476  }
477 };
478 
479 /// Serializable representation of MachineFrameInfo.
480 ///
481 /// Doesn't serialize attributes like 'StackAlignment', 'IsStackRealignable' and
482 /// 'RealignOption' as they are determined by the target and LLVM function
483 /// attributes.
484 /// It also doesn't serialize attributes like 'NumFixedObject' and
485 /// 'HasVarSizedObjects' as they are determined by the frame objects themselves.
487  bool IsFrameAddressTaken = false;
488  bool IsReturnAddressTaken = false;
489  bool HasStackMap = false;
490  bool HasPatchPoint = false;
491  uint64_t StackSize = 0;
492  int OffsetAdjustment = 0;
493  unsigned MaxAlignment = 0;
494  bool AdjustsStack = false;
495  bool HasCalls = false;
497  // TODO: Serialize FunctionContextIdx
498  unsigned MaxCallFrameSize = ~0u; ///< ~0u means: not computed yet.
499  unsigned CVBytesOfCalleeSavedRegisters = 0;
500  bool HasOpaqueSPAdjustment = false;
501  bool HasVAStart = false;
502  bool HasMustTailInVarArgFunc = false;
503  unsigned LocalFrameSize = 0;
506 
507  bool operator==(const MachineFrameInfo &Other) const {
508  return IsFrameAddressTaken == Other.IsFrameAddressTaken &&
509  IsReturnAddressTaken == Other.IsReturnAddressTaken &&
510  HasStackMap == Other.HasStackMap &&
511  HasPatchPoint == Other.HasPatchPoint &&
512  StackSize == Other.StackSize &&
513  OffsetAdjustment == Other.OffsetAdjustment &&
514  MaxAlignment == Other.MaxAlignment &&
515  AdjustsStack == Other.AdjustsStack && HasCalls == Other.HasCalls &&
516  StackProtector == Other.StackProtector &&
517  MaxCallFrameSize == Other.MaxCallFrameSize &&
518  CVBytesOfCalleeSavedRegisters ==
520  HasOpaqueSPAdjustment == Other.HasOpaqueSPAdjustment &&
521  HasVAStart == Other.HasVAStart &&
522  HasMustTailInVarArgFunc == Other.HasMustTailInVarArgFunc &&
523  LocalFrameSize == Other.LocalFrameSize &&
524  SavePoint == Other.SavePoint && RestorePoint == Other.RestorePoint;
525  }
526 };
527 
528 template <> struct MappingTraits<MachineFrameInfo> {
529  static void mapping(IO &YamlIO, MachineFrameInfo &MFI) {
530  YamlIO.mapOptional("isFrameAddressTaken", MFI.IsFrameAddressTaken, false);
531  YamlIO.mapOptional("isReturnAddressTaken", MFI.IsReturnAddressTaken, false);
532  YamlIO.mapOptional("hasStackMap", MFI.HasStackMap, false);
533  YamlIO.mapOptional("hasPatchPoint", MFI.HasPatchPoint, false);
534  YamlIO.mapOptional("stackSize", MFI.StackSize, (uint64_t)0);
535  YamlIO.mapOptional("offsetAdjustment", MFI.OffsetAdjustment, (int)0);
536  YamlIO.mapOptional("maxAlignment", MFI.MaxAlignment, (unsigned)0);
537  YamlIO.mapOptional("adjustsStack", MFI.AdjustsStack, false);
538  YamlIO.mapOptional("hasCalls", MFI.HasCalls, false);
539  YamlIO.mapOptional("stackProtector", MFI.StackProtector,
540  StringValue()); // Don't print it out when it's empty.
541  YamlIO.mapOptional("maxCallFrameSize", MFI.MaxCallFrameSize, (unsigned)~0);
542  YamlIO.mapOptional("cvBytesOfCalleeSavedRegisters",
544  YamlIO.mapOptional("hasOpaqueSPAdjustment", MFI.HasOpaqueSPAdjustment,
545  false);
546  YamlIO.mapOptional("hasVAStart", MFI.HasVAStart, false);
547  YamlIO.mapOptional("hasMustTailInVarArgFunc", MFI.HasMustTailInVarArgFunc,
548  false);
549  YamlIO.mapOptional("localFrameSize", MFI.LocalFrameSize, (unsigned)0);
550  YamlIO.mapOptional("savePoint", MFI.SavePoint,
551  StringValue()); // Don't print it out when it's empty.
552  YamlIO.mapOptional("restorePoint", MFI.RestorePoint,
553  StringValue()); // Don't print it out when it's empty.
554  }
555 };
556 
557 /// Targets should override this in a way that mirrors the implementation of
558 /// llvm::MachineFunctionInfo.
560  virtual ~MachineFunctionInfo() {}
561  virtual void mappingImpl(IO &YamlIO) {}
562 };
563 
564 template <> struct MappingTraits<std::unique_ptr<MachineFunctionInfo>> {
565  static void mapping(IO &YamlIO, std::unique_ptr<MachineFunctionInfo> &MFI) {
566  if (MFI)
567  MFI->mappingImpl(YamlIO);
568  }
569 };
570 
573  unsigned Alignment = 0;
574  bool ExposesReturnsTwice = false;
575  // GISel MachineFunctionProperties.
576  bool Legalized = false;
577  bool RegBankSelected = false;
578  bool Selected = false;
579  bool FailedISel = false;
580  // Register information
581  bool TracksRegLiveness = false;
582  bool HasWinCFI = false;
583  std::vector<VirtualRegisterDefinition> VirtualRegisters;
584  std::vector<MachineFunctionLiveIn> LiveIns;
586  // TODO: Serialize the various register masks.
587  // Frame information
589  std::vector<FixedMachineStackObject> FixedStackObjects;
590  std::vector<MachineStackObject> StackObjects;
591  std::vector<MachineConstantPoolValue> Constants; /// Constant pool.
592  std::unique_ptr<MachineFunctionInfo> MachineFuncInfo;
593  std::vector<CallSiteInfo> CallSitesInfo;
596 };
597 
598 template <> struct MappingTraits<MachineFunction> {
599  static void mapping(IO &YamlIO, MachineFunction &MF) {
600  YamlIO.mapRequired("name", MF.Name);
601  YamlIO.mapOptional("alignment", MF.Alignment, (unsigned)0);
602  YamlIO.mapOptional("exposesReturnsTwice", MF.ExposesReturnsTwice, false);
603  YamlIO.mapOptional("legalized", MF.Legalized, false);
604  YamlIO.mapOptional("regBankSelected", MF.RegBankSelected, false);
605  YamlIO.mapOptional("selected", MF.Selected, false);
606  YamlIO.mapOptional("failedISel", MF.FailedISel, false);
607  YamlIO.mapOptional("tracksRegLiveness", MF.TracksRegLiveness, false);
608  YamlIO.mapOptional("hasWinCFI", MF.HasWinCFI, false);
609  YamlIO.mapOptional("registers", MF.VirtualRegisters,
610  std::vector<VirtualRegisterDefinition>());
611  YamlIO.mapOptional("liveins", MF.LiveIns,
612  std::vector<MachineFunctionLiveIn>());
613  YamlIO.mapOptional("calleeSavedRegisters", MF.CalleeSavedRegisters,
614  Optional<std::vector<FlowStringValue>>());
615  YamlIO.mapOptional("frameInfo", MF.FrameInfo, MachineFrameInfo());
616  YamlIO.mapOptional("fixedStack", MF.FixedStackObjects,
617  std::vector<FixedMachineStackObject>());
618  YamlIO.mapOptional("stack", MF.StackObjects,
619  std::vector<MachineStackObject>());
620  YamlIO.mapOptional("callSites", MF.CallSitesInfo,
621  std::vector<CallSiteInfo>());
622  YamlIO.mapOptional("constants", MF.Constants,
623  std::vector<MachineConstantPoolValue>());
624  YamlIO.mapOptional("machineFunctionInfo", MF.MachineFuncInfo);
625  if (!YamlIO.outputting() || !MF.JumpTableInfo.Entries.empty())
626  YamlIO.mapOptional("jumpTable", MF.JumpTableInfo, MachineJumpTable());
627  YamlIO.mapOptional("body", MF.Body, BlockStringValue());
628  }
629 };
630 
631 } // end namespace yaml
632 } // end namespace llvm
633 
634 #endif // LLVM_CODEGEN_MIRYAMLMAPPING_H
Represents a range in source code.
Definition: SMLoc.h:48
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
Definition: StringRef.h:218
StringValue(const char Val[])
This class represents lattice values for constants.
Definition: AllocatorList.h:23
static StringRef input(StringRef Scalar, void *Ctx, StringValue &S)
static void mapping(IO &YamlIO, MachineConstantPoolValue &Constant)
static void output(const FlowStringValue &S, void *, raw_ostream &OS)
Optional< std::vector< FlowStringValue > > CalleeSavedRegisters
Serializable representation of CallSiteInfo.
static QuotingType mustQuote(StringRef S)
unsigned Reg
EK_Inline - Jump table entries are emitted inline at their point of use.
bool operator==(const ArgRegPair &Other) const
FlowStringValue(std::string Value)
static QuotingType mustQuote(StringRef Scalar)
static void output(const UnsignedValue &Value, void *Ctx, raw_ostream &OS)
bool operator==(const Entry &Other) const
std::unique_ptr< MachineFunctionInfo > MachineFuncInfo
Constant pool.
static void enumeration(yaml::IO &IO, MachineStackObject::ObjectType &Type)
static void enumeration(yaml::IO &IO, FixedMachineStackObject::ObjectType &Type)
TargetStackID::Value StackID
MachineInstrLoc CallLocation
static void mapping(yaml::IO &YamlIO, FixedMachineStackObject &Object)
JTEntryKind
JTEntryKind - This enum indicates how each entry of the jump table is represented and emitted...
Definition: BitVector.h:937
bool operator==(const MachineInstrLoc &Other) const
Serializable representation of the fixed stack object from the MachineFrameInfo class.
bool operator==(const MachineFrameInfo &Other) const
static void mapping(IO &YamlIO, MachineFunction &MF)
std::vector< VirtualRegisterDefinition > VirtualRegisters
EK_LabelDifference32 - Each entry is the address of the block minus the address of the jump table...
static void mapping(IO &YamlIO, MachineJumpTable::Entry &Entry)
bool operator==(const StringValue &Other) const
EK_BlockAddress - Each entry is a plain address of block, e.g.
bool operator==(const MachineConstantPoolValue &Other) const
static StringRef input(StringRef Scalar, void *Ctx, UnsignedValue &Value)
EK_GPRel64BlockAddress - Each entry is an address of block, encoded with a relocation as gp-relative...
std::vector< FlowStringValue > Blocks
EK_Custom32 - Each entry is a 32-bit value that is custom lowered by the TargetLowering::LowerCustomJ...
Serializable representation of stack object from the MachineFrameInfo class.
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:45
This is an important base class in LLVM.
Definition: Constant.h:41
static void mapping(IO &YamlIO, MachineFunctionLiveIn &LiveIn)
MachineJumpTable JumpTableInfo
Identifies call instruction location in machine function.
static void mapping(IO &YamlIO, std::unique_ptr< MachineFunctionInfo > &MFI)
static void mapping(IO &YamlIO, CallSiteInfo &CSInfo)
unsigned MaxCallFrameSize
~0u means: not computed yet.
static void enumeration(yaml::IO &IO, TargetStackID::Value &ID)
std::vector< MachineStackObject > StackObjects
virtual void mappingImpl(IO &YamlIO)
Serializable representation of MachineFrameInfo.
bool operator==(const UnsignedValue &Other) const
StringValue(std::string Value)
static void mapping(yaml::IO &YamlIO, MachineStackObject &Object)
static StringRef input(StringRef Scalar, void *Ctx, BlockStringValue &S)
Optional< int64_t > LocalOffset
static void mapping(IO &YamlIO, CallSiteInfo::ArgRegPair &ArgReg)
bool operator==(const CallSiteInfo &Other) const
static void mapping(IO &YamlIO, MachineFrameInfo &MFI)
static void mapping(IO &YamlIO, VirtualRegisterDefinition &Reg)
A wrapper around std::string which contains a source range that&#39;s being set during parsing...
Targets should override this in a way that mirrors the implementation of llvm::MachineFunctionInfo.
std::vector< MachineFunctionLiveIn > LiveIns
static void enumeration(yaml::IO &IO, MachineJumpTableInfo::JTEntryKind &EntryKind)
bool operator==(const MachineStackObject &Other) const
static StringRef input(StringRef Scalar, void *Ctx, FlowStringValue &S)
A wrapper around unsigned which contains a source range that&#39;s being set during parsing.
std::vector< Entry > Entries
static void mapping(IO &YamlIO, MachineJumpTable &JT)
static QuotingType mustQuote(StringRef S)
std::vector< MachineConstantPoolValue > Constants
uint32_t Size
Definition: Profile.cpp:46
bool operator==(const BlockStringValue &Other) const
std::vector< CallSiteInfo > CallSitesInfo
bool operator==(const FixedMachineStackObject &Other) const
static void output(const StringValue &S, void *, raw_ostream &OS)
std::vector< FixedMachineStackObject > FixedStackObjects
LLVM Value Representation.
Definition: Value.h:72
bool operator==(const MachineJumpTable &Other) const
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:45
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48
UnsignedValue(unsigned Value)
EK_GPRel32BlockAddress - Each entry is an address of block, encoded with a relocation as gp-relative...
MachineJumpTableInfo::JTEntryKind Kind
static void output(const BlockStringValue &S, void *Ctx, raw_ostream &OS)
std::vector< ArgRegPair > ArgForwardingRegs
bool operator==(const VirtualRegisterDefinition &Other) const
bool operator==(const MachineFunctionLiveIn &Other) const
SMRange getSourceRange() const
Definition: YAMLParser.h:159
Abstract base class for all Nodes.
Definition: YAMLParser.h:113