1 //===- MIRYAMLMapping.h - Describes the mapping between MIR and YAML ------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // The MIR serialization library is currently a work in progress. It can't
11 // serialize machine functions at this time.
13 // This file implements the mapping between various MIR data structures and
14 // their corresponding YAML representation.
16 //===----------------------------------------------------------------------===//
18 #ifndef LLVM_LIB_CODEGEN_MIRYAMLMAPPING_H
19 #define LLVM_LIB_CODEGEN_MIRYAMLMAPPING_H
21 #include "llvm/ADT/StringRef.h"
22 #include "llvm/Support/YAMLTraits.h"
25 LLVM_YAML_IS_SEQUENCE_VECTOR(std::string)
30 struct MachineBasicBlock {
32 unsigned Alignment = 0;
33 bool IsLandingPad = false;
34 bool AddressTaken = false;
35 // TODO: Serialize the successors and liveins.
37 std::vector<std::string> Instructions;
40 template <> struct MappingTraits<MachineBasicBlock> {
41 static void mapping(IO &YamlIO, MachineBasicBlock &MBB) {
42 YamlIO.mapOptional("name", MBB.Name,
43 std::string()); // Don't print out an empty name.
44 YamlIO.mapOptional("alignment", MBB.Alignment);
45 YamlIO.mapOptional("isLandingPad", MBB.IsLandingPad);
46 YamlIO.mapOptional("addressTaken", MBB.AddressTaken);
47 YamlIO.mapOptional("instructions", MBB.Instructions);
51 } // end namespace yaml
52 } // end namespace llvm
54 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::MachineBasicBlock)
59 struct MachineFunction {
61 unsigned Alignment = 0;
62 bool ExposesReturnsTwice = false;
63 bool HasInlineAsm = false;
65 std::vector<MachineBasicBlock> BasicBlocks;
68 template <> struct MappingTraits<MachineFunction> {
69 static void mapping(IO &YamlIO, MachineFunction &MF) {
70 YamlIO.mapRequired("name", MF.Name);
71 YamlIO.mapOptional("alignment", MF.Alignment);
72 YamlIO.mapOptional("exposesReturnsTwice", MF.ExposesReturnsTwice);
73 YamlIO.mapOptional("hasInlineAsm", MF.HasInlineAsm);
74 YamlIO.mapOptional("body", MF.BasicBlocks);
78 } // end namespace yaml
79 } // end namespace llvm