[clang] Adding `asuint` implementation to hlsl (PR #107292)
Justin Bogner via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 10 10:14:49 PDT 2024
================
@@ -387,6 +387,65 @@ float3 asin(float3);
_HLSL_BUILTIN_ALIAS(__builtin_elementwise_asin)
float4 asin(float4);
+//===----------------------------------------------------------------------===//
+// asuint builtins
+//===----------------------------------------------------------------------===//
+
+/// \fn uint asuint(T Val)
+/// \brief Interprets the bit pattern of x as an unsigned integer.
+/// \param Val The input value.
+
+__attribute__((__always_inline__, __nodebug__)) static inline uint
----------------
bogner wrote:
I kind of disagree with this, and I find the version with the macro pretty hard to follow.
1. Even if we have a macro to help with the attributes or something, it shouldn't be called "alias" - this isn't an alias at all (because of the static assert).
2. I don't really like that this single macro is defining multiple functions. The uses of `_HLSL_BUILTIN_ALIAS` decorate the definitions but each definition is written out clearly in source.
I could see some value in putting the `__attribute__((__always_inline__, __nodebug__))` bit in a macro so that it's easy to be consistent, but I don't think the function definitions themselves should be done this way.
https://github.com/llvm/llvm-project/pull/107292
More information about the cfe-commits
mailing list