@@ -478,9 +478,7 @@ RISCVISAInfo::parseNormalizedArchString(StringRef Arch) {
478
478
" failed to parse major version number" );
479
479
ISAInfo->addExtension (ExtName, {MajorVersion, MinorVersion});
480
480
}
481
- ISAInfo->updateFLen ();
482
- ISAInfo->updateMinVLen ();
483
- ISAInfo->updateMaxELen ();
481
+ ISAInfo->updateImpliedLengths ();
484
482
return std::move (ISAInfo);
485
483
}
486
484
@@ -906,50 +904,51 @@ void RISCVISAInfo::updateCombination() {
906
904
} while (MadeChange);
907
905
}
908
906
909
- void RISCVISAInfo::updateFLen () {
910
- FLen = 0 ;
907
+ void RISCVISAInfo::updateImpliedLengths () {
908
+ assert (FLen == 0 && MaxELenFp == 0 && MaxELen == 0 && MinVLen == 0 &&
909
+ " Expected lengths to be initialied to zero" );
910
+
911
911
// TODO: Handle q extension.
912
912
if (Exts.count (" d" ))
913
913
FLen = 64 ;
914
914
else if (Exts.count (" f" ))
915
915
FLen = 32 ;
916
- }
917
916
918
- void RISCVISAInfo::updateMinVLen () {
919
- for (auto const &Ext : Exts) {
920
- StringRef ExtName = Ext.first ;
921
- bool IsZvlExt = ExtName.consume_front (" zvl" ) && ExtName.consume_back (" b" );
922
- if (IsZvlExt) {
923
- unsigned ZvlLen;
924
- if (!ExtName.getAsInteger (10 , ZvlLen))
925
- MinVLen = std::max (MinVLen, ZvlLen);
926
- }
927
- }
928
- }
929
-
930
- void RISCVISAInfo::updateMaxELen () {
931
- assert (MaxELenFp == 0 && MaxELen == 0 );
932
917
if (Exts.count (" v" )) {
933
918
MaxELenFp = std::max (MaxELenFp, 64u );
934
919
MaxELen = std::max (MaxELen, 64u );
935
920
}
936
921
937
- // handles EEW restriction by sub-extension zve
938
922
for (auto const &Ext : Exts) {
939
923
StringRef ExtName = Ext.first ;
940
- bool IsZveExt = ExtName.consume_front (" zve" );
941
- if (IsZveExt) {
942
- if (ExtName.back () == ' f' )
924
+ // Infer MaxELen and MaxELenFp from Zve(32/64)(x/f/d)
925
+ if (ExtName.consume_front (" zve" )) {
926
+ unsigned ZveELen;
927
+ if (ExtName.consumeInteger (10 , ZveELen))
928
+ continue ;
929
+
930
+ if (ExtName == " f" )
943
931
MaxELenFp = std::max (MaxELenFp, 32u );
944
- else if (ExtName. back () == ' d ' )
932
+ else if (ExtName == " d " )
945
933
MaxELenFp = std::max (MaxELenFp, 64u );
946
- else if (ExtName. back () != ' x ' )
934
+ else if (ExtName != " x " )
947
935
continue ;
948
936
949
- ExtName = ExtName.drop_back ();
950
- unsigned ZveELen;
951
- if (!ExtName.getAsInteger (10 , ZveELen))
952
- MaxELen = std::max (MaxELen, ZveELen);
937
+ MaxELen = std::max (MaxELen, ZveELen);
938
+ continue ;
939
+ }
940
+
941
+ // Infer MinVLen from zvl*b.
942
+ if (ExtName.consume_front (" zvl" )) {
943
+ unsigned ZvlLen;
944
+ if (ExtName.consumeInteger (10 , ZvlLen))
945
+ continue ;
946
+
947
+ if (ExtName != " b" )
948
+ continue ;
949
+
950
+ MinVLen = std::max (MinVLen, ZvlLen);
951
+ continue ;
953
952
}
954
953
}
955
954
}
@@ -975,9 +974,7 @@ llvm::Expected<std::unique_ptr<RISCVISAInfo>>
975
974
RISCVISAInfo::postProcessAndChecking (std::unique_ptr<RISCVISAInfo> &&ISAInfo) {
976
975
ISAInfo->updateImplication ();
977
976
ISAInfo->updateCombination ();
978
- ISAInfo->updateFLen ();
979
- ISAInfo->updateMinVLen ();
980
- ISAInfo->updateMaxELen ();
977
+ ISAInfo->updateImpliedLengths ();
981
978
982
979
if (Error Result = ISAInfo->checkDependency ())
983
980
return std::move (Result);
0 commit comments