]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/include/llvm/CodeGen/MIRYamlMapping.h
Update LLDB snapshot to upstream r241361
[FreeBSD/FreeBSD.git] / contrib / llvm / include / llvm / CodeGen / MIRYamlMapping.h
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 // The MIR serialization library is currently a work in progress. It can't
11 // serialize machine functions at this time.
12 //
13 // This file implements the mapping between various MIR data structures and
14 // their corresponding YAML representation.
15 //
16 //===----------------------------------------------------------------------===//
17
18 #ifndef LLVM_LIB_CODEGEN_MIRYAMLMAPPING_H
19 #define LLVM_LIB_CODEGEN_MIRYAMLMAPPING_H
20
21 #include "llvm/ADT/StringRef.h"
22 #include "llvm/Support/YAMLTraits.h"
23 #include <vector>
24
25 namespace llvm {
26 namespace yaml {
27
28 struct MachineBasicBlock {
29   std::string Name;
30   unsigned Alignment = 0;
31   bool IsLandingPad = false;
32   bool AddressTaken = false;
33   // TODO: Serialize the successors and liveins.
34   // TODO: Serialize machine instructions.
35 };
36
37 template <> struct MappingTraits<MachineBasicBlock> {
38   static void mapping(IO &YamlIO, MachineBasicBlock &MBB) {
39     YamlIO.mapOptional("name", MBB.Name,
40                        std::string()); // Don't print out an empty name.
41     YamlIO.mapOptional("alignment", MBB.Alignment);
42     YamlIO.mapOptional("isLandingPad", MBB.IsLandingPad);
43     YamlIO.mapOptional("addressTaken", MBB.AddressTaken);
44   }
45 };
46
47 } // end namespace yaml
48 } // end namespace llvm
49
50 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::MachineBasicBlock)
51
52 namespace llvm {
53 namespace yaml {
54
55 struct MachineFunction {
56   StringRef Name;
57   unsigned Alignment = 0;
58   bool ExposesReturnsTwice = false;
59   bool HasInlineAsm = false;
60
61   std::vector<MachineBasicBlock> BasicBlocks;
62 };
63
64 template <> struct MappingTraits<MachineFunction> {
65   static void mapping(IO &YamlIO, MachineFunction &MF) {
66     YamlIO.mapRequired("name", MF.Name);
67     YamlIO.mapOptional("alignment", MF.Alignment);
68     YamlIO.mapOptional("exposesReturnsTwice", MF.ExposesReturnsTwice);
69     YamlIO.mapOptional("hasInlineAsm", MF.HasInlineAsm);
70     YamlIO.mapOptional("body", MF.BasicBlocks);
71   }
72 };
73
74 } // end namespace yaml
75 } // end namespace llvm
76
77 #endif