[clang] [llvm] Adding splitdouble HLSL function (PR #109331)

Tex Riddell via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 24 19:53:13 PDT 2024


================
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -verify
+
+void test_no_second_arg(double D) {
+  __builtin_hlsl_elementwise_splitdouble(D);
+ // expected-error at -1 {{too few arguments to function call, expected 3, have 1}} 
+}
+
+void test_no_third_arg(double D) {
+  uint A;
+  __builtin_hlsl_elementwise_splitdouble(D, A);
+ // expected-error at -1 {{too few arguments to function call, expected 3, have 2}} 
+}
+
+void test_too_many_arg(double D) {
+  uint A, B, C;
+  __builtin_hlsl_elementwise_splitdouble(D, A, B, C);
+ // expected-error at -1 {{too many arguments to function call, expected 3, have 4}} 
+}
+
+void test_first_arg_type_mismatch(bool3 D) {
+  uint3 A, B;
+  __builtin_hlsl_elementwise_splitdouble(D, A, B);
+ // expected-error at -1 {{invalid operand of type 'bool3' (aka 'vector<bool, 3>') where 'double' or a vector of such type is required}} 
+}
+
+void test_second_arg_type_mismatch(double D) {
+  bool A;
+  uint B;
+  __builtin_hlsl_elementwise_splitdouble(D, A, B);
+ // expected-error at -1 {{invalid operand of type 'bool' where 'unsigned int' or a vector of such type is required}} 
+}
+
+void test_third_arg_type_mismatch(double D) {
+  bool A;
+  uint B;
+  __builtin_hlsl_elementwise_splitdouble(D, B, A);
+ // expected-error at -1 {{invalid operand of type 'bool' where 'unsigned int' or a vector of such type is required}} 
----------------
tex3d wrote:

Sorry for the late added comment, but it just came to mind: most intrinsics have only input arguments, but this has two output arguments.  We don't have any tests for cases where the output argument is `const` or not an L-Value reference, such that it cannot be written to as an output.  Do we handle that gracefully?  That seems like it would be good to try.

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


More information about the cfe-commits mailing list