[clang] [HLSL] Implement support for HLSL intrinsic - select (PR #107129)
Damyan Pepper via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 3 15:49:43 PDT 2024
================
@@ -1544,6 +1604,30 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
return true;
break;
}
+ case Builtin::BI__builtin_hlsl_select: {
+ if (SemaRef.checkArgCount(TheCall, 3))
+ return true;
+ QualType ArgTy = TheCall->getArg(0)->getType();
+ if (ArgTy->isBooleanType()) {
+ if (CheckBoolSelect(&SemaRef, TheCall))
+ return true;
+ } else if (ArgTy->isVectorType() &&
+ ArgTy->getAs<VectorType>()->getElementType()->isBooleanType()) {
+ if (CheckVectorSelect(&SemaRef, TheCall))
+ return true;
+ } else { // first operand is not a bool or a vector of bools.
+ SemaRef.Diag(TheCall->getArg(0)->getBeginLoc(),
+ diag::err_typecheck_convert_incompatible)
+ << TheCall->getArg(0)->getType() << getASTContext().BoolTy
+ << 1 << 0 << 0;
+ SemaRef.Diag(TheCall->getArg(0)->getBeginLoc(),
+ diag::err_builtin_non_vector_type)
+ << "First" << "__builtin_hlsl_select" << TheCall->getArg(0)->getType()
+ << TheCall->getArg(0)->getSourceRange();
+ return true;
----------------
damyanp wrote:
Wondering why this case doesn't also use a helper function and instead inlines the detection and diagnostic code here.
https://github.com/llvm/llvm-project/pull/107129
More information about the cfe-commits
mailing list