36 for (
unsigned I = 1, N = TheCall->
getNumArgs(); I < N; ++I) {
39 S->
Diag(TheCall->
getBeginLoc(), diag::err_vec_builtin_incompatible_vector)
55 assert(Checks.size() == NumArgs &&
56 "Wrong number of checks for Number of args.");
58 for (
unsigned I = 0; I < NumArgs; ++I) {
75 return S->
Diag(
Loc, diag::err_builtin_invalid_arg_type)
76 << ArgOrdinal << 5 << 0
86 return S->
Diag(
Loc, diag::err_builtin_invalid_arg_type)
87 << ArgOrdinal << 1 << 0
92static std::optional<int>
98 Call->setArg(Argument, Arg.
get());
100 const Expr *IntArg = Arg.
get();
109 SemaRef.
Diag(PDiag.first, PDiag.second);
112 return {Eval.
Val.
getInt().getZExtValue()};
128 auto AddressSpaceNotInGeneric = [&](
LangAS AS) {
134 AddressSpaceNotInGeneric(PtrTy->getPointeeType().getAddressSpace())) {
136 diag::err_spirv_builtin_generic_cast_invalid_arg)
137 <<
Call->getSourceRange();
143 if (std::optional<int> SCInt =
150 SemaRef.
Diag(
Call->getArg(1)->getBeginLoc(),
151 diag::err_spirv_enum_not_valid)
152 << 0 <<
Call->getArg(1)->getSourceRange();
158 auto RT =
Call->getArg(0)->getType();
159 RT = RT->getPointeeType();
160 auto Qual = RT.getQualifiers();
176 Qual.setAddressSpace(AddrSpace);
187 TI.
getTriple().getArch() != llvm::Triple::spirv) {
192 TI.
getTriple().getArch() != llvm::Triple::spirv32 &&
193 TI.
getTriple().getArch() != llvm::Triple::spirv64) {
199 case SPIRV::BI__builtin_spirv_distance: {
206 if (VTyA ==
nullptr) {
208 diag::err_typecheck_convert_incompatible)
218 if (VTyB ==
nullptr) {
220 diag::err_typecheck_convert_incompatible)
227 QualType RetTy = VTyA->getElementType();
231 case SPIRV::BI__builtin_spirv_length: {
237 if (VTy ==
nullptr) {
239 diag::err_typecheck_convert_incompatible)
245 QualType RetTy = VTy->getElementType();
249 case SPIRV::BI__builtin_spirv_reflect: {
256 if (VTyA ==
nullptr) {
258 diag::err_typecheck_convert_incompatible)
268 if (VTyB ==
nullptr) {
270 diag::err_typecheck_convert_incompatible)
281 case SPIRV::BI__builtin_spirv_refract: {
297 diag::err_vec_builtin_incompatible_vector)
310 diag::err_hlsl_builtin_scalar_vector_mismatch)
318 case SPIRV::BI__builtin_spirv_smoothstep: {
339 case SPIRV::BI__builtin_spirv_faceforward: {
360 case SPIRV::BI__builtin_spirv_generic_cast_to_ptr_explicit: {
This file declares semantic analysis for SPIRV constructs.
Enumerates target-specific builtins in their own namespaces within namespace clang.
QualType getVectorType(QualType VectorType, unsigned NumElts, VectorKind VecKind) const
Return the unique reference to a vector type of the specified element type and size.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
SourceLocation getBeginLoc() const
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return null.
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
This represents one expression.
bool EvaluateAsConstantExpr(EvalResult &Result, const ASTContext &Ctx, ConstantExprKind Kind=ConstantExprKind::Normal) const
Evaluate an expression that is required to be a constant expression.
PointerType - C99 6.7.5.1 - Pointer Declarators.
A (possibly-)qualified type.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
bool CheckSPIRVBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, CallExpr *TheCall)
Sema - This implements semantic analysis and AST building for C.
ExprResult DefaultFunctionArrayLvalueConversion(Expr *E, bool Diagnose=true)
ASTContext & getASTContext() const
const LangOptions & LangOpts
bool checkArgCount(CallExpr *Call, unsigned DesiredArgCount)
Checks that a call expression's argument count is the desired number.
Encodes a location in the source.
A trivial tuple used to represent a source range.
SourceLocation getEndLoc() const LLVM_READONLY
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
SourceLocation getBeginLoc() const LLVM_READONLY
Exposes information about the current target.
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
bool isFloat16Type() const
const T * castAs() const
Member-template castAs<specific type>.
bool isFloat32Type() const
bool hasFloatingRepresentation() const
Determine whether this type has a floating-point representation of some sort, e.g....
bool isVectorType() const
const T * getAs() const
Member-template getAs<specific type>'.
Represents a GCC generic vector type.
Defines the clang::TargetInfo interface.
The JSON file list parser is used to communicate input to InstallAPI.
static bool CheckFloatOrHalfScalarRepresentation(Sema *S, SourceLocation Loc, int ArgOrdinal, clang::QualType PassedType)
static bool CheckFloatOrHalfRepresentation(Sema *S, SourceLocation Loc, int ArgOrdinal, clang::QualType PassedType)
static bool CheckAllArgTypesAreCorrect(Sema *S, CallExpr *TheCall, llvm::ArrayRef< llvm::function_ref< bool(Sema *, SourceLocation, int, QualType)> > Checks)
StorageClass
Storage classes.
static std::optional< int > processConstant32BitIntArgument(Sema &SemaRef, CallExpr *Call, int Argument)
static bool CheckAllArgsHaveSameType(Sema *S, CallExpr *TheCall)
LangAS
Defines the address space values used by the address space qualifier of QualType.
static bool checkGenericCastToPtr(Sema &SemaRef, CallExpr *Call)
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs.
@ Generic
not a target-specific vector type
EvalResult is a struct with detailed info about an evaluated expression.
APValue Val
Val - This is the value the expression can be folded to.
SmallVectorImpl< PartialDiagnosticAt > * Diag
Diag - If this is non-null, it will be filled in with a stack of notes indicating why evaluation fail...