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"
28 struct MachineBasicBlock {
30 unsigned Alignment = 0;
31 bool IsLandingPad = false;
32 bool AddressTaken = false;
33 // TODO: Serialize the successors and liveins.
34 // TODO: Serialize machine instructions.
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);
47 } // end namespace yaml
48 } // end namespace llvm
50 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::MachineBasicBlock)
55 struct MachineFunction {
57 unsigned Alignment = 0;
58 bool ExposesReturnsTwice = false;
59 bool HasInlineAsm = false;
61 std::vector<MachineBasicBlock> BasicBlocks;
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);
74 } // end namespace yaml
75 } // end namespace llvm