assert(NewLog2LMUL <= 3 && NewLog2LMUL >= -3 &&
"Bad LMUL number!");
44 return "mf"+ utostr(1ULL << (-
Log2LMUL));
45 return "m"+ utostr(1ULL <<
Log2LMUL);
49 intLog2ScaleResult = 0;
50 switch(ElementBitwidth) {
67 if(Log2ScaleResult < 0)
69 return1 << Log2ScaleResult;
74RVVType::RVVType(
BasicTypeBT,
intLog2LMUL,
76: BT(BT), LMUL(
LMULType(Log2LMUL)) {
78applyModifier(prototype);
84initClangBuiltinStr();
107boolRVVType::verifyType()
const{
114 if(
isFloat() && ElementBitwidth == 8)
116 if(
isBFloat() && ElementBitwidth != 16)
118 if(IsTuple && (NF == 1 || NF > 8))
120 if(IsTuple && (1 << std::max(0, LMUL.
Log2LMUL)) * NF > 8)
123 switch(ElementBitwidth) {
127 return(
V<= 64 && isPowerOf2_32(
V));
130 return(
V<= 32 && isPowerOf2_32(
V));
133 return(
V<= 16 && isPowerOf2_32(
V));
136 return(
V<= 8 && isPowerOf2_32(
V));
141voidRVVType::initBuiltinStr() {
142assert(
isValid() &&
"RVVType is invalid");
143 switch(ScalarType) {
150BuiltinStr =
"I"+ BuiltinStr;
164assert(ElementBitwidth == 1);
169 switch(ElementBitwidth) {
183llvm_unreachable(
"Unhandled ElementBitwidth!");
186BuiltinStr =
"S"+ BuiltinStr;
188BuiltinStr =
"U"+ BuiltinStr;
191 switch(ElementBitwidth) {
202llvm_unreachable(
"Unhandled ElementBitwidth!");
209llvm_unreachable(
"ScalarType is invalid!");
212BuiltinStr =
"I"+ BuiltinStr;
220BuiltinStr =
"q"+ utostr(*Scale) + BuiltinStr;
228BuiltinStr =
"T"+ utostr(NF) + BuiltinStr;
231voidRVVType::initClangBuiltinStr() {
232assert(
isValid() &&
"RVVType is invalid");
233assert(
isVector() &&
"Handle Vector type only");
235ClangBuiltinStr =
"__rvv_";
236 switch(ScalarType) {
238ClangBuiltinStr +=
"bool"+ utostr(64 / *Scale) +
"_t";
241ClangBuiltinStr +=
"float";
244ClangBuiltinStr +=
"bfloat";
247ClangBuiltinStr +=
"int";
250ClangBuiltinStr +=
"uint";
253llvm_unreachable(
"ScalarTypeKind is invalid");
255ClangBuiltinStr += utostr(ElementBitwidth) + LMUL.
str() +
256(IsTuple ?
"x"+ utostr(NF) :
"") +
"_t";
259voidRVVType::initTypeStr() {
260assert(
isValid() &&
"RVVType is invalid");
267 returnTwine(TypeStr + Twine(ElementBitwidth) +
"_t").str();
268 returnTwine(
"v"+ TypeStr + Twine(ElementBitwidth) + LMUL.
str() +
269(IsTuple ?
"x"+ utostr(NF) :
"") +
"_t")
273 switch(ScalarType) {
286Str =
"unsigned long";
297Str +=
"vbool"+ utostr(64 / *Scale) +
"_t";
301 if(ElementBitwidth == 64)
303 else if(ElementBitwidth == 32)
305 else if(ElementBitwidth == 16)
308llvm_unreachable(
"Unhandled floating type.");
314 if(ElementBitwidth == 16)
317llvm_unreachable(
"Unhandled floating type.");
328llvm_unreachable(
"ScalarType is invalid!");
334voidRVVType::initShortStr() {
335 switch(ScalarType) {
338ShortStr =
"b"+ utostr(64 / *Scale);
341ShortStr =
"f"+ utostr(ElementBitwidth);
344ShortStr =
"bf"+ utostr(ElementBitwidth);
347ShortStr =
"i"+ utostr(ElementBitwidth);
350ShortStr =
"u"+ utostr(ElementBitwidth);
353llvm_unreachable(
"Unhandled case!");
356ShortStr += LMUL.
str();
358ShortStr +=
"x"+ utostr(NF);
362assert(2 <= NF && NF <= 8 &&
"2 <= NF <= 8");
367voidRVVType::applyBasicType() {
374ElementBitwidth = 16;
378ElementBitwidth = 32;
382ElementBitwidth = 64;
386ElementBitwidth = 16;
390ElementBitwidth = 32;
394ElementBitwidth = 64;
398ElementBitwidth = 16;
402llvm_unreachable(
"Unhandled type code!");
404assert(ElementBitwidth != 0 &&
"Bad element bitwidth!");
407std::optional<PrototypeDescriptor>
409llvm::StringRef PrototypeDescriptorStr) {
414 if(PrototypeDescriptorStr.empty())
418 autoPType = PrototypeDescriptorStr.back();
461llvm_unreachable(
"Illegal primitive type transformers!");
463PD.
PT=
static_cast<uint8_t
>(
PT);
464PrototypeDescriptorStr = PrototypeDescriptorStr.drop_back();
467 if(PrototypeDescriptorStr.starts_with(
"(")) {
469 "VectorTypeModifier should only have one modifier");
470 size_tIdx = PrototypeDescriptorStr.find(
')');
471assert(Idx != StringRef::npos);
472StringRef
ComplexType= PrototypeDescriptorStr.slice(1, Idx);
473PrototypeDescriptorStr = PrototypeDescriptorStr.drop_front(Idx + 1);
474assert(!PrototypeDescriptorStr.contains(
'(') &&
475 "Only allow one vector type modifier");
478 if(ComplexTT.first ==
"Log2EEW") {
480 if(ComplexTT.second.getAsInteger(10, Log2EEW)) {
481llvm_unreachable(
"Invalid Log2EEW value!");
498llvm_unreachable(
"Invalid Log2EEW value, should be [3-6]");
501}
else if(ComplexTT.first ==
"FixedSEW") {
503 if(ComplexTT.second.getAsInteger(10, NewSEW)) {
504llvm_unreachable(
"Invalid FixedSEW value!");
521llvm_unreachable(
"Invalid FixedSEW value, should be 8, 16, 32 or 64");
524}
else if(ComplexTT.first ==
"LFixedLog2LMUL") {
526 if(ComplexTT.second.getAsInteger(10, Log2LMUL)) {
527llvm_unreachable(
"Invalid LFixedLog2LMUL value!");
553llvm_unreachable(
"Invalid LFixedLog2LMUL value, should be [-3, 3]");
556}
else if(ComplexTT.first ==
"SFixedLog2LMUL") {
558 if(ComplexTT.second.getAsInteger(10, Log2LMUL)) {
559llvm_unreachable(
"Invalid SFixedLog2LMUL value!");
585llvm_unreachable(
"Invalid LFixedLog2LMUL value, should be [-3, 3]");
589}
else if(ComplexTT.first ==
"SEFixedLog2LMUL") {
591 if(ComplexTT.second.getAsInteger(10, Log2LMUL)) {
592llvm_unreachable(
"Invalid SEFixedLog2LMUL value!");
618llvm_unreachable(
"Invalid LFixedLog2LMUL value, should be [-3, 3]");
621}
else if(ComplexTT.first ==
"Tuple") {
623 if(ComplexTT.second.getAsInteger(10, NF)) {
624llvm_unreachable(
"Invalid NF value!");
629llvm_unreachable(
"Illegal complex type transformers!");
632PD.
VTM=
static_cast<uint8_t
>(
VTM);
636 for(
charI : PrototypeDescriptorStr) {
640llvm_unreachable(
"'P' transformer cannot be used after 'C'");
642llvm_unreachable(
"'P' transformer cannot be used twice");
664llvm_unreachable(
"Illegal non-primitive type transformer!");
667PD.
TM=
static_cast<uint8_t
>(
TM);
679Scale = LMUL.
getScale(ElementBitwidth);
697ElementBitwidth = 32;
707ElementBitwidth *= 2;
709Scale = LMUL.
getScale(ElementBitwidth);
712ElementBitwidth *= 4;
714Scale = LMUL.
getScale(ElementBitwidth);
717ElementBitwidth *= 8;
719Scale = LMUL.
getScale(ElementBitwidth);
723Scale = LMUL.
getScale(ElementBitwidth);
751applyFixedLog2LMUL(-3, FixedLMULType::LargerThan);
754applyFixedLog2LMUL(-2, FixedLMULType::LargerThan);
757applyFixedLog2LMUL(-1, FixedLMULType::LargerThan);
760applyFixedLog2LMUL(0, FixedLMULType::LargerThan);
763applyFixedLog2LMUL(1, FixedLMULType::LargerThan);
766applyFixedLog2LMUL(2, FixedLMULType::LargerThan);
769applyFixedLog2LMUL(3, FixedLMULType::LargerThan);
772applyFixedLog2LMUL(-3, FixedLMULType::SmallerThan);
775applyFixedLog2LMUL(-2, FixedLMULType::SmallerThan);
778applyFixedLog2LMUL(-1, FixedLMULType::SmallerThan);
781applyFixedLog2LMUL(0, FixedLMULType::SmallerThan);
784applyFixedLog2LMUL(1, FixedLMULType::SmallerThan);
787applyFixedLog2LMUL(2, FixedLMULType::SmallerThan);
790applyFixedLog2LMUL(3, FixedLMULType::SmallerThan);
793applyFixedLog2LMUL(-3, FixedLMULType::SmallerOrEqual);
796applyFixedLog2LMUL(-2, FixedLMULType::SmallerOrEqual);
799applyFixedLog2LMUL(-1, FixedLMULType::SmallerOrEqual);
802applyFixedLog2LMUL(0, FixedLMULType::SmallerOrEqual);
805applyFixedLog2LMUL(1, FixedLMULType::SmallerOrEqual);
808applyFixedLog2LMUL(2, FixedLMULType::SmallerOrEqual);
811applyFixedLog2LMUL(3, FixedLMULType::SmallerOrEqual);
821NF = 2 +
static_cast<uint8_t
>(Transformer.
VTM) -
833 for(
unsignedTypeModifierMaskShift = 0;
835++TypeModifierMaskShift) {
836 unsignedTypeModifierMask = 1 << TypeModifierMaskShift;
837 if((
static_cast<unsigned>(Transformer.
TM) & TypeModifierMask) !=
840 switch(
static_cast<TypeModifier>(TypeModifierMask)) {
866Scale = LMUL.
getScale(ElementBitwidth);
869llvm_unreachable(
"Unknown type modifier mask!");
874voidRVVType::applyLog2EEW(
unsignedLog2EEW) {
876LMUL.
MulLog2LMUL(Log2EEW - Log2_32(ElementBitwidth));
878ElementBitwidth = 1 << Log2EEW;
880Scale = LMUL.
getScale(ElementBitwidth);
883voidRVVType::applyFixedSEW(
unsignedNewSEW) {
885 if(ElementBitwidth == NewSEW) {
890ElementBitwidth = NewSEW;
891Scale = LMUL.
getScale(ElementBitwidth);
894voidRVVType::applyFixedLog2LMUL(
intLog2LMUL,
enumFixedLMULType Type) {
896 caseFixedLMULType::LargerThan:
902 caseFixedLMULType::SmallerThan:
908 caseFixedLMULType::SmallerOrEqual:
917LMUL = LMULType(Log2LMUL);
918Scale = LMUL.
getScale(ElementBitwidth);
921std::optional<RVVTypes>
930Types.push_back(*
T);
941assert(Log2LMUL >= -3 && Log2LMUL <= 3);
942 return(Log2LMUL + 3) | (
static_cast<uint64_t
>(BT) & 0xff) << 8 |
943((uint64_t)(Proto.
PT& 0xff) << 16) |
944((uint64_t)(Proto.
TM& 0xff) << 24) |
945((uint64_t)(Proto.
VTM& 0xff) << 32);
952 autoIt = LegalTypes.find(Idx);
953 if(It != LegalTypes.end())
954 return&(It->second);
956 if(IllegalTypes.count(Idx))
963std::pair<std::unordered_map<uint64_t, RVVType>::iterator,
bool>
964InsertResult = LegalTypes.insert({Idx,
T});
965 return&(InsertResult.first->second);
968IllegalTypes.insert(Idx);
976StringRef NewName, StringRef Suffix, StringRef NewOverloadedName,
977StringRef OverloadedSuffix, StringRef IRName,
boolIsMasked,
978 boolHasMaskedOffOperand,
boolHasVL,
PolicySchemeScheme,
979 boolSupportOverloading,
boolHasBuiltinAlias, StringRef ManualCodegen,
980 const RVVTypes&OutInTypes,
conststd::vector<int64_t> &NewIntrinsicTypes,
981 unsignedNF,
PolicyNewPolicyAttrs,
boolHasFRMRoundModeOp)
982: IRName(IRName), IsMasked(IsMasked),
983HasMaskedOffOperand(HasMaskedOffOperand), HasVL(HasVL), Scheme(Scheme),
984SupportOverloading(SupportOverloading), HasBuiltinAlias(HasBuiltinAlias),
985ManualCodegen(ManualCodegen.str()), NF(NF), PolicyAttrs(NewPolicyAttrs) {
988BuiltinName = NewName.str();
990 if(NewOverloadedName.empty())
991OverloadedName = NewName.split(
"_").first.str();
993OverloadedName = NewOverloadedName.str();
995Name +=
"_"+ Suffix.str();
996 if(!OverloadedSuffix.empty())
997OverloadedName +=
"_"+ OverloadedSuffix.str();
1000PolicyAttrs, HasFRMRoundModeOp);
1003OutputType = OutInTypes[0];
1004InputTypes.assign(OutInTypes.begin() + 1, OutInTypes.end());
1008IntrinsicTypes = NewIntrinsicTypes;
1011 for(
auto&I : IntrinsicTypes) {
1021 for(
const auto&
T: InputTypes) {
1022S +=
T->getBuiltinStr();
1031 for(
autoPD : PrototypeDescriptors) {
1033SuffixStrs.push_back((*T)->getShortStr());
1035 returnjoin(SuffixStrs,
"_");
1040 boolHasMaskedOffOperand,
boolHasVL,
unsignedNF,
1047 if(HasMaskedOffOperand && !PolicyAttrs.
isTAMAPolicy()) {
1049NewPrototype.insert(NewPrototype.begin() + 1, NewPrototype[0]);
1050}
else if(NF > 1) {
1057NewPrototype.insert(NewPrototype.begin() + 1, MaskoffType);
1065NewPrototype.insert(NewPrototype.begin() + NF + 1, NF, MaskoffType);
1069 if(HasMaskedOffOperand && NF > 1) {
1076NewPrototype.insert(NewPrototype.begin() + 1,
1079NewPrototype.insert(NewPrototype.begin() + NF + 1,
1087 if(PolicyAttrs.
isTUPolicy() && HasPassthruOp)
1088NewPrototype.insert(NewPrototype.begin(), NewPrototype[0]);
1089}
else if(PolicyAttrs.
isTUPolicy() && HasPassthruOp) {
1096NewPrototype.insert(NewPrototype.begin(), MaskoffType);
1105NewPrototype.insert(NewPrototype.begin() + NF + 1, NF, MaskoffType);
1114 returnNewPrototype;
1123 boolHasMaskPolicy) {
1124 if(HasTailPolicy && HasMaskPolicy)
1131 if(HasTailPolicy && !HasMaskPolicy)
1134 if(!HasTailPolicy && HasMaskPolicy)
1137llvm_unreachable(
"An RVV instruction should not be without both tail policy " 1138 "and mask policy");
1142 boolIsMasked,
boolHasPolicy, std::string &Name, std::string &BuiltinName,
1143std::string &OverloadedName,
Policy&PolicyAttrs,
boolHasFRMRoundModeOp) {
1145 autoappendPolicySuffix = [&](
conststd::string &suffix) {
1147BuiltinName += suffix;
1148OverloadedName += suffix;
1151 if(HasFRMRoundModeOp) {
1153BuiltinName +=
"_rm";
1158appendPolicySuffix(
"_tumu");
1160appendPolicySuffix(
"_tum");
1162appendPolicySuffix(
"_mu");
1165BuiltinName +=
"_m";
1167llvm_unreachable(
"Unhandled policy condition");
1170appendPolicySuffix(
"_tu");
1174llvm_unreachable(
"Unhandled policy condition");
1180 constStringRef Primaries(
"evwqom0ztulf");
1181 while(!Prototypes.empty()) {
1185 if(Prototypes[0] ==
'(')
1186Idx = Prototypes.find_first_of(
')');
1187Idx = Prototypes.find_first_of(Primaries, Idx);
1188assert(Idx != StringRef::npos);
1190Prototypes.slice(0, Idx + 1));
1192llvm_unreachable(
"Error during parsing prototype.");
1193PrototypeDescriptors.push_back(*PD);
1194Prototypes = Prototypes.drop_front(Idx + 1);
1196 returnPrototypeDescriptors;
1201OS <<
"\""<<
Record.Name <<
"\",";
1202 if(
Record.OverloadedName ==
nullptr||
1203StringRef(
Record.OverloadedName).empty())
1206OS <<
"\""<<
Record.OverloadedName <<
"\",";
1207OS <<
Record.PrototypeIndex <<
",";
1208OS <<
Record.SuffixIndex <<
",";
1209OS <<
Record.OverloadedSuffixIndex <<
",";
1210OS << (
int)
Record.PrototypeLength <<
",";
1211OS << (
int)
Record.SuffixLength <<
",";
1212OS << (
int)
Record.OverloadedSuffixSize <<
",";
1213OS <<
Record.RequiredExtensions <<
",";
1214OS << (
int)
Record.TypeRangeMask <<
",";
1215OS << (
int)
Record.Log2LMULMask <<
",";
1216OS << (
int)
Record.NF <<
",";
1217OS << (
int)
Record.HasMasked <<
",";
1218OS << (
int)
Record.HasVL <<
",";
1219OS << (
int)
Record.HasMaskedOffOperand <<
",";
1220OS << (
int)
Record.HasTailPolicy <<
",";
1221OS << (
int)
Record.HasMaskPolicy <<
",";
1222OS << (
int)
Record.HasFRMRoundModeOp <<
",";
1224OS << (
int)
Record.UnMaskedPolicyScheme <<
",";
1225OS << (
int)
Record.MaskedPolicyScheme <<
",";
static bool getTypeString(SmallStringEnc &Enc, const Decl *D, const CodeGen::CodeGenModule &CGM, TypeStringCache &TSC)
The XCore ABI includes a type information section that communicates symbol type information to the li...
llvm::MachO::Record Record
static bool isVector(QualType QT, QualType ElementType)
This helper function returns true if QT is a vector type that has element type ElementType.
Complex values, per C99 6.2.5p11.
bool isTUMUPolicy() const
bool isTUMAPolicy() const
bool isTAMUPolicy() const
bool isTAMAPolicy() const
bool hasPassthruOperand() const
static llvm::SmallVector< Policy > getSupportedMaskedPolicies(bool HasTailPolicy, bool HasMaskPolicy)
bool hasMaskedOffOperand() 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)
RVVIntrinsic(llvm::StringRef Name, llvm::StringRef Suffix, llvm::StringRef OverloadedName, llvm::StringRef OverloadedSuffix, llvm::StringRef IRName, bool IsMasked, bool HasMaskedOffOperand, bool HasVL, PolicyScheme Scheme, bool SupportOverloading, bool HasBuiltinAlias, llvm::StringRef ManualCodegen, const RVVTypes &Types, const std::vector< int64_t > &IntrinsicTypes, unsigned NF, Policy PolicyAttrs, bool HasFRMRoundModeOp)
static llvm::SmallVector< Policy > getSupportedUnMaskedPolicies()
std::string getBuiltinTypeStr() 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...
bool isSignedInteger() const
const std::string & getBuiltinStr() const
The base class of the type hierarchy.
llvm::raw_ostream & operator<<(llvm::raw_ostream &OS, const RVVIntrinsicRecord &RVVInstrRecord)
llvm::SmallVector< PrototypeDescriptor > parsePrototypes(llvm::StringRef Prototypes)
static uint64_t computeRVVTypeHashValue(BasicType BT, int Log2LMUL, PrototypeDescriptor Proto)
std::optional< unsigned > VScaleVal
static VectorTypeModifier getTupleVTM(unsigned NF)
std::vector< RVVTypePtr > RVVTypes
The JSON file list parser is used to communicate input to InstallAPI.
const FunctionProtoType * T
Diagnostic wrappers for TextAPI types for error reporting.
std::optional< unsigned > getScale(unsigned ElementBitwidth) const
void MulLog2LMUL(int Log2LMUL)
static std::optional< PrototypeDescriptor > parsePrototypeDescriptor(llvm::StringRef PrototypeStr)
static const PrototypeDescriptor VL
static const PrototypeDescriptor Mask
static const PrototypeDescriptor Vector
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4