MIR Serialization: Serialize simple MachineRegisterInfo attributes.
[oota-llvm.git] / lib / CodeGen / MIRPrinter.cpp
index 801f6c25ac523b0986607a88f9296dc7bb59eea3..5d13890e1ab95f64975b8ed026765ecff54c8d34 100644 (file)
@@ -15,6 +15,7 @@
 #include "MIRPrinter.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/CodeGen/MachineFunction.h"
+#include "llvm/CodeGen/MachineRegisterInfo.h"
 #include "llvm/CodeGen/MIRYamlMapping.h"
 #include "llvm/IR/BasicBlock.h"
 #include "llvm/IR/Module.h"
@@ -38,6 +39,7 @@ public:
 
   void print(const MachineFunction &MF);
 
+  void convert(yaml::MachineFunction &MF, const MachineRegisterInfo &RegInfo);
   void convert(yaml::MachineBasicBlock &YamlMBB, const MachineBasicBlock &MBB);
 };
 
@@ -78,6 +80,7 @@ void MIRPrinter::print(const MachineFunction &MF) {
   YamlMF.Alignment = MF.getAlignment();
   YamlMF.ExposesReturnsTwice = MF.exposesReturnsTwice();
   YamlMF.HasInlineAsm = MF.hasInlineAsm();
+  convert(YamlMF, MF.getRegInfo());
   for (const auto &MBB : MF) {
     yaml::MachineBasicBlock YamlMBB;
     convert(YamlMBB, MBB);
@@ -87,6 +90,13 @@ void MIRPrinter::print(const MachineFunction &MF) {
   Out << YamlMF;
 }
 
+void MIRPrinter::convert(yaml::MachineFunction &MF,
+                         const MachineRegisterInfo &RegInfo) {
+  MF.IsSSA = RegInfo.isSSA();
+  MF.TracksRegLiveness = RegInfo.tracksLiveness();
+  MF.TracksSubRegLiveness = RegInfo.subRegLivenessEnabled();
+}
+
 void MIRPrinter::convert(yaml::MachineBasicBlock &YamlMBB,
                          const MachineBasicBlock &MBB) {
   // TODO: Serialize unnamed BB references.