@@ -634,6 +634,55 @@ LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::CalledGlobal)
634634namespace llvm {
635635namespace yaml {
636636
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+
637686template <> struct MappingTraits <MachineJumpTable> {
638687 static void mapping (IO &YamlIO, MachineJumpTable &JT) {
639688 YamlIO.mapRequired (" kind" , JT.Kind );
@@ -642,6 +691,14 @@ template <> struct MappingTraits<MachineJumpTable> {
642691 }
643692};
644693
694+ } // namespace yaml
695+ } // namespace llvm
696+
697+ LLVM_YAML_IS_SEQUENCE_VECTOR (llvm::yaml::SaveRestorePointEntry)
698+
699+ namespace llvm {
700+ namespace yaml {
701+
645702// / Serializable representation of MachineFrameInfo.
646703// /
647704// / Doesn't serialize attributes like 'StackAlignment', 'IsStackRealignable' and
@@ -669,8 +726,8 @@ struct MachineFrameInfo {
669726 bool HasTailCall = false ;
670727 bool IsCalleeSavedInfoValid = false ;
671728 unsigned LocalFrameSize = 0 ;
672- StringValue SavePoint ;
673- StringValue RestorePoint ;
729+ SaveRestorePoints SavePoints ;
730+ SaveRestorePoints RestorePoints ;
674731
675732 bool operator ==(const MachineFrameInfo &Other) const {
676733 return IsFrameAddressTaken == Other.IsFrameAddressTaken &&
@@ -691,7 +748,8 @@ struct MachineFrameInfo {
691748 HasMustTailInVarArgFunc == Other.HasMustTailInVarArgFunc &&
692749 HasTailCall == Other.HasTailCall &&
693750 LocalFrameSize == Other.LocalFrameSize &&
694- SavePoint == Other.SavePoint && RestorePoint == Other.RestorePoint &&
751+ SavePoints == Other.SavePoints &&
752+ RestorePoints == Other.RestorePoints &&
695753 IsCalleeSavedInfoValid == Other.IsCalleeSavedInfoValid ;
696754 }
697755};
@@ -723,10 +781,14 @@ template <> struct MappingTraits<MachineFrameInfo> {
723781 YamlIO.mapOptional (" isCalleeSavedInfoValid" , MFI.IsCalleeSavedInfoValid ,
724782 false );
725783 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.
730792 }
731793};
732794
0 commit comments