Lines Matching +full:version +full:- +full:minor
1 //===-- RISCVISAInfo.cpp - RISC-V Arch String Parser ----------------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
29 /// Supported version.
30 RISCVISAUtils::ExtensionVersion Version; member
75 static void PrintExtension(StringRef Name, StringRef Version, in PrintExtension() argument
79 outs() << left_justify(Name, 21) << left_justify(Version, VersionWidth) in PrintExtension()
84 outs() << "All available -march extensions for RISC-V\n\n"; in printSupportedExtensions()
85 PrintExtension("Name", "Version", (DescMap.empty() ? "" : "Description")); in printSupportedExtensions()
89 ExtMap[E.Name] = {E.Version.Major, E.Version.Minor}; in printSupportedExtensions()
91 std::string Version = in printSupportedExtensions() local
92 std::to_string(E.second.Major) + "." + std::to_string(E.second.Minor); in printSupportedExtensions()
93 PrintExtension(E.first, Version, DescMap[E.first]); in printSupportedExtensions()
99 ExtMap[E.Name] = {E.Version.Major, E.Version.Minor}; in printSupportedExtensions()
101 std::string Version = in printSupportedExtensions() local
102 std::to_string(E.second.Major) + "." + std::to_string(E.second.Minor); in printSupportedExtensions()
103 PrintExtension(E.first, Version, DescMap["experimental-" + E.first]); in printSupportedExtensions()
114 outs() << "\nUse -march to specify the target's extension.\n" in printSupportedExtensions()
115 "For example, clang -march=rv32i_v1p0\n"; in printSupportedExtensions()
121 outs() << "Extensions enabled for the given RISC-V target\n\n"; in printEnabledExtensions()
122 PrintExtension("Name", "Version", (DescMap.empty() ? "" : "Description")); in printEnabledExtensions()
128 FullExtMap[E.Name] = {E.Version.Major, E.Version.Minor}; in printEnabledExtensions()
129 ExtMap[E.Name] = {E.Version.Major, E.Version.Minor}; in printEnabledExtensions()
132 std::string Version = in printEnabledExtensions() local
133 std::to_string(E.second.Major) + "." + std::to_string(E.second.Minor); in printEnabledExtensions()
134 PrintExtension(E.first, Version, DescMap[E.first]); in printEnabledExtensions()
141 if (EnabledFeatureNames.count("experimental-" + Name.str()) != 0) { in printEnabledExtensions()
142 FullExtMap[E.Name] = {E.Version.Major, E.Version.Minor}; in printEnabledExtensions()
143 ExtMap[E.Name] = {E.Version.Major, E.Version.Minor}; in printEnabledExtensions()
147 std::string Version = in printEnabledExtensions() local
148 std::to_string(E.second.Major) + "." + std::to_string(E.second.Minor); in printEnabledExtensions()
149 PrintExtension(E.first, Version, DescMap["experimental-" + E.first]); in printEnabledExtensions()
154 outs() << "\nISA String: " << ISAString.get()->toString() << "\n"; in printEnabledExtensions()
158 return Ext.consume_front("experimental-"); in stripExperimentalPrefix()
161 // This function finds the last character that doesn't belong to a version
162 // (e.g. zba1p0 is extension 'zba' of version '1p0'). So the function will
163 // consume [0-9]*p[0-9]* starting from the backward. An extension name will not
166 // have version numbers and no extension name. It assumes the extension name
170 "Already guarded by if-statement in ::parseArchString"); in findLastNonVersionCharacter()
172 int Pos = Ext.size() - 1; in findLastNonVersionCharacter()
174 Pos--; in findLastNonVersionCharacter()
175 if (Pos > 0 && Ext[Pos] == 'p' && isDigit(Ext[Pos - 1])) { in findLastNonVersionCharacter()
176 Pos--; in findLastNonVersionCharacter()
178 Pos--; in findLastNonVersionCharacter()
196 // Find default version of an extension. in findDefaultVersion()
197 // TODO: We might set default version based on profile or ISA spec. in findDefaultVersion()
202 if (I == ExtInfo.end() || I->Name != ExtName) in findDefaultVersion()
205 return I->Version; in findDefaultVersion()
212 return "standard supervisor-level extension"; in getExtensionTypeDesc()
214 return "non-standard user-level extension"; in getExtensionTypeDesc()
216 return "standard user-level extension"; in getExtensionTypeDesc()
234 if (I == std::end(SupportedExperimentalExtensions) || I->Name != Ext) in isExperimentalExtension()
237 return I->Version; in isExperimentalExtension()
248 return I != ExtInfo.end() && I->Name == Ext; in isSupportedExtensionFeature()
257 if (I != ExtInfo.end() && I->Name == Ext) in isSupportedExtension()
271 if (I->Version.Major == MajorVersion && I->Version.Minor == MinorVersion) in isSupportedExtension()
292 // https://github.com/riscv/riscv-isa-manual/blob/main/src/naming.adoc#base-integer-isa) in toFeatures()
293 // and is not recognized in clang -cc1 in toFeatures()
300 Features.push_back((llvm::Twine("+experimental-") + ExtName).str()); in toFeatures()
309 Features.push_back((llvm::Twine("-") + Ext.Name).str()); in toFeatures()
315 Features.push_back((llvm::Twine("-experimental-") + Ext.Name).str()); in toFeatures()
327 return getError("unsupported standard user-level extension '" + ExtName + in getErrorForInvalidExt()
334 // Extensions may have a version number, and may be separated by
336 // Version number is divided into major and minor version numbers,
337 // separated by a 'p'. If the minor version is 0 then 'p0' can be
338 // omitted from the version string. E.g., rv32i2p0, rv32i2, rv32i2p1.
340 unsigned &Minor, unsigned &ConsumeLength, in getExtensionVersion() argument
345 Minor = 0; in getExtensionVersion()
352 In = In.substr(MajorStr.size() + MinorStr.size() - 1); in getExtensionVersion()
354 // Expected 'p' to be followed by minor version number. in getExtensionVersion()
356 return getError("minor version number missing after 'p' for extension '" + in getExtensionVersion()
362 return getError("Failed to parse major version number for extension '" + in getExtensionVersion()
365 if (!MinorStr.empty() && MinorStr.getAsInteger(10, Minor)) in getExtensionVersion()
366 return getError("Failed to parse minor version number for extension '" + in getExtensionVersion()
374 // Expected multi-character extension with version number to have no in getExtensionVersion()
379 "multi-character extensions must be separated by underscores"); in getExtensionVersion()
381 // If experimental extension, require use of current version number in getExtensionVersion()
384 return getError("requires '-menable-experimental-extensions' " in getExtensionVersion()
391 "experimental extension requires explicit version number `" + Ext + in getExtensionVersion()
396 (Major != SupportedVers.Major || Minor != SupportedVers.Minor)) { in getExtensionVersion()
397 std::string Error = "unsupported version number " + MajorStr.str(); in getExtensionVersion()
402 "." + utostr(SupportedVers.Minor) + ")"; in getExtensionVersion()
408 // Exception rule for `g`, we don't have clear version scheme for that on in getExtensionVersion()
415 Major = DefaultVersion->Major; in getExtensionVersion()
416 Minor = DefaultVersion->Minor; in getExtensionVersion()
423 if (RISCVISAInfo::isSupportedExtension(Ext, Major, Minor)) in getExtensionVersion()
429 std::string Error = "unsupported version number " + MajorStr.str(); in getExtensionVersion()
442 ISAInfo->Exts = Exts; in createFromExtMap()
455 assert(ExtName.size() > 1 && (ExtName[0] == '+' || ExtName[0] == '-')); in parseFeatures()
457 ExtName = ExtName.drop_front(1); // Drop '+' or '-' in parseFeatures()
466 // `save-restore`, skip those feature. in parseFeatures()
468 ExtensionInfoIterator->Name != ExtName) in parseFeatures()
472 ISAInfo->Exts[ExtName.str()] = ExtensionInfoIterator->Version; in parseFeatures()
474 ISAInfo->Exts.erase(ExtName.str()); in parseFeatures()
482 // RISC-V ISA strings must be [a-z0-9_] in parseNormalizedArchString()
485 return getError("string may only contain [a-z0-9_]"); in parseNormalizedArchString()
500 // and separated by _. Split by _ and then extract the name and version in parseNormalizedArchString()
516 return getError("extension lacks version in expected format"); in parseNormalizedArchString()
519 return getError("failed to parse minor version number"); in parseNormalizedArchString()
521 // Split Prefix into the extension name and the major version number in parseNormalizedArchString()
525 if (!isDigit(Prefix[VersionStart - 1])) in parseNormalizedArchString()
527 --VersionStart; in parseNormalizedArchString()
530 return getError("extension lacks version in expected format"); in parseNormalizedArchString()
538 return getError("failed to parse major version number"); in parseNormalizedArchString()
545 if (!ISAInfo->Exts in parseNormalizedArchString()
552 ISAInfo->updateImpliedLengths(); in parseNormalizedArchString()
559 // RISC-V ISA strings must be [a-z0-9_] in parseArchString()
562 return getError("string may only contain [a-z0-9_]"); in parseArchString()
577 Arch.starts_with(std::prev(I)->Name); in parseArchString()
581 Arch.starts_with(std::prev(I)->Name)); in parseArchString()
583 return getError("requires '-menable-experimental-extensions' " in parseArchString()
585 std::prev(I)->Name + "'"); in parseArchString()
589 --I; in parseArchString()
590 std::string NewArch = I->MArch.str(); in parseArchString()
591 StringRef ArchWithoutProfile = Arch.drop_front(I->Name.size()); in parseArchString()
610 // Ref: Table 22.1 in RISC-V User-Level ISA V2.2 in parseArchString()
615 unsigned Major, Minor, ConsumeLength; in parseArchString() local
626 StringRef(&Baseline, 1), Arch, Major, Minor, ConsumeLength, in parseArchString()
630 ISAInfo->Exts[std::string(1, Baseline)] = {Major, Minor}; in parseArchString()
635 return getError("version not supported for 'g'"); in parseArchString()
640 // No matter which version is given to `g`, we always set imafd to default in parseArchString()
641 // version since the we don't have clear version scheme for that on in parseArchString()
644 auto Version = findDefaultVersion(Ext); in parseArchString() local
645 assert(Version && "Default extension version not found?"); in parseArchString()
647 ISAInfo->Exts[std::string(Ext)] = {Version->Major, Version->Minor}; in parseArchString()
652 // Consume the base ISA version number and any '_' between rvxxx and the in parseArchString()
673 Desc = "standard user-level extension"; in parseArchString()
677 // general purpose and standard user-level extensions. in parseArchString()
678 // Parse the ISA string containing non-standard user-level in parseArchString()
679 // extensions, standard supervisor-level extensions and in parseArchString()
680 // non-standard supervisor-level extensions. in parseArchString()
682 // version number (major, minor) and are separated by a single in parseArchString()
695 return getError("invalid standard user-level extension '" + in parseArchString()
699 unsigned Major, Minor, ConsumeLength; in parseArchString() local
700 if (auto E = getExtensionVersion(Name, Vers, Major, Minor, ConsumeLength, in parseArchString()
712 if (!ISAInfo->Exts in parseArchString()
714 RISCVISAUtils::ExtensionVersion{Major, Minor}) in parseArchString()
821 auto Version = findDefaultVersion("i"); in updateImplication() local
822 Exts["i"] = *Version; in updateImplication()
845 auto Version = findDefaultVersion(ImpliedExt); in updateImplication() local
846 Exts[ImpliedExt] = *Version; in updateImplication()
854 auto Version = findDefaultVersion("zcf"); in updateImplication() local
855 Exts["zcf"] = *Version; in updateImplication()
881 auto Version = findDefaultVersion(CombineExt); in updateCombination() local
882 Exts[CombineExt.str()] = *Version; in updateCombination()
949 Arch << ExtInfo.Major << "p" << ExtInfo.Minor; in toString()
957 ISAInfo->updateImplication(); in postProcessAndChecking()
958 ISAInfo->updateCombination(); in postProcessAndChecking()
959 ISAInfo->updateImpliedLengths(); in postProcessAndChecking()
961 if (Error Result = ISAInfo->checkDependency()) in postProcessAndChecking()
997 unsigned Major, Minor, ConsumeLength; in isSupportedExtensionWithVersion() local
998 if (auto E = getExtensionVersion(Name, Vers, Major, Minor, ConsumeLength, in isSupportedExtensionWithVersion()
1020 return isExperimentalExtension(Name) ? "experimental-" + Name.str() in getTargetFeatureForExtension()