[clang] [HLSL] Implement a header only distance intrinsic (PR #117240)

Damyan Pepper via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 21 14:20:23 PST 2024


================
@@ -853,6 +853,45 @@ float3 degrees(float3);
 _HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_degrees)
 float4 degrees(float4);
 
+//===----------------------------------------------------------------------===//
+// distance builtins
+//===----------------------------------------------------------------------===//
+
+/// \fn K distance(T X, T Y)
+/// \brief Returns a distance scalar between two vectors of \a X and \a Y.
+/// \param X The X input value.
+/// \param Y The Y input value.
+
+template <typename T>
+constexpr __detail::enable_if_t<
+    __detail::is_same<float, T>::value || __detail::is_same<half, T>::value, T>
+distance_impl(T X, T Y) {
----------------
damyanp wrote:

It doesn't necessarily need to be moved to a different header to put it in a different namespace.

Wondering how far we can go with having lots of headers....would having one header per-builtin be reasonable? Would precompiled headers totally swallow any per-file overhead there?

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


More information about the cfe-commits mailing list