[clang] [HLSL] Shore up floating point conversions (PR #90222)

Damyan Pepper via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 26 08:42:50 PDT 2024


================
@@ -0,0 +1,229 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -fnative-half-type -finclude-default-header -Wconversion -verify -o - %s
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -fnative-half-type -finclude-default-header -ast-dump %s | FileCheck %s
+
+// This test verifies floating point type implicit conversion ranks for overload
+// resolution. In HLSL the built-in type ranks are half < float < double. This
+// applies to both scalar and vector types.
+
+// HLSL allows implicit truncation fo types, so it differentiates between
+// promotions (converting to larger types) and conversions (converting to
+// smaller types). Promotions are preferred over conversions. Promotions prefer
+// promoting to the next lowest type in the ranking order. Conversions prefer
+// converting to the next highest type in the ranking order.
+
+void HalfFloatDouble(double D);
+void HalfFloatDouble(float F);
+void HalfFloatDouble(half H);
+
+// CHECK: FunctionDecl {{.*}} used HalfFloatDouble 'void (double)'
----------------
damyanp wrote:

Just a question: are these `CHECK: FunctionDecl`s here as a sanity check, or are they validating something about this change or have some functional purpose to making the test work?

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


More information about the cfe-commits mailing list