[clang] [AMDGPU] Add sema check for global_atomic_fadd_v2f16 builtin (PR #158145)
Matt Arsenault via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 11 23:49:47 PDT 2025
================
@@ -436,4 +440,32 @@ void SemaAMDGPU::handleAMDGPUMaxNumWorkGroupsAttr(Decl *D,
addAMDGPUMaxNumWorkGroupsAttr(D, AL, AL.getArgAsExpr(0), YExpr, ZExpr);
}
+
+bool SemaAMDGPU::checkAMDGCNAtomicFaddV2F16Type(CallExpr *TheCall) {
+ // Check that the pointer argument is a pointer to v2f16
+
+ Expr *Arg = TheCall->getArg(1);
+ QualType ArgType = Arg->getType();
+
+ // Check if it's a vector type
+ if (!ArgType->isVectorType()) {
+ Diag(Arg->getBeginLoc(), diag::err_typecheck_call_different_arg_types)
+ << "expected _Float16 vector of length 2" << ArgType
+ << Arg->getSourceRange();
+ return true;
+ }
+
+ const VectorType *VT = ArgType->getAs<VectorType>();
+
+ // Check element type (should be _Float16) and vector length (should be 2)
+ QualType ElementType = VT->getElementType();
+ if (!ElementType->isFloat16Type() || VT->getNumElements() != 2) {
----------------
arsenm wrote:
The builtin already knows what type it is. You should not need to add custom type checking
https://github.com/llvm/llvm-project/pull/158145
More information about the cfe-commits
mailing list