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 @@ -15,6 +15,7 @@ #include "llvm/Support/raw_ostream.h" #include +#include #include #include @@ -64,6 +65,7 @@ {"zvamo", RISCVExtensionVersion{0, 10}}, {"zvlsseg", RISCVExtensionVersion{0, 10}}, + {"zvl128b", RISCVExtensionVersion{0, 10}}, {"zfh", RISCVExtensionVersion{0, 1}}, }; @@ -72,6 +74,18 @@ return Ext.consume_front("experimental-"); } +static size_t findFirstNonVersionCharacter(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; +} + void RISCVISAInfo::addExtension(StringRef ExtName, unsigned MajorVersion, unsigned MinorVersion) { RISCVExtensionInfo Ext; @@ -612,7 +626,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));