[clang] [llvm] [HLSL] Implement f32tof16() intrinsic (PR #172469)
Alex Sepkowski via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 8 15:46:57 PST 2026
================
@@ -211,6 +211,58 @@ static Value *handleElementwiseF16ToF32(CodeGenFunction &CGF,
llvm_unreachable("Intrinsic F16ToF32 not supported by target architecture");
}
+static Value *handleElementwiseF32ToF16(CodeGenFunction &CGF,
+ const CallExpr *E) {
+ Value *Op0 = CGF.EmitScalarExpr(E->getArg(0));
+ QualType Op0Ty = E->getArg(0)->getType();
+ llvm::Type *ResType = CGF.IntTy;
+ uint64_t NumElements = 0;
+ if (Op0->getType()->isVectorTy()) {
+ NumElements =
+ E->getArg(0)->getType()->castAs<clang::VectorType>()->getNumElements();
----------------
alsepkow wrote:
nit: Because NumElements is only used for SPIRV would it make more sense to declare it and set it after the isDXIL block on 229?
I assume you just copied the logic from handleElementWiseF16ToF32, could also change it there.
https://github.com/llvm/llvm-project/pull/172469
More information about the cfe-commits
mailing list