diff --git a/llvm/lib/Support/RISCVISAInfo.cpp b/llvm/lib/Support/RISCVISAInfo.cpp --- a/llvm/lib/Support/RISCVISAInfo.cpp +++ b/llvm/lib/Support/RISCVISAInfo.cpp @@ -71,6 +71,18 @@ return Ext.consume_front("experimental-"); } +static size_t findFirstNonVersionCharacter(const StringRef &Ext) { + int Pos = Ext.size() - 1; + while (Pos >= 0 && isDigit(Ext[Pos])) + Pos--; + if (Pos > 0 && Ext[Pos] == 'p' && isDigit(Ext[Pos - 1])) { + Pos--; + while (Pos >= 0 && isDigit(Ext[Pos])) + Pos--; + } + return Pos; +} + struct FindByName { FindByName(StringRef Ext) : Ext(Ext){}; StringRef Ext; @@ -637,7 +649,7 @@ StringRef Type = getExtensionType(Ext); StringRef Desc = getExtensionTypeDesc(Ext); - auto Pos = Ext.find_if(isDigit); + auto Pos = findFirstNonVersionCharacter(Ext) + 1; StringRef Name(Ext.substr(0, Pos)); StringRef Vers(Ext.substr(Pos));