[clang] [llvm] Add length HLSL function to DirectX Backend (PR #101256)

Farzon Lotfi via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 30 15:35:32 PDT 2024


================
@@ -63,5 +63,7 @@ let TargetPrefix = "spv" in {
   def int_spv_frac : DefaultAttrsIntrinsic<[LLVMMatchType<0>], [llvm_anyfloat_ty]>;
   def int_spv_lerp : Intrinsic<[LLVMMatchType<0>], [llvm_anyfloat_ty, LLVMMatchType<0>,LLVMMatchType<0>], 
     [IntrNoMem, IntrWillReturn] >;
+  def int_spv_length : Intrinsic<[LLVMMatchType<0>], [llvm_anyfloat_ty, LLVMMatchType<0>,LLVMMatchType<0>], 
----------------
farzonl wrote:

this needs to also be `DefaultAttrsIntrinsic<[LLVMVectorElementType<0>], [llvm_anyfloat_ty]>;` like you have it on `int_dx_length`.  `LLVMMatchType<0>` will match `llvm_anyfloat_ty` which means it will make the expected return be a vector when length returns are scalars.  Also if you don't use `DefaultAttrsIntrinsic` you won't get all the  default behaviors of intrinsics. 

https://github.com/llvm/llvm-project/pull/101256


More information about the llvm-commits mailing list