File indexing completed on 2026-05-10 08:44:37
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LLVM_SUPPORT_RISCVISAINFO_H
0010 #define LLVM_SUPPORT_RISCVISAINFO_H
0011
0012 #include "llvm/ADT/StringMap.h"
0013 #include "llvm/ADT/StringRef.h"
0014 #include "llvm/Support/Error.h"
0015 #include "llvm/Support/RISCVISAUtils.h"
0016
0017 #include <map>
0018 #include <set>
0019 #include <string>
0020 #include <vector>
0021
0022 namespace llvm {
0023
0024 class RISCVISAInfo {
0025 public:
0026 RISCVISAInfo(const RISCVISAInfo &) = delete;
0027 RISCVISAInfo &operator=(const RISCVISAInfo &) = delete;
0028
0029
0030
0031
0032
0033
0034 static llvm::Expected<std::unique_ptr<RISCVISAInfo>>
0035 parseArchString(StringRef Arch, bool EnableExperimentalExtension,
0036 bool ExperimentalExtensionVersionCheck = true);
0037
0038
0039
0040
0041 static llvm::Expected<std::unique_ptr<RISCVISAInfo>>
0042 parseNormalizedArchString(StringRef Arch);
0043
0044
0045 static llvm::Expected<std::unique_ptr<RISCVISAInfo>>
0046 parseFeatures(unsigned XLen, const std::vector<std::string> &Features);
0047
0048 static llvm::Expected<std::unique_ptr<RISCVISAInfo>>
0049 createFromExtMap(unsigned XLen,
0050 const RISCVISAUtils::OrderedExtensionMap &Exts);
0051
0052
0053 std::vector<std::string> toFeatures(bool AddAllExtensions = false,
0054 bool IgnoreUnknown = true) const;
0055
0056 const RISCVISAUtils::OrderedExtensionMap &getExtensions() const {
0057 return Exts;
0058 }
0059
0060 unsigned getXLen() const { return XLen; }
0061 unsigned getFLen() const { return FLen; }
0062 unsigned getMinVLen() const { return MinVLen; }
0063 unsigned getMaxVLen() const { return 65536; }
0064 unsigned getMaxELen() const { return MaxELen; }
0065 unsigned getMaxELenFp() const { return MaxELenFp; }
0066
0067 bool hasExtension(StringRef Ext) const;
0068 std::string toString() const;
0069 StringRef computeDefaultABI() const;
0070
0071 static bool isSupportedExtensionFeature(StringRef Ext);
0072 static bool isSupportedExtension(StringRef Ext);
0073 static bool isSupportedExtensionWithVersion(StringRef Ext);
0074 static bool isSupportedExtension(StringRef Ext, unsigned MajorVersion,
0075 unsigned MinorVersion);
0076 static std::string getTargetFeatureForExtension(StringRef Ext);
0077
0078 static void printSupportedExtensions(StringMap<StringRef> &DescMap);
0079 static void printEnabledExtensions(bool IsRV64,
0080 std::set<StringRef> &EnabledFeatureNames,
0081 StringMap<StringRef> &DescMap);
0082
0083
0084
0085 static std::pair<int, int> getRISCVFeaturesBitsInfo(StringRef Ext);
0086
0087
0088 static constexpr unsigned FeatureBitSize = 2;
0089
0090 private:
0091 RISCVISAInfo(unsigned XLen) : XLen(XLen) {}
0092
0093 unsigned XLen;
0094 unsigned FLen = 0;
0095 unsigned MinVLen = 0;
0096 unsigned MaxELen = 0, MaxELenFp = 0;
0097
0098 RISCVISAUtils::OrderedExtensionMap Exts;
0099
0100 Error checkDependency();
0101
0102 void updateImplication();
0103 void updateCombination();
0104
0105
0106 void updateImpliedLengths();
0107
0108 static llvm::Expected<std::unique_ptr<RISCVISAInfo>>
0109 postProcessAndChecking(std::unique_ptr<RISCVISAInfo> &&ISAInfo);
0110 };
0111
0112 }
0113
0114 #endif