@@ -634,6 +634,55 @@ LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::CalledGlobal)
634
634
namespace llvm {
635
635
namespace yaml {
636
636
637
+ // Struct representing one save/restore point in the 'savePoint'/'restorePoint'
638
+ // list
639
+ struct SaveRestorePointEntry {
640
+ StringValue Point;
641
+
642
+ bool operator ==(const SaveRestorePointEntry &Other) const {
643
+ return Point == Other.Point ;
644
+ }
645
+ };
646
+
647
+ using SaveRestorePoints =
648
+ std::variant<std::vector<SaveRestorePointEntry>, StringValue>;
649
+
650
+ template <> struct PolymorphicTraits <SaveRestorePoints> {
651
+
652
+ static NodeKind getKind (const SaveRestorePoints &SRPoints) {
653
+ if (std::holds_alternative<std::vector<SaveRestorePointEntry>>(SRPoints))
654
+ return NodeKind::Sequence;
655
+ if (std::holds_alternative<StringValue>(SRPoints))
656
+ return NodeKind::Scalar;
657
+ llvm_unreachable (" Unsupported NodeKind of SaveRestorePoints" );
658
+ }
659
+
660
+ static SaveRestorePointEntry &getAsMap (SaveRestorePoints &SRPoints) {
661
+ llvm_unreachable (" SaveRestorePoints can't be represented as Map" );
662
+ }
663
+
664
+ static std::vector<SaveRestorePointEntry> &
665
+ getAsSequence (SaveRestorePoints &SRPoints) {
666
+ if (!std::holds_alternative<std::vector<SaveRestorePointEntry>>(SRPoints))
667
+ SRPoints = std::vector<SaveRestorePointEntry>();
668
+
669
+ return std::get<std::vector<SaveRestorePointEntry>>(SRPoints);
670
+ }
671
+
672
+ static StringValue &getAsScalar (SaveRestorePoints &SRPoints) {
673
+ if (!std::holds_alternative<StringValue>(SRPoints))
674
+ SRPoints = StringValue ();
675
+
676
+ return std::get<StringValue>(SRPoints);
677
+ }
678
+ };
679
+
680
+ template <> struct MappingTraits <SaveRestorePointEntry> {
681
+ static void mapping (IO &YamlIO, SaveRestorePointEntry &Entry) {
682
+ YamlIO.mapRequired (" point" , Entry.Point );
683
+ }
684
+ };
685
+
637
686
template <> struct MappingTraits <MachineJumpTable> {
638
687
static void mapping (IO &YamlIO, MachineJumpTable &JT) {
639
688
YamlIO.mapRequired (" kind" , JT.Kind );
@@ -642,6 +691,14 @@ template <> struct MappingTraits<MachineJumpTable> {
642
691
}
643
692
};
644
693
694
+ } // namespace yaml
695
+ } // namespace llvm
696
+
697
+ LLVM_YAML_IS_SEQUENCE_VECTOR (llvm::yaml::SaveRestorePointEntry)
698
+
699
+ namespace llvm {
700
+ namespace yaml {
701
+
645
702
// / Serializable representation of MachineFrameInfo.
646
703
// /
647
704
// / Doesn't serialize attributes like 'StackAlignment', 'IsStackRealignable' and
@@ -669,8 +726,8 @@ struct MachineFrameInfo {
669
726
bool HasTailCall = false ;
670
727
bool IsCalleeSavedInfoValid = false ;
671
728
unsigned LocalFrameSize = 0 ;
672
- StringValue SavePoint ;
673
- StringValue RestorePoint ;
729
+ SaveRestorePoints SavePoints ;
730
+ SaveRestorePoints RestorePoints ;
674
731
675
732
bool operator ==(const MachineFrameInfo &Other) const {
676
733
return IsFrameAddressTaken == Other.IsFrameAddressTaken &&
@@ -691,7 +748,8 @@ struct MachineFrameInfo {
691
748
HasMustTailInVarArgFunc == Other.HasMustTailInVarArgFunc &&
692
749
HasTailCall == Other.HasTailCall &&
693
750
LocalFrameSize == Other.LocalFrameSize &&
694
- SavePoint == Other.SavePoint && RestorePoint == Other.RestorePoint &&
751
+ SavePoints == Other.SavePoints &&
752
+ RestorePoints == Other.RestorePoints &&
695
753
IsCalleeSavedInfoValid == Other.IsCalleeSavedInfoValid ;
696
754
}
697
755
};
@@ -723,10 +781,14 @@ template <> struct MappingTraits<MachineFrameInfo> {
723
781
YamlIO.mapOptional (" isCalleeSavedInfoValid" , MFI.IsCalleeSavedInfoValid ,
724
782
false );
725
783
YamlIO.mapOptional (" localFrameSize" , MFI.LocalFrameSize , (unsigned )0 );
726
- YamlIO.mapOptional (" savePoint" , MFI.SavePoint ,
727
- StringValue ()); // Don't print it out when it's empty.
728
- YamlIO.mapOptional (" restorePoint" , MFI.RestorePoint ,
729
- StringValue ()); // Don't print it out when it's empty.
784
+ YamlIO.mapOptional (
785
+ " savePoint" , MFI.SavePoints ,
786
+ SaveRestorePoints (
787
+ StringValue ())); // Don't print it out when it's empty.
788
+ YamlIO.mapOptional (
789
+ " restorePoint" , MFI.RestorePoints ,
790
+ SaveRestorePoints (
791
+ StringValue ())); // Don't print it out when it's empty.
730
792
}
731
793
};
732
794
0 commit comments