9#ifndef CLANG_SUPPORT_RISCVVINTRINSICUTILS_H
10#define CLANG_SUPPORT_RISCVVINTRINSICUTILS_H
12#include "llvm/ADT/ArrayRef.h"
13#include "llvm/ADT/BitmaskEnum.h"
14#include "llvm/ADT/SmallVector.h"
15#include "llvm/ADT/StringRef.h"
20#include <unordered_map>
128 : TailPolicy(TailPolicy), MaskPolicy(MaskPolicy) {}
155 return TailPolicy ==
Other.TailPolicy && MaskPolicy ==
Other.MaskPolicy;
162 if (MaskPolicy !=
Other.MaskPolicy)
163 return Other.MaskPolicy < MaskPolicy;
164 return TailPolicy <
Other.TailPolicy;
176 :
PT(static_cast<uint8_t>(
PT)),
VTM(static_cast<uint8_t>(
VTM)),
177 TM(static_cast<uint8_t>(
TM)) {}
186 return !(*
this == PD);
197 static std::optional<PrototypeDescriptor>
240 std::string
str()
const;
241 std::optional<unsigned>
getScale(
unsigned ElementBitwidth)
const;
257 bool IsPointer =
false;
259 bool IsImmediate =
false;
261 bool IsConstant =
false;
262 unsigned ElementBitwidth = 0;
265 bool IsTuple =
false;
268 std::string BuiltinStr;
269 std::string ClangBuiltinStr;
271 std::string ShortStr;
273 enum class FixedLMULType { LargerThan, SmallerThan, SmallerOrEqual };
294 if (ShortStr.empty())
300 bool isScalar()
const {
return Scale && *Scale == 0; }
301 bool isVector()
const {
return Scale && *Scale != 0; }
303 return isVector() && ElementBitwidth == Width;
314 return isFloat() && ElementBitwidth == Width;
324 assert(NF > 1 && NF <= 8 &&
"Only legal NF should be fetched");
330 bool verifyType()
const;
333 void applyBasicType();
339 void applyLog2EEW(
unsigned Log2EEW);
340 void applyFixedSEW(
unsigned NewSEW);
341 void applyFixedLog2LMUL(
int Log2LMUL,
enum FixedLMULType
Type);
344 void initBuiltinStr();
346 void initClangBuiltinStr();
357 std::unordered_map<uint64_t, RVVType> LegalTypes;
358 std::set<uint64_t> IllegalTypes;
365 std::optional<RVVTypes>
385 std::string BuiltinName;
387 std::string OverloadedName;
390 bool HasMaskedOffOperand;
393 bool SupportOverloading;
394 bool HasBuiltinAlias;
395 std::string ManualCodegen;
400 std::vector<int64_t> IntrinsicTypes;
405 RVVIntrinsic(llvm::StringRef Name, llvm::StringRef Suffix,
406 llvm::StringRef OverloadedName, llvm::StringRef OverloadedSuffix,
407 llvm::StringRef IRName,
bool IsMasked,
bool HasMaskedOffOperand,
408 bool HasVL,
PolicyScheme Scheme,
bool SupportOverloading,
409 bool HasBuiltinAlias, llvm::StringRef ManualCodegen,
411 const std::vector<int64_t> &IntrinsicTypes,
412 unsigned NF,
Policy PolicyAttrs,
bool HasFRMRoundModeOp);
419 bool hasVL()
const {
return HasVL; }
434 unsigned getNF()
const {
return NF; }
436 return IntrinsicTypes;
456 llvm_unreachable(
"unsupport policy");
469 bool IsMasked,
bool HasMaskedOffOperand,
bool HasVL,
471 Policy PolicyAttrs,
bool IsTuple);
478 std::string &Name, std::string &BuiltinName,
479 std::string &OverloadedName,
480 Policy &PolicyAttrs,
bool HasFRMRoundModeOp);
564llvm::raw_ostream &operator<<(
llvm::raw_ostream &OS,
bool isTUMUPolicy() const
Policy(PolicyType TailPolicy)
bool isTUMAPolicy() const
bool operator==(const Policy &Other) const
bool isTAMUPolicy() const
bool operator!=(const Policy &Other) const
bool operator<(const Policy &Other) const
Policy(PolicyType TailPolicy, PolicyType MaskPolicy)
bool isTAMAPolicy() const
bool hasPassthruOperand() const
static llvm::SmallVector< Policy > getSupportedMaskedPolicies(bool HasTailPolicy, bool HasMaskPolicy)
llvm::StringRef getBuiltinName() const
llvm::StringRef getIRName() const
const std::vector< int64_t > & getIntrinsicTypes() const
bool hasMaskedOffOperand() const
Policy getPolicyAttrs() const
static llvm::SmallVector< PrototypeDescriptor > computeBuiltinTypes(llvm::ArrayRef< PrototypeDescriptor > Prototype, bool IsMasked, bool HasMaskedOffOperand, bool HasVL, unsigned NF, PolicyScheme DefaultScheme, Policy PolicyAttrs, bool IsTuple)
static void updateNamesAndPolicy(bool IsMasked, bool HasPolicy, std::string &Name, std::string &BuiltinName, std::string &OverloadedName, Policy &PolicyAttrs, bool HasFRMRoundModeOp)
static std::string getSuffixStr(RVVTypeCache &TypeCache, BasicType Type, int Log2LMUL, llvm::ArrayRef< PrototypeDescriptor > PrototypeDescriptors)
bool hasPolicyOperand() const
bool hasManualCodegen() const
bool hasBuiltinAlias() const
static llvm::SmallVector< Policy > getSupportedUnMaskedPolicies()
RVVTypePtr getOutputType() const
unsigned getPolicyAttrsBits() const
bool supportOverloading() const
llvm::StringRef getManualCodegen() const
std::string getBuiltinTypeStr() const
const RVVTypes & getInputTypes() const
PolicyScheme getPolicyScheme() const
std::optional< RVVTypePtr > computeType(BasicType BT, int Log2LMUL, PrototypeDescriptor Proto)
std::optional< RVVTypes > computeTypes(BasicType BT, int Log2LMUL, unsigned NF, llvm::ArrayRef< PrototypeDescriptor > Prototype)
Compute output and input types by applying different config (basic type and LMUL with type transforme...
const std::string & getTypeStr() const
ScalarTypeKind getScalarType() const
bool isFloatVector(unsigned Width) const
bool isSignedInteger() const
const std::string & getShortStr()
const std::string & getClangBuiltinStr() const
VScaleVal getScale() const
bool isFloat(unsigned Width) const
bool isVector(unsigned Width) const
unsigned getElementBitwidth() const
const std::string & getBuiltinStr() const
The base class of the type hierarchy.
llvm::SmallVector< PrototypeDescriptor > parsePrototypes(llvm::StringRef Prototypes)
LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE()
std::optional< unsigned > VScaleVal
@ LLVM_MARK_AS_BITMASK_ENUM
@ RVV_REQ_Xsfvfnrclipxfqf
std::vector< RVVTypePtr > RVVTypes
The JSON file list parser is used to communicate input to InstallAPI.
@ Other
Other implicit parameter.
Diagnostic wrappers for TextAPI types for error reporting.
std::optional< unsigned > getScale(unsigned ElementBitwidth) const
void MulLog2LMUL(int Log2LMUL)
bool operator!=(const PrototypeDescriptor &PD) const
static std::optional< PrototypeDescriptor > parsePrototypeDescriptor(llvm::StringRef PrototypeStr)
static const PrototypeDescriptor VL
constexpr PrototypeDescriptor()=default
static const PrototypeDescriptor Mask
constexpr PrototypeDescriptor(uint8_t PT, uint8_t VTM, uint8_t TM)
static const PrototypeDescriptor Vector
constexpr PrototypeDescriptor(BaseTypeModifier PT, VectorTypeModifier VTM=VectorTypeModifier::NoModifier, TypeModifier TM=TypeModifier::NoModifier)
bool operator==(const PrototypeDescriptor &PD) const
bool operator<(const PrototypeDescriptor &PD) const
uint8_t OverloadedSuffixSize
uint16_t OverloadedSuffixIndex
uint8_t MaskedPolicyScheme
const char * OverloadedName
uint8_t UnMaskedPolicyScheme
uint32_t RequiredExtensions