LLVM 19.0.0git
RISCVISAInfo.h
Go to the documentation of this file.
1//===-- RISCVISAInfo.h - RISC-V ISA Information -----------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_SUPPORT_RISCVISAINFO_H
10#define LLVM_SUPPORT_RISCVISAINFO_H
11
12#include "llvm/ADT/StringMap.h"
13#include "llvm/ADT/StringRef.h"
14#include "llvm/Support/Error.h"
16
17#include <map>
18#include <string>
19#include <vector>
20
21namespace llvm {
22void riscvExtensionsHelp(StringMap<StringRef> DescMap);
23
25public:
26 RISCVISAInfo(const RISCVISAInfo &) = delete;
28
30 : XLen(XLen), FLen(0), MinVLen(0), MaxELen(0), MaxELenFp(0), Exts(Exts) {}
31
32 /// Parse RISC-V ISA info from arch string.
33 /// If IgnoreUnknown is set, any unrecognised extension names or
34 /// extensions with unrecognised versions will be silently dropped, except
35 /// for the special case of the base 'i' and 'e' extensions, where the
36 /// default version will be used (as ignoring the base is not possible).
38 parseArchString(StringRef Arch, bool EnableExperimentalExtension,
39 bool ExperimentalExtensionVersionCheck = true,
40 bool IgnoreUnknown = false);
41
42 /// Parse RISC-V ISA info from an arch string that is already in normalized
43 /// form (as defined in the psABI). Unlike parseArchString, this function
44 /// will not error for unrecognized extension names or extension versions.
47
48 /// Parse RISC-V ISA info from feature vector.
50 parseFeatures(unsigned XLen, const std::vector<std::string> &Features);
51
52 /// Convert RISC-V ISA info to a feature vector.
53 std::vector<std::string> toFeatures(bool AddAllExtensions = false,
54 bool IgnoreUnknown = true) const;
55
57 return Exts;
58 }
59
60 unsigned getXLen() const { return XLen; }
61 unsigned getFLen() const { return FLen; }
62 unsigned getMinVLen() const { return MinVLen; }
63 unsigned getMaxVLen() const { return 65536; }
64 unsigned getMaxELen() const { return MaxELen; }
65 unsigned getMaxELenFp() const { return MaxELenFp; }
66
67 bool hasExtension(StringRef Ext) const;
68 std::string toString() const;
70
72 static bool isSupportedExtension(StringRef Ext);
74 static bool isSupportedExtension(StringRef Ext, unsigned MajorVersion,
75 unsigned MinorVersion);
77 postProcessAndChecking(std::unique_ptr<RISCVISAInfo> &&ISAInfo);
78 static std::string getTargetFeatureForExtension(StringRef Ext);
79
80private:
81 RISCVISAInfo(unsigned XLen)
82 : XLen(XLen), FLen(0), MinVLen(0), MaxELen(0), MaxELenFp(0) {}
83
84 unsigned XLen;
85 unsigned FLen;
86 unsigned MinVLen;
87 unsigned MaxELen, MaxELenFp;
88
90
91 void addExtension(StringRef ExtName, RISCVISAUtils::ExtensionVersion Version);
92
93 Error checkDependency();
94
95 void updateImplication();
96 void updateCombination();
97 void updateFLen();
98 void updateMinVLen();
99 void updateMaxELen();
100};
101
102} // namespace llvm
103
104#endif
This file defines the StringMap class.
Tagged union holding either a T or a Error.
Definition: Error.h:474
static bool isSupportedExtensionFeature(StringRef Ext)
RISCVISAInfo & operator=(const RISCVISAInfo &)=delete
static std::string getTargetFeatureForExtension(StringRef Ext)
unsigned getMinVLen() const
Definition: RISCVISAInfo.h:62
static 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...
bool hasExtension(StringRef Ext) const
RISCVISAInfo(const RISCVISAInfo &)=delete
unsigned getFLen() const
Definition: RISCVISAInfo.h:61
std::string toString() const
static llvm::Expected< std::unique_ptr< RISCVISAInfo > > postProcessAndChecking(std::unique_ptr< RISCVISAInfo > &&ISAInfo)
const RISCVISAUtils::OrderedExtensionMap & getExtensions() const
Definition: RISCVISAInfo.h:56
StringRef computeDefaultABI() const
unsigned getMaxVLen() const
Definition: RISCVISAInfo.h:63
static bool isSupportedExtension(StringRef Ext)
RISCVISAInfo(unsigned XLen, RISCVISAUtils::OrderedExtensionMap &Exts)
Definition: RISCVISAInfo.h:29
static llvm::Expected< std::unique_ptr< RISCVISAInfo > > parseFeatures(unsigned XLen, const std::vector< std::string > &Features)
Parse RISC-V ISA info from feature vector.
unsigned getMaxELen() const
Definition: RISCVISAInfo.h:64
unsigned getXLen() const
Definition: RISCVISAInfo.h:60
unsigned getMaxELenFp() const
Definition: RISCVISAInfo.h:65
std::vector< std::string > toFeatures(bool AddAllExtensions=false, bool IgnoreUnknown=true) const
Convert RISC-V ISA info to a feature vector.
static llvm::Expected< std::unique_ptr< RISCVISAInfo > > parseArchString(StringRef Arch, bool EnableExperimentalExtension, bool ExperimentalExtensionVersionCheck=true, bool IgnoreUnknown=false)
Parse RISC-V ISA info from arch string.
static bool isSupportedExtensionWithVersion(StringRef Ext)
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
std::map< std::string, ExtensionVersion, ExtensionComparator > OrderedExtensionMap
OrderedExtensionMap is std::map, it's specialized to keep entries in canonical order of extension.
Definition: RISCVISAUtils.h:43
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
void riscvExtensionsHelp(StringMap< StringRef > DescMap)