[clang] [llvm] [HLSL][DXIL] Implement `refract` intrinsic (PR #136026)
Sarah Spall via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 24 12:03:05 PDT 2025
================
@@ -16,88 +16,90 @@ namespace clang {
SemaSPIRV::SemaSPIRV(Sema &S) : SemaBase(S) {}
+/// Checks if the first `NumArgsToCheck` arguments of a function call are of
+/// vector type. If any of the arguments is not a vector type, it emits a
+/// diagnostic error and returns `true`. Otherwise, it returns `false`.
+///
+/// \param TheCall The function call expression to check.
+/// \param NumArgsToCheck The number of arguments to check for vector type.
+/// \return `true` if any of the arguments is not a vector type, `false`
+/// otherwise.
+
+bool SemaSPIRV::CheckVectorArgs(CallExpr *TheCall, unsigned NumArgsToCheck) {
+ for (unsigned i = 0; i < NumArgsToCheck; ++i) {
+ ExprResult Arg = TheCall->getArg(i);
+ QualType ArgTy = Arg.get()->getType();
+ auto *VTy = ArgTy->getAs<VectorType>();
+ if (VTy == nullptr) {
+ SemaRef.Diag(Arg.get()->getBeginLoc(),
+ diag::err_typecheck_convert_incompatible)
+ << ArgTy
+ << SemaRef.Context.getVectorType(ArgTy, 2, VectorKind::Generic) << 1
+ << 0 << 0;
+ return true;
+ }
+ }
+ return false;
+}
+
bool SemaSPIRV::CheckSPIRVBuiltinFunctionCall(unsigned BuiltinID,
CallExpr *TheCall) {
switch (BuiltinID) {
case SPIRV::BI__builtin_spirv_distance: {
----------------
spall wrote:
does this not need to check that the element type is a float? Is that checked previously?
https://github.com/llvm/llvm-project/pull/136026
More information about the cfe-commits
mailing list