[RISCV] Fix the problem of parsing long version numbers
authorShao-Ce SUN <sunshaoce@iscas.ac.cn>
Tue, 28 Jun 2022 03:30:53 +0000 (11:30 +0800)
committerShao-Ce SUN <sunshaoce@iscas.ac.cn>
Tue, 28 Jun 2022 03:48:14 +0000 (11:48 +0800)
For example, when parsing Zbpbo0p911, an error will be reported:
"multi-character extensions must be separated by underscores"

Reviewed By: asb

Differential Revision: https://reviews.llvm.org/D128644

llvm/lib/Support/RISCVISAInfo.cpp

index 6b2614d..1057dba 100644 (file)
@@ -348,7 +348,7 @@ static Error getExtensionVersion(StringRef Ext, StringRef In, unsigned &Major,
 
   if (!MajorStr.empty() && In.consume_front("p")) {
     MinorStr = In.take_while(isDigit);
-    In = In.substr(MajorStr.size() + 1);
+    In = In.substr(MajorStr.size() + MinorStr.size() - 1);
 
     // Expected 'p' to be followed by minor version number.
     if (MinorStr.empty()) {