26#define GET_EXTENSION_STRTAB
27#include "llvm/TargetParser/RISCVTargetParserDef.inc"
31struct RISCVSupportedExtension {
38 bool operator<(
const RISCVSupportedExtension &
RHS)
const {
57#define GET_SUPPORTED_EXTENSIONS
58#include "llvm/TargetParser/RISCVTargetParserDef.inc"
60#define GET_SUPPORTED_PROFILES
61#include "llvm/TargetParser/RISCVTargetParserDef.inc"
65 static std::atomic<bool> TableChecked(
false);
66 if (!TableChecked.load(std::memory_order_relaxed)) {
68 "Extensions are not sorted by name");
70 "Experimental extensions are not sorted by name");
72 "Profiles are not sorted by name");
74 "Experimental profiles are not sorted by name");
75 TableChecked.store(
true, std::memory_order_relaxed);
83 unsigned VersionWidth = Description.
empty() ? 0 : 10;
85 << Description <<
"\n";
89 outs() <<
"All available -march extensions for RISC-V\n\n";
93 for (
const auto &E : SupportedExtensions)
94 ExtMap[E.name().str()] = {E.Version.Major, E.Version.Minor};
95 for (
const auto &E : ExtMap) {
97 std::to_string(E.second.Major) +
"." + std::to_string(E.second.Minor);
101 outs() <<
"\nExperimental extensions\n";
103 for (
const auto &E : SupportedExperimentalExtensions)
104 ExtMap[E.name().str()] = {E.Version.Major, E.Version.Minor};
105 for (
const auto &E : ExtMap) {
107 std::to_string(E.second.Major) +
"." + std::to_string(E.second.Minor);
111 outs() <<
"\nSupported Profiles\n";
112 for (
const auto &
P : SupportedProfiles)
115 outs() <<
"\nExperimental Profiles\n";
116 for (
const auto &
P : SupportedExperimentalProfiles)
119 outs() <<
"\nUse -march to specify the target's extension.\n"
120 "For example, clang -march=rv32i_v1p0\n";
124 bool IsRV64, std::set<StringRef> &EnabledFeatureNames,
126 outs() <<
"Extensions enabled for the given RISC-V target\n\n";
131 for (
const auto &E : SupportedExtensions)
132 if (EnabledFeatureNames.count(E.name()) != 0) {
133 FullExtMap[E.name().str()] = {E.Version.Major, E.Version.Minor};
134 ExtMap[E.name().str()] = {E.Version.Major, E.Version.Minor};
136 for (
const auto &E : ExtMap) {
138 std::to_string(E.second.Major) +
"." + std::to_string(E.second.Minor);
142 outs() <<
"\nExperimental extensions\n";
144 for (
const auto &E : SupportedExperimentalExtensions) {
145 if (EnabledFeatureNames.count(
"experimental-" + E.name().str()) != 0) {
146 FullExtMap[E.name().str()] = {E.Version.Major, E.Version.Minor};
147 ExtMap[E.name().str()] = {E.Version.Major, E.Version.Minor};
150 for (
const auto &E : ExtMap) {
152 std::to_string(E.second.Major) +
"." + std::to_string(E.second.Minor);
156 unsigned XLen = IsRV64 ? 64 : 32;
158 outs() <<
"\nISA String: " << ISAString.get()->toString() <<
"\n";
174 "Already guarded by if-statement in ::parseArchString");
176 int Pos = Ext.
size() - 1;
177 while (Pos > 0 &&
isDigit(Ext[Pos]))
179 if (Pos > 0 && Ext[Pos] ==
'p' &&
isDigit(Ext[Pos - 1])) {
181 while (Pos > 0 &&
isDigit(Ext[Pos]))
189 bool operator()(
const RISCVSupportedExtension &
LHS, StringRef
RHS) {
192 bool operator()(StringRef
LHS,
const RISCVSupportedExtension &
RHS) {
198static std::optional<RISCVISAUtils::ExtensionVersion>
202 for (
auto &ExtInfo : {
ArrayRef(SupportedExtensions),
203 ArrayRef(SupportedExperimentalExtensions)}) {
206 if (
I == ExtInfo.end() ||
I->name() != ExtName)
216 return "standard supervisor-level extension";
218 return "non-standard user-level extension";
220 return "standard user-level extension";
234static std::optional<RISCVISAUtils::ExtensionVersion>
238 if (
I == std::end(SupportedExperimentalExtensions) ||
I->name() != Ext)
248 IsExperimental ?
ArrayRef(SupportedExperimentalExtensions)
252 return I != ExtInfo.
end() &&
I->name() == Ext;
258 for (
auto ExtInfo : {
ArrayRef(SupportedExtensions),
259 ArrayRef(SupportedExperimentalExtensions)}) {
261 if (
I != ExtInfo.end() &&
I->name() == Ext)
269 unsigned MinorVersion) {
270 for (
auto ExtInfo : {
ArrayRef(SupportedExtensions),
271 ArrayRef(SupportedExperimentalExtensions)}) {
273 std::equal_range(ExtInfo.begin(), ExtInfo.end(), Ext, LessExtName());
275 if (
I->Version.Major == MajorVersion &&
I->Version.Minor == MinorVersion)
288 return Exts.count(Ext) != 0;
292 bool IgnoreUnknown)
const {
293 std::vector<std::string> Features;
294 for (
const auto &[ExtName,
_] : Exts) {
299 Features.push_back((
llvm::Twine(
"+experimental-") + ExtName).str());
301 Features.push_back((
llvm::Twine(
"+") + ExtName).str());
304 if (AddAllExtensions) {
305 for (
const RISCVSupportedExtension &Ext : SupportedExtensions) {
306 if (Exts.count(Ext.name()))
308 Features.push_back((
llvm::Twine(
"-") + Ext.name()).str());
311 for (
const RISCVSupportedExtension &Ext : SupportedExperimentalExtensions) {
312 if (Exts.count(Ext.name()))
314 Features.push_back((
llvm::Twine(
"-experimental-") + Ext.name()).str());
325 if (ExtName.
size() == 1) {
326 return getError(
"unsupported standard user-level extension '" + ExtName +
339 unsigned &Minor,
unsigned &ConsumeLength,
340 bool EnableExperimentalExtension,
341 bool ExperimentalExtensionVersionCheck) {
346 MajorStr = In.take_while(
isDigit);
347 In = In.substr(MajorStr.
size());
349 if (!MajorStr.
empty() && In.consume_front(
"p")) {
350 MinorStr = In.take_while(
isDigit);
351 In = In.substr(MajorStr.
size() + MinorStr.
size() - 1);
354 if (MinorStr.
empty()) {
355 return getError(
"minor version number missing after 'p' for extension '" +
361 return getError(
"Failed to parse major version number for extension '" +
365 return getError(
"Failed to parse minor version number for extension '" +
368 ConsumeLength = MajorStr.
size();
370 if (!MinorStr.
empty())
371 ConsumeLength += MinorStr.
size() + 1 ;
376 if (Ext.
size() > 1 && In.size())
378 "multi-character extensions must be separated by underscores");
382 if (!EnableExperimentalExtension)
383 return getError(
"requires '-menable-experimental-extensions' "
384 "for experimental extension '" +
387 if (ExperimentalExtensionVersionCheck &&
390 "experimental extension requires explicit version number `" + Ext +
393 auto SupportedVers = *ExperimentalExtension;
394 if (ExperimentalExtensionVersionCheck &&
395 (Major != SupportedVers.Major || Minor != SupportedVers.Minor)) {
396 std::string
Error =
"unsupported version number " + MajorStr.
str();
397 if (!MinorStr.
empty())
399 Error +=
" for experimental extension '" + Ext.
str() +
400 "' (this compiler supports " +
utostr(SupportedVers.Major) +
401 "." +
utostr(SupportedVers.Minor) +
")";
428 std::string
Error =
"unsupported version number " + MajorStr.
str();
429 if (!MinorStr.
empty())
431 Error +=
" for extension '" + Ext.
str() +
"'";
438 assert(XLen == 32 || XLen == 64);
439 std::unique_ptr<RISCVISAInfo> ISAInfo(
new RISCVISAInfo(XLen));
441 ISAInfo->Exts = Exts;
443 return RISCVISAInfo::postProcessAndChecking(std::move(ISAInfo));
448 const std::vector<std::string> &Features) {
449 assert(XLen == 32 || XLen == 64);
450 std::unique_ptr<RISCVISAInfo> ISAInfo(
new RISCVISAInfo(XLen));
453 assert(ExtName.size() > 1 && (ExtName[0] ==
'+' || ExtName[0] ==
'-'));
454 bool Add = ExtName[0] ==
'+';
455 ExtName = ExtName.drop_front(1);
457 auto ExtensionInfos = Experimental
458 ?
ArrayRef(SupportedExperimentalExtensions)
460 auto ExtensionInfoIterator =
465 if (ExtensionInfoIterator == ExtensionInfos.end() ||
466 ExtensionInfoIterator->name() != ExtName)
470 ISAInfo->Exts[ExtName.str()] = ExtensionInfoIterator->Version;
472 ISAInfo->Exts.erase(ExtName.str());
475 return RISCVISAInfo::postProcessAndChecking(std::move(ISAInfo));
483 return getError(
"string may only contain [a-z0-9_]");
492 auto IsBaseISA = [](
char C) {
return C ==
'i' ||
C ==
'e' ||
C ==
'y'; };
493 if (XLen == 0 || Arch.
empty() || !IsBaseISA(Arch[0]))
494 return getError(
"arch string must begin with valid base ISA");
495 char BaseISA = Arch[0];
497 std::unique_ptr<RISCVISAInfo> ISAInfo(
new RISCVISAInfo(XLen));
502 while (!Arch.
empty()) {
503 if (Arch[0] ==
'_') {
504 if (Arch.
size() == 1 || Arch[1] ==
'_')
505 return getError(
"extension name missing after separator '_'");
509 size_t Idx = Arch.
find(
'_');
514 std::tie(Prefix, MinorVersionStr) = Ext.
rsplit(
'p');
515 if (MinorVersionStr.
empty())
516 return getError(
"extension lacks version in expected format");
517 unsigned MajorVersion, MinorVersion;
519 return getError(
"failed to parse minor version number");
523 size_t VersionStart = Prefix.size();
524 while (VersionStart != 0) {
525 if (!
isDigit(Prefix[VersionStart - 1]))
529 if (VersionStart == Prefix.size())
530 return getError(
"extension lacks version in expected format");
532 if (VersionStart == 0)
533 return getError(
"missing extension name");
535 StringRef ExtName = Prefix.slice(0, VersionStart);
536 StringRef MajorVersionStr = Prefix.substr(VersionStart);
538 return getError(
"failed to parse major version number");
540 if (IsBaseISA(ExtName[0])) {
541 if (ExtName.
size() > 1)
543 "' is missing version number");
544 if (ExtName[0] != BaseISA)
545 return getError(
"conflicting base ISAs '" +
Twine(BaseISA) +
"' and '" +
548 ExtName.
size() > 1) {
550 "' is missing version number");
553 if ((ExtName[0] ==
'z' || ExtName[0] ==
's' || ExtName[0] ==
'x') &&
556 "' must be followed by a letter");
563 return getError(
"duplicate extension '" + ExtName +
"'");
569 ISAInfo->updateImpliedLengths();
570 return std::move(ISAInfo);
575 bool ExperimentalExtensionVersionCheck) {
579 return getError(
"string may only contain [a-z0-9_]");
593 bool FoundProfile =
I != std::begin(SupportedProfiles) &&
597 FoundProfile = (
I != std::begin(SupportedExperimentalProfiles) &&
599 if (FoundProfile && !EnableExperimentalExtension) {
600 return getError(
"requires '-menable-experimental-extensions' "
602 std::prev(
I)->Name +
"'");
607 std::string NewArch =
I->MArch.str();
609 if (!ArchWithoutProfile.
empty()) {
610 if (ArchWithoutProfile.
front() !=
'_')
611 return getError(
"additional extensions must be after separator '_'");
612 NewArch += ArchWithoutProfile.
str();
615 ExperimentalExtensionVersionCheck);
619 if (XLen == 0 || Arch.
empty())
621 "string must begin with rv32{i,e,g,y}, rv64{i,e,g,y}, or a supported "
624 std::unique_ptr<RISCVISAInfo> ISAInfo(
new RISCVISAInfo(XLen));
628 char Baseline = Arch.
front();
632 unsigned Major, Minor, ConsumeLength;
638 "\' should be 'e', 'i', 'g' or 'y'");
647 StringRef(&Baseline, 1), Arch, Major, Minor, ConsumeLength,
648 EnableExperimentalExtension, ExperimentalExtensionVersionCheck))
651 ISAInfo->Exts[std::string(1, Baseline)] = {Major, Minor};
656 return getError(
"version not supported for 'g'");
667 ISAInfo->Exts[std::string(Ext)] = {
Version->Major,
Version->Minor};
676 while (!Arch.
empty()) {
677 if (Arch.
front() ==
'_') {
678 if (Arch.
size() == 1 || Arch[1] ==
'_')
679 return getError(
"extension name missing after separator '_'");
683 size_t Idx = Arch.
find(
'_');
693 Desc =
"standard user-level extension";
694 }
else if (Ext.
front() ==
'z' || Ext.
front() ==
's' ||
695 Ext.
front() ==
'x') {
707 Name = Ext.
substr(0, Pos);
712 if (Name.size() ==
Type.size())
715 return getError(
"invalid standard user-level extension '" +
719 unsigned Major, Minor, ConsumeLength;
721 EnableExperimentalExtension,
722 ExperimentalExtensionVersionCheck))
725 if (Name.size() == 1)
726 Ext = Ext.
substr(ConsumeLength);
736 return getError(
"duplicated " +
Desc +
" '" + Name +
"'");
738 }
while (!Ext.
empty());
743 if (Baseline ==
'g') {
745 if (ISAInfo->Exts.count(Ext))
750 ISAInfo->Exts[std::string(Ext)] = {
Version->Major,
Version->Minor};
754 return RISCVISAInfo::postProcessAndChecking(std::move(ISAInfo));
758 return getError(
"'" + Ext1 +
"' and '" + Ext2 +
759 "' extensions are incompatible");
763 return getError(
"'" + Ext +
"' is incompatible with " +
Base +
" base");
767 return getError(
"'" + Ext +
"' requires '" + ReqExt +
768 "' extension to also be specified");
771Error RISCVISAInfo::checkDependency() {
772 bool HasE = Exts.count(
"e") != 0;
773 bool HasI = Exts.count(
"i") != 0;
774 bool HasF = Exts.count(
"f") != 0;
775 bool HasD = Exts.count(
"d") != 0;
776 bool HasZfinx = Exts.count(
"zfinx") != 0;
777 bool HasVector = Exts.count(
"zve32x") != 0;
778 bool HasZvl = MinVLen != 0;
779 bool HasZcmp = Exts.count(
"zcmp") != 0;
780 bool HasXqccmp = Exts.count(
"xqccmp") != 0;
781 bool HasZcmt = Exts.count(
"zcmt") != 0;
782 bool HasXqccmt = Exts.count(
"xqccmt") != 0;
784 static constexpr StringLiteral ZcdOverlaps[] = {
785 {
"zcmt"}, {
"zcmp"}, {
"xqccmi"}, {
"xqccmp"},
786 {
"xqccmt"}, {
"xqciac"}, {
"xqcicm"},
788 static constexpr StringLiteral RV32Only[] = {
789 {
"zcf"}, {
"zclsd"}, {
"zilsd"}, {
"xwchc"}, {
"xqccmi"},
790 {
"xqci"}, {
"xqcia"}, {
"xqciac"}, {
"xqcibi"}, {
"xqcibm"},
791 {
"xqcicli"}, {
"xqcicm"}, {
"xqcics"}, {
"xqcicsr"}, {
"xqciint"},
792 {
"xqciio"}, {
"xqcilb"}, {
"xqcili"}, {
"xqcilia"}, {
"xqcilo"},
793 {
"xqcilsm"}, {
"xqcisim"}, {
"xqcisls"}, {
"xqcisync"},
799 if (HasF && HasZfinx)
802 if (HasZvl && !HasVector)
805 if (Exts.count(
"xsfvfbfexp16e") &&
806 !(Exts.count(
"zvfbfmin") || Exts.count(
"zvfbfa")))
808 "'xsfvfbfexp16e' requires 'zvfbfmin' or "
809 "'zvfbfa' extension to also be specified");
811 if (Exts.count(
"zcd"))
812 for (
auto Ext : ZcdOverlaps)
817 for (
auto Ext : RV32Only)
819 return getError(Twine(
"'") + Ext +
"' is only supported for 'rv32'");
821 if (Exts.count(
"xwchc") != 0) {
825 if (Exts.count(
"zcb") != 0)
829 if (Exts.count(
"zclsd") != 0 && Exts.count(
"zcf") != 0)
832 if (Exts.count(
"y") != 0) {
835 if (Exts.count(
"zclsd") != 0)
837 if (Exts.count(
"zcf") != 0)
841 if (Exts.count(
"zcd") != 0)
843 for (
auto Ext : ZcdOverlaps)
849 if (HasZcmp && HasXqccmp)
852 if (HasZcmt && HasXqccmt)
878#define GET_IMPLIED_EXTENSIONS
879#include "llvm/TargetParser/RISCVTargetParserDef.inc"
881void RISCVISAInfo::updateImplication() {
887 for (
auto const &Ext : Exts)
890 while (!WorkList.
empty()) {
892 auto Range = std::equal_range(std::begin(ImpliedExts),
893 std::end(ImpliedExts), ExtName);
895 StringRef ImpliedExt = Implied.impliedExt();
896 auto [It, Inserted] = Exts.try_emplace(ImpliedExt.
str());
900 It->second = *Version;
906 if (Exts.count(
"c") && Exts.count(
"d") && !Exts.count(
"zcd") &&
907 (XLen == 32 || !Exts.count(
"y"))) {
909 Exts[
"zcd"] = *Version;
913 if (XLen == 32 && Exts.count(
"c") && Exts.count(
"f") && !Exts.count(
"zcf") &&
916 Exts[
"zcf"] = *Version;
920 if (XLen == 32 && Exts.count(
"zce") && Exts.count(
"f") &&
921 !Exts.count(
"zcf") && !Exts.count(
"y")) {
923 Exts[
"zcf"] = *Version;
941 if (Exts.count(
"zca") && !Exts.count(
"c")) {
942 bool ShouldAddC =
false;
946 Exts.count(
"zcd") && (Exts.count(
"y") || Exts.count(
"zcf"));
947 else if (Exts.count(
"f"))
948 ShouldAddC = Exts.count(
"y") || Exts.count(
"zcf");
951 }
else if (XLen == 64) {
953 ShouldAddC = Exts.count(
"y") || Exts.count(
"zcd");
959 Exts[
"c"] = *Version;
963 if (!Exts.count(
"zce") && Exts.count(
"zca") && Exts.count(
"zcb") &&
964 Exts.count(
"zcmp") && Exts.count(
"zcmt")) {
965 bool ShouldAddZce =
false;
967 ShouldAddZce = !Exts.count(
"f") || Exts.count(
"zcf") || Exts.count(
"y");
968 }
else if (XLen == 64) {
970 ShouldAddZce = !Exts.count(
"y");
978 bool HasE = Exts.count(
"e") != 0;
979 bool HasI = Exts.count(
"i") != 0;
983 if (!HasE && !HasI) {
985 Exts[
"i"] = *Version;
993 {
"a"}, {
"b"}, {
"zk"}, {
"zkn"}, {
"zks"},
994 {
"zvkn"}, {
"zvknc"}, {
"zvkng"}, {
"zvks"}, {
"zvksc"},
995 {
"zvksg"}, {
"xqci"}, {
"xsfmm32a"},
998void RISCVISAInfo::updateCombination() {
999 bool MadeChange =
false;
1003 if (Exts.count(CombineExt))
1008 auto Range = std::equal_range(std::begin(ImpliedExts),
1009 std::end(ImpliedExts), CombineExt);
1010 bool HasAllRequiredFeatures = std::all_of(
1011 Range.first,
Range.second, [&](
const ImpliedExtsEntry &Implied) {
1012 return Exts.count(Implied.impliedExt());
1014 if (HasAllRequiredFeatures) {
1016 Exts[CombineExt.str()] = *
Version;
1020 }
while (MadeChange);
1023void RISCVISAInfo::updateImpliedLengths() {
1024 assert(FLen == 0 && MaxELenFp == 0 && MaxELen == 0 && MinVLen == 0 &&
1025 "Expected lengths to be initialied to zero");
1027 if (Exts.count(
"q"))
1029 else if (Exts.count(
"d"))
1031 else if (Exts.count(
"f"))
1034 if (Exts.count(
"v")) {
1035 MaxELenFp = std::max(MaxELenFp, 64u);
1036 MaxELen = std::max(MaxELen, 64u);
1039 for (
auto const &Ext : Exts) {
1040 StringRef ExtName = Ext.first;
1048 MaxELenFp = std::max(MaxELenFp, 32u);
1049 else if (ExtName ==
"d")
1050 MaxELenFp = std::max(MaxELenFp, 64u);
1051 else if (ExtName !=
"x")
1054 MaxELen = std::max(MaxELen, ZveELen);
1067 MinVLen = std::max(MinVLen, ZvlLen);
1077 Arch <<
"rv" << XLen;
1079 bool HasY = Exts.count(
"y") != 0;
1081 for (
auto const &Ext : Exts) {
1091 auto ExtInfo = Ext.second;
1092 Arch << LS << ExtName;
1093 Arch << ExtInfo.Major <<
"p" << ExtInfo.Minor;
1100RISCVISAInfo::postProcessAndChecking(std::unique_ptr<RISCVISAInfo> &&ISAInfo) {
1101 ISAInfo->updateImplication();
1102 ISAInfo->updateCombination();
1103 ISAInfo->updateImpliedLengths();
1105 if (
Error Result = ISAInfo->checkDependency())
1106 return std::move(Result);
1107 return std::move(ISAInfo);
1111 bool HasY = Exts.
count(
"y") != 0;
1113 if (Exts.count(
"xcheriot"))
1115 if (Exts.count(
"e"))
1116 return HasY ?
"il32pc64e" :
"ilp32e";
1117 if (Exts.count(
"d"))
1118 return HasY ?
"il32pc64d" :
"ilp32d";
1119 if (Exts.count(
"f"))
1120 return HasY ?
"il32pc64f" :
"ilp32f";
1121 return HasY ?
"il32pc64" :
"ilp32";
1122 }
else if (XLen == 64) {
1124 if (Exts.count(
"e"))
1126 if (Exts.count(
"d"))
1127 return HasY ?
"l64pc128d" :
"lp64d";
1128 if (Exts.count(
"f"))
1129 return HasY ?
"l64pc128f" :
"lp64f";
1130 return HasY ?
"l64pc128" :
"lp64";
1145 unsigned Major, Minor, ConsumeLength;
1157 return std::string();
1163 return std::string();
1166 return std::string();
1178#define GET_RISCVExtensionBitmaskTable_IMPL
1179#include "llvm/TargetParser/RISCVTargetParserDef.inc"
1185 for (
auto E : ExtensionBitmask)
1187 return std::make_pair(E.GroupID, E.BitPosition);
1188 return std::make_pair(-1, -1);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
static void verifyTables()
static StringRef getExtensionTypeDesc(StringRef Ext)
static const char * RISCVGImplicationsZi[]
static std::optional< RISCVISAUtils::ExtensionVersion > findDefaultVersion(StringRef ExtName)
static size_t findLastNonVersionCharacter(StringRef Ext)
static Error getExtensionRequiresError(StringRef Ext, StringRef ReqExt)
static StringRef getExtensionType(StringRef Ext)
static Error getErrorForInvalidExt(StringRef ExtName)
static constexpr StringLiteral CombineIntoExts[]
static bool stripExperimentalPrefix(StringRef &Ext)
static std::optional< RISCVISAUtils::ExtensionVersion > isExperimentalExtension(StringRef Ext)
static void PrintExtension(StringRef Name, StringRef Version, StringRef Description)
static Error getBaseIncompatibleError(StringRef Ext, StringRef Base)
static Error getExtensionVersion(StringRef Ext, StringRef In, unsigned &Major, unsigned &Minor, unsigned &ConsumeLength, bool EnableExperimentalExtension, bool ExperimentalExtensionVersionCheck)
static Error getIncompatibleError(StringRef Ext1, StringRef Ext2)
static Error getError(const Twine &Message)
static const char * RISCVGImplications[]
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
static void verifyTables()
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
A helper class to return the specified delimiter string after the first invocation of operator String...
static LLVM_ABI bool isSupportedExtensionFeature(StringRef Ext)
static LLVM_ABI std::string getTargetFeatureForExtension(StringRef Ext)
static LLVM_ABI llvm::Expected< std::unique_ptr< RISCVISAInfo > > parseNormalizedArchString(StringRef Arch)
Parse RISC-V ISA info from an arch string that is already in normalized form (as defined in the psABI...
LLVM_ABI bool hasExtension(StringRef Ext) const
RISCVISAInfo(const RISCVISAInfo &)=delete
LLVM_ABI std::string toString() const
LLVM_ABI StringRef computeDefaultABI() const
static LLVM_ABI llvm::Expected< std::unique_ptr< RISCVISAInfo > > parseArchString(StringRef Arch, bool EnableExperimentalExtension, bool ExperimentalExtensionVersionCheck=true)
Parse RISC-V ISA info from arch string.
static LLVM_ABI bool isSupportedExtension(StringRef Ext)
static LLVM_ABI void printEnabledExtensions(bool IsRV64, std::set< StringRef > &EnabledFeatureNames, StringMap< StringRef > &DescMap)
static LLVM_ABI void printSupportedExtensions(StringMap< StringRef > &DescMap)
static LLVM_ABI llvm::Expected< std::unique_ptr< RISCVISAInfo > > parseFeatures(unsigned XLen, const std::vector< std::string > &Features)
Parse RISC-V ISA info from feature vector.
static LLVM_ABI std::pair< int, int > getRISCVFeaturesBitsInfo(StringRef Ext)
Return the group id and bit position of __riscv_feature_bits.
static LLVM_ABI llvm::Expected< std::unique_ptr< RISCVISAInfo > > createFromExtMap(unsigned XLen, const RISCVISAUtils::OrderedExtensionMap &Exts)
LLVM_ABI std::vector< std::string > toFeatures(bool AddAllExtensions=false, bool IgnoreUnknown=true) const
Convert RISC-V ISA info to a feature vector.
static LLVM_ABI bool isSupportedExtensionWithVersion(StringRef Ext)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
A wrapper around a string literal that serves as a proxy for constructing global tables of StringRefs...
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Represent a constant reference to a string, i.e.
bool consumeInteger(unsigned Radix, T &Result)
Parse the current string as an integer of the specified radix.
bool getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
std::string str() const
Get the contents as an std::string.
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
constexpr bool empty() const
Check if the string is empty.
StringRef drop_front(size_t N=1) const
Return a StringRef equal to 'this' but with the first N elements dropped.
StringRef slice(size_t Start, size_t End) const
Return a reference to the substring from [Start, End).
constexpr size_t size() const
Get the string size.
char front() const
Get the first character in the string.
StringRef take_front(size_t N=1) const
Return a StringRef equal to 'this' but with only the first N elements remaining.
size_t find(char C, size_t From=0) const
Search for the first character C in the string.
size_t count(char C) const
Return the number of occurrences of C in the string.
std::pair< StringRef, StringRef > rsplit(StringRef Separator) const
Split into two substrings around the last occurrence of a separator string.
bool consume_front(char Prefix)
Returns true if this StringRef has the given prefix and removes that prefix.
bool equals_insensitive(StringRef RHS) const
Check for string equality, ignoring case.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
The instances of the Type class are immutable: once they are created, they are never changed.
raw_ostream & indent(unsigned NumSpaces)
indent - Insert 'NumSpaces' spaces.
A raw_ostream that writes to an std::string.
std::string & str()
Returns the string's reference.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr StringLiteral AllStdExts
std::map< std::string, ExtensionVersion, ExtensionComparator > OrderedExtensionMap
OrderedExtensionMap is std::map, it's specialized to keep entries in canonical order of extension.
static constexpr uint64_t DefaultVersion
This is an optimization pass for GlobalISel generic memory operations.
bool operator<(int64_t V1, const APSInt &V2)
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
bool isLower(char C)
Checks if character C is a lowercase letter as classified by "C" locale.
LLVM_ABI raw_fd_ostream & outs()
This returns a reference to a raw_fd_ostream for standard output.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
std::string utostr(uint64_t X, bool isNeg=false)
auto upper_bound(R &&Range, T &&Value)
Provide wrappers to std::upper_bound which take ranges instead of having to pass begin/end explicitly...
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
bool isDigit(char C)
Checks if character C is one of the 10 decimal digits.
bool is_sorted(R &&Range, Compare C)
Wrapper function around std::is_sorted to check if elements in a range R are sorted with respect to a...
FormattedString left_justify(StringRef Str, unsigned Width)
left_justify - append spaces after string so total output is Width characters.
auto lower_bound(R &&Range, T &&Value)
Provide wrappers to std::lower_bound which take ranges instead of having to pass begin/end explicitly...
ArrayRef(const T &OneElt) -> ArrayRef< T >
void consumeError(Error Err)
Consume a Error without doing anything.
LLVM_ABI void reportFatalUsageError(Error Err)
Report a fatal error that does not indicate a bug in LLVM.
StringTable::Offset ImpliedOff
StringTable::Offset NameOff
bool operator<(const ImpliedExtsEntry &Other) const
StringRef impliedExt() const
StringTable::Offset NameOff
Represents the major and version number components of a RISC-V extension.