clang 20.0.0git
SemaRISCV.cpp
Go to the documentation of this file.
1//===------ SemaRISCV.cpp ------- RISC-V target-specific routines ---------===//
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// This file implements semantic analysis functions specific to RISC-V.
10//
11//===----------------------------------------------------------------------===//
12
15#include "clang/AST/Decl.h"
20#include "clang/Sema/Attr.h"
22#include "clang/Sema/Lookup.h"
25#include "clang/Sema/Sema.h"
27#include "llvm/ADT/SmallVector.h"
28#include "llvm/TargetParser/RISCVTargetParser.h"
29#include <optional>
30#include <string>
31#include <vector>
32
33using namespace llvm;
34using namespace clang;
35using namespace clang::RISCV;
36
38
39namespace {
40
41// Function definition of a RVV intrinsic.
42struct RVVIntrinsicDef {
43 /// Mapping to which clang built-in function, e.g. __builtin_rvv_vadd.
44 std::string BuiltinName;
45
46 /// Function signature, first element is return type.
47 RVVTypes Signature;
48};
49
50struct RVVOverloadIntrinsicDef {
51 // Indexes of RISCVIntrinsicManagerImpl::IntrinsicList.
53};
54
55} // namespace
56
58#define DECL_SIGNATURE_TABLE
59#include "clang/Basic/riscv_vector_builtin_sema.inc"
60#undef DECL_SIGNATURE_TABLE
61};
62
64#define DECL_SIGNATURE_TABLE
65#include "clang/Basic/riscv_sifive_vector_builtin_sema.inc"
66#undef DECL_SIGNATURE_TABLE
67};
68
70#define DECL_INTRINSIC_RECORDS
71#include "clang/Basic/riscv_vector_builtin_sema.inc"
72#undef DECL_INTRINSIC_RECORDS
73};
74
76#define DECL_INTRINSIC_RECORDS
77#include "clang/Basic/riscv_sifive_vector_builtin_sema.inc"
78#undef DECL_INTRINSIC_RECORDS
79};
80
81// Get subsequence of signature table.
83ProtoSeq2ArrayRef(IntrinsicKind K, uint16_t Index, uint8_t Length) {
84 switch (K) {
85 case IntrinsicKind::RVV:
86 return ArrayRef(&RVVSignatureTable[Index], Length);
87 case IntrinsicKind::SIFIVE_VECTOR:
88 return ArrayRef(&RVSiFiveVectorSignatureTable[Index], Length);
89 }
90 llvm_unreachable("Unhandled IntrinsicKind");
91}
92
93static QualType RVVType2Qual(ASTContext &Context, const RVVType *Type) {
94 QualType QT;
95 switch (Type->getScalarType()) {
96 case ScalarTypeKind::Void:
97 QT = Context.VoidTy;
98 break;
99 case ScalarTypeKind::Size_t:
100 QT = Context.getSizeType();
101 break;
102 case ScalarTypeKind::Ptrdiff_t:
103 QT = Context.getPointerDiffType();
104 break;
105 case ScalarTypeKind::UnsignedLong:
106 QT = Context.UnsignedLongTy;
107 break;
108 case ScalarTypeKind::SignedLong:
109 QT = Context.LongTy;
110 break;
111 case ScalarTypeKind::Boolean:
112 QT = Context.BoolTy;
113 break;
114 case ScalarTypeKind::SignedInteger:
115 QT = Context.getIntTypeForBitwidth(Type->getElementBitwidth(), true);
116 break;
117 case ScalarTypeKind::UnsignedInteger:
118 QT = Context.getIntTypeForBitwidth(Type->getElementBitwidth(), false);
119 break;
120 case ScalarTypeKind::BFloat:
121 QT = Context.BFloat16Ty;
122 break;
123 case ScalarTypeKind::Float:
124 switch (Type->getElementBitwidth()) {
125 case 64:
126 QT = Context.DoubleTy;
127 break;
128 case 32:
129 QT = Context.FloatTy;
130 break;
131 case 16:
132 QT = Context.Float16Ty;
133 break;
134 default:
135 llvm_unreachable("Unsupported floating point width.");
136 }
137 break;
138 case Invalid:
139 case Undefined:
140 llvm_unreachable("Unhandled type.");
141 }
142 if (Type->isVector()) {
143 if (Type->isTuple())
144 QT = Context.getScalableVectorType(QT, *Type->getScale(), Type->getNF());
145 else
146 QT = Context.getScalableVectorType(QT, *Type->getScale());
147 }
148
149 if (Type->isConstant())
150 QT = Context.getConstType(QT);
151
152 // Transform the type to a pointer as the last step, if necessary.
153 if (Type->isPointer())
154 QT = Context.getPointerType(QT);
155
156 return QT;
157}
158
159namespace {
160class RISCVIntrinsicManagerImpl : public sema::RISCVIntrinsicManager {
161private:
162 Sema &S;
163 ASTContext &Context;
164 RVVTypeCache TypeCache;
165 bool ConstructedRISCVVBuiltins;
166 bool ConstructedRISCVSiFiveVectorBuiltins;
167
168 // List of all RVV intrinsic.
169 std::vector<RVVIntrinsicDef> IntrinsicList;
170 // Mapping function name to index of IntrinsicList.
171 StringMap<uint16_t> Intrinsics;
172 // Mapping function name to RVVOverloadIntrinsicDef.
173 StringMap<RVVOverloadIntrinsicDef> OverloadIntrinsics;
174
175 // Create RVVIntrinsicDef.
176 void InitRVVIntrinsic(const RVVIntrinsicRecord &Record, StringRef SuffixStr,
177 StringRef OverloadedSuffixStr, bool IsMask,
178 RVVTypes &Types, bool HasPolicy, Policy PolicyAttrs);
179
180 // Create FunctionDecl for a vector intrinsic.
181 void CreateRVVIntrinsicDecl(LookupResult &LR, IdentifierInfo *II,
182 Preprocessor &PP, uint32_t Index,
183 bool IsOverload);
184
185 void ConstructRVVIntrinsics(ArrayRef<RVVIntrinsicRecord> Recs,
186 IntrinsicKind K);
187
188public:
189 RISCVIntrinsicManagerImpl(clang::Sema &S) : S(S), Context(S.Context) {
190 ConstructedRISCVVBuiltins = false;
191 ConstructedRISCVSiFiveVectorBuiltins = false;
192 }
193
194 // Initialize IntrinsicList
195 void InitIntrinsicList() override;
196
197 // Create RISC-V vector intrinsic and insert into symbol table if found, and
198 // return true, otherwise return false.
200 Preprocessor &PP) override;
201};
202} // namespace
203
204void RISCVIntrinsicManagerImpl::ConstructRVVIntrinsics(
206 const TargetInfo &TI = Context.getTargetInfo();
207 static const std::pair<const char *, RVVRequire> FeatureCheckList[] = {
208 {"64bit", RVV_REQ_RV64},
209 {"xsfvcp", RVV_REQ_Xsfvcp},
210 {"xsfvfnrclipxfqf", RVV_REQ_Xsfvfnrclipxfqf},
211 {"xsfvfwmaccqqq", RVV_REQ_Xsfvfwmaccqqq},
212 {"xsfvqmaccdod", RVV_REQ_Xsfvqmaccdod},
213 {"xsfvqmaccqoq", RVV_REQ_Xsfvqmaccqoq},
214 {"zvbb", RVV_REQ_Zvbb},
215 {"zvbc", RVV_REQ_Zvbc},
216 {"zvkb", RVV_REQ_Zvkb},
217 {"zvkg", RVV_REQ_Zvkg},
218 {"zvkned", RVV_REQ_Zvkned},
219 {"zvknha", RVV_REQ_Zvknha},
220 {"zvknhb", RVV_REQ_Zvknhb},
221 {"zvksed", RVV_REQ_Zvksed},
222 {"zvksh", RVV_REQ_Zvksh},
223 {"zvfbfwma", RVV_REQ_Zvfbfwma},
224 {"zvfbfmin", RVV_REQ_Zvfbfmin},
225 {"zvfh", RVV_REQ_Zvfh},
226 {"experimental", RVV_REQ_Experimental}};
227
228 // Construction of RVVIntrinsicRecords need to sync with createRVVIntrinsics
229 // in RISCVVEmitter.cpp.
230 for (auto &Record : Recs) {
231 // Check requirements.
232 if (llvm::any_of(FeatureCheckList, [&](const auto &Item) {
233 return (Record.RequiredExtensions & Item.second) == Item.second &&
234 !TI.hasFeature(Item.first);
235 }))
236 continue;
237
238 // Create Intrinsics for each type and LMUL.
239 BasicType BaseType = BasicType::Unknown;
240 ArrayRef<PrototypeDescriptor> BasicProtoSeq =
241 ProtoSeq2ArrayRef(K, Record.PrototypeIndex, Record.PrototypeLength);
243 ProtoSeq2ArrayRef(K, Record.SuffixIndex, Record.SuffixLength);
244 ArrayRef<PrototypeDescriptor> OverloadedSuffixProto = ProtoSeq2ArrayRef(
245 K, Record.OverloadedSuffixIndex, Record.OverloadedSuffixSize);
246
247 PolicyScheme UnMaskedPolicyScheme =
248 static_cast<PolicyScheme>(Record.UnMaskedPolicyScheme);
249 PolicyScheme MaskedPolicyScheme =
250 static_cast<PolicyScheme>(Record.MaskedPolicyScheme);
251
252 const Policy DefaultPolicy;
253
256 BasicProtoSeq, /*IsMasked=*/false,
257 /*HasMaskedOffOperand=*/false, Record.HasVL, Record.NF,
258 UnMaskedPolicyScheme, DefaultPolicy, Record.IsTuple);
259
261 if (Record.HasMasked)
263 BasicProtoSeq, /*IsMasked=*/true, Record.HasMaskedOffOperand,
264 Record.HasVL, Record.NF, MaskedPolicyScheme, DefaultPolicy,
265 Record.IsTuple);
266
267 bool UnMaskedHasPolicy = UnMaskedPolicyScheme != PolicyScheme::SchemeNone;
268 bool MaskedHasPolicy = MaskedPolicyScheme != PolicyScheme::SchemeNone;
269 SmallVector<Policy> SupportedUnMaskedPolicies =
271 SmallVector<Policy> SupportedMaskedPolicies =
273 Record.HasMaskPolicy);
274
275 for (unsigned int TypeRangeMaskShift = 0;
276 TypeRangeMaskShift <= static_cast<unsigned int>(BasicType::MaxOffset);
277 ++TypeRangeMaskShift) {
278 unsigned int BaseTypeI = 1 << TypeRangeMaskShift;
279 BaseType = static_cast<BasicType>(BaseTypeI);
280
281 if ((BaseTypeI & Record.TypeRangeMask) != BaseTypeI)
282 continue;
283
284 // TODO: Remove the check below and use RequiredFeatures in
285 // riscv_vector.td to check the intrinsics instead, the type check should
286 // be done in checkRVVTypeSupport. This check also not able to work on the
287 // intrinsics that have Float16 but the BaseType is not Float16 such as
288 // `vfcvt_f_x_v`.
289 if (BaseType == BasicType::Float16) {
290 if ((Record.RequiredExtensions & RVV_REQ_Zvfhmin) == RVV_REQ_Zvfhmin) {
291 if (!TI.hasFeature("zvfhmin"))
292 continue;
293 } else if (!TI.hasFeature("zvfh")) {
294 continue;
295 }
296 }
297
298 // Expanded with different LMUL.
299 for (int Log2LMUL = -3; Log2LMUL <= 3; Log2LMUL++) {
300 if (!(Record.Log2LMULMask & (1 << (Log2LMUL + 3))))
301 continue;
302
303 std::optional<RVVTypes> Types =
304 TypeCache.computeTypes(BaseType, Log2LMUL, Record.NF, ProtoSeq);
305
306 // Ignored to create new intrinsic if there are any illegal types.
307 if (!Types.has_value())
308 continue;
309
310 std::string SuffixStr = RVVIntrinsic::getSuffixStr(
311 TypeCache, BaseType, Log2LMUL, SuffixProto);
312 std::string OverloadedSuffixStr = RVVIntrinsic::getSuffixStr(
313 TypeCache, BaseType, Log2LMUL, OverloadedSuffixProto);
314
315 // Create non-masked intrinsic.
316 InitRVVIntrinsic(Record, SuffixStr, OverloadedSuffixStr, false, *Types,
317 UnMaskedHasPolicy, DefaultPolicy);
318
319 // Create non-masked policy intrinsic.
320 if (Record.UnMaskedPolicyScheme != PolicyScheme::SchemeNone) {
321 for (auto P : SupportedUnMaskedPolicies) {
324 BasicProtoSeq, /*IsMasked=*/false,
325 /*HasMaskedOffOperand=*/false, Record.HasVL, Record.NF,
326 UnMaskedPolicyScheme, P, Record.IsTuple);
327 std::optional<RVVTypes> PolicyTypes = TypeCache.computeTypes(
328 BaseType, Log2LMUL, Record.NF, PolicyPrototype);
329 InitRVVIntrinsic(Record, SuffixStr, OverloadedSuffixStr,
330 /*IsMask=*/false, *PolicyTypes, UnMaskedHasPolicy,
331 P);
332 }
333 }
334 if (!Record.HasMasked)
335 continue;
336 // Create masked intrinsic.
337 std::optional<RVVTypes> MaskTypes =
338 TypeCache.computeTypes(BaseType, Log2LMUL, Record.NF, ProtoMaskSeq);
339 InitRVVIntrinsic(Record, SuffixStr, OverloadedSuffixStr, true,
340 *MaskTypes, MaskedHasPolicy, DefaultPolicy);
341 if (Record.MaskedPolicyScheme == PolicyScheme::SchemeNone)
342 continue;
343 // Create masked policy intrinsic.
344 for (auto P : SupportedMaskedPolicies) {
347 BasicProtoSeq, /*IsMasked=*/true, Record.HasMaskedOffOperand,
348 Record.HasVL, Record.NF, MaskedPolicyScheme, P,
349 Record.IsTuple);
350 std::optional<RVVTypes> PolicyTypes = TypeCache.computeTypes(
351 BaseType, Log2LMUL, Record.NF, PolicyPrototype);
352 InitRVVIntrinsic(Record, SuffixStr, OverloadedSuffixStr,
353 /*IsMask=*/true, *PolicyTypes, MaskedHasPolicy, P);
354 }
355 } // End for different LMUL
356 } // End for different TypeRange
357 }
358}
359
360void RISCVIntrinsicManagerImpl::InitIntrinsicList() {
361
362 if (S.RISCV().DeclareRVVBuiltins && !ConstructedRISCVVBuiltins) {
363 ConstructedRISCVVBuiltins = true;
364 ConstructRVVIntrinsics(RVVIntrinsicRecords, IntrinsicKind::RVV);
365 }
367 !ConstructedRISCVSiFiveVectorBuiltins) {
368 ConstructedRISCVSiFiveVectorBuiltins = true;
369 ConstructRVVIntrinsics(RVSiFiveVectorIntrinsicRecords,
370 IntrinsicKind::SIFIVE_VECTOR);
371 }
372}
373
374// Compute name and signatures for intrinsic with practical types.
375void RISCVIntrinsicManagerImpl::InitRVVIntrinsic(
376 const RVVIntrinsicRecord &Record, StringRef SuffixStr,
377 StringRef OverloadedSuffixStr, bool IsMasked, RVVTypes &Signature,
378 bool HasPolicy, Policy PolicyAttrs) {
379 // Function name, e.g. vadd_vv_i32m1.
380 std::string Name = Record.Name;
381 if (!SuffixStr.empty())
382 Name += "_" + SuffixStr.str();
383
384 // Overloaded function name, e.g. vadd.
385 std::string OverloadedName;
386 if (!Record.OverloadedName)
387 OverloadedName = StringRef(Record.Name).split("_").first.str();
388 else
389 OverloadedName = Record.OverloadedName;
390 if (!OverloadedSuffixStr.empty())
391 OverloadedName += "_" + OverloadedSuffixStr.str();
392
393 // clang built-in function name, e.g. __builtin_rvv_vadd.
394 std::string BuiltinName = std::string(Record.Name);
395
396 RVVIntrinsic::updateNamesAndPolicy(IsMasked, HasPolicy, Name, BuiltinName,
397 OverloadedName, PolicyAttrs,
398 Record.HasFRMRoundModeOp);
399
400 // Put into IntrinsicList.
401 uint16_t Index = IntrinsicList.size();
402 assert(IntrinsicList.size() == (size_t)Index &&
403 "Intrinsics indices overflow.");
404 IntrinsicList.push_back({BuiltinName, Signature});
405
406 // Creating mapping to Intrinsics.
407 Intrinsics.insert({Name, Index});
408
409 // Get the RVVOverloadIntrinsicDef.
410 RVVOverloadIntrinsicDef &OverloadIntrinsicDef =
411 OverloadIntrinsics[OverloadedName];
412
413 // And added the index.
414 OverloadIntrinsicDef.Indexes.push_back(Index);
415}
416
417void RISCVIntrinsicManagerImpl::CreateRVVIntrinsicDecl(LookupResult &LR,
418 IdentifierInfo *II,
419 Preprocessor &PP,
420 uint32_t Index,
421 bool IsOverload) {
422 ASTContext &Context = S.Context;
423 RVVIntrinsicDef &IDef = IntrinsicList[Index];
424 RVVTypes Sigs = IDef.Signature;
425 size_t SigLength = Sigs.size();
426 RVVType *ReturnType = Sigs[0];
427 QualType RetType = RVVType2Qual(Context, ReturnType);
429 QualType BuiltinFuncType;
430
431 // Skip return type, and convert RVVType to QualType for arguments.
432 for (size_t i = 1; i < SigLength; ++i)
433 ArgTypes.push_back(RVVType2Qual(Context, Sigs[i]));
434
436 Context.getDefaultCallingConvention(false, false, true));
437
438 PI.Variadic = false;
439
441 BuiltinFuncType = Context.getFunctionType(RetType, ArgTypes, PI);
443
444 FunctionDecl *RVVIntrinsicDecl = FunctionDecl::Create(
445 Context, Parent, Loc, Loc, II, BuiltinFuncType, /*TInfo=*/nullptr,
447 /*isInlineSpecified*/ false,
448 /*hasWrittenPrototype*/ true);
449
450 // Create Decl objects for each parameter, adding them to the
451 // FunctionDecl.
452 const auto *FP = cast<FunctionProtoType>(BuiltinFuncType);
454 for (unsigned IParm = 0, E = FP->getNumParams(); IParm != E; ++IParm) {
455 ParmVarDecl *Parm =
456 ParmVarDecl::Create(Context, RVVIntrinsicDecl, Loc, Loc, nullptr,
457 FP->getParamType(IParm), nullptr, SC_None, nullptr);
458 Parm->setScopeInfo(0, IParm);
459 ParmList.push_back(Parm);
460 }
461 RVVIntrinsicDecl->setParams(ParmList);
462
463 // Add function attributes.
464 if (IsOverload)
465 RVVIntrinsicDecl->addAttr(OverloadableAttr::CreateImplicit(Context));
466
467 // Setup alias to __builtin_rvv_*
468 IdentifierInfo &IntrinsicII =
469 PP.getIdentifierTable().get("__builtin_rvv_" + IDef.BuiltinName);
470 RVVIntrinsicDecl->addAttr(
471 BuiltinAliasAttr::CreateImplicit(S.Context, &IntrinsicII));
472
473 // Add to symbol table.
474 LR.addDecl(RVVIntrinsicDecl);
475}
476
477bool RISCVIntrinsicManagerImpl::CreateIntrinsicIfFound(LookupResult &LR,
478 IdentifierInfo *II,
479 Preprocessor &PP) {
480 StringRef Name = II->getName();
481 if (!Name.consume_front("__riscv_"))
482 return false;
483
484 // Lookup the function name from the overload intrinsics first.
485 auto OvIItr = OverloadIntrinsics.find(Name);
486 if (OvIItr != OverloadIntrinsics.end()) {
487 const RVVOverloadIntrinsicDef &OvIntrinsicDef = OvIItr->second;
488 for (auto Index : OvIntrinsicDef.Indexes)
489 CreateRVVIntrinsicDecl(LR, II, PP, Index,
490 /*IsOverload*/ true);
491
492 // If we added overloads, need to resolve the lookup result.
493 LR.resolveKind();
494 return true;
495 }
496
497 // Lookup the function name from the intrinsics.
498 auto Itr = Intrinsics.find(Name);
499 if (Itr != Intrinsics.end()) {
500 CreateRVVIntrinsicDecl(LR, II, PP, Itr->second,
501 /*IsOverload*/ false);
502 return true;
503 }
504
505 // It's not an RVV intrinsics.
506 return false;
507}
508
509namespace clang {
510std::unique_ptr<clang::sema::RISCVIntrinsicManager>
512 return std::make_unique<RISCVIntrinsicManagerImpl>(S);
513}
514
515bool SemaRISCV::CheckLMUL(CallExpr *TheCall, unsigned ArgNum) {
516 llvm::APSInt Result;
517
518 // We can't check the value of a dependent argument.
519 Expr *Arg = TheCall->getArg(ArgNum);
520 if (Arg->isTypeDependent() || Arg->isValueDependent())
521 return false;
522
523 // Check constant-ness first.
524 if (SemaRef.BuiltinConstantArg(TheCall, ArgNum, Result))
525 return true;
526
527 int64_t Val = Result.getSExtValue();
528 if ((Val >= 0 && Val <= 3) || (Val >= 5 && Val <= 7))
529 return false;
530
531 return Diag(TheCall->getBeginLoc(), diag::err_riscv_builtin_invalid_lmul)
532 << Arg->getSourceRange();
533}
534
535static bool CheckInvalidVLENandLMUL(const TargetInfo &TI, CallExpr *TheCall,
536 Sema &S, QualType Type, int EGW) {
537 assert((EGW == 128 || EGW == 256) && "EGW can only be 128 or 256 bits");
538
539 // LMUL * VLEN >= EGW
542 unsigned ElemSize = S.Context.getTypeSize(Info.ElementType);
543 unsigned MinElemCount = Info.EC.getKnownMinValue();
544
545 unsigned EGS = EGW / ElemSize;
546 // If EGS is less than or equal to the minimum number of elements, then the
547 // type is valid.
548 if (EGS <= MinElemCount)
549 return false;
550
551 // Otherwise, we need vscale to be at least EGS / MinElemCont.
552 assert(EGS % MinElemCount == 0);
553 unsigned VScaleFactor = EGS / MinElemCount;
554 // Vscale is VLEN/RVVBitsPerBlock.
555 unsigned MinRequiredVLEN = VScaleFactor * llvm::RISCV::RVVBitsPerBlock;
556 std::string RequiredExt = "zvl" + std::to_string(MinRequiredVLEN) + "b";
557 if (!TI.hasFeature(RequiredExt))
558 return S.Diag(TheCall->getBeginLoc(),
559 diag::err_riscv_type_requires_extension)
560 << Type << RequiredExt;
561
562 return false;
563}
564
566 unsigned BuiltinID,
567 CallExpr *TheCall) {
568 ASTContext &Context = getASTContext();
569 // vmulh.vv, vmulh.vx, vmulhu.vv, vmulhu.vx, vmulhsu.vv, vmulhsu.vx,
570 // vsmul.vv, vsmul.vx are not included for EEW=64 in Zve64*.
571 switch (BuiltinID) {
572 default:
573 break;
574 case RISCVVector::BI__builtin_rvv_vmulhsu_vv:
575 case RISCVVector::BI__builtin_rvv_vmulhsu_vx:
576 case RISCVVector::BI__builtin_rvv_vmulhsu_vv_tu:
577 case RISCVVector::BI__builtin_rvv_vmulhsu_vx_tu:
578 case RISCVVector::BI__builtin_rvv_vmulhsu_vv_m:
579 case RISCVVector::BI__builtin_rvv_vmulhsu_vx_m:
580 case RISCVVector::BI__builtin_rvv_vmulhsu_vv_mu:
581 case RISCVVector::BI__builtin_rvv_vmulhsu_vx_mu:
582 case RISCVVector::BI__builtin_rvv_vmulhsu_vv_tum:
583 case RISCVVector::BI__builtin_rvv_vmulhsu_vx_tum:
584 case RISCVVector::BI__builtin_rvv_vmulhsu_vv_tumu:
585 case RISCVVector::BI__builtin_rvv_vmulhsu_vx_tumu:
586 case RISCVVector::BI__builtin_rvv_vmulhu_vv:
587 case RISCVVector::BI__builtin_rvv_vmulhu_vx:
588 case RISCVVector::BI__builtin_rvv_vmulhu_vv_tu:
589 case RISCVVector::BI__builtin_rvv_vmulhu_vx_tu:
590 case RISCVVector::BI__builtin_rvv_vmulhu_vv_m:
591 case RISCVVector::BI__builtin_rvv_vmulhu_vx_m:
592 case RISCVVector::BI__builtin_rvv_vmulhu_vv_mu:
593 case RISCVVector::BI__builtin_rvv_vmulhu_vx_mu:
594 case RISCVVector::BI__builtin_rvv_vmulhu_vv_tum:
595 case RISCVVector::BI__builtin_rvv_vmulhu_vx_tum:
596 case RISCVVector::BI__builtin_rvv_vmulhu_vv_tumu:
597 case RISCVVector::BI__builtin_rvv_vmulhu_vx_tumu:
598 case RISCVVector::BI__builtin_rvv_vmulh_vv:
599 case RISCVVector::BI__builtin_rvv_vmulh_vx:
600 case RISCVVector::BI__builtin_rvv_vmulh_vv_tu:
601 case RISCVVector::BI__builtin_rvv_vmulh_vx_tu:
602 case RISCVVector::BI__builtin_rvv_vmulh_vv_m:
603 case RISCVVector::BI__builtin_rvv_vmulh_vx_m:
604 case RISCVVector::BI__builtin_rvv_vmulh_vv_mu:
605 case RISCVVector::BI__builtin_rvv_vmulh_vx_mu:
606 case RISCVVector::BI__builtin_rvv_vmulh_vv_tum:
607 case RISCVVector::BI__builtin_rvv_vmulh_vx_tum:
608 case RISCVVector::BI__builtin_rvv_vmulh_vv_tumu:
609 case RISCVVector::BI__builtin_rvv_vmulh_vx_tumu:
610 case RISCVVector::BI__builtin_rvv_vsmul_vv:
611 case RISCVVector::BI__builtin_rvv_vsmul_vx:
612 case RISCVVector::BI__builtin_rvv_vsmul_vv_tu:
613 case RISCVVector::BI__builtin_rvv_vsmul_vx_tu:
614 case RISCVVector::BI__builtin_rvv_vsmul_vv_m:
615 case RISCVVector::BI__builtin_rvv_vsmul_vx_m:
616 case RISCVVector::BI__builtin_rvv_vsmul_vv_mu:
617 case RISCVVector::BI__builtin_rvv_vsmul_vx_mu:
618 case RISCVVector::BI__builtin_rvv_vsmul_vv_tum:
619 case RISCVVector::BI__builtin_rvv_vsmul_vx_tum:
620 case RISCVVector::BI__builtin_rvv_vsmul_vv_tumu:
621 case RISCVVector::BI__builtin_rvv_vsmul_vx_tumu: {
623 TheCall->getType()->castAs<BuiltinType>());
624
625 if (Context.getTypeSize(Info.ElementType) == 64 && !TI.hasFeature("v"))
626 return Diag(TheCall->getBeginLoc(),
627 diag::err_riscv_builtin_requires_extension)
628 << /* IsExtension */ true << TheCall->getSourceRange() << "v";
629
630 break;
631 }
632 }
633
634 switch (BuiltinID) {
635 case RISCVVector::BI__builtin_rvv_vsetvli:
636 return SemaRef.BuiltinConstantArgRange(TheCall, 1, 0, 3) ||
637 CheckLMUL(TheCall, 2);
638 case RISCVVector::BI__builtin_rvv_vsetvlimax:
639 return SemaRef.BuiltinConstantArgRange(TheCall, 0, 0, 3) ||
640 CheckLMUL(TheCall, 1);
641 case RISCVVector::BI__builtin_rvv_vget_v: {
643 Context.getBuiltinVectorTypeInfo(cast<BuiltinType>(
644 TheCall->getType().getCanonicalType().getTypePtr()));
646 Context.getBuiltinVectorTypeInfo(cast<BuiltinType>(
647 TheCall->getArg(0)->getType().getCanonicalType().getTypePtr()));
648 unsigned MaxIndex;
649 if (VecInfo.NumVectors != 1) // vget for tuple type
650 MaxIndex = VecInfo.NumVectors;
651 else // vget for non-tuple type
652 MaxIndex = (VecInfo.EC.getKnownMinValue() * VecInfo.NumVectors) /
653 (ResVecInfo.EC.getKnownMinValue() * ResVecInfo.NumVectors);
654 return SemaRef.BuiltinConstantArgRange(TheCall, 1, 0, MaxIndex - 1);
655 }
656 case RISCVVector::BI__builtin_rvv_vset_v: {
658 Context.getBuiltinVectorTypeInfo(cast<BuiltinType>(
659 TheCall->getType().getCanonicalType().getTypePtr()));
661 Context.getBuiltinVectorTypeInfo(cast<BuiltinType>(
662 TheCall->getArg(2)->getType().getCanonicalType().getTypePtr()));
663 unsigned MaxIndex;
664 if (ResVecInfo.NumVectors != 1) // vset for tuple type
665 MaxIndex = ResVecInfo.NumVectors;
666 else // vset fo non-tuple type
667 MaxIndex = (ResVecInfo.EC.getKnownMinValue() * ResVecInfo.NumVectors) /
668 (VecInfo.EC.getKnownMinValue() * VecInfo.NumVectors);
669 return SemaRef.BuiltinConstantArgRange(TheCall, 1, 0, MaxIndex - 1);
670 }
671 // Vector Crypto
672 case RISCVVector::BI__builtin_rvv_vaeskf1_vi_tu:
673 case RISCVVector::BI__builtin_rvv_vaeskf2_vi_tu:
674 case RISCVVector::BI__builtin_rvv_vaeskf2_vi:
675 case RISCVVector::BI__builtin_rvv_vsm4k_vi_tu: {
676 QualType Op1Type = TheCall->getArg(0)->getType();
677 QualType Op2Type = TheCall->getArg(1)->getType();
678 return CheckInvalidVLENandLMUL(TI, TheCall, SemaRef, Op1Type, 128) ||
679 CheckInvalidVLENandLMUL(TI, TheCall, SemaRef, Op2Type, 128) ||
680 SemaRef.BuiltinConstantArgRange(TheCall, 2, 0, 31);
681 }
682 case RISCVVector::BI__builtin_rvv_vsm3c_vi_tu:
683 case RISCVVector::BI__builtin_rvv_vsm3c_vi: {
684 QualType Op1Type = TheCall->getArg(0)->getType();
685 return CheckInvalidVLENandLMUL(TI, TheCall, SemaRef, Op1Type, 256) ||
686 SemaRef.BuiltinConstantArgRange(TheCall, 2, 0, 31);
687 }
688 case RISCVVector::BI__builtin_rvv_vaeskf1_vi:
689 case RISCVVector::BI__builtin_rvv_vsm4k_vi: {
690 QualType Op1Type = TheCall->getArg(0)->getType();
691 return CheckInvalidVLENandLMUL(TI, TheCall, SemaRef, Op1Type, 128) ||
692 SemaRef.BuiltinConstantArgRange(TheCall, 1, 0, 31);
693 }
694 case RISCVVector::BI__builtin_rvv_vaesdf_vv:
695 case RISCVVector::BI__builtin_rvv_vaesdf_vs:
696 case RISCVVector::BI__builtin_rvv_vaesdm_vv:
697 case RISCVVector::BI__builtin_rvv_vaesdm_vs:
698 case RISCVVector::BI__builtin_rvv_vaesef_vv:
699 case RISCVVector::BI__builtin_rvv_vaesef_vs:
700 case RISCVVector::BI__builtin_rvv_vaesem_vv:
701 case RISCVVector::BI__builtin_rvv_vaesem_vs:
702 case RISCVVector::BI__builtin_rvv_vaesz_vs:
703 case RISCVVector::BI__builtin_rvv_vsm4r_vv:
704 case RISCVVector::BI__builtin_rvv_vsm4r_vs:
705 case RISCVVector::BI__builtin_rvv_vaesdf_vv_tu:
706 case RISCVVector::BI__builtin_rvv_vaesdf_vs_tu:
707 case RISCVVector::BI__builtin_rvv_vaesdm_vv_tu:
708 case RISCVVector::BI__builtin_rvv_vaesdm_vs_tu:
709 case RISCVVector::BI__builtin_rvv_vaesef_vv_tu:
710 case RISCVVector::BI__builtin_rvv_vaesef_vs_tu:
711 case RISCVVector::BI__builtin_rvv_vaesem_vv_tu:
712 case RISCVVector::BI__builtin_rvv_vaesem_vs_tu:
713 case RISCVVector::BI__builtin_rvv_vaesz_vs_tu:
714 case RISCVVector::BI__builtin_rvv_vsm4r_vv_tu:
715 case RISCVVector::BI__builtin_rvv_vsm4r_vs_tu: {
716 QualType Op1Type = TheCall->getArg(0)->getType();
717 QualType Op2Type = TheCall->getArg(1)->getType();
718 return CheckInvalidVLENandLMUL(TI, TheCall, SemaRef, Op1Type, 128) ||
719 CheckInvalidVLENandLMUL(TI, TheCall, SemaRef, Op2Type, 128);
720 }
721 case RISCVVector::BI__builtin_rvv_vsha2ch_vv:
722 case RISCVVector::BI__builtin_rvv_vsha2cl_vv:
723 case RISCVVector::BI__builtin_rvv_vsha2ms_vv:
724 case RISCVVector::BI__builtin_rvv_vsha2ch_vv_tu:
725 case RISCVVector::BI__builtin_rvv_vsha2cl_vv_tu:
726 case RISCVVector::BI__builtin_rvv_vsha2ms_vv_tu: {
727 QualType Op1Type = TheCall->getArg(0)->getType();
728 QualType Op2Type = TheCall->getArg(1)->getType();
729 QualType Op3Type = TheCall->getArg(2)->getType();
731 Context.getBuiltinVectorTypeInfo(Op1Type->castAs<BuiltinType>());
732 uint64_t ElemSize = Context.getTypeSize(Info.ElementType);
733 if (ElemSize == 64 && !TI.hasFeature("zvknhb"))
734 return Diag(TheCall->getBeginLoc(),
735 diag::err_riscv_builtin_requires_extension)
736 << /* IsExtension */ true << TheCall->getSourceRange() << "zvknb";
737
738 return CheckInvalidVLENandLMUL(TI, TheCall, SemaRef, Op1Type,
739 ElemSize * 4) ||
740 CheckInvalidVLENandLMUL(TI, TheCall, SemaRef, Op2Type,
741 ElemSize * 4) ||
742 CheckInvalidVLENandLMUL(TI, TheCall, SemaRef, Op3Type, ElemSize * 4);
743 }
744
745 case RISCVVector::BI__builtin_rvv_sf_vc_i_se:
746 // bit_27_26, bit_24_20, bit_11_7, simm5, sew, log2lmul
747 return SemaRef.BuiltinConstantArgRange(TheCall, 0, 0, 3) ||
748 SemaRef.BuiltinConstantArgRange(TheCall, 1, 0, 31) ||
749 SemaRef.BuiltinConstantArgRange(TheCall, 2, 0, 31) ||
750 SemaRef.BuiltinConstantArgRange(TheCall, 3, -16, 15) ||
751 CheckLMUL(TheCall, 5);
752 case RISCVVector::BI__builtin_rvv_sf_vc_iv_se:
753 // bit_27_26, bit_11_7, vs2, simm5
754 return SemaRef.BuiltinConstantArgRange(TheCall, 0, 0, 3) ||
755 SemaRef.BuiltinConstantArgRange(TheCall, 1, 0, 31) ||
756 SemaRef.BuiltinConstantArgRange(TheCall, 3, -16, 15);
757 case RISCVVector::BI__builtin_rvv_sf_vc_v_i:
758 case RISCVVector::BI__builtin_rvv_sf_vc_v_i_se:
759 // bit_27_26, bit_24_20, simm5
760 return SemaRef.BuiltinConstantArgRange(TheCall, 0, 0, 3) ||
761 SemaRef.BuiltinConstantArgRange(TheCall, 1, 0, 31) ||
762 SemaRef.BuiltinConstantArgRange(TheCall, 2, -16, 15);
763 case RISCVVector::BI__builtin_rvv_sf_vc_v_iv:
764 case RISCVVector::BI__builtin_rvv_sf_vc_v_iv_se:
765 // bit_27_26, vs2, simm5
766 return SemaRef.BuiltinConstantArgRange(TheCall, 0, 0, 3) ||
767 SemaRef.BuiltinConstantArgRange(TheCall, 2, -16, 15);
768 case RISCVVector::BI__builtin_rvv_sf_vc_ivv_se:
769 case RISCVVector::BI__builtin_rvv_sf_vc_ivw_se:
770 case RISCVVector::BI__builtin_rvv_sf_vc_v_ivv:
771 case RISCVVector::BI__builtin_rvv_sf_vc_v_ivw:
772 case RISCVVector::BI__builtin_rvv_sf_vc_v_ivv_se:
773 case RISCVVector::BI__builtin_rvv_sf_vc_v_ivw_se:
774 // bit_27_26, vd, vs2, simm5
775 return SemaRef.BuiltinConstantArgRange(TheCall, 0, 0, 3) ||
776 SemaRef.BuiltinConstantArgRange(TheCall, 3, -16, 15);
777 case RISCVVector::BI__builtin_rvv_sf_vc_x_se:
778 // bit_27_26, bit_24_20, bit_11_7, xs1, sew, log2lmul
779 return SemaRef.BuiltinConstantArgRange(TheCall, 0, 0, 3) ||
780 SemaRef.BuiltinConstantArgRange(TheCall, 1, 0, 31) ||
781 SemaRef.BuiltinConstantArgRange(TheCall, 2, 0, 31) ||
782 CheckLMUL(TheCall, 5);
783 case RISCVVector::BI__builtin_rvv_sf_vc_xv_se:
784 case RISCVVector::BI__builtin_rvv_sf_vc_vv_se:
785 // bit_27_26, bit_11_7, vs2, xs1/vs1
786 case RISCVVector::BI__builtin_rvv_sf_vc_v_x:
787 case RISCVVector::BI__builtin_rvv_sf_vc_v_x_se:
788 // bit_27_26, bit_24-20, xs1
789 return SemaRef.BuiltinConstantArgRange(TheCall, 0, 0, 3) ||
790 SemaRef.BuiltinConstantArgRange(TheCall, 1, 0, 31);
791 case RISCVVector::BI__builtin_rvv_sf_vc_vvv_se:
792 case RISCVVector::BI__builtin_rvv_sf_vc_xvv_se:
793 case RISCVVector::BI__builtin_rvv_sf_vc_vvw_se:
794 case RISCVVector::BI__builtin_rvv_sf_vc_xvw_se:
795 // bit_27_26, vd, vs2, xs1
796 case RISCVVector::BI__builtin_rvv_sf_vc_v_xv:
797 case RISCVVector::BI__builtin_rvv_sf_vc_v_vv:
798 case RISCVVector::BI__builtin_rvv_sf_vc_v_xv_se:
799 case RISCVVector::BI__builtin_rvv_sf_vc_v_vv_se:
800 // bit_27_26, vs2, xs1/vs1
801 case RISCVVector::BI__builtin_rvv_sf_vc_v_xvv:
802 case RISCVVector::BI__builtin_rvv_sf_vc_v_vvv:
803 case RISCVVector::BI__builtin_rvv_sf_vc_v_xvw:
804 case RISCVVector::BI__builtin_rvv_sf_vc_v_vvw:
805 case RISCVVector::BI__builtin_rvv_sf_vc_v_xvv_se:
806 case RISCVVector::BI__builtin_rvv_sf_vc_v_vvv_se:
807 case RISCVVector::BI__builtin_rvv_sf_vc_v_xvw_se:
808 case RISCVVector::BI__builtin_rvv_sf_vc_v_vvw_se:
809 // bit_27_26, vd, vs2, xs1/vs1
810 return SemaRef.BuiltinConstantArgRange(TheCall, 0, 0, 3);
811 case RISCVVector::BI__builtin_rvv_sf_vc_fv_se:
812 // bit_26, bit_11_7, vs2, fs1
813 return SemaRef.BuiltinConstantArgRange(TheCall, 0, 0, 1) ||
814 SemaRef.BuiltinConstantArgRange(TheCall, 1, 0, 31);
815 case RISCVVector::BI__builtin_rvv_sf_vc_fvv_se:
816 case RISCVVector::BI__builtin_rvv_sf_vc_fvw_se:
817 case RISCVVector::BI__builtin_rvv_sf_vc_v_fvv:
818 case RISCVVector::BI__builtin_rvv_sf_vc_v_fvw:
819 case RISCVVector::BI__builtin_rvv_sf_vc_v_fvv_se:
820 case RISCVVector::BI__builtin_rvv_sf_vc_v_fvw_se:
821 // bit_26, vd, vs2, fs1
822 case RISCVVector::BI__builtin_rvv_sf_vc_v_fv:
823 case RISCVVector::BI__builtin_rvv_sf_vc_v_fv_se:
824 // bit_26, vs2, fs1
825 return SemaRef.BuiltinConstantArgRange(TheCall, 0, 0, 1);
826 // Check if byteselect is in [0, 3]
827 case RISCV::BI__builtin_riscv_aes32dsi:
828 case RISCV::BI__builtin_riscv_aes32dsmi:
829 case RISCV::BI__builtin_riscv_aes32esi:
830 case RISCV::BI__builtin_riscv_aes32esmi:
831 case RISCV::BI__builtin_riscv_sm4ks:
832 case RISCV::BI__builtin_riscv_sm4ed:
833 return SemaRef.BuiltinConstantArgRange(TheCall, 2, 0, 3);
834 // Check if rnum is in [0, 10]
835 case RISCV::BI__builtin_riscv_aes64ks1i:
836 return SemaRef.BuiltinConstantArgRange(TheCall, 1, 0, 10);
837 // Check if value range for vxrm is in [0, 3]
838 case RISCVVector::BI__builtin_rvv_vaaddu_vv:
839 case RISCVVector::BI__builtin_rvv_vaaddu_vx:
840 case RISCVVector::BI__builtin_rvv_vaadd_vv:
841 case RISCVVector::BI__builtin_rvv_vaadd_vx:
842 case RISCVVector::BI__builtin_rvv_vasubu_vv:
843 case RISCVVector::BI__builtin_rvv_vasubu_vx:
844 case RISCVVector::BI__builtin_rvv_vasub_vv:
845 case RISCVVector::BI__builtin_rvv_vasub_vx:
846 case RISCVVector::BI__builtin_rvv_vsmul_vv:
847 case RISCVVector::BI__builtin_rvv_vsmul_vx:
848 case RISCVVector::BI__builtin_rvv_vssra_vv:
849 case RISCVVector::BI__builtin_rvv_vssra_vx:
850 case RISCVVector::BI__builtin_rvv_vssrl_vv:
851 case RISCVVector::BI__builtin_rvv_vssrl_vx:
852 case RISCVVector::BI__builtin_rvv_vnclip_wv:
853 case RISCVVector::BI__builtin_rvv_vnclip_wx:
854 case RISCVVector::BI__builtin_rvv_vnclipu_wv:
855 case RISCVVector::BI__builtin_rvv_vnclipu_wx:
856 return SemaRef.BuiltinConstantArgRange(TheCall, 2, 0, 3);
857 case RISCVVector::BI__builtin_rvv_vaaddu_vv_tu:
858 case RISCVVector::BI__builtin_rvv_vaaddu_vx_tu:
859 case RISCVVector::BI__builtin_rvv_vaadd_vv_tu:
860 case RISCVVector::BI__builtin_rvv_vaadd_vx_tu:
861 case RISCVVector::BI__builtin_rvv_vasubu_vv_tu:
862 case RISCVVector::BI__builtin_rvv_vasubu_vx_tu:
863 case RISCVVector::BI__builtin_rvv_vasub_vv_tu:
864 case RISCVVector::BI__builtin_rvv_vasub_vx_tu:
865 case RISCVVector::BI__builtin_rvv_vsmul_vv_tu:
866 case RISCVVector::BI__builtin_rvv_vsmul_vx_tu:
867 case RISCVVector::BI__builtin_rvv_vssra_vv_tu:
868 case RISCVVector::BI__builtin_rvv_vssra_vx_tu:
869 case RISCVVector::BI__builtin_rvv_vssrl_vv_tu:
870 case RISCVVector::BI__builtin_rvv_vssrl_vx_tu:
871 case RISCVVector::BI__builtin_rvv_vnclip_wv_tu:
872 case RISCVVector::BI__builtin_rvv_vnclip_wx_tu:
873 case RISCVVector::BI__builtin_rvv_vnclipu_wv_tu:
874 case RISCVVector::BI__builtin_rvv_vnclipu_wx_tu:
875 case RISCVVector::BI__builtin_rvv_vaaddu_vv_m:
876 case RISCVVector::BI__builtin_rvv_vaaddu_vx_m:
877 case RISCVVector::BI__builtin_rvv_vaadd_vv_m:
878 case RISCVVector::BI__builtin_rvv_vaadd_vx_m:
879 case RISCVVector::BI__builtin_rvv_vasubu_vv_m:
880 case RISCVVector::BI__builtin_rvv_vasubu_vx_m:
881 case RISCVVector::BI__builtin_rvv_vasub_vv_m:
882 case RISCVVector::BI__builtin_rvv_vasub_vx_m:
883 case RISCVVector::BI__builtin_rvv_vsmul_vv_m:
884 case RISCVVector::BI__builtin_rvv_vsmul_vx_m:
885 case RISCVVector::BI__builtin_rvv_vssra_vv_m:
886 case RISCVVector::BI__builtin_rvv_vssra_vx_m:
887 case RISCVVector::BI__builtin_rvv_vssrl_vv_m:
888 case RISCVVector::BI__builtin_rvv_vssrl_vx_m:
889 case RISCVVector::BI__builtin_rvv_vnclip_wv_m:
890 case RISCVVector::BI__builtin_rvv_vnclip_wx_m:
891 case RISCVVector::BI__builtin_rvv_vnclipu_wv_m:
892 case RISCVVector::BI__builtin_rvv_vnclipu_wx_m:
893 return SemaRef.BuiltinConstantArgRange(TheCall, 3, 0, 3);
894 case RISCVVector::BI__builtin_rvv_vaaddu_vv_tum:
895 case RISCVVector::BI__builtin_rvv_vaaddu_vv_tumu:
896 case RISCVVector::BI__builtin_rvv_vaaddu_vv_mu:
897 case RISCVVector::BI__builtin_rvv_vaaddu_vx_tum:
898 case RISCVVector::BI__builtin_rvv_vaaddu_vx_tumu:
899 case RISCVVector::BI__builtin_rvv_vaaddu_vx_mu:
900 case RISCVVector::BI__builtin_rvv_vaadd_vv_tum:
901 case RISCVVector::BI__builtin_rvv_vaadd_vv_tumu:
902 case RISCVVector::BI__builtin_rvv_vaadd_vv_mu:
903 case RISCVVector::BI__builtin_rvv_vaadd_vx_tum:
904 case RISCVVector::BI__builtin_rvv_vaadd_vx_tumu:
905 case RISCVVector::BI__builtin_rvv_vaadd_vx_mu:
906 case RISCVVector::BI__builtin_rvv_vasubu_vv_tum:
907 case RISCVVector::BI__builtin_rvv_vasubu_vv_tumu:
908 case RISCVVector::BI__builtin_rvv_vasubu_vv_mu:
909 case RISCVVector::BI__builtin_rvv_vasubu_vx_tum:
910 case RISCVVector::BI__builtin_rvv_vasubu_vx_tumu:
911 case RISCVVector::BI__builtin_rvv_vasubu_vx_mu:
912 case RISCVVector::BI__builtin_rvv_vasub_vv_tum:
913 case RISCVVector::BI__builtin_rvv_vasub_vv_tumu:
914 case RISCVVector::BI__builtin_rvv_vasub_vv_mu:
915 case RISCVVector::BI__builtin_rvv_vasub_vx_tum:
916 case RISCVVector::BI__builtin_rvv_vasub_vx_tumu:
917 case RISCVVector::BI__builtin_rvv_vasub_vx_mu:
918 case RISCVVector::BI__builtin_rvv_vsmul_vv_mu:
919 case RISCVVector::BI__builtin_rvv_vsmul_vx_mu:
920 case RISCVVector::BI__builtin_rvv_vssra_vv_mu:
921 case RISCVVector::BI__builtin_rvv_vssra_vx_mu:
922 case RISCVVector::BI__builtin_rvv_vssrl_vv_mu:
923 case RISCVVector::BI__builtin_rvv_vssrl_vx_mu:
924 case RISCVVector::BI__builtin_rvv_vnclip_wv_mu:
925 case RISCVVector::BI__builtin_rvv_vnclip_wx_mu:
926 case RISCVVector::BI__builtin_rvv_vnclipu_wv_mu:
927 case RISCVVector::BI__builtin_rvv_vnclipu_wx_mu:
928 case RISCVVector::BI__builtin_rvv_vsmul_vv_tum:
929 case RISCVVector::BI__builtin_rvv_vsmul_vx_tum:
930 case RISCVVector::BI__builtin_rvv_vssra_vv_tum:
931 case RISCVVector::BI__builtin_rvv_vssra_vx_tum:
932 case RISCVVector::BI__builtin_rvv_vssrl_vv_tum:
933 case RISCVVector::BI__builtin_rvv_vssrl_vx_tum:
934 case RISCVVector::BI__builtin_rvv_vnclip_wv_tum:
935 case RISCVVector::BI__builtin_rvv_vnclip_wx_tum:
936 case RISCVVector::BI__builtin_rvv_vnclipu_wv_tum:
937 case RISCVVector::BI__builtin_rvv_vnclipu_wx_tum:
938 case RISCVVector::BI__builtin_rvv_vsmul_vv_tumu:
939 case RISCVVector::BI__builtin_rvv_vsmul_vx_tumu:
940 case RISCVVector::BI__builtin_rvv_vssra_vv_tumu:
941 case RISCVVector::BI__builtin_rvv_vssra_vx_tumu:
942 case RISCVVector::BI__builtin_rvv_vssrl_vv_tumu:
943 case RISCVVector::BI__builtin_rvv_vssrl_vx_tumu:
944 case RISCVVector::BI__builtin_rvv_vnclip_wv_tumu:
945 case RISCVVector::BI__builtin_rvv_vnclip_wx_tumu:
946 case RISCVVector::BI__builtin_rvv_vnclipu_wv_tumu:
947 case RISCVVector::BI__builtin_rvv_vnclipu_wx_tumu:
948 return SemaRef.BuiltinConstantArgRange(TheCall, 4, 0, 3);
949 case RISCVVector::BI__builtin_rvv_vfsqrt_v_rm:
950 case RISCVVector::BI__builtin_rvv_vfrec7_v_rm:
951 case RISCVVector::BI__builtin_rvv_vfcvt_x_f_v_rm:
952 case RISCVVector::BI__builtin_rvv_vfcvt_xu_f_v_rm:
953 case RISCVVector::BI__builtin_rvv_vfcvt_f_x_v_rm:
954 case RISCVVector::BI__builtin_rvv_vfcvt_f_xu_v_rm:
955 case RISCVVector::BI__builtin_rvv_vfwcvt_x_f_v_rm:
956 case RISCVVector::BI__builtin_rvv_vfwcvt_xu_f_v_rm:
957 case RISCVVector::BI__builtin_rvv_vfncvt_x_f_w_rm:
958 case RISCVVector::BI__builtin_rvv_vfncvt_xu_f_w_rm:
959 case RISCVVector::BI__builtin_rvv_vfncvt_f_x_w_rm:
960 case RISCVVector::BI__builtin_rvv_vfncvt_f_xu_w_rm:
961 case RISCVVector::BI__builtin_rvv_vfncvt_f_f_w_rm:
962 return SemaRef.BuiltinConstantArgRange(TheCall, 1, 0, 4);
963 case RISCVVector::BI__builtin_rvv_vfadd_vv_rm:
964 case RISCVVector::BI__builtin_rvv_vfadd_vf_rm:
965 case RISCVVector::BI__builtin_rvv_vfsub_vv_rm:
966 case RISCVVector::BI__builtin_rvv_vfsub_vf_rm:
967 case RISCVVector::BI__builtin_rvv_vfrsub_vf_rm:
968 case RISCVVector::BI__builtin_rvv_vfwadd_vv_rm:
969 case RISCVVector::BI__builtin_rvv_vfwadd_vf_rm:
970 case RISCVVector::BI__builtin_rvv_vfwsub_vv_rm:
971 case RISCVVector::BI__builtin_rvv_vfwsub_vf_rm:
972 case RISCVVector::BI__builtin_rvv_vfwadd_wv_rm:
973 case RISCVVector::BI__builtin_rvv_vfwadd_wf_rm:
974 case RISCVVector::BI__builtin_rvv_vfwsub_wv_rm:
975 case RISCVVector::BI__builtin_rvv_vfwsub_wf_rm:
976 case RISCVVector::BI__builtin_rvv_vfmul_vv_rm:
977 case RISCVVector::BI__builtin_rvv_vfmul_vf_rm:
978 case RISCVVector::BI__builtin_rvv_vfdiv_vv_rm:
979 case RISCVVector::BI__builtin_rvv_vfdiv_vf_rm:
980 case RISCVVector::BI__builtin_rvv_vfrdiv_vf_rm:
981 case RISCVVector::BI__builtin_rvv_vfwmul_vv_rm:
982 case RISCVVector::BI__builtin_rvv_vfwmul_vf_rm:
983 case RISCVVector::BI__builtin_rvv_vfredosum_vs_rm:
984 case RISCVVector::BI__builtin_rvv_vfredusum_vs_rm:
985 case RISCVVector::BI__builtin_rvv_vfwredosum_vs_rm:
986 case RISCVVector::BI__builtin_rvv_vfwredusum_vs_rm:
987 case RISCVVector::BI__builtin_rvv_vfsqrt_v_rm_tu:
988 case RISCVVector::BI__builtin_rvv_vfrec7_v_rm_tu:
989 case RISCVVector::BI__builtin_rvv_vfcvt_x_f_v_rm_tu:
990 case RISCVVector::BI__builtin_rvv_vfcvt_xu_f_v_rm_tu:
991 case RISCVVector::BI__builtin_rvv_vfcvt_f_x_v_rm_tu:
992 case RISCVVector::BI__builtin_rvv_vfcvt_f_xu_v_rm_tu:
993 case RISCVVector::BI__builtin_rvv_vfwcvt_x_f_v_rm_tu:
994 case RISCVVector::BI__builtin_rvv_vfwcvt_xu_f_v_rm_tu:
995 case RISCVVector::BI__builtin_rvv_vfncvt_x_f_w_rm_tu:
996 case RISCVVector::BI__builtin_rvv_vfncvt_xu_f_w_rm_tu:
997 case RISCVVector::BI__builtin_rvv_vfncvt_f_x_w_rm_tu:
998 case RISCVVector::BI__builtin_rvv_vfncvt_f_xu_w_rm_tu:
999 case RISCVVector::BI__builtin_rvv_vfncvt_f_f_w_rm_tu:
1000 case RISCVVector::BI__builtin_rvv_vfsqrt_v_rm_m:
1001 case RISCVVector::BI__builtin_rvv_vfrec7_v_rm_m:
1002 case RISCVVector::BI__builtin_rvv_vfcvt_x_f_v_rm_m:
1003 case RISCVVector::BI__builtin_rvv_vfcvt_xu_f_v_rm_m:
1004 case RISCVVector::BI__builtin_rvv_vfcvt_f_x_v_rm_m:
1005 case RISCVVector::BI__builtin_rvv_vfcvt_f_xu_v_rm_m:
1006 case RISCVVector::BI__builtin_rvv_vfwcvt_x_f_v_rm_m:
1007 case RISCVVector::BI__builtin_rvv_vfwcvt_xu_f_v_rm_m:
1008 case RISCVVector::BI__builtin_rvv_vfncvt_x_f_w_rm_m:
1009 case RISCVVector::BI__builtin_rvv_vfncvt_xu_f_w_rm_m:
1010 case RISCVVector::BI__builtin_rvv_vfncvt_f_x_w_rm_m:
1011 case RISCVVector::BI__builtin_rvv_vfncvt_f_xu_w_rm_m:
1012 case RISCVVector::BI__builtin_rvv_vfncvt_f_f_w_rm_m:
1013 return SemaRef.BuiltinConstantArgRange(TheCall, 2, 0, 4);
1014 case RISCVVector::BI__builtin_rvv_vfadd_vv_rm_tu:
1015 case RISCVVector::BI__builtin_rvv_vfadd_vf_rm_tu:
1016 case RISCVVector::BI__builtin_rvv_vfsub_vv_rm_tu:
1017 case RISCVVector::BI__builtin_rvv_vfsub_vf_rm_tu:
1018 case RISCVVector::BI__builtin_rvv_vfrsub_vf_rm_tu:
1019 case RISCVVector::BI__builtin_rvv_vfwadd_vv_rm_tu:
1020 case RISCVVector::BI__builtin_rvv_vfwadd_vf_rm_tu:
1021 case RISCVVector::BI__builtin_rvv_vfwsub_vv_rm_tu:
1022 case RISCVVector::BI__builtin_rvv_vfwsub_vf_rm_tu:
1023 case RISCVVector::BI__builtin_rvv_vfwadd_wv_rm_tu:
1024 case RISCVVector::BI__builtin_rvv_vfwadd_wf_rm_tu:
1025 case RISCVVector::BI__builtin_rvv_vfwsub_wv_rm_tu:
1026 case RISCVVector::BI__builtin_rvv_vfwsub_wf_rm_tu:
1027 case RISCVVector::BI__builtin_rvv_vfmul_vv_rm_tu:
1028 case RISCVVector::BI__builtin_rvv_vfmul_vf_rm_tu:
1029 case RISCVVector::BI__builtin_rvv_vfdiv_vv_rm_tu:
1030 case RISCVVector::BI__builtin_rvv_vfdiv_vf_rm_tu:
1031 case RISCVVector::BI__builtin_rvv_vfrdiv_vf_rm_tu:
1032 case RISCVVector::BI__builtin_rvv_vfwmul_vv_rm_tu:
1033 case RISCVVector::BI__builtin_rvv_vfwmul_vf_rm_tu:
1034 case RISCVVector::BI__builtin_rvv_vfredosum_vs_rm_tu:
1035 case RISCVVector::BI__builtin_rvv_vfredusum_vs_rm_tu:
1036 case RISCVVector::BI__builtin_rvv_vfwredosum_vs_rm_tu:
1037 case RISCVVector::BI__builtin_rvv_vfwredusum_vs_rm_tu:
1038 case RISCVVector::BI__builtin_rvv_vfmacc_vv_rm:
1039 case RISCVVector::BI__builtin_rvv_vfmacc_vf_rm:
1040 case RISCVVector::BI__builtin_rvv_vfnmacc_vv_rm:
1041 case RISCVVector::BI__builtin_rvv_vfnmacc_vf_rm:
1042 case RISCVVector::BI__builtin_rvv_vfmsac_vv_rm:
1043 case RISCVVector::BI__builtin_rvv_vfmsac_vf_rm:
1044 case RISCVVector::BI__builtin_rvv_vfnmsac_vv_rm:
1045 case RISCVVector::BI__builtin_rvv_vfnmsac_vf_rm:
1046 case RISCVVector::BI__builtin_rvv_vfmadd_vv_rm:
1047 case RISCVVector::BI__builtin_rvv_vfmadd_vf_rm:
1048 case RISCVVector::BI__builtin_rvv_vfnmadd_vv_rm:
1049 case RISCVVector::BI__builtin_rvv_vfnmadd_vf_rm:
1050 case RISCVVector::BI__builtin_rvv_vfmsub_vv_rm:
1051 case RISCVVector::BI__builtin_rvv_vfmsub_vf_rm:
1052 case RISCVVector::BI__builtin_rvv_vfnmsub_vv_rm:
1053 case RISCVVector::BI__builtin_rvv_vfnmsub_vf_rm:
1054 case RISCVVector::BI__builtin_rvv_vfwmacc_vv_rm:
1055 case RISCVVector::BI__builtin_rvv_vfwmacc_vf_rm:
1056 case RISCVVector::BI__builtin_rvv_vfwnmacc_vv_rm:
1057 case RISCVVector::BI__builtin_rvv_vfwnmacc_vf_rm:
1058 case RISCVVector::BI__builtin_rvv_vfwmsac_vv_rm:
1059 case RISCVVector::BI__builtin_rvv_vfwmsac_vf_rm:
1060 case RISCVVector::BI__builtin_rvv_vfwnmsac_vv_rm:
1061 case RISCVVector::BI__builtin_rvv_vfwnmsac_vf_rm:
1062 case RISCVVector::BI__builtin_rvv_vfmacc_vv_rm_tu:
1063 case RISCVVector::BI__builtin_rvv_vfmacc_vf_rm_tu:
1064 case RISCVVector::BI__builtin_rvv_vfnmacc_vv_rm_tu:
1065 case RISCVVector::BI__builtin_rvv_vfnmacc_vf_rm_tu:
1066 case RISCVVector::BI__builtin_rvv_vfmsac_vv_rm_tu:
1067 case RISCVVector::BI__builtin_rvv_vfmsac_vf_rm_tu:
1068 case RISCVVector::BI__builtin_rvv_vfnmsac_vv_rm_tu:
1069 case RISCVVector::BI__builtin_rvv_vfnmsac_vf_rm_tu:
1070 case RISCVVector::BI__builtin_rvv_vfmadd_vv_rm_tu:
1071 case RISCVVector::BI__builtin_rvv_vfmadd_vf_rm_tu:
1072 case RISCVVector::BI__builtin_rvv_vfnmadd_vv_rm_tu:
1073 case RISCVVector::BI__builtin_rvv_vfnmadd_vf_rm_tu:
1074 case RISCVVector::BI__builtin_rvv_vfmsub_vv_rm_tu:
1075 case RISCVVector::BI__builtin_rvv_vfmsub_vf_rm_tu:
1076 case RISCVVector::BI__builtin_rvv_vfnmsub_vv_rm_tu:
1077 case RISCVVector::BI__builtin_rvv_vfnmsub_vf_rm_tu:
1078 case RISCVVector::BI__builtin_rvv_vfwmacc_vv_rm_tu:
1079 case RISCVVector::BI__builtin_rvv_vfwmacc_vf_rm_tu:
1080 case RISCVVector::BI__builtin_rvv_vfwnmacc_vv_rm_tu:
1081 case RISCVVector::BI__builtin_rvv_vfwnmacc_vf_rm_tu:
1082 case RISCVVector::BI__builtin_rvv_vfwmsac_vv_rm_tu:
1083 case RISCVVector::BI__builtin_rvv_vfwmsac_vf_rm_tu:
1084 case RISCVVector::BI__builtin_rvv_vfwnmsac_vv_rm_tu:
1085 case RISCVVector::BI__builtin_rvv_vfwnmsac_vf_rm_tu:
1086 case RISCVVector::BI__builtin_rvv_vfadd_vv_rm_m:
1087 case RISCVVector::BI__builtin_rvv_vfadd_vf_rm_m:
1088 case RISCVVector::BI__builtin_rvv_vfsub_vv_rm_m:
1089 case RISCVVector::BI__builtin_rvv_vfsub_vf_rm_m:
1090 case RISCVVector::BI__builtin_rvv_vfrsub_vf_rm_m:
1091 case RISCVVector::BI__builtin_rvv_vfwadd_vv_rm_m:
1092 case RISCVVector::BI__builtin_rvv_vfwadd_vf_rm_m:
1093 case RISCVVector::BI__builtin_rvv_vfwsub_vv_rm_m:
1094 case RISCVVector::BI__builtin_rvv_vfwsub_vf_rm_m:
1095 case RISCVVector::BI__builtin_rvv_vfwadd_wv_rm_m:
1096 case RISCVVector::BI__builtin_rvv_vfwadd_wf_rm_m:
1097 case RISCVVector::BI__builtin_rvv_vfwsub_wv_rm_m:
1098 case RISCVVector::BI__builtin_rvv_vfwsub_wf_rm_m:
1099 case RISCVVector::BI__builtin_rvv_vfmul_vv_rm_m:
1100 case RISCVVector::BI__builtin_rvv_vfmul_vf_rm_m:
1101 case RISCVVector::BI__builtin_rvv_vfdiv_vv_rm_m:
1102 case RISCVVector::BI__builtin_rvv_vfdiv_vf_rm_m:
1103 case RISCVVector::BI__builtin_rvv_vfrdiv_vf_rm_m:
1104 case RISCVVector::BI__builtin_rvv_vfwmul_vv_rm_m:
1105 case RISCVVector::BI__builtin_rvv_vfwmul_vf_rm_m:
1106 case RISCVVector::BI__builtin_rvv_vfredosum_vs_rm_m:
1107 case RISCVVector::BI__builtin_rvv_vfredusum_vs_rm_m:
1108 case RISCVVector::BI__builtin_rvv_vfwredosum_vs_rm_m:
1109 case RISCVVector::BI__builtin_rvv_vfwredusum_vs_rm_m:
1110 case RISCVVector::BI__builtin_rvv_vfsqrt_v_rm_tum:
1111 case RISCVVector::BI__builtin_rvv_vfrec7_v_rm_tum:
1112 case RISCVVector::BI__builtin_rvv_vfcvt_x_f_v_rm_tum:
1113 case RISCVVector::BI__builtin_rvv_vfcvt_xu_f_v_rm_tum:
1114 case RISCVVector::BI__builtin_rvv_vfcvt_f_x_v_rm_tum:
1115 case RISCVVector::BI__builtin_rvv_vfcvt_f_xu_v_rm_tum:
1116 case RISCVVector::BI__builtin_rvv_vfwcvt_x_f_v_rm_tum:
1117 case RISCVVector::BI__builtin_rvv_vfwcvt_xu_f_v_rm_tum:
1118 case RISCVVector::BI__builtin_rvv_vfncvt_x_f_w_rm_tum:
1119 case RISCVVector::BI__builtin_rvv_vfncvt_xu_f_w_rm_tum:
1120 case RISCVVector::BI__builtin_rvv_vfncvt_f_x_w_rm_tum:
1121 case RISCVVector::BI__builtin_rvv_vfncvt_f_xu_w_rm_tum:
1122 case RISCVVector::BI__builtin_rvv_vfncvt_f_f_w_rm_tum:
1123 case RISCVVector::BI__builtin_rvv_vfsqrt_v_rm_tumu:
1124 case RISCVVector::BI__builtin_rvv_vfrec7_v_rm_tumu:
1125 case RISCVVector::BI__builtin_rvv_vfcvt_x_f_v_rm_tumu:
1126 case RISCVVector::BI__builtin_rvv_vfcvt_xu_f_v_rm_tumu:
1127 case RISCVVector::BI__builtin_rvv_vfcvt_f_x_v_rm_tumu:
1128 case RISCVVector::BI__builtin_rvv_vfcvt_f_xu_v_rm_tumu:
1129 case RISCVVector::BI__builtin_rvv_vfwcvt_x_f_v_rm_tumu:
1130 case RISCVVector::BI__builtin_rvv_vfwcvt_xu_f_v_rm_tumu:
1131 case RISCVVector::BI__builtin_rvv_vfncvt_x_f_w_rm_tumu:
1132 case RISCVVector::BI__builtin_rvv_vfncvt_xu_f_w_rm_tumu:
1133 case RISCVVector::BI__builtin_rvv_vfncvt_f_x_w_rm_tumu:
1134 case RISCVVector::BI__builtin_rvv_vfncvt_f_xu_w_rm_tumu:
1135 case RISCVVector::BI__builtin_rvv_vfncvt_f_f_w_rm_tumu:
1136 case RISCVVector::BI__builtin_rvv_vfsqrt_v_rm_mu:
1137 case RISCVVector::BI__builtin_rvv_vfrec7_v_rm_mu:
1138 case RISCVVector::BI__builtin_rvv_vfcvt_x_f_v_rm_mu:
1139 case RISCVVector::BI__builtin_rvv_vfcvt_xu_f_v_rm_mu:
1140 case RISCVVector::BI__builtin_rvv_vfcvt_f_x_v_rm_mu:
1141 case RISCVVector::BI__builtin_rvv_vfcvt_f_xu_v_rm_mu:
1142 case RISCVVector::BI__builtin_rvv_vfwcvt_x_f_v_rm_mu:
1143 case RISCVVector::BI__builtin_rvv_vfwcvt_xu_f_v_rm_mu:
1144 case RISCVVector::BI__builtin_rvv_vfncvt_x_f_w_rm_mu:
1145 case RISCVVector::BI__builtin_rvv_vfncvt_xu_f_w_rm_mu:
1146 case RISCVVector::BI__builtin_rvv_vfncvt_f_x_w_rm_mu:
1147 case RISCVVector::BI__builtin_rvv_vfncvt_f_xu_w_rm_mu:
1148 case RISCVVector::BI__builtin_rvv_vfncvt_f_f_w_rm_mu:
1149 return SemaRef.BuiltinConstantArgRange(TheCall, 3, 0, 4);
1150 case RISCVVector::BI__builtin_rvv_vfmacc_vv_rm_m:
1151 case RISCVVector::BI__builtin_rvv_vfmacc_vf_rm_m:
1152 case RISCVVector::BI__builtin_rvv_vfnmacc_vv_rm_m:
1153 case RISCVVector::BI__builtin_rvv_vfnmacc_vf_rm_m:
1154 case RISCVVector::BI__builtin_rvv_vfmsac_vv_rm_m:
1155 case RISCVVector::BI__builtin_rvv_vfmsac_vf_rm_m:
1156 case RISCVVector::BI__builtin_rvv_vfnmsac_vv_rm_m:
1157 case RISCVVector::BI__builtin_rvv_vfnmsac_vf_rm_m:
1158 case RISCVVector::BI__builtin_rvv_vfmadd_vv_rm_m:
1159 case RISCVVector::BI__builtin_rvv_vfmadd_vf_rm_m:
1160 case RISCVVector::BI__builtin_rvv_vfnmadd_vv_rm_m:
1161 case RISCVVector::BI__builtin_rvv_vfnmadd_vf_rm_m:
1162 case RISCVVector::BI__builtin_rvv_vfmsub_vv_rm_m:
1163 case RISCVVector::BI__builtin_rvv_vfmsub_vf_rm_m:
1164 case RISCVVector::BI__builtin_rvv_vfnmsub_vv_rm_m:
1165 case RISCVVector::BI__builtin_rvv_vfnmsub_vf_rm_m:
1166 case RISCVVector::BI__builtin_rvv_vfwmacc_vv_rm_m:
1167 case RISCVVector::BI__builtin_rvv_vfwmacc_vf_rm_m:
1168 case RISCVVector::BI__builtin_rvv_vfwnmacc_vv_rm_m:
1169 case RISCVVector::BI__builtin_rvv_vfwnmacc_vf_rm_m:
1170 case RISCVVector::BI__builtin_rvv_vfwmsac_vv_rm_m:
1171 case RISCVVector::BI__builtin_rvv_vfwmsac_vf_rm_m:
1172 case RISCVVector::BI__builtin_rvv_vfwnmsac_vv_rm_m:
1173 case RISCVVector::BI__builtin_rvv_vfwnmsac_vf_rm_m:
1174 case RISCVVector::BI__builtin_rvv_vfadd_vv_rm_tum:
1175 case RISCVVector::BI__builtin_rvv_vfadd_vf_rm_tum:
1176 case RISCVVector::BI__builtin_rvv_vfsub_vv_rm_tum:
1177 case RISCVVector::BI__builtin_rvv_vfsub_vf_rm_tum:
1178 case RISCVVector::BI__builtin_rvv_vfrsub_vf_rm_tum:
1179 case RISCVVector::BI__builtin_rvv_vfwadd_vv_rm_tum:
1180 case RISCVVector::BI__builtin_rvv_vfwadd_vf_rm_tum:
1181 case RISCVVector::BI__builtin_rvv_vfwsub_vv_rm_tum:
1182 case RISCVVector::BI__builtin_rvv_vfwsub_vf_rm_tum:
1183 case RISCVVector::BI__builtin_rvv_vfwadd_wv_rm_tum:
1184 case RISCVVector::BI__builtin_rvv_vfwadd_wf_rm_tum:
1185 case RISCVVector::BI__builtin_rvv_vfwsub_wv_rm_tum:
1186 case RISCVVector::BI__builtin_rvv_vfwsub_wf_rm_tum:
1187 case RISCVVector::BI__builtin_rvv_vfmul_vv_rm_tum:
1188 case RISCVVector::BI__builtin_rvv_vfmul_vf_rm_tum:
1189 case RISCVVector::BI__builtin_rvv_vfdiv_vv_rm_tum:
1190 case RISCVVector::BI__builtin_rvv_vfdiv_vf_rm_tum:
1191 case RISCVVector::BI__builtin_rvv_vfrdiv_vf_rm_tum:
1192 case RISCVVector::BI__builtin_rvv_vfwmul_vv_rm_tum:
1193 case RISCVVector::BI__builtin_rvv_vfwmul_vf_rm_tum:
1194 case RISCVVector::BI__builtin_rvv_vfmacc_vv_rm_tum:
1195 case RISCVVector::BI__builtin_rvv_vfmacc_vf_rm_tum:
1196 case RISCVVector::BI__builtin_rvv_vfnmacc_vv_rm_tum:
1197 case RISCVVector::BI__builtin_rvv_vfnmacc_vf_rm_tum:
1198 case RISCVVector::BI__builtin_rvv_vfmsac_vv_rm_tum:
1199 case RISCVVector::BI__builtin_rvv_vfmsac_vf_rm_tum:
1200 case RISCVVector::BI__builtin_rvv_vfnmsac_vv_rm_tum:
1201 case RISCVVector::BI__builtin_rvv_vfnmsac_vf_rm_tum:
1202 case RISCVVector::BI__builtin_rvv_vfmadd_vv_rm_tum:
1203 case RISCVVector::BI__builtin_rvv_vfmadd_vf_rm_tum:
1204 case RISCVVector::BI__builtin_rvv_vfnmadd_vv_rm_tum:
1205 case RISCVVector::BI__builtin_rvv_vfnmadd_vf_rm_tum:
1206 case RISCVVector::BI__builtin_rvv_vfmsub_vv_rm_tum:
1207 case RISCVVector::BI__builtin_rvv_vfmsub_vf_rm_tum:
1208 case RISCVVector::BI__builtin_rvv_vfnmsub_vv_rm_tum:
1209 case RISCVVector::BI__builtin_rvv_vfnmsub_vf_rm_tum:
1210 case RISCVVector::BI__builtin_rvv_vfwmacc_vv_rm_tum:
1211 case RISCVVector::BI__builtin_rvv_vfwmacc_vf_rm_tum:
1212 case RISCVVector::BI__builtin_rvv_vfwnmacc_vv_rm_tum:
1213 case RISCVVector::BI__builtin_rvv_vfwnmacc_vf_rm_tum:
1214 case RISCVVector::BI__builtin_rvv_vfwmsac_vv_rm_tum:
1215 case RISCVVector::BI__builtin_rvv_vfwmsac_vf_rm_tum:
1216 case RISCVVector::BI__builtin_rvv_vfwnmsac_vv_rm_tum:
1217 case RISCVVector::BI__builtin_rvv_vfwnmsac_vf_rm_tum:
1218 case RISCVVector::BI__builtin_rvv_vfredosum_vs_rm_tum:
1219 case RISCVVector::BI__builtin_rvv_vfredusum_vs_rm_tum:
1220 case RISCVVector::BI__builtin_rvv_vfwredosum_vs_rm_tum:
1221 case RISCVVector::BI__builtin_rvv_vfwredusum_vs_rm_tum:
1222 case RISCVVector::BI__builtin_rvv_vfadd_vv_rm_tumu:
1223 case RISCVVector::BI__builtin_rvv_vfadd_vf_rm_tumu:
1224 case RISCVVector::BI__builtin_rvv_vfsub_vv_rm_tumu:
1225 case RISCVVector::BI__builtin_rvv_vfsub_vf_rm_tumu:
1226 case RISCVVector::BI__builtin_rvv_vfrsub_vf_rm_tumu:
1227 case RISCVVector::BI__builtin_rvv_vfwadd_vv_rm_tumu:
1228 case RISCVVector::BI__builtin_rvv_vfwadd_vf_rm_tumu:
1229 case RISCVVector::BI__builtin_rvv_vfwsub_vv_rm_tumu:
1230 case RISCVVector::BI__builtin_rvv_vfwsub_vf_rm_tumu:
1231 case RISCVVector::BI__builtin_rvv_vfwadd_wv_rm_tumu:
1232 case RISCVVector::BI__builtin_rvv_vfwadd_wf_rm_tumu:
1233 case RISCVVector::BI__builtin_rvv_vfwsub_wv_rm_tumu:
1234 case RISCVVector::BI__builtin_rvv_vfwsub_wf_rm_tumu:
1235 case RISCVVector::BI__builtin_rvv_vfmul_vv_rm_tumu:
1236 case RISCVVector::BI__builtin_rvv_vfmul_vf_rm_tumu:
1237 case RISCVVector::BI__builtin_rvv_vfdiv_vv_rm_tumu:
1238 case RISCVVector::BI__builtin_rvv_vfdiv_vf_rm_tumu:
1239 case RISCVVector::BI__builtin_rvv_vfrdiv_vf_rm_tumu:
1240 case RISCVVector::BI__builtin_rvv_vfwmul_vv_rm_tumu:
1241 case RISCVVector::BI__builtin_rvv_vfwmul_vf_rm_tumu:
1242 case RISCVVector::BI__builtin_rvv_vfmacc_vv_rm_tumu:
1243 case RISCVVector::BI__builtin_rvv_vfmacc_vf_rm_tumu:
1244 case RISCVVector::BI__builtin_rvv_vfnmacc_vv_rm_tumu:
1245 case RISCVVector::BI__builtin_rvv_vfnmacc_vf_rm_tumu:
1246 case RISCVVector::BI__builtin_rvv_vfmsac_vv_rm_tumu:
1247 case RISCVVector::BI__builtin_rvv_vfmsac_vf_rm_tumu:
1248 case RISCVVector::BI__builtin_rvv_vfnmsac_vv_rm_tumu:
1249 case RISCVVector::BI__builtin_rvv_vfnmsac_vf_rm_tumu:
1250 case RISCVVector::BI__builtin_rvv_vfmadd_vv_rm_tumu:
1251 case RISCVVector::BI__builtin_rvv_vfmadd_vf_rm_tumu:
1252 case RISCVVector::BI__builtin_rvv_vfnmadd_vv_rm_tumu:
1253 case RISCVVector::BI__builtin_rvv_vfnmadd_vf_rm_tumu:
1254 case RISCVVector::BI__builtin_rvv_vfmsub_vv_rm_tumu:
1255 case RISCVVector::BI__builtin_rvv_vfmsub_vf_rm_tumu:
1256 case RISCVVector::BI__builtin_rvv_vfnmsub_vv_rm_tumu:
1257 case RISCVVector::BI__builtin_rvv_vfnmsub_vf_rm_tumu:
1258 case RISCVVector::BI__builtin_rvv_vfwmacc_vv_rm_tumu:
1259 case RISCVVector::BI__builtin_rvv_vfwmacc_vf_rm_tumu:
1260 case RISCVVector::BI__builtin_rvv_vfwnmacc_vv_rm_tumu:
1261 case RISCVVector::BI__builtin_rvv_vfwnmacc_vf_rm_tumu:
1262 case RISCVVector::BI__builtin_rvv_vfwmsac_vv_rm_tumu:
1263 case RISCVVector::BI__builtin_rvv_vfwmsac_vf_rm_tumu:
1264 case RISCVVector::BI__builtin_rvv_vfwnmsac_vv_rm_tumu:
1265 case RISCVVector::BI__builtin_rvv_vfwnmsac_vf_rm_tumu:
1266 case RISCVVector::BI__builtin_rvv_vfadd_vv_rm_mu:
1267 case RISCVVector::BI__builtin_rvv_vfadd_vf_rm_mu:
1268 case RISCVVector::BI__builtin_rvv_vfsub_vv_rm_mu:
1269 case RISCVVector::BI__builtin_rvv_vfsub_vf_rm_mu:
1270 case RISCVVector::BI__builtin_rvv_vfrsub_vf_rm_mu:
1271 case RISCVVector::BI__builtin_rvv_vfwadd_vv_rm_mu:
1272 case RISCVVector::BI__builtin_rvv_vfwadd_vf_rm_mu:
1273 case RISCVVector::BI__builtin_rvv_vfwsub_vv_rm_mu:
1274 case RISCVVector::BI__builtin_rvv_vfwsub_vf_rm_mu:
1275 case RISCVVector::BI__builtin_rvv_vfwadd_wv_rm_mu:
1276 case RISCVVector::BI__builtin_rvv_vfwadd_wf_rm_mu:
1277 case RISCVVector::BI__builtin_rvv_vfwsub_wv_rm_mu:
1278 case RISCVVector::BI__builtin_rvv_vfwsub_wf_rm_mu:
1279 case RISCVVector::BI__builtin_rvv_vfmul_vv_rm_mu:
1280 case RISCVVector::BI__builtin_rvv_vfmul_vf_rm_mu:
1281 case RISCVVector::BI__builtin_rvv_vfdiv_vv_rm_mu:
1282 case RISCVVector::BI__builtin_rvv_vfdiv_vf_rm_mu:
1283 case RISCVVector::BI__builtin_rvv_vfrdiv_vf_rm_mu:
1284 case RISCVVector::BI__builtin_rvv_vfwmul_vv_rm_mu:
1285 case RISCVVector::BI__builtin_rvv_vfwmul_vf_rm_mu:
1286 case RISCVVector::BI__builtin_rvv_vfmacc_vv_rm_mu:
1287 case RISCVVector::BI__builtin_rvv_vfmacc_vf_rm_mu:
1288 case RISCVVector::BI__builtin_rvv_vfnmacc_vv_rm_mu:
1289 case RISCVVector::BI__builtin_rvv_vfnmacc_vf_rm_mu:
1290 case RISCVVector::BI__builtin_rvv_vfmsac_vv_rm_mu:
1291 case RISCVVector::BI__builtin_rvv_vfmsac_vf_rm_mu:
1292 case RISCVVector::BI__builtin_rvv_vfnmsac_vv_rm_mu:
1293 case RISCVVector::BI__builtin_rvv_vfnmsac_vf_rm_mu:
1294 case RISCVVector::BI__builtin_rvv_vfmadd_vv_rm_mu:
1295 case RISCVVector::BI__builtin_rvv_vfmadd_vf_rm_mu:
1296 case RISCVVector::BI__builtin_rvv_vfnmadd_vv_rm_mu:
1297 case RISCVVector::BI__builtin_rvv_vfnmadd_vf_rm_mu:
1298 case RISCVVector::BI__builtin_rvv_vfmsub_vv_rm_mu:
1299 case RISCVVector::BI__builtin_rvv_vfmsub_vf_rm_mu:
1300 case RISCVVector::BI__builtin_rvv_vfnmsub_vv_rm_mu:
1301 case RISCVVector::BI__builtin_rvv_vfnmsub_vf_rm_mu:
1302 case RISCVVector::BI__builtin_rvv_vfwmacc_vv_rm_mu:
1303 case RISCVVector::BI__builtin_rvv_vfwmacc_vf_rm_mu:
1304 case RISCVVector::BI__builtin_rvv_vfwnmacc_vv_rm_mu:
1305 case RISCVVector::BI__builtin_rvv_vfwnmacc_vf_rm_mu:
1306 case RISCVVector::BI__builtin_rvv_vfwmsac_vv_rm_mu:
1307 case RISCVVector::BI__builtin_rvv_vfwmsac_vf_rm_mu:
1308 case RISCVVector::BI__builtin_rvv_vfwnmsac_vv_rm_mu:
1309 case RISCVVector::BI__builtin_rvv_vfwnmsac_vf_rm_mu:
1310 return SemaRef.BuiltinConstantArgRange(TheCall, 4, 0, 4);
1311 case RISCV::BI__builtin_riscv_ntl_load:
1312 case RISCV::BI__builtin_riscv_ntl_store:
1313 DeclRefExpr *DRE =
1314 cast<DeclRefExpr>(TheCall->getCallee()->IgnoreParenCasts());
1315 assert((BuiltinID == RISCV::BI__builtin_riscv_ntl_store ||
1316 BuiltinID == RISCV::BI__builtin_riscv_ntl_load) &&
1317 "Unexpected RISC-V nontemporal load/store builtin!");
1318 bool IsStore = BuiltinID == RISCV::BI__builtin_riscv_ntl_store;
1319 unsigned NumArgs = IsStore ? 3 : 2;
1320
1321 if (SemaRef.checkArgCountAtLeast(TheCall, NumArgs - 1))
1322 return true;
1323
1324 if (SemaRef.checkArgCountAtMost(TheCall, NumArgs))
1325 return true;
1326
1327 // Domain value should be compile-time constant.
1328 // 2 <= domain <= 5
1329 if (TheCall->getNumArgs() == NumArgs &&
1330 SemaRef.BuiltinConstantArgRange(TheCall, NumArgs - 1, 2, 5))
1331 return true;
1332
1333 Expr *PointerArg = TheCall->getArg(0);
1334 ExprResult PointerArgResult =
1336
1337 if (PointerArgResult.isInvalid())
1338 return true;
1339 PointerArg = PointerArgResult.get();
1340
1341 const PointerType *PtrType = PointerArg->getType()->getAs<PointerType>();
1342 if (!PtrType) {
1343 Diag(DRE->getBeginLoc(), diag::err_nontemporal_builtin_must_be_pointer)
1344 << PointerArg->getType() << PointerArg->getSourceRange();
1345 return true;
1346 }
1347
1348 QualType ValType = PtrType->getPointeeType();
1349 ValType = ValType.getUnqualifiedType();
1350 if (!ValType->isIntegerType() && !ValType->isAnyPointerType() &&
1351 !ValType->isBlockPointerType() && !ValType->isFloatingType() &&
1352 !ValType->isVectorType() && !ValType->isRVVSizelessBuiltinType()) {
1353 Diag(DRE->getBeginLoc(),
1354 diag::err_nontemporal_builtin_must_be_pointer_intfltptr_or_vector)
1355 << PointerArg->getType() << PointerArg->getSourceRange();
1356 return true;
1357 }
1358
1359 if (!IsStore) {
1360 TheCall->setType(ValType);
1361 return false;
1362 }
1363
1364 ExprResult ValArg = TheCall->getArg(1);
1366 Context, ValType, /*consume*/ false);
1367 ValArg =
1369 if (ValArg.isInvalid())
1370 return true;
1371
1372 TheCall->setArg(1, ValArg.get());
1373 TheCall->setType(Context.VoidTy);
1374 return false;
1375 }
1376
1377 return false;
1378}
1379
1381 const llvm::StringMap<bool> &FeatureMap) {
1384 unsigned EltSize = SemaRef.Context.getTypeSize(Info.ElementType);
1385 unsigned MinElts = Info.EC.getKnownMinValue();
1386
1387 if (Info.ElementType->isSpecificBuiltinType(BuiltinType::Double) &&
1388 !FeatureMap.lookup("zve64d"))
1389 Diag(Loc, diag::err_riscv_type_requires_extension, D) << Ty << "zve64d";
1390 // (ELEN, LMUL) pairs of (8, mf8), (16, mf4), (32, mf2), (64, m1) requires at
1391 // least zve64x
1392 else if (((EltSize == 64 && Info.ElementType->isIntegerType()) ||
1393 MinElts == 1) &&
1394 !FeatureMap.lookup("zve64x"))
1395 Diag(Loc, diag::err_riscv_type_requires_extension, D) << Ty << "zve64x";
1396 else if (Info.ElementType->isFloat16Type() && !FeatureMap.lookup("zvfh") &&
1397 !FeatureMap.lookup("zvfhmin"))
1398 Diag(Loc, diag::err_riscv_type_requires_extension, D)
1399 << Ty << "zvfh or zvfhmin";
1400 else if (Info.ElementType->isBFloat16Type() && !FeatureMap.lookup("zvfbfmin"))
1401 Diag(Loc, diag::err_riscv_type_requires_extension, D) << Ty << "zvfbfmin";
1402 else if (Info.ElementType->isSpecificBuiltinType(BuiltinType::Float) &&
1403 !FeatureMap.lookup("zve32f"))
1404 Diag(Loc, diag::err_riscv_type_requires_extension, D) << Ty << "zve32f";
1405 // Given that caller already checked isRVVType() before calling this function,
1406 // if we don't have at least zve32x supported, then we need to emit error.
1407 else if (!FeatureMap.lookup("zve32x"))
1408 Diag(Loc, diag::err_riscv_type_requires_extension, D) << Ty << "zve32x";
1409}
1410
1411/// Are the two types RVV-bitcast-compatible types? I.e. is bitcasting from the
1412/// first RVV type (e.g. an RVV scalable type) to the second type (e.g. an RVV
1413/// VLS type) allowed?
1414///
1415/// This will also return false if the two given types do not make sense from
1416/// the perspective of RVV bitcasts.
1418 assert(srcTy->isVectorType() || destTy->isVectorType());
1419
1420 auto ValidScalableConversion = [](QualType FirstType, QualType SecondType) {
1421 if (!FirstType->isRVVSizelessBuiltinType())
1422 return false;
1423
1424 const auto *VecTy = SecondType->getAs<VectorType>();
1425 return VecTy && VecTy->getVectorKind() == VectorKind::RVVFixedLengthData;
1426 };
1427
1428 return ValidScalableConversion(srcTy, destTy) ||
1429 ValidScalableConversion(destTy, srcTy);
1430}
1431
1433 // Warn about repeated attributes.
1434 if (const auto *A = D->getAttr<RISCVInterruptAttr>()) {
1435 Diag(AL.getRange().getBegin(),
1436 diag::warn_riscv_repeated_interrupt_attribute);
1437 Diag(A->getLocation(), diag::note_riscv_repeated_interrupt_attribute);
1438 return;
1439 }
1440
1441 // Check the attribute argument. Argument is optional.
1442 if (!AL.checkAtMostNumArgs(SemaRef, 1))
1443 return;
1444
1445 StringRef Str;
1446 SourceLocation ArgLoc;
1447
1448 // 'machine'is the default interrupt mode.
1449 if (AL.getNumArgs() == 0)
1450 Str = "machine";
1451 else if (!SemaRef.checkStringLiteralArgumentAttr(AL, 0, Str, &ArgLoc))
1452 return;
1453
1454 // Semantic checks for a function with the 'interrupt' attribute:
1455 // - Must be a function.
1456 // - Must have no parameters.
1457 // - Must have the 'void' return type.
1458 // - The attribute itself must either have no argument or one of the
1459 // valid interrupt types, see [RISCVInterruptDocs].
1460
1461 if (D->getFunctionType() == nullptr) {
1462 Diag(D->getLocation(), diag::warn_attribute_wrong_decl_type)
1464 return;
1465 }
1466
1468 Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid)
1469 << /*RISC-V*/ 2 << 0;
1470 return;
1471 }
1472
1473 if (!getFunctionOrMethodResultType(D)->isVoidType()) {
1474 Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid)
1475 << /*RISC-V*/ 2 << 1;
1476 return;
1477 }
1478
1479 RISCVInterruptAttr::InterruptType Kind;
1480 if (!RISCVInterruptAttr::ConvertStrToInterruptType(Str, Kind)) {
1481 Diag(AL.getLoc(), diag::warn_attribute_type_not_supported)
1482 << AL << Str << ArgLoc;
1483 return;
1484 }
1485
1486 D->addAttr(::new (getASTContext())
1487 RISCVInterruptAttr(getASTContext(), AL, Kind));
1488}
1489
1490bool SemaRISCV::isAliasValid(unsigned BuiltinID, StringRef AliasName) {
1491 return BuiltinID >= RISCV::FirstRVVBuiltin &&
1492 BuiltinID <= RISCV::LastRVVBuiltin;
1493}
1494
1496
1497} // namespace clang
Defines the clang::ASTContext interface.
NodeId Parent
Definition: ASTDiff.cpp:191
StringRef P
Defines enum values for all the target-independent builtin functions.
const Decl * D
Expr * E
llvm::MachO::Record Record
Definition: MachO.h:31
Defines the clang::Preprocessor interface.
SourceLocation Loc
Definition: SemaObjC.cpp:759
static const RVVIntrinsicRecord RVSiFiveVectorIntrinsicRecords[]
Definition: SemaRISCV.cpp:75
static const RVVIntrinsicRecord RVVIntrinsicRecords[]
Definition: SemaRISCV.cpp:69
static const PrototypeDescriptor RVSiFiveVectorSignatureTable[]
Definition: SemaRISCV.cpp:63
static QualType RVVType2Qual(ASTContext &Context, const RVVType *Type)
Definition: SemaRISCV.cpp:93
static ArrayRef< PrototypeDescriptor > ProtoSeq2ArrayRef(IntrinsicKind K, uint16_t Index, uint8_t Length)
Definition: SemaRISCV.cpp:83
static const PrototypeDescriptor RVVSignatureTable[]
Definition: SemaRISCV.cpp:57
This file declares semantic analysis functions specific to RISC-V.
Enumerates target-specific builtins in their own namespaces within namespace clang.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:187
BuiltinVectorTypeInfo getBuiltinVectorTypeInfo(const BuiltinType *VecTy) const
Returns the element type, element count and number of vectors (in case of tuple) for a builtin vector...
TranslationUnitDecl * getTranslationUnitDecl() const
Definition: ASTContext.h:1101
CanQualType LongTy
Definition: ASTContext.h:1128
QualType getScalableVectorType(QualType EltTy, unsigned NumElts, unsigned NumFields=1) const
Return the unique reference to a scalable vector type of the specified element type and scalable numb...
CanQualType FloatTy
Definition: ASTContext.h:1131
CanQualType DoubleTy
Definition: ASTContext.h:1131
CallingConv getDefaultCallingConvention(bool IsVariadic, bool IsCXXMethod, bool IsBuiltin=false) const
Retrieves the default calling convention for the current target.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
QualType getConstType(QualType T) const
Return the uniqued reference to the type for a const qualified type.
Definition: ASTContext.h:1345
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
CanQualType BoolTy
Definition: ASTContext.h:1120
QualType getIntTypeForBitwidth(unsigned DestWidth, unsigned Signed) const
getIntTypeForBitwidth - sets integer QualTy according to specified details: bitwidth,...
CanQualType UnsignedLongTy
Definition: ASTContext.h:1129
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
CanQualType Float16Ty
Definition: ASTContext.h:1145
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
Definition: ASTContext.h:2394
CanQualType VoidTy
Definition: ASTContext.h:1119
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
Definition: ASTContext.h:1615
const TargetInfo & getTargetInfo() const
Definition: ASTContext.h:779
CanQualType BFloat16Ty
Definition: ASTContext.h:1144
PtrTy get() const
Definition: Ownership.h:170
bool isInvalid() const
Definition: Ownership.h:166
SourceLocation getLoc() const
This class is used for builtin types like 'int'.
Definition: Type.h:3023
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition: Expr.h:2830
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
Definition: Expr.h:3021
void setArg(unsigned Arg, Expr *ArgExpr)
setArg - Set the specified argument.
Definition: Expr.h:3034
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Expr.cpp:1638
Expr * getCallee()
Definition: Expr.h:2980
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
Definition: Expr.h:3008
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1436
A reference to a declared variable, function, enum, etc.
Definition: Expr.h:1265
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Expr.cpp:551
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:86
T * getAttr() const
Definition: DeclBase.h:580
void addAttr(Attr *A)
Definition: DeclBase.cpp:1013
const FunctionType * getFunctionType(bool BlocksToo=true) const
Looks through the Decl's underlying type to extract a FunctionType when possible.
Definition: DeclBase.cpp:1178
SourceLocation getLocation() const
Definition: DeclBase.h:446
This represents one expression.
Definition: Expr.h:110
Expr * IgnoreParenCasts() LLVM_READONLY
Skip past any parentheses and casts which might surround this expression until reaching a fixed point...
Definition: Expr.cpp:3075
void setType(QualType t)
Definition: Expr.h:143
bool isValueDependent() const
Determines whether the value of this expression depends on.
Definition: Expr.h:175
bool isTypeDependent() const
Determines whether the type of this expression depends on.
Definition: Expr.h:192
QualType getType() const
Definition: Expr.h:142
bool isFPConstrained() const
Definition: LangOptions.h:875
Represents a function declaration or definition.
Definition: Decl.h:1932
static FunctionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation NLoc, DeclarationName N, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool UsesFPIntrin=false, bool isInlineSpecified=false, bool hasWrittenPrototype=true, ConstexprSpecKind ConstexprKind=ConstexprSpecKind::Unspecified, Expr *TrailingRequiresClause=nullptr)
Definition: Decl.h:2121
One of these records is kept for each identifier that is lexed.
StringRef getName() const
Return the actual identifier string.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
Describes an entity that is being initialized.
static InitializedEntity InitializeParameter(ASTContext &Context, ParmVarDecl *Parm)
Create the initialization entity for a parameter.
Represents the results of name lookup.
Definition: Lookup.h:46
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
Definition: Lookup.h:475
void resolveKind()
Resolves the result kind of the lookup, possibly hiding decls.
Definition: SemaLookup.cpp:485
SourceLocation getNameLoc() const
Gets the location of the identifier.
Definition: Lookup.h:664
Represents a parameter to a function.
Definition: Decl.h:1722
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
Definition: Decl.h:1755
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
Definition: Decl.cpp:2903
ParsedAttr - Represents a syntactic attribute.
Definition: ParsedAttr.h:129
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this attribute.
Definition: ParsedAttr.h:386
bool checkAtMostNumArgs(class Sema &S, unsigned Num) const
Check if the attribute has at most as many args as Num.
Definition: ParsedAttr.cpp:308
PointerType - C99 6.7.5.1 - Pointer Declarators.
Definition: Type.h:3187
QualType getPointeeType() const
Definition: Type.h:3197
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Definition: Preprocessor.h:137
IdentifierTable & getIdentifierTable()
A (possibly-)qualified type.
Definition: Type.h:941
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
Definition: Type.h:7750
QualType getCanonicalType() const
Definition: Type.h:7802
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
Definition: Type.h:7844
static llvm::SmallVector< Policy > getSupportedMaskedPolicies(bool HasTailPolicy, bool HasMaskPolicy)
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)
static llvm::SmallVector< Policy > getSupportedUnMaskedPolicies()
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
Definition: SemaBase.cpp:60
ASTContext & getASTContext() const
Definition: SemaBase.cpp:9
Sema & SemaRef
Definition: SemaBase.h:40
bool CheckBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, CallExpr *TheCall)
Definition: SemaRISCV.cpp:565
bool CheckLMUL(CallExpr *TheCall, unsigned ArgNum)
Definition: SemaRISCV.cpp:515
bool isAliasValid(unsigned BuiltinID, llvm::StringRef AliasName)
Definition: SemaRISCV.cpp:1490
bool DeclareSiFiveVectorBuiltins
Indicate RISC-V SiFive vector builtin functions enabled or not.
Definition: SemaRISCV.h:51
SemaRISCV(Sema &S)
Definition: SemaRISCV.cpp:1495
void checkRVVTypeSupport(QualType Ty, SourceLocation Loc, Decl *D, const llvm::StringMap< bool > &FeatureMap)
Definition: SemaRISCV.cpp:1380
bool isValidRVVBitcast(QualType srcType, QualType destType)
Are the two types RVV-bitcast-compatible types? I.e.
Definition: SemaRISCV.cpp:1417
void handleInterruptAttr(Decl *D, const ParsedAttr &AL)
Definition: SemaRISCV.cpp:1432
bool DeclareRVVBuiltins
Indicate RISC-V vector builtin functions enabled or not.
Definition: SemaRISCV.h:48
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:493
bool checkArgCountAtMost(CallExpr *Call, unsigned MaxArgCount)
Checks that a call expression's argument count is at most the desired number.
ASTContext & Context
Definition: Sema.h:962
ExprResult DefaultFunctionArrayLvalueConversion(Expr *E, bool Diagnose=true)
Definition: SemaExpr.cpp:752
FPOptions & getCurFPFeatures()
Definition: Sema.h:555
SemaRISCV & RISCV()
Definition: Sema.h:1194
bool checkArgCountAtLeast(CallExpr *Call, unsigned MinArgCount)
Checks that a call expression's argument count is at least the desired number.
bool BuiltinConstantArg(CallExpr *TheCall, int ArgNum, llvm::APSInt &Result)
BuiltinConstantArg - Handle a check if argument ArgNum of CallExpr TheCall is a constant expression.
ExprResult PerformCopyInitialization(const InitializedEntity &Entity, SourceLocation EqualLoc, ExprResult Init, bool TopLevelOfInitList=false, bool AllowExplicit=false)
Definition: SemaInit.cpp:9656
bool BuiltinConstantArgRange(CallExpr *TheCall, int ArgNum, int Low, int High, bool RangeIsError=true)
BuiltinConstantArgRange - Handle a check if argument ArgNum of CallExpr TheCall is a constant express...
bool checkStringLiteralArgumentAttr(const AttributeCommonInfo &CI, const Expr *E, StringRef &Str, SourceLocation *ArgLocation=nullptr)
Check if the argument E is a ASCII string literal.
Encodes a location in the source.
SourceLocation getBegin() const
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
Definition: Stmt.cpp:326
Exposes information about the current target.
Definition: TargetInfo.h:218
virtual bool hasFeature(StringRef Feature) const
Determine whether the given target has the given feature.
Definition: TargetInfo.h:1487
The base class of the type hierarchy.
Definition: Type.h:1829
bool isBlockPointerType() const
Definition: Type.h:8017
bool isFloat16Type() const
Definition: Type.h:8328
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
Definition: Type.h:8359
const T * castAs() const
Member-template castAs<specific type>.
Definition: Type.h:8607
bool isSpecificBuiltinType(unsigned K) const
Test for a particular builtin type.
Definition: Type.h:8288
bool isBFloat16Type() const
Definition: Type.h:8340
bool isVectorType() const
Definition: Type.h:8115
bool isRVVSizelessBuiltinType() const
Returns true for RVV scalable vector types.
Definition: Type.cpp:2497
bool isFloatingType() const
Definition: Type.cpp:2249
bool isAnyPointerType() const
Definition: Type.h:8011
const T * getAs() const
Member-template getAs<specific type>'.
Definition: Type.h:8540
Represents a GCC generic vector type.
Definition: Type.h:4021
VectorKind getVectorKind() const
Definition: Type.h:4041
virtual bool CreateIntrinsicIfFound(LookupResult &LR, IdentifierInfo *II, Preprocessor &PP)=0
Defines the clang::TargetInfo interface.
RISCV builtins.
std::vector< RVVTypePtr > RVVTypes
The JSON file list parser is used to communicate input to InstallAPI.
@ ExpectedFunction
Definition: ParsedAttr.h:1091
QualType getFunctionOrMethodResultType(const Decl *D)
Definition: Attr.h:98
std::unique_ptr< sema::RISCVIntrinsicManager > CreateRISCVIntrinsicManager(Sema &S)
Definition: SemaRISCV.cpp:511
@ SC_Extern
Definition: Specifiers.h:251
@ SC_None
Definition: Specifiers.h:250
@ Result
The result type of a method or function.
static bool CheckInvalidVLENandLMUL(const TargetInfo &TI, CallExpr *TheCall, Sema &S, QualType Type, int EGW)
Definition: SemaRISCV.cpp:535
bool hasFunctionProto(const Decl *D)
hasFunctionProto - Return true if the given decl has a argument information.
Definition: Attr.h:55
unsigned getFunctionOrMethodNumParams(const Decl *D)
getFunctionOrMethodNumParams - Return number of function or method parameters.
Definition: Attr.h:64
@ RVVFixedLengthData
is RISC-V RVV fixed-length data vector
Diagnostic wrappers for TextAPI types for error reporting.
Definition: Dominators.h:30
Extra information about a function prototype.
Definition: Type.h:5087