@@ -592,40 +592,39 @@ RISCVISAInfo::parseArchString(StringRef Arch, bool EnableExperimentalExtension,
592
592
return createStringError (errc::invalid_argument,
593
593
" string must be lowercase" );
594
594
595
- if (Arch.starts_with (" rvi" ) || Arch.starts_with (" rva" ) ||
596
- Arch.starts_with (" rvb" ) || Arch.starts_with (" rvm" )) {
595
+ // ISA string must begin with rv32, rv64, or a profile.
596
+ unsigned XLen = 0 ;
597
+ if (Arch.consume_front (" rv32" )) {
598
+ XLen = 32 ;
599
+ } else if (Arch.consume_front (" rv64" )) {
600
+ XLen = 64 ;
601
+ } else {
602
+ // Try parsing as a profile.
597
603
const auto *FoundProfile =
598
604
llvm::find_if (SupportedProfiles, [Arch](const RISCVProfile &Profile) {
599
605
return Arch.starts_with (Profile.Name );
600
606
});
601
607
602
- if (FoundProfile == std::end (SupportedProfiles))
603
- return createStringError (errc::invalid_argument, " unsupported profile" );
604
-
605
- std::string NewArch = FoundProfile->MArch .str ();
606
- StringRef ArchWithoutProfile = Arch.substr (FoundProfile->Name .size ());
607
- if (!ArchWithoutProfile.empty ()) {
608
- if (!ArchWithoutProfile.starts_with (" _" ))
609
- return createStringError (
610
- errc::invalid_argument,
611
- " additional extensions must be after separator '_'" );
612
- NewArch += ArchWithoutProfile.str ();
608
+ if (FoundProfile != std::end (SupportedProfiles)) {
609
+ std::string NewArch = FoundProfile->MArch .str ();
610
+ StringRef ArchWithoutProfile = Arch.drop_front (FoundProfile->Name .size ());
611
+ if (!ArchWithoutProfile.empty ()) {
612
+ if (ArchWithoutProfile.front () != ' _' )
613
+ return createStringError (
614
+ errc::invalid_argument,
615
+ " additional extensions must be after separator '_'" );
616
+ NewArch += ArchWithoutProfile.str ();
617
+ }
618
+ return parseArchString (NewArch, EnableExperimentalExtension,
619
+ ExperimentalExtensionVersionCheck, IgnoreUnknown);
613
620
}
614
- return parseArchString (NewArch, EnableExperimentalExtension,
615
- ExperimentalExtensionVersionCheck, IgnoreUnknown);
616
621
}
617
622
618
- // ISA string must begin with rv32 or rv64.
619
- unsigned XLen = 0 ;
620
- if (Arch.consume_front (" rv32" ))
621
- XLen = 32 ;
622
- else if (Arch.consume_front (" rv64" ))
623
- XLen = 64 ;
624
-
625
623
if (XLen == 0 || Arch.empty ())
626
624
return createStringError (
627
625
errc::invalid_argument,
628
- " string must begin with rv32{i,e,g} or rv64{i,e,g}" );
626
+ " string must begin with rv32{i,e,g}, rv64{i,e,g}, or a supported "
627
+ " profile name" );
629
628
630
629
std::unique_ptr<RISCVISAInfo> ISAInfo (new RISCVISAInfo (XLen));
631
630
MapVector<std::string, RISCVISAUtils::ExtensionVersion,
0 commit comments