[clang] [HLSL] Implement the 'and' HLSL function (PR #127098)

Justin Bogner via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 19 11:15:50 PST 2025


================
@@ -249,6 +249,23 @@ bool all(double3);
 _HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
 bool all(double4);
 
+//===----------------------------------------------------------------------===//
+// and builtins
+//===----------------------------------------------------------------------===//
+
+/// \fn bool and(bool x, bool y)
+/// \brief Logically ands two boolean vectors elementwise and produces a bool
+/// vector output.
+
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
+bool and (bool x, bool y);
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
+bool2 and (bool2 x, bool2 y);
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
+bool3 and (bool3 x, bool3 y);
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
+bool4 and (bool4 x, bool4 y);
----------------
bogner wrote:

```suggestion
// TODO: Clean up clang-format marker once we've resolved
//       https://github.com/llvm/llvm-project/issues/127851
//
// clang-format off
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
bool and(bool x, bool y);
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
bool2 and(bool2 x, bool2 y);
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
bool3 and(bool3 x, bool3 y);
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
bool4 and(bool4 x, bool4 y);
// clang-format on
```

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


More information about the cfe-commits mailing list