[clang] [llvm] [HLSL] Implementation of the frac intrinsic (PR #83315)

Justin Bogner via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 28 11:38:54 PST 2024


================
@@ -0,0 +1,69 @@
+// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
+// RUN:   dxil-pc-shadermodel6.3-library %s -fnative-half-type \
+// RUN:   -emit-llvm -disable-llvm-passes -o - | FileCheck %s \ 
+// RUN:   --check-prefixes=CHECK,NATIVE_HALF
+// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
+// RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
+// RUN:   -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF
+
+// NATIVE_HALF: define noundef half @
+// NATIVE_HALF: %dx.frac = call half @llvm.dx.frac.f16(
+// NATIVE_HALF: ret half %dx.frac
+// NO_HALF: define noundef float @"?test_frac_half@@YA$halff@$halff@@Z"(
+// NO_HALF: %dx.frac = call float @llvm.dx.frac.f32(
+// NO_HALF: ret float %dx.frac
+half test_frac_half ( half p0 ) {
+  return frac ( p0 );
+}
----------------
bogner wrote:

Please follow LLVM formatting conventions in test cases, ie:
```c++
half test_frac_half(half p0) {
  return frac (p0);
}
```
(aside: we should probably teach clang-format to recognize hlsl)

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


More information about the cfe-commits mailing list