@@ -721,6 +721,16 @@ RISCVISAInfo::parseArchString(StringRef Arch, bool EnableExperimentalExtension,
721
721
return RISCVISAInfo::postProcessAndChecking (std::move (ISAInfo));
722
722
}
723
723
724
+ static Error getIncompatibleError (StringRef Ext1, StringRef Ext2) {
725
+ return getError (" '" + Ext1 + " ' and '" + Ext2 +
726
+ " ' extensions are incompatible" );
727
+ }
728
+
729
+ static Error getExtensionRequiresError (StringRef Ext, StringRef ReqExt) {
730
+ return getError (" '" + Ext + " ' requires '" + ReqExt +
731
+ " ' extension to also be specified" );
732
+ }
733
+
724
734
Error RISCVISAInfo::checkDependency () {
725
735
bool HasE = Exts.count (" e" ) != 0 ;
726
736
bool HasI = Exts.count (" i" ) != 0 ;
@@ -733,29 +743,24 @@ Error RISCVISAInfo::checkDependency() {
733
743
bool HasZcmt = Exts.count (" zcmt" ) != 0 ;
734
744
735
745
if (HasI && HasE)
736
- return getError ( " 'I' and 'E' extensions are incompatible " );
746
+ return getIncompatibleError ( " I " , " E " );
737
747
738
748
if (HasF && HasZfinx)
739
- return getError ( " 'f' and ' zfinx' extensions are incompatible " );
749
+ return getIncompatibleError ( " f " , " zfinx" );
740
750
741
751
if (HasZvl && !HasVector)
742
- return getError (Twine (" '" ) + " zvl*b" +
743
- " ' requires 'v' or 'zve*' extension to also be specified" );
752
+ return getExtensionRequiresError (" zvl*b" , " v' or 'zve*" );
744
753
745
754
if (!HasVector)
746
755
for (auto Ext :
747
756
{" zvbb" , " zvbc32e" , " zvkb" , " zvkg" , " zvkgs" , " zvkned" , " zvknha" , " zvksed" , " zvksh" })
748
757
if (Exts.count (Ext))
749
- return getError (
750
- Twine (" '" ) + Ext +
751
- " ' requires 'v' or 'zve*' extension to also be specified" );
758
+ return getExtensionRequiresError (Ext, " v' or 'zve*" );
752
759
753
760
if (!Exts.count (" zve64x" ))
754
761
for (auto Ext : {" zvknhb" , " zvbc" })
755
762
if (Exts.count (Ext))
756
- return getError (
757
- Twine (" '" ) + Ext +
758
- " ' requires 'v' or 'zve64*' extension to also be specified" );
763
+ return getExtensionRequiresError (Ext, " v' or 'zve64*" );
759
764
760
765
if ((HasZcmt || Exts.count (" zcmp" )) && HasD && (HasC || Exts.count (" zcd" )))
761
766
return getError (Twine (" '" ) + (HasZcmt ? " zcmt" : " zcmp" ) +
@@ -769,19 +774,17 @@ Error RISCVISAInfo::checkDependency() {
769
774
if (!(Exts.count (" a" ) || Exts.count (" zaamo" )))
770
775
for (auto Ext : {" zacas" , " zabha" })
771
776
if (Exts.count (Ext))
772
- return getError (
773
- Twine (" '" ) + Ext +
774
- " ' requires 'a' or 'zaamo' extension to also be specified" );
777
+ return getExtensionRequiresError (Ext, " a' or 'zaamo" );
775
778
776
779
if (Exts.count (" xwchc" ) != 0 ) {
777
780
if (XLen != 32 )
778
781
return getError (" 'Xwchc' is only supported for 'rv32'" );
779
782
780
783
if (HasD)
781
- return getError ( " 'D' and ' Xwchc' extensions are incompatible " );
784
+ return getIncompatibleError ( " D " , " Xwchc" );
782
785
783
786
if (Exts.count (" zcb" ) != 0 )
784
- return getError ( " ' Xwchc' and ' Zcb' extensions are incompatible " );
787
+ return getIncompatibleError ( " Xwchc" , " Zcb" );
785
788
}
786
789
787
790
return Error::success ();
0 commit comments