[clang] [HLSL] Rewrite HLSL alias intrinsics into TableGen (PR #188814)
Deric C. via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 7 17:28:45 PDT 2026
https://github.com/Icohedron updated https://github.com/llvm/llvm-project/pull/188814
>From d5af8c0c51310bc79957d5858a7ee461392aa1bd Mon Sep 17 00:00:00 2001
From: Deric Cheung <cheung.deric at gmail.com>
Date: Tue, 24 Mar 2026 14:40:08 -0700
Subject: [PATCH 01/12] Rewrite a subset of HLSL intrinsics into TableGen
Assisted-by: GitHub Copilot
---
clang/include/clang/Basic/HLSLIntrinsics.td | 163 ++++++++-
.../lib/Headers/hlsl/hlsl_alias_intrinsics.h | 310 ------------------
clang/lib/Headers/hlsl/hlsl_intrinsics.h | 74 -----
.../test/SemaHLSL/BuiltIns/cross-errors.hlsl | 12 +-
.../SemaHLSL/BuiltIns/dot2add-errors.hlsl | 4 +-
.../SemaHLSL/BuiltIns/refract-errors.hlsl | 58 ++--
6 files changed, 192 insertions(+), 429 deletions(-)
diff --git a/clang/include/clang/Basic/HLSLIntrinsics.td b/clang/include/clang/Basic/HLSLIntrinsics.td
index b205491e6ca78..8811f747f3452 100644
--- a/clang/include/clang/Basic/HLSLIntrinsics.td
+++ b/clang/include/clang/Basic/HLSLIntrinsics.td
@@ -313,8 +313,163 @@ class HLSLOneArgInlineBuiltin<string name> : HLSLBuiltin<name> {
// Intrinsic definitions (sorted alphabetically by function name)
//===----------------------------------------------------------------------===//
-// TODO: Convert hand-written overloads from hlsl_intrinsics.h and
-// hlsl_alias_intrinsics.h into TableGen below.
-// Include "hlsl_alias_intrinsics_gen.inc" in hlsl_alias_intrinsics.h
-// Include "hlsl_inline_intrinsics_gen.inc" in hlsl_intrinsics.h
+// Returns the absolute value of the input value, Val.
+def hlsl_abs : HLSLOneArgBuiltin<"abs", "__builtin_elementwise_abs"> {
+ let Doc = [{
+\fn T abs(T Val)
+\brief Returns the absolute value of the input value, \a Val.
+\param Val The input value.
+}];
+ let VaryingTypes = SignedTypes;
+ let VaryingMatDims = [];
+}
+
+// Unsigned abs is a constexpr identity — unsigned values are already non-negative.
+def hlsl_abs_unsigned : HLSLOneArgInlineBuiltin<"abs"> {
+ let ParamNames = ["V"];
+ let Body = "return V;";
+ let IsConstexpr = 1;
+ let VaryingTypes = UnsignedIntTypes;
+ let VaryingMatDims = [];
+}
+
+// Returns the boolean AND of two bool values or vectors.
+def hlsl_and : HLSLTwoArgBuiltin<"and", "__builtin_hlsl_and"> {
+ let Doc = [{
+\fn bool and(bool x, bool y)
+\brief Logically ands two boolean vectors or matrices elementwise and
+produces a bool vector or matrix output.
+}];
+ let VaryingTypes = [BoolTy];
+}
+
+// Returns the cross product of two floating-point, 3D vectors.
+// Two separate defs are needed because the float and half variants alias
+// different builtins (__builtin_hlsl_crossf32 vs __builtin_hlsl_crossf16).
+def hlsl_cross_float : HLSLBuiltin<"cross", "__builtin_hlsl_crossf32"> {
+ let Doc = [{
+\fn T cross(T x, T y)
+\brief Returns the cross product of two floating-point, 3D vectors.
+\param x [in] The first floating-point, 3D vector.
+\param y [in] The second floating-point, 3D vector.
+
+Result is the cross product of x and y, i.e., the resulting
+components are, in order :
+x[1] * y[2] - y[1] * x[2]
+x[2] * y[0] - y[2] * x[0]
+x[0] * y[1] - y[0] * x[1]
+}];
+ let Args = [VectorType<FloatTy, 3>, VectorType<FloatTy, 3>];
+ let ReturnType = VectorType<FloatTy, 3>;
+}
+
+def hlsl_cross_half : HLSLBuiltin<"cross", "__builtin_hlsl_crossf16"> {
+ let Args = [VectorType<HalfTy, 3>, VectorType<HalfTy, 3>];
+ let ReturnType = VectorType<HalfTy, 3>;
+}
+
+// Returns the dot product (a scalar value) of X and Y.
+def hlsl_dot : HLSLTwoArgBuiltin<"dot", "__builtin_hlsl_dot"> {
+ let Doc = [{
+\fn K dot(T X, T Y)
+\brief Return the dot product (a scalar value) of \a X and \a Y.
+\param X The X input value.
+\param Y The Y input value.
+}];
+ let ReturnType = VaryingElemType;
+ let VaryingTypes = NumericTypesNoDbl;
+ let VaryingMatDims = [];
+}
+
+// double dot only has scalar overload (no vectors).
+def hlsl_dot_double : HLSLBuiltin<"dot", "__builtin_hlsl_dot"> {
+ let Args = [Varying, Varying];
+ let ReturnType = VaryingElemType;
+ let VaryingTypes = [DoubleTy];
+ let VaryingScalar = 1;
+}
+
+// Dot product of 2 half vectors plus a float scalar.
+def hlsl_dot2add : HLSLBuiltin<"dot2add"> {
+ let Doc = [{
+\fn float dot2add(half2 A, half2 B, float C)
+\brief Dot product of 2 vector of type half and add a float scalar value.
+\param A The first input value to dot product.
+\param B The second input value to dot product.
+\param C The input value added to the dot product.
+}];
+ let DetailFunc = "dot2add_impl";
+ let ParamNames = ["A", "B", "C"];
+ let Args = [VectorType<HalfTy, 2>, VectorType<HalfTy, 2>, FloatTy];
+ let ReturnType = FloatTy;
+ let Availability = SM6_4;
+}
+
+// Blocks execution of all threads in a group until all group shared accesses
+// have been completed and all threads in the group have reached this call.
+def hlsl_group_memory_barrier_with_group_sync :
+ HLSLBuiltin<"GroupMemoryBarrierWithGroupSync",
+ "__builtin_hlsl_group_memory_barrier_with_group_sync"> {
+ let Doc = [{
+\fn void GroupMemoryBarrierWithGroupSync(void)
+\brief Blocks execution of all threads in a group until all group shared
+accesses have been completed and all threads in the group have reached this
+call.
+}];
+ let IsConvergent = 1;
+}
+
+// Determines if the specified value x is infinite.
+def hlsl_isinf : HLSLOneArgBuiltin<"isinf", "__builtin_hlsl_elementwise_isinf"> {
+ let Doc = [{
+\fn T isinf(T x)
+\brief Determines if the specified value \a x is infinite.
+\param x The specified input value.
+
+Returns a value of the same size as the input, with a value set
+to True if the x parameter is +INF or -INF. Otherwise, False.
+}];
+ let ReturnType = VaryingShape<BoolTy>;
+ let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingMatDims = [];
+}
+
+// Returns a refraction vector using an entering ray, a surface normal, and
+// a refraction index.
+def hlsl_refract : HLSLBuiltin<"refract"> {
+ let Doc = [{
+\fn T refract(T I, T N, T eta)
+\brief Returns a refraction using an entering ray, \a I, a surface
+normal, \a N and refraction index \a eta
+\param I The entering ray.
+\param N The surface normal.
+\param eta The refraction index.
+
+The return value is a floating-point vector that represents the refraction
+using the refraction index, \a eta, for the direction of the entering ray,
+\a I, off a surface with the normal \a N.
+
+This function calculates the refraction vector using the following formulas:
+k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I))
+if k < 0.0 the result is 0.0
+otherwise, the result is eta * I - (eta * dot(N, I) + sqrt(k)) * N
+
+I and N must already be normalized in order to achieve the desired result.
+
+I and N must be a scalar or vector whose component type is
+floating-point.
+
+eta must be a 16-bit or 32-bit floating-point scalar.
+
+Result type, the type of I, and the type of N must all be the same type.
+}];
+ let DetailFunc = "refract_impl";
+ let ParamNames = ["I", "N", "eta"];
+ let Args = [Varying, Varying, VaryingElemType];
+ let ReturnType = Varying;
+ let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingScalar = 1;
+ let VaryingVecSizes = [2, 3, 4];
+ let VaryingMatDims = [];
+}
diff --git a/clang/lib/Headers/hlsl/hlsl_alias_intrinsics.h b/clang/lib/Headers/hlsl/hlsl_alias_intrinsics.h
index 76fca33ae0c13..90e681b55fa12 100644
--- a/clang/lib/Headers/hlsl/hlsl_alias_intrinsics.h
+++ b/clang/lib/Headers/hlsl/hlsl_alias_intrinsics.h
@@ -41,97 +41,6 @@ namespace hlsl {
// Generated by clang-tblgen from HLSLIntrinsics.td (alias intrinsics).
#include "hlsl_alias_intrinsics_gen.inc"
-//===----------------------------------------------------------------------===//
-// abs builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn T abs(T Val)
-/// \brief Returns the absolute value of the input value, \a Val.
-/// \param Val The input value.
-
-#ifdef __HLSL_ENABLE_16_BIT
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
-int16_t abs(int16_t);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
-int16_t2 abs(int16_t2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
-int16_t3 abs(int16_t3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
-int16_t4 abs(int16_t4);
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-constexpr uint16_t abs(uint16_t V) { return V; }
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-constexpr uint16_t2 abs(uint16_t2 V) { return V; }
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-constexpr uint16_t3 abs(uint16_t3 V) { return V; }
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-constexpr uint16_t4 abs(uint16_t4 V) { return V; }
-#endif
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
-half abs(half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
-half2 abs(half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
-half3 abs(half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
-half4 abs(half4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
-int abs(int);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
-int2 abs(int2);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
-int3 abs(int3);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
-int4 abs(int4);
-
-constexpr uint abs(uint V) { return V; }
-constexpr uint2 abs(uint2 V) { return V; }
-constexpr uint3 abs(uint3 V) { return V; }
-constexpr uint4 abs(uint4 V) { return V; }
-
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
-float abs(float);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
-float2 abs(float2);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
-float3 abs(float3);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
-float4 abs(float4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
-int64_t abs(int64_t);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
-int64_t2 abs(int64_t2);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
-int64_t3 abs(int64_t3);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
-int64_t4 abs(int64_t4);
-
-constexpr uint64_t abs(uint64_t V) { return V; }
-constexpr uint64_t2 abs(uint64_t2 V) { return V; }
-constexpr uint64_t3 abs(uint64_t3 V) { return V; }
-constexpr uint64_t4 abs(uint64_t4 V) { return V; }
-
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
-double abs(double);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
-double2 abs(double2);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
-double3 abs(double3);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
-double4 abs(double4);
-
//===----------------------------------------------------------------------===//
// acos builtins
//===----------------------------------------------------------------------===//
@@ -295,60 +204,6 @@ 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 or matrices elementwise and
-/// produces a bool vector or matrix output.
-
-// 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);
-
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
-bool1x2 and(bool1x2 x, bool1x2 y);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
-bool1x3 and(bool1x3 x, bool1x3 y);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
-bool1x4 and(bool1x4 x, bool1x4 y);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
-bool2x1 and(bool2x1 x, bool2x1 y);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
-bool2x2 and(bool2x2 x, bool2x2 y);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
-bool2x3 and(bool2x3 x, bool2x3 y);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
-bool2x4 and(bool2x4 x, bool2x4 y);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
-bool3x1 and(bool3x1 x, bool3x1 y);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
-bool3x2 and(bool3x2 x, bool3x2 y);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
-bool3x3 and(bool3x3 x, bool3x3 y);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
-bool3x4 and(bool3x4 x, bool3x4 y);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
-bool4x1 and(bool4x1 x, bool4x1 y);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
-bool4x2 and(bool4x2 x, bool4x2 y);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
-bool4x3 and(bool4x3 x, bool4x3 y);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
-bool4x4 and(bool4x4 x, bool4x4 y);
-// clang-format on
-
//===----------------------------------------------------------------------===//
// any builtins
//===----------------------------------------------------------------------===//
@@ -912,104 +767,6 @@ float3 degrees(float3);
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_degrees)
float4 degrees(float4);
-//===----------------------------------------------------------------------===//
-// dot product builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn K dot(T X, T Y)
-/// \brief Return the dot product (a scalar value) of \a X and \a Y.
-/// \param X The X input value.
-/// \param Y The Y input value.
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-half dot(half, half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-half dot(half2, half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-half dot(half3, half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-half dot(half4, half4);
-
-#ifdef __HLSL_ENABLE_16_BIT
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-int16_t dot(int16_t, int16_t);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-int16_t dot(int16_t2, int16_t2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-int16_t dot(int16_t3, int16_t3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-int16_t dot(int16_t4, int16_t4);
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-uint16_t dot(uint16_t, uint16_t);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-uint16_t dot(uint16_t2, uint16_t2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-uint16_t dot(uint16_t3, uint16_t3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-uint16_t dot(uint16_t4, uint16_t4);
-#endif
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-float dot(float, float);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-float dot(float2, float2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-float dot(float3, float3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-float dot(float4, float4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-double dot(double, double);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-int dot(int, int);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-int dot(int2, int2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-int dot(int3, int3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-int dot(int4, int4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-uint dot(uint, uint);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-uint dot(uint2, uint2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-uint dot(uint3, uint3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-uint dot(uint4, uint4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-int64_t dot(int64_t, int64_t);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-int64_t dot(int64_t2, int64_t2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-int64_t dot(int64_t3, int64_t3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-int64_t dot(int64_t4, int64_t4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-uint64_t dot(uint64_t, uint64_t);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-uint64_t dot(uint64_t2, uint64_t2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-uint64_t dot(uint64_t3, uint64_t3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-uint64_t dot(uint64_t4, uint64_t4);
-
//===----------------------------------------------------------------------===//
// dot4add builtins
//===----------------------------------------------------------------------===//
@@ -1267,39 +1024,6 @@ float3 frac(float3);
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_frac)
float4 frac(float4);
-//===----------------------------------------------------------------------===//
-// isinf builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn T isinf(T x)
-/// \brief Determines if the specified value \a x is infinite.
-/// \param x The specified input value.
-///
-/// Returns a value of the same size as the input, with a value set
-/// to True if the x parameter is +INF or -INF. Otherwise, False.
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_isinf)
-bool isinf(half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_isinf)
-bool2 isinf(half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_isinf)
-bool3 isinf(half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_isinf)
-bool4 isinf(half4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_isinf)
-bool isinf(float);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_isinf)
-bool2 isinf(float2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_isinf)
-bool3 isinf(float3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_isinf)
-bool4 isinf(float4);
-
//===----------------------------------------------------------------------===//
// isnan builtins
//===----------------------------------------------------------------------===//
@@ -2019,28 +1743,6 @@ uint64_t3 reversebits(uint64_t3);
_HLSL_BUILTIN_ALIAS(__builtin_elementwise_bitreverse)
uint64_t4 reversebits(uint64_t4);
-//===----------------------------------------------------------------------===//
-// cross builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn T cross(T x, T y)
-/// \brief Returns the cross product of two floating-point, 3D vectors.
-/// \param x [in] The first floating-point, 3D vector.
-/// \param y [in] The second floating-point, 3D vector.
-///
-/// Result is the cross product of x and y, i.e., the resulting
-/// components are, in order :
-/// x[1] * y[2] - y[1] * x[2]
-/// x[2] * y[0] - y[2] * x[0]
-/// x[0] * y[1] - y[0] * x[1]
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_crossf16)
-half3 cross(half3, half3);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_crossf32)
-float3 cross(float3, float3);
-
//===----------------------------------------------------------------------===//
// rcp builtins
//===----------------------------------------------------------------------===//
@@ -3773,18 +3475,6 @@ float3 radians(float3);
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_radians)
float4 radians(float4);
-//===----------------------------------------------------------------------===//
-// GroupMemoryBarrierWithGroupSync builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn void GroupMemoryBarrierWithGroupSync(void)
-/// \brief Blocks execution of all threads in a group until all group shared
-/// accesses have been completed and all threads in the group have reached this
-/// call.
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_group_memory_barrier_with_group_sync)
-__attribute__((convergent)) void GroupMemoryBarrierWithGroupSync(void);
-
//===----------------------------------------------------------------------===//
// ddx_coarse builtin
//===----------------------------------------------------------------------===//
diff --git a/clang/lib/Headers/hlsl/hlsl_intrinsics.h b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
index 6a37a50064411..95d77eed41853 100644
--- a/clang/lib/Headers/hlsl/hlsl_intrinsics.h
+++ b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
@@ -178,21 +178,6 @@ const inline float distance(__detail::HLSL_FIXED_VECTOR<float, N> X,
return __detail::distance_vec_impl(X, Y);
}
-//===----------------------------------------------------------------------===//
-// dot2add builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn float dot2add(half2 A, half2 B, float C)
-/// \brief Dot product of 2 vector of type half and add a float scalar value.
-/// \param A The first input value to dot product.
-/// \param B The second input value to dot product.
-/// \param C The input value added to the dot product.
-
-_HLSL_AVAILABILITY(shadermodel, 6.4)
-const inline float dot2add(half2 A, half2 B, float C) {
- return __detail::dot2add_impl(A, B, C);
-}
-
//===----------------------------------------------------------------------===//
// dst builtins
//===----------------------------------------------------------------------===//
@@ -563,65 +548,6 @@ reflect(__detail::HLSL_FIXED_VECTOR<float, L> I,
return __detail::reflect_vec_impl(I, N);
}
-//===----------------------------------------------------------------------===//
-// refract builtin
-//===----------------------------------------------------------------------===//
-
-/// \fn T refract(T I, T N, T eta)
-/// \brief Returns a refraction using an entering ray, \a I, a surface
-/// normal, \a N and refraction index \a eta
-/// \param I The entering ray.
-/// \param N The surface normal.
-/// \param eta The refraction index.
-///
-/// The return value is a floating-point vector that represents the refraction
-/// using the refraction index, \a eta, for the direction of the entering ray,
-/// \a I, off a surface with the normal \a N.
-///
-/// This function calculates the refraction vector using the following formulas:
-/// k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I))
-/// if k < 0.0 the result is 0.0
-/// otherwise, the result is eta * I - (eta * dot(N, I) + sqrt(k)) * N
-///
-/// I and N must already be normalized in order to achieve the desired result.
-///
-/// I and N must be a scalar or vector whose component type is
-/// floating-point.
-///
-/// eta must be a 16-bit or 32-bit floating-point scalar.
-///
-/// Result type, the type of I, and the type of N must all be the same type.
-
-template <typename T>
-_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
-const inline __detail::enable_if_t<__detail::is_arithmetic<T>::Value &&
- __detail::is_same<half, T>::value,
- T> refract(T I, T N, T eta) {
- return __detail::refract_impl(I, N, eta);
-}
-
-template <typename T>
-const inline __detail::enable_if_t<
- __detail::is_arithmetic<T>::Value && __detail::is_same<float, T>::value, T>
-refract(T I, T N, T eta) {
- return __detail::refract_impl(I, N, eta);
-}
-
-template <int L>
-_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
-const inline __detail::HLSL_FIXED_VECTOR<half, L> refract(
- __detail::HLSL_FIXED_VECTOR<half, L> I,
- __detail::HLSL_FIXED_VECTOR<half, L> N, half eta) {
- return __detail::refract_impl(I, N, eta);
-}
-
-template <int L>
-const inline __detail::HLSL_FIXED_VECTOR<float, L>
-refract(__detail::HLSL_FIXED_VECTOR<float, L> I,
- __detail::HLSL_FIXED_VECTOR<float, L> N, float eta) {
- return __detail::refract_impl(I, N, eta);
-}
-
//===----------------------------------------------------------------------===//
// smoothstep builtin
//===----------------------------------------------------------------------===//
diff --git a/clang/test/SemaHLSL/BuiltIns/cross-errors.hlsl b/clang/test/SemaHLSL/BuiltIns/cross-errors.hlsl
index 2c3e8d1560c87..c9bd1bdd3cb8e 100644
--- a/clang/test/SemaHLSL/BuiltIns/cross-errors.hlsl
+++ b/clang/test/SemaHLSL/BuiltIns/cross-errors.hlsl
@@ -4,8 +4,8 @@ void test_too_few_arg()
{
return cross();
// expected-error at -1 {{no matching function for call to 'cross'}}
- // expected-note at hlsl/hlsl_alias_intrinsics.h:* {{candidate function not viable: requires 2 arguments, but 0 were provided}}
- // expected-note at hlsl/hlsl_alias_intrinsics.h:* {{candidate function not viable: requires 2 arguments, but 0 were provided}}
+ // expected-note at hlsl/hlsl_alias_intrinsics_gen.inc:* {{candidate function not viable: requires 2 arguments, but 0 were provided}}
+ // expected-note at hlsl/hlsl_alias_intrinsics_gen.inc:* {{candidate function not viable: requires 2 arguments, but 0 were provided}}
}
void test_too_few_arg_f32()
@@ -24,8 +24,8 @@ void test_too_many_arg(float3 p0)
{
return cross(p0, p0, p0);
// expected-error at -1 {{no matching function for call to 'cross'}}
- // expected-note at hlsl/hlsl_alias_intrinsics.h:* {{candidate function not viable: requires 2 arguments, but 3 were provided}}
- // expected-note at hlsl/hlsl_alias_intrinsics.h:* {{candidate function not viable: requires 2 arguments, but 3 were provided}}
+ // expected-note at hlsl/hlsl_alias_intrinsics_gen.inc:* {{candidate function not viable: requires 2 arguments, but 3 were provided}}
+ // expected-note at hlsl/hlsl_alias_intrinsics_gen.inc:* {{candidate function not viable: requires 2 arguments, but 3 were provided}}
}
void test_too_many_arg_f32(float3 p0)
@@ -56,6 +56,6 @@ void test_ambiguous(int p0)
{
return cross(p0,p0);
// expected-error at -1 {{call to 'cross' is ambiguous}}
- // expected-note at hlsl/hlsl_alias_intrinsics.h:* {{candidate function}}
- // expected-note at hlsl/hlsl_alias_intrinsics.h:* {{candidate function}}
+ // expected-note at hlsl/hlsl_alias_intrinsics_gen.inc:* {{candidate function}}
+ // expected-note at hlsl/hlsl_alias_intrinsics_gen.inc:* {{candidate function}}
}
diff --git a/clang/test/SemaHLSL/BuiltIns/dot2add-errors.hlsl b/clang/test/SemaHLSL/BuiltIns/dot2add-errors.hlsl
index 84333ba08b9b8..e576f73669002 100644
--- a/clang/test/SemaHLSL/BuiltIns/dot2add-errors.hlsl
+++ b/clang/test/SemaHLSL/BuiltIns/dot2add-errors.hlsl
@@ -3,11 +3,11 @@
float test_too_few_arg() {
return dot2add();
// expected-error at -1 {{no matching function for call to 'dot2add'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function not viable: requires 3 arguments, but 0 were provided}}
+ // expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* {{candidate function not viable: requires 3 arguments, but 0 were provided}}
}
float test_too_many_arg(half2 p1, half2 p2, float p3) {
return dot2add(p1, p2, p3, p1);
// expected-error at -1 {{no matching function for call to 'dot2add'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function not viable: requires 3 arguments, but 4 were provided}}
+ // expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* {{candidate function not viable: requires 3 arguments, but 4 were provided}}
}
diff --git a/clang/test/SemaHLSL/BuiltIns/refract-errors.hlsl b/clang/test/SemaHLSL/BuiltIns/refract-errors.hlsl
index fce41a4a46d38..8d9949f52aeb0 100644
--- a/clang/test/SemaHLSL/BuiltIns/refract-errors.hlsl
+++ b/clang/test/SemaHLSL/BuiltIns/refract-errors.hlsl
@@ -3,64 +3,56 @@
float test_no_second_arg(float3 p0) {
return refract(p0);
// expected-error at -1 {{no matching function for call to 'refract'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 3 arguments, but 1 was provided}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 3 arguments, but 1 was provided}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 3 arguments, but 1 was provided}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 3 arguments, but 1 was provided}}
+ // expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* 8 {{candidate function not viable: requires 3 arguments, but 1 was provided}}
}
float test_no_third_arg(float3 p0) {
return refract(p0, p0);
// expected-error at -1 {{no matching function for call to 'refract'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 3 arguments, but 2 were provided}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 3 arguments, but 2 were provided}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 3 arguments, but 2 were provided}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 3 arguments, but 2 were provided}}
+ // expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* 8 {{candidate function not viable: requires 3 arguments, but 2 were provided}}
}
float test_too_many_arg(float2 p0) {
return refract(p0, p0, p0, p0);
// expected-error at -1 {{no matching function for call to 'refract'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 3 arguments, but 4 were provided}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 3 arguments, but 4 were provided}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 3 arguments, but 4 were provided}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 3 arguments, but 4 were provided}}
+ // expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* 8 {{candidate function not viable: requires 3 arguments, but 4 were provided}}
}
float test_double_inputs(double p0, double p1, double p2) {
return refract(p0, p1, p2);
- // expected-error at -1 {{no matching function for call to 'refract'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
+ // expected-error at -1 {{call to 'refract' is ambiguous}}
+ // expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* 2 {{candidate function}}
}
float test_int_inputs(int p0, int p1, int p2) {
return refract(p0, p1, p2);
- // expected-error at -1 {{no matching function for call to 'refract'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
+ // expected-error at -1 {{call to 'refract' is ambiguous}}
+ // expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* 2 {{candidate function}}
}
float1 test_vec1_inputs(float1 p0, float1 p1, float1 p2) {
return refract(p0, p1, p2);
- // expected-error at -1 {{no matching function for call to 'refract'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = float1]: no type named 'Type' in 'hlsl::__detail::enable_if<false, vector<float, 1>>'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = float1]: no type named 'Type' in 'hlsl::__detail::enable_if<false, vector<float, 1>>'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with L = 1]: no type named 'Type' in 'hlsl::__detail::enable_if<false, half>'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with L = 1]: no type named 'Type' in 'hlsl::__detail::enable_if<false, float>'}}
+ // expected-warning at -1 {{implicit conversion turns vector to scalar: 'float1' (aka 'vector<float, 1>') to 'float'}}
+ // expected-warning at -2 {{implicit conversion turns vector to scalar: 'float1' (aka 'vector<float, 1>') to 'float'}}
+ // expected-warning at -3 {{implicit conversion turns vector to scalar: 'float1' (aka 'vector<float, 1>') to 'float'}}
}
typedef float float5 __attribute__((ext_vector_type(5)));
-float5 test_vec5_inputs(float5 p0, float5 p1, float p2) {
+float5 test_vec5_inputs(float5 p0, float5 p1, float p2) {
return refract(p0, p1, p2);
- // expected-error at -1 {{no matching function for call to 'refract'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: deduced conflicting types for parameter 'T' ('float5' (vector of 5 'float' values) vs. 'float')}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: deduced conflicting types for parameter 'T' ('float5' (vector of 5 'float' values) vs. 'float')}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with L = 5]: no type named 'Type' in 'hlsl::__detail::enable_if<false, half>'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with L = 5]: no type named 'Type' in 'hlsl::__detail::enable_if<false, float>'}}
+ // expected-error at -1 {{call to 'refract' is ambiguous}}
+ // expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* 4 {{candidate function}}
+}
+
+half3 test_half_inputs_with_float(half3 p0, half3 p1, float p3) {
+ return refract(p0, p1, p3);
+ // expected-error at -1 {{call to 'refract' is ambiguous}}
+ // expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* 6 {{candidate function}}
+}
+
+half3 test_half_inputs_with_float_literal(half3 p0, half3 p1) {
+ return refract(p0, p1, 0.5);
+ // expected-error at -1 {{call to 'refract' is ambiguous}}
+ // expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* 6 {{candidate function}}
}
>From 9d43348826f55a6d2e31300d6b4e75c50c07b79a Mon Sep 17 00:00:00 2001
From: Deric Cheung <cheung.deric at gmail.com>
Date: Wed, 25 Mar 2026 14:29:34 -0700
Subject: [PATCH 02/12] Only rewrite inline/detail HLSL intrinsics into
TableGen
Also move alias intrinsics present in hlsl_intrinsics.h over to hlsl_alias_intrinsics.h
Removed some one-line __detail helper functions and made them inline Body HLSL builtin definitions in HLSLIntrinsics.td
Assisted-by: GitHub Copilot
---
clang/include/clang/Basic/HLSLIntrinsics.td | 383 ++++++++++---
.../lib/Headers/hlsl/hlsl_alias_intrinsics.h | 305 +++++++++++
.../lib/Headers/hlsl/hlsl_intrinsic_helpers.h | 32 +-
clang/lib/Headers/hlsl/hlsl_intrinsics.h | 517 ------------------
clang/test/CodeGenHLSL/builtins/distance.hlsl | 8 +-
clang/test/CodeGenHLSL/builtins/dst.hlsl | 11 +-
clang/test/CodeGenHLSL/builtins/ldexp.hlsl | 48 +-
.../resources/NonUniformResourceIndex.hlsl | 15 +-
.../BuiltIns/D3DCOLORtoUBYTE4-errors.hlsl | 8 +-
.../test/SemaHLSL/BuiltIns/cross-errors.hlsl | 12 +-
.../SemaHLSL/BuiltIns/distance-errors.hlsl | 37 +-
.../SemaHLSL/BuiltIns/faceforward-errors.hlsl | 27 +-
clang/test/SemaHLSL/BuiltIns/fmod-errors.hlsl | 37 +-
.../test/SemaHLSL/BuiltIns/ldexp-errors.hlsl | 27 +-
.../test/SemaHLSL/BuiltIns/length-errors.hlsl | 51 +-
.../SemaHLSL/BuiltIns/reflect-errors.hlsl | 37 +-
.../SemaHLSL/BuiltIns/smoothstep-errors.hlsl | 42 +-
17 files changed, 741 insertions(+), 856 deletions(-)
diff --git a/clang/include/clang/Basic/HLSLIntrinsics.td b/clang/include/clang/Basic/HLSLIntrinsics.td
index 8811f747f3452..57a612caaba74 100644
--- a/clang/include/clang/Basic/HLSLIntrinsics.td
+++ b/clang/include/clang/Basic/HLSLIntrinsics.td
@@ -313,19 +313,16 @@ class HLSLOneArgInlineBuiltin<string name> : HLSLBuiltin<name> {
// Intrinsic definitions (sorted alphabetically by function name)
//===----------------------------------------------------------------------===//
-// Returns the absolute value of the input value, Val.
-def hlsl_abs : HLSLOneArgBuiltin<"abs", "__builtin_elementwise_abs"> {
+// Unsigned abs is a constexpr identity — unsigned values are already non-negative.
+def hlsl_abs_unsigned : HLSLOneArgInlineBuiltin<"abs"> {
let Doc = [{
\fn T abs(T Val)
\brief Returns the absolute value of the input value, \a Val.
\param Val The input value.
-}];
- let VaryingTypes = SignedTypes;
- let VaryingMatDims = [];
-}
-// Unsigned abs is a constexpr identity — unsigned values are already non-negative.
-def hlsl_abs_unsigned : HLSLOneArgInlineBuiltin<"abs"> {
+Unsigned overload — unsigned values are already non-negative, so this
+function returns its input unchanged.
+}];
let ParamNames = ["V"];
let Body = "return V;";
let IsConstexpr = 1;
@@ -333,60 +330,108 @@ def hlsl_abs_unsigned : HLSLOneArgInlineBuiltin<"abs"> {
let VaryingMatDims = [];
}
-// Returns the boolean AND of two bool values or vectors.
-def hlsl_and : HLSLTwoArgBuiltin<"and", "__builtin_hlsl_and"> {
+// Checks whether the value is fully mapped.
+def hlsl_check_access_fully_mapped : HLSLBuiltin<"CheckAccessFullyMapped"> {
+ let Doc = [{
+\fn bool CheckAccessFullyMapped(uint Status)
+\brief Checks whether the value is fully mapped.
+\param Status The status value to check.
+}];
+ let ParamNames = ["Status"];
+ let Body = "return static_cast<bool>(Status);";
+ let Args = [UIntTy];
+ let ReturnType = BoolTy;
+}
+
+// Converts a floating-point, 4D vector set by a D3DCOLOR to a UBYTE4.
+def hlsl_d3d_color_to_ubyte4 : HLSLBuiltin<"D3DCOLORtoUBYTE4"> {
let Doc = [{
-\fn bool and(bool x, bool y)
-\brief Logically ands two boolean vectors or matrices elementwise and
-produces a bool vector or matrix output.
+\fn int4 D3DCOLORtoUBYTE4(float4 x)
+\brief Converts a floating-point, 4D vector set by a D3DCOLOR to a UBYTE4.
+\param x [in] The floating-point vector4 to convert.
+
+The return value is the UBYTE4 representation of the \a x parameter.
+
+This function swizzles and scales components of the \a x parameter. Use this
+function to compensate for the lack of UBYTE4 support in some hardware.
}];
- let VaryingTypes = [BoolTy];
+ // Use the same scaling factor used by FXC, and DXC for DXIL
+ // (i.e., 255.001953)
+ // https://github.com/microsoft/DirectXShaderCompiler/blob/070d0d5a2beacef9eeb51037a9b04665716fd6f3/lib/HLSL/HLOperationLower.cpp#L666C1-L697C2
+ // The DXC implementation refers to a comment on the following stackoverflow
+ // discussion to justify the scaling factor: "Built-in rounding, necessary
+ // because of truncation. 0.001953 * 256 = 0.5"
+ // https://stackoverflow.com/questions/52103720/why-does-d3dcolortoubyte4-multiplies-components-by-255-001953f
+ let Body = "return V.zyxw * 255.001953f;";
+ let ParamNames = ["V"];
+ let Args = [VectorType<FloatTy, 4>];
+ let ReturnType = VectorType<IntTy, 4>;
+ let IsConstexpr = 1;
}
-// Returns the cross product of two floating-point, 3D vectors.
-// Two separate defs are needed because the float and half variants alias
-// different builtins (__builtin_hlsl_crossf32 vs __builtin_hlsl_crossf16).
-def hlsl_cross_float : HLSLBuiltin<"cross", "__builtin_hlsl_crossf32"> {
+// Computes the partial derivative with regard to the x screen space coordinate.
+def hlsl_ddx : HLSLBuiltin<"ddx"> {
let Doc = [{
-\fn T cross(T x, T y)
-\brief Returns the cross product of two floating-point, 3D vectors.
-\param x [in] The first floating-point, 3D vector.
-\param y [in] The second floating-point, 3D vector.
-
-Result is the cross product of x and y, i.e., the resulting
-components are, in order :
-x[1] * y[2] - y[1] * x[2]
-x[2] * y[0] - y[2] * x[0]
-x[0] * y[1] - y[0] * x[1]
+\fn T ddx(T x)
+\brief Computes the partial derivative of the specified value with regard to
+the screen-space x-coordinate.
+\param x [in] The floating-point scalar or vector to process.
}];
- let Args = [VectorType<FloatTy, 3>, VectorType<FloatTy, 3>];
- let ReturnType = VectorType<FloatTy, 3>;
+ let DetailFunc = "ddx_impl";
+ let ParamNames = ["input"];
+ let Args = [Varying];
+ let ReturnType = Varying;
+ let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingScalar = 1;
+ let VaryingVecSizes = [2, 3, 4];
+ let VaryingMatDims = [];
}
-def hlsl_cross_half : HLSLBuiltin<"cross", "__builtin_hlsl_crossf16"> {
- let Args = [VectorType<HalfTy, 3>, VectorType<HalfTy, 3>];
- let ReturnType = VectorType<HalfTy, 3>;
+// Computes the partial derivative with regard to the y screen space coordinate.
+def hlsl_ddy : HLSLBuiltin<"ddy"> {
+ let Doc = [{
+\fn T ddy(T x)
+\brief Computes the partial derivative of the specified value with regard to
+the screen-space y-coordinate.
+\param x [in] The floating-point scalar or vector to process.
+}];
+ let DetailFunc = "ddy_impl";
+ let ParamNames = ["input"];
+ let Args = [Varying];
+ let ReturnType = Varying;
+ let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingScalar = 1;
+ let VaryingVecSizes = [2, 3, 4];
+ let VaryingMatDims = [];
}
-// Returns the dot product (a scalar value) of X and Y.
-def hlsl_dot : HLSLTwoArgBuiltin<"dot", "__builtin_hlsl_dot"> {
+// Returns a distance scalar between X and Y (scalar overloads).
+// Scalar distance is equivalent to abs(X - Y).
+def hlsl_distance : HLSLBuiltin<"distance"> {
let Doc = [{
-\fn K dot(T X, T Y)
-\brief Return the dot product (a scalar value) of \a X and \a Y.
+\fn K distance(T X, T Y)
+\brief Returns a distance scalar between \a X and \a Y.
\param X The X input value.
\param Y The Y input value.
}];
- let ReturnType = VaryingElemType;
- let VaryingTypes = NumericTypesNoDbl;
+ let ParamNames = ["X", "Y"];
+ let Body = "return abs(X - Y);";
+ let Args = [Varying, Varying];
+ let ReturnType = Varying;
+ let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingScalar = 1;
let VaryingMatDims = [];
}
-// double dot only has scalar overload (no vectors).
-def hlsl_dot_double : HLSLBuiltin<"dot", "__builtin_hlsl_dot"> {
+// Returns a distance scalar between X and Y (vector overloads).
+def hlsl_distance_vec : HLSLBuiltin<"distance"> {
+ let DetailFunc = "distance_vec_impl";
+ let ParamNames = ["X", "Y"];
let Args = [Varying, Varying];
let ReturnType = VaryingElemType;
- let VaryingTypes = [DoubleTy];
- let VaryingScalar = 1;
+ let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingVecSizes = [2, 3, 4];
+ let VaryingMatDims = [];
}
// Dot product of 2 half vectors plus a float scalar.
@@ -405,32 +450,214 @@ def hlsl_dot2add : HLSLBuiltin<"dot2add"> {
let Availability = SM6_4;
}
-// Blocks execution of all threads in a group until all group shared accesses
-// have been completed and all threads in the group have reached this call.
-def hlsl_group_memory_barrier_with_group_sync :
- HLSLBuiltin<"GroupMemoryBarrierWithGroupSync",
- "__builtin_hlsl_group_memory_barrier_with_group_sync"> {
+// Calculates a distance vector.
+def hlsl_dst : HLSLBuiltin<"dst"> {
+ let Doc = [{
+\fn vector<T, 4> dst(vector<T, 4> Src0, vector<T, 4> Src1)
+\brief Calculates a distance vector.
+\param Src0 [in] Contains the squared distance.
+\param Src1 [in] Contains the reciprocal distance.
+
+Return the computed distance vector.
+}];
+ let ParamNames = ["Src0", "Src1"];
+ let Body = "return {1, Src0[1] * Src1[1], Src0[2], Src1[3]};";
+ let Args = [Varying, Varying];
+ let ReturnType = Varying;
+ let VaryingTypes = AllFloatTypes;
+ let VaryingVecSizes = [4];
+ let VaryingMatDims = [];
+}
+
+// Flips the surface-normal to face in a direction opposite to I.
+def hlsl_faceforward : HLSLBuiltin<"faceforward"> {
let Doc = [{
-\fn void GroupMemoryBarrierWithGroupSync(void)
-\brief Blocks execution of all threads in a group until all group shared
-accesses have been completed and all threads in the group have reached this
-call.
+\fn T faceforward(T N, T I, T Ng)
+\brief Flips the surface-normal (if needed) to face in a direction opposite
+to \a I. Returns the result in terms of \a N.
+\param N The resulting floating-point surface-normal vector.
+\param I A floating-point, incident vector that points from the view
+position to the shading position.
+\param Ng A floating-point surface-normal vector.
+
+Return a floating-point, surface normal vector that is facing the view
+direction.
}];
- let IsConvergent = 1;
+ let DetailFunc = "faceforward_impl";
+ let ParamNames = ["N", "I", "Ng"];
+ let Args = [Varying, Varying, Varying];
+ let ReturnType = Varying;
+ let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingScalar = 1;
+ let VaryingVecSizes = [2, 3, 4];
+ let VaryingMatDims = [];
}
-// Determines if the specified value x is infinite.
-def hlsl_isinf : HLSLOneArgBuiltin<"isinf", "__builtin_hlsl_elementwise_isinf"> {
+// Returns the floating-point remainder of x/y (scalar overloads).
+def hlsl_fmod : HLSLBuiltin<"fmod"> {
let Doc = [{
-\fn T isinf(T x)
-\brief Determines if the specified value \a x is infinite.
-\param x The specified input value.
+\fn T fmod(T x, T y)
+\brief Returns the floating-point remainder of x/y.
+\param x [in] The dividend.
+\param y [in] The divisor.
-Returns a value of the same size as the input, with a value set
-to True if the x parameter is +INF or -INF. Otherwise, False.
+Return the floating-point remainder of the x parameter divided by the y
+parameter.
}];
- let ReturnType = VaryingShape<BoolTy>;
+ let DetailFunc = "fmod_impl";
+ let ParamNames = ["X", "Y"];
+ let Args = [Varying, Varying];
+ let ReturnType = Varying;
let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingScalar = 1;
+ let VaryingMatDims = [];
+}
+
+// Returns the floating-point remainder of x/y (vector overloads).
+def hlsl_fmod_vec : HLSLBuiltin<"fmod"> {
+ let DetailFunc = "fmod_vec_impl";
+ let ParamNames = ["X", "Y"];
+ let Args = [Varying, Varying];
+ let ReturnType = Varying;
+ let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingVecSizes = [2, 3, 4];
+ let VaryingMatDims = [];
+}
+
+// Computes the sum of the absolute values of the partial derivatives.
+def hlsl_fwidth : HLSLBuiltin<"fwidth"> {
+ let Doc = [{
+\fn T fwidth(T x)
+\brief Computes the sum of the absolute values of the partial derivatives
+with regard to the x and y screen space coordinates.
+\param x [in] The floating-point scalar or vector to process.
+}];
+ let DetailFunc = "fwidth_impl";
+ let ParamNames = ["input"];
+ let Args = [Varying];
+ let ReturnType = Varying;
+ let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingScalar = 1;
+ let VaryingVecSizes = [2, 3, 4];
+ let VaryingMatDims = [];
+}
+
+// Returns the result of multiplying the specified value by two raised
+// to the power of the specified exponent.
+def hlsl_ldexp : HLSLBuiltin<"ldexp"> {
+ let Doc = [{
+\fn T ldexp(T X, T Exp)
+\brief Returns the result of multiplying the specified value by two raised
+to the power of the specified exponent.
+\param X [in] The specified value.
+\param Exp [in] The specified exponent.
+
+This function uses the following formula: X * 2^Exp
+}];
+ // ldexp(X, Exp) = X * 2^Exp, implemented as exp2(Exp) * X.
+ let ParamNames = ["X", "Exp"];
+ let Body = "return exp2(Exp) * X;";
+ let Args = [Varying, Varying];
+ let ReturnType = Varying;
+ let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingScalar = 1;
+ let VaryingVecSizes = [2, 3, 4];
+ let VaryingMatDims = [];
+}
+
+// Returns the length of the specified floating-point vector (scalar overloads).
+// Scalar length is equivalent to abs(X).
+def hlsl_length : HLSLBuiltin<"length"> {
+ let Doc = [{
+\fn T length(T x)
+\brief Returns the length of the specified floating-point vector.
+\param x [in] The vector of floats, or a scalar float.
+
+Length is based on the following formula: sqrt(x[0]^2 + x[1]^2 + ...).
+}];
+ let ParamNames = ["X"];
+ let Body = "return abs(X);";
+ let Args = [Varying];
+ let ReturnType = Varying;
+ let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingScalar = 1;
+ let VaryingMatDims = [];
+}
+
+// Returns the length of the specified floating-point vector (vector overloads).
+def hlsl_length_vec : HLSLBuiltin<"length"> {
+ let DetailFunc = "length_vec_impl";
+ let ParamNames = ["X"];
+ let Args = [Varying];
+ let ReturnType = VaryingElemType;
+ let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingVecSizes = [2, 3, 4];
+ let VaryingMatDims = [];
+}
+
+// Returns a lighting coefficient vector.
+def hlsl_lit_half : HLSLBuiltin<"lit"> {
+ let Doc = [{
+\fn vector<T, 4> lit(T NDotL, T NDotH, T M)
+\brief Returns a lighting coefficient vector.
+\param NDotL The dot product of the normalized surface normal and the
+light vector.
+\param NDotH The dot product of the half-angle vector and the surface
+normal.
+\param M A specular exponent.
+
+This function returns a lighting coefficient vector (ambient, diffuse,
+specular, 1).
+}];
+ let DetailFunc = "lit_impl";
+ let ParamNames = ["NDotL", "NDotH", "M"];
+ let Args = [HalfTy, HalfTy, HalfTy];
+ let ReturnType = VectorType<HalfTy, 4>;
+}
+
+def hlsl_lit_float : HLSLBuiltin<"lit"> {
+ let DetailFunc = "lit_impl";
+ let ParamNames = ["NDotL", "NDotH", "M"];
+ let Args = [FloatTy, FloatTy, FloatTy];
+ let ReturnType = VectorType<FloatTy, 4>;
+}
+
+// Returns a reflection vector (scalar overloads).
+// Scalar reflect: V = I - 2 * N * I * N (dot product is just multiplication
+// for scalars).
+def hlsl_reflect : HLSLBuiltin<"reflect"> {
+ let Doc = [{
+\fn T reflect(T I, T N)
+\brief Returns a reflection using an incident ray, \a I, and a surface
+normal, \a N.
+\param I The incident ray.
+\param N The surface normal.
+
+The return value is a floating-point vector that represents the reflection
+of the incident ray, \a I, off a surface with the normal \a N.
+
+This function calculates the reflection vector using the following formula:
+V = I - 2 * N * dot(I N) .
+
+N must already be normalized in order to achieve the desired result.
+}];
+ let ParamNames = ["I", "N"];
+ let Body = "return I - 2 * N * I * N;";
+ let Args = [Varying, Varying];
+ let ReturnType = Varying;
+ let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingScalar = 1;
+ let VaryingMatDims = [];
+}
+
+// Returns a reflection vector (vector overloads).
+def hlsl_reflect_vec : HLSLBuiltin<"reflect"> {
+ let DetailFunc = "reflect_vec_impl";
+ let ParamNames = ["I", "N"];
+ let Args = [Varying, Varying];
+ let ReturnType = Varying;
+ let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingVecSizes = [2, 3, 4];
let VaryingMatDims = [];
}
@@ -473,3 +700,37 @@ Result type, the type of I, and the type of N must all be the same type.
let VaryingMatDims = [];
}
+
+// Returns a smooth Hermite interpolation between 0 and 1 (scalar overloads).
+def hlsl_smoothstep : HLSLBuiltin<"smoothstep"> {
+ let Doc = [{
+\fn T smoothstep(T Min, T Max, T X)
+\brief Returns a smooth Hermite interpolation between 0 and 1, if \a X is in
+the range [\a Min, \a Max].
+\param Min The minimum range of the x parameter.
+\param Max The maximum range of the x parameter.
+\param X The specified value to be interpolated.
+
+The return value is 0.0 if \a X <= \a Min and 1.0 if \a X >= \a Max. When \a
+Min < \a X < \a Max, the function performs smooth Hermite interpolation
+between 0 and 1.
+}];
+ let DetailFunc = "smoothstep_impl";
+ let ParamNames = ["Min", "Max", "X"];
+ let Args = [Varying, Varying, Varying];
+ let ReturnType = Varying;
+ let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingScalar = 1;
+ let VaryingMatDims = [];
+}
+
+// Returns a smooth Hermite interpolation between 0 and 1 (vector overloads).
+def hlsl_smoothstep_vec : HLSLBuiltin<"smoothstep"> {
+ let DetailFunc = "smoothstep_vec_impl";
+ let ParamNames = ["Min", "Max", "X"];
+ let Args = [Varying, Varying, Varying];
+ let ReturnType = Varying;
+ let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingVecSizes = [2, 3, 4];
+ let VaryingMatDims = [];
+}
diff --git a/clang/lib/Headers/hlsl/hlsl_alias_intrinsics.h b/clang/lib/Headers/hlsl/hlsl_alias_intrinsics.h
index 90e681b55fa12..ea4353b5eb042 100644
--- a/clang/lib/Headers/hlsl/hlsl_alias_intrinsics.h
+++ b/clang/lib/Headers/hlsl/hlsl_alias_intrinsics.h
@@ -41,6 +41,78 @@ namespace hlsl {
// Generated by clang-tblgen from HLSLIntrinsics.td (alias intrinsics).
#include "hlsl_alias_intrinsics_gen.inc"
+//===----------------------------------------------------------------------===//
+// abs builtins
+//===----------------------------------------------------------------------===//
+
+/// \fn T abs(T Val)
+/// \brief Returns the absolute value of the input value, \a Val.
+/// \param Val The input value.
+
+#ifdef __HLSL_ENABLE_16_BIT
+_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
+_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
+int16_t abs(int16_t);
+_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
+_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
+int16_t2 abs(int16_t2);
+_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
+_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
+int16_t3 abs(int16_t3);
+_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
+_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
+int16_t4 abs(int16_t4);
+#endif
+
+_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
+_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
+half abs(half);
+_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
+_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
+half2 abs(half2);
+_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
+_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
+half3 abs(half3);
+_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
+_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
+half4 abs(half4);
+
+_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
+int abs(int);
+_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
+int2 abs(int2);
+_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
+int3 abs(int3);
+_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
+int4 abs(int4);
+
+_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
+float abs(float);
+_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
+float2 abs(float2);
+_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
+float3 abs(float3);
+_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
+float4 abs(float4);
+
+_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
+int64_t abs(int64_t);
+_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
+int64_t2 abs(int64_t2);
+_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
+int64_t3 abs(int64_t3);
+_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
+int64_t4 abs(int64_t4);
+
+_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
+double abs(double);
+_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
+double2 abs(double2);
+_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
+double3 abs(double3);
+_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
+double4 abs(double4);
+
//===----------------------------------------------------------------------===//
// acos builtins
//===----------------------------------------------------------------------===//
@@ -204,6 +276,60 @@ 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 or matrices elementwise and
+/// produces a bool vector or matrix output.
+
+// 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);
+
+
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
+bool1x2 and(bool1x2 x, bool1x2 y);
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
+bool1x3 and(bool1x3 x, bool1x3 y);
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
+bool1x4 and(bool1x4 x, bool1x4 y);
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
+bool2x1 and(bool2x1 x, bool2x1 y);
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
+bool2x2 and(bool2x2 x, bool2x2 y);
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
+bool2x3 and(bool2x3 x, bool2x3 y);
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
+bool2x4 and(bool2x4 x, bool2x4 y);
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
+bool3x1 and(bool3x1 x, bool3x1 y);
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
+bool3x2 and(bool3x2 x, bool3x2 y);
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
+bool3x3 and(bool3x3 x, bool3x3 y);
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
+bool3x4 and(bool3x4 x, bool3x4 y);
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
+bool4x1 and(bool4x1 x, bool4x1 y);
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
+bool4x2 and(bool4x2 x, bool4x2 y);
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
+bool4x3 and(bool4x3 x, bool4x3 y);
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
+bool4x4 and(bool4x4 x, bool4x4 y);
+// clang-format on
+
//===----------------------------------------------------------------------===//
// any builtins
//===----------------------------------------------------------------------===//
@@ -767,6 +893,104 @@ float3 degrees(float3);
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_degrees)
float4 degrees(float4);
+//===----------------------------------------------------------------------===//
+// dot product builtins
+//===----------------------------------------------------------------------===//
+
+/// \fn K dot(T X, T Y)
+/// \brief Return the dot product (a scalar value) of \a X and \a Y.
+/// \param X The X input value.
+/// \param Y The Y input value.
+
+_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
+half dot(half, half);
+_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
+half dot(half2, half2);
+_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
+half dot(half3, half3);
+_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
+half dot(half4, half4);
+
+#ifdef __HLSL_ENABLE_16_BIT
+_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
+int16_t dot(int16_t, int16_t);
+_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
+int16_t dot(int16_t2, int16_t2);
+_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
+int16_t dot(int16_t3, int16_t3);
+_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
+int16_t dot(int16_t4, int16_t4);
+
+_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
+uint16_t dot(uint16_t, uint16_t);
+_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
+uint16_t dot(uint16_t2, uint16_t2);
+_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
+uint16_t dot(uint16_t3, uint16_t3);
+_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
+uint16_t dot(uint16_t4, uint16_t4);
+#endif
+
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
+float dot(float, float);
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
+float dot(float2, float2);
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
+float dot(float3, float3);
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
+float dot(float4, float4);
+
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
+double dot(double, double);
+
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
+int dot(int, int);
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
+int dot(int2, int2);
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
+int dot(int3, int3);
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
+int dot(int4, int4);
+
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
+uint dot(uint, uint);
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
+uint dot(uint2, uint2);
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
+uint dot(uint3, uint3);
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
+uint dot(uint4, uint4);
+
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
+int64_t dot(int64_t, int64_t);
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
+int64_t dot(int64_t2, int64_t2);
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
+int64_t dot(int64_t3, int64_t3);
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
+int64_t dot(int64_t4, int64_t4);
+
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
+uint64_t dot(uint64_t, uint64_t);
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
+uint64_t dot(uint64_t2, uint64_t2);
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
+uint64_t dot(uint64_t3, uint64_t3);
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
+uint64_t dot(uint64_t4, uint64_t4);
+
//===----------------------------------------------------------------------===//
// dot4add builtins
//===----------------------------------------------------------------------===//
@@ -1024,6 +1248,39 @@ float3 frac(float3);
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_frac)
float4 frac(float4);
+//===----------------------------------------------------------------------===//
+// isinf builtins
+//===----------------------------------------------------------------------===//
+
+/// \fn T isinf(T x)
+/// \brief Determines if the specified value \a x is infinite.
+/// \param x The specified input value.
+///
+/// Returns a value of the same size as the input, with a value set
+/// to True if the x parameter is +INF or -INF. Otherwise, False.
+
+_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_isinf)
+bool isinf(half);
+_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_isinf)
+bool2 isinf(half2);
+_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_isinf)
+bool3 isinf(half3);
+_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_isinf)
+bool4 isinf(half4);
+
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_isinf)
+bool isinf(float);
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_isinf)
+bool2 isinf(float2);
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_isinf)
+bool3 isinf(float3);
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_isinf)
+bool4 isinf(float4);
+
//===----------------------------------------------------------------------===//
// isnan builtins
//===----------------------------------------------------------------------===//
@@ -1618,6 +1875,20 @@ float3 normalize(float3);
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_normalize)
float4 normalize(float4);
+//===----------------------------------------------------------------------===//
+// NonUniformResourceIndex builtins
+//===----------------------------------------------------------------------===//
+
+/// \fn uint NonUniformResourceIndex(uint I)
+/// \brief A compiler hint to indicate that a resource index varies across
+/// threads within a wave (i.e., it is non-uniform).
+/// \param I [in] Resource array index.
+///
+/// The return value is the \a I parameter.
+
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_resource_nonuniformindex)
+uint NonUniformResourceIndex(uint);
+
//===----------------------------------------------------------------------===//
// or builtins
//===----------------------------------------------------------------------===//
@@ -1743,6 +2014,28 @@ uint64_t3 reversebits(uint64_t3);
_HLSL_BUILTIN_ALIAS(__builtin_elementwise_bitreverse)
uint64_t4 reversebits(uint64_t4);
+//===----------------------------------------------------------------------===//
+// cross builtins
+//===----------------------------------------------------------------------===//
+
+/// \fn T cross(T x, T y)
+/// \brief Returns the cross product of two floating-point, 3D vectors.
+/// \param x [in] The first floating-point, 3D vector.
+/// \param y [in] The second floating-point, 3D vector.
+///
+/// Result is the cross product of x and y, i.e., the resulting
+/// components are, in order :
+/// x[1] * y[2] - y[1] * x[2]
+/// x[2] * y[0] - y[2] * x[0]
+/// x[0] * y[1] - y[0] * x[1]
+
+_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_crossf16)
+half3 cross(half3, half3);
+
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_crossf32)
+float3 cross(float3, float3);
+
//===----------------------------------------------------------------------===//
// rcp builtins
//===----------------------------------------------------------------------===//
@@ -3475,6 +3768,18 @@ float3 radians(float3);
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_radians)
float4 radians(float4);
+//===----------------------------------------------------------------------===//
+// GroupMemoryBarrierWithGroupSync builtins
+//===----------------------------------------------------------------------===//
+
+/// \fn void GroupMemoryBarrierWithGroupSync(void)
+/// \brief Blocks execution of all threads in a group until all group shared
+/// accesses have been completed and all threads in the group have reached this
+/// call.
+
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_group_memory_barrier_with_group_sync)
+__attribute__((convergent)) void GroupMemoryBarrierWithGroupSync(void);
+
//===----------------------------------------------------------------------===//
// ddx_coarse builtin
//===----------------------------------------------------------------------===//
diff --git a/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h b/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h
index f04be2a1aff2a..ef6eacc5c8cc6 100644
--- a/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h
+++ b/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h
@@ -12,19 +12,6 @@
namespace hlsl {
namespace __detail {
-constexpr int4 d3d_color_to_ubyte4_impl(float4 V) {
- // Use the same scaling factor used by FXC, and DXC for DXIL
- // (i.e., 255.001953)
- // https://github.com/microsoft/DirectXShaderCompiler/blob/070d0d5a2beacef9eeb51037a9b04665716fd6f3/lib/HLSL/HLOperationLower.cpp#L666C1-L697C2
- // The DXC implementation refers to a comment on the following stackoverflow
- // discussion to justify the scaling factor: "Built-in rounding, necessary
- // because of truncation. 0.001953 * 256 = 0.5"
- // https://stackoverflow.com/questions/52103720/why-does-d3dcolortoubyte4-multiplies-components-by-255-001953f
- return V.zyxw * 255.001953f;
-}
-
-template <typename T> constexpr T length_impl(T X) { return abs(X); }
-
template <typename T, int N>
constexpr enable_if_t<is_same<float, T>::value || is_same<half, T>::value, T>
length_vec_impl(vector<T, N> X) {
@@ -35,15 +22,6 @@ length_vec_impl(vector<T, N> X) {
#endif
}
-template <typename T>
-constexpr vector<T, 4> dst_impl(vector<T, 4> Src0, vector<T, 4> Src1) {
- return {1, Src0[1] * Src1[1], Src0[2], Src1[3]};
-}
-
-template <typename T> constexpr T distance_impl(T X, T Y) {
- return length_impl(X - Y);
-}
-
template <typename T, int N>
constexpr enable_if_t<is_same<float, T>::value || is_same<half, T>::value, T>
distance_vec_impl(vector<T, N> X, vector<T, N> Y) {
@@ -73,10 +51,6 @@ enable_if_t<is_same<double, T>::value, T> mul_vec_impl(vector<T, N> x,
return sum;
}
-template <typename T> constexpr T reflect_impl(T I, T N) {
- return I - 2 * N * I * N;
-}
-
template <typename T, int L>
constexpr vector<T, L> reflect_vec_impl(vector<T, L> I, vector<T, L> N) {
#if (__has_builtin(__builtin_spirv_reflect))
@@ -152,11 +126,7 @@ template <typename T> constexpr vector<T, 4> lit_impl(T NDotL, T NDotH, T M) {
}
template <typename T> constexpr T faceforward_impl(T N, T I, T Ng) {
- return select(dot(I, Ng) < 0, N, -N);
-}
-
-template <typename T> constexpr T ldexp_impl(T X, T Exp) {
- return exp2(Exp) * X;
+ return select<T>(dot(I, Ng) < 0, N, -N);
}
template <typename K, typename T, int BitWidth>
diff --git a/clang/lib/Headers/hlsl/hlsl_intrinsics.h b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
index 95d77eed41853..cced7b0eabb1f 100644
--- a/clang/lib/Headers/hlsl/hlsl_intrinsics.h
+++ b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
@@ -141,114 +141,6 @@ constexpr __detail::enable_if_t<__detail::is_same<int16_t, T>::value ||
}
#endif
-//===----------------------------------------------------------------------===//
-// distance builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn K distance(T X, T Y)
-/// \brief Returns a distance scalar between \a X and \a Y.
-/// \param X The X input value.
-/// \param Y The Y input value.
-
-template <typename T>
-_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
-const inline __detail::enable_if_t<__detail::is_arithmetic<T>::Value &&
- __detail::is_same<half, T>::value,
- T> distance(T X, T Y) {
- return __detail::distance_impl(X, Y);
-}
-
-template <typename T>
-const inline __detail::enable_if_t<
- __detail::is_arithmetic<T>::Value && __detail::is_same<float, T>::value, T>
-distance(T X, T Y) {
- return __detail::distance_impl(X, Y);
-}
-
-template <int N>
-_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
-const inline half distance(__detail::HLSL_FIXED_VECTOR<half, N> X,
- __detail::HLSL_FIXED_VECTOR<half, N> Y) {
- return __detail::distance_vec_impl(X, Y);
-}
-
-template <int N>
-const inline float distance(__detail::HLSL_FIXED_VECTOR<float, N> X,
- __detail::HLSL_FIXED_VECTOR<float, N> Y) {
- return __detail::distance_vec_impl(X, Y);
-}
-
-//===----------------------------------------------------------------------===//
-// dst builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn vector<T, 4> dst(vector<T, 4>, vector<T, 4>)
-/// \brief Calculates a distance vector.
-/// \param Src0 [in] Contains the squared distance
-/// \param Src1 [in] Contains the reciprocal distance
-///
-/// Return the computed distance vector
-
-_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
-const inline half4 dst(half4 Src0, half4 Src1) {
- return __detail::dst_impl(Src0, Src1);
-}
-
-const inline float4 dst(float4 Src0, float4 Src1) {
- return __detail::dst_impl(Src0, Src1);
-}
-
-const inline double4 dst(double4 Src0, double4 Src1) {
- return __detail::dst_impl(Src0, Src1);
-}
-
-//===----------------------------------------------------------------------===//
-// faceforward builtin
-//===----------------------------------------------------------------------===//
-
-/// \fn T faceforward(T N, T I, T Ng)
-/// \brief Flips the surface-normal (if needed) to face in a direction opposite
-/// to \a I. Returns the result in terms of \a N.
-/// \param N The resulting floating-point surface-normal vector.
-/// \param I A floating-point, incident vector that points from the view
-/// position to the shading position.
-/// \param Ng A floating-point surface-normal vector.
-///
-/// Return a floating-point, surface normal vector that is facing the view
-/// direction.
-
-template <typename T>
-_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
-const inline __detail::enable_if_t<__detail::is_arithmetic<T>::Value &&
- __detail::is_same<half, T>::value,
- T> faceforward(T N, T I, T Ng) {
- return __detail::faceforward_impl(N, I, Ng);
-}
-
-template <typename T>
-const inline __detail::enable_if_t<
- __detail::is_arithmetic<T>::Value && __detail::is_same<float, T>::value, T>
-faceforward(T N, T I, T Ng) {
- return __detail::faceforward_impl(N, I, Ng);
-}
-
-template <int L>
-_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
-const inline __detail::HLSL_FIXED_VECTOR<half, L> faceforward(
- __detail::HLSL_FIXED_VECTOR<half, L> N,
- __detail::HLSL_FIXED_VECTOR<half, L> I,
- __detail::HLSL_FIXED_VECTOR<half, L> Ng) {
- return __detail::faceforward_impl(N, I, Ng);
-}
-
-template <int L>
-const inline __detail::HLSL_FIXED_VECTOR<float, L>
-faceforward(__detail::HLSL_FIXED_VECTOR<float, L> N,
- __detail::HLSL_FIXED_VECTOR<float, L> I,
- __detail::HLSL_FIXED_VECTOR<float, L> Ng) {
- return __detail::faceforward_impl(N, I, Ng);
-}
-
//===----------------------------------------------------------------------===//
// firstbithigh builtins
//===----------------------------------------------------------------------===//
@@ -310,415 +202,6 @@ firstbithigh(vector<T, N> X) {
return __detail::firstbithigh_impl<vector<uint, N>, vector<T, N>, 64>(X);
}
-//===----------------------------------------------------------------------===//
-// fmod builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn T fmod(T x, T y)
-/// \brief Returns the linear interpolation of x to y.
-/// \param x [in] The dividend.
-/// \param y [in] The divisor.
-///
-/// Return the floating-point remainder of the x parameter divided by the y
-/// parameter.
-
-template <typename T>
-_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
-const inline __detail::enable_if_t<__detail::is_arithmetic<T>::Value &&
- __detail::is_same<half, T>::value,
- T> fmod(T X, T Y) {
- return __detail::fmod_impl(X, Y);
-}
-
-template <typename T>
-const inline __detail::enable_if_t<
- __detail::is_arithmetic<T>::Value && __detail::is_same<float, T>::value, T>
-fmod(T X, T Y) {
- return __detail::fmod_impl(X, Y);
-}
-
-template <int N>
-_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
-const inline __detail::HLSL_FIXED_VECTOR<half, N> fmod(
- __detail::HLSL_FIXED_VECTOR<half, N> X,
- __detail::HLSL_FIXED_VECTOR<half, N> Y) {
- return __detail::fmod_vec_impl(X, Y);
-}
-
-template <int N>
-const inline __detail::HLSL_FIXED_VECTOR<float, N>
-fmod(__detail::HLSL_FIXED_VECTOR<float, N> X,
- __detail::HLSL_FIXED_VECTOR<float, N> Y) {
- return __detail::fmod_vec_impl(X, Y);
-}
-
-//===----------------------------------------------------------------------===//
-// ldexp builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn T ldexp(T X, T Exp)
-/// \brief Returns the result of multiplying the specified value by two raised
-/// to the power of the specified exponent.
-/// \param X [in] The specified value.
-/// \param Exp [in] The specified exponent.
-///
-/// This function uses the following formula: X * 2^Exp
-
-template <typename T>
-_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
-const inline __detail::enable_if_t<__detail::is_arithmetic<T>::Value &&
- __detail::is_same<half, T>::value,
- T> ldexp(T X, T Exp) {
- return __detail::ldexp_impl(X, Exp);
-}
-
-template <typename T>
-const inline __detail::enable_if_t<
- __detail::is_arithmetic<T>::Value && __detail::is_same<float, T>::value, T>
-ldexp(T X, T Exp) {
- return __detail::ldexp_impl(X, Exp);
-}
-
-template <int N>
-_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
-const inline __detail::HLSL_FIXED_VECTOR<half, N> ldexp(
- __detail::HLSL_FIXED_VECTOR<half, N> X,
- __detail::HLSL_FIXED_VECTOR<half, N> Exp) {
- return __detail::ldexp_impl(X, Exp);
-}
-
-template <int N>
-const inline __detail::HLSL_FIXED_VECTOR<float, N>
-ldexp(__detail::HLSL_FIXED_VECTOR<float, N> X,
- __detail::HLSL_FIXED_VECTOR<float, N> Exp) {
- return __detail::ldexp_impl(X, Exp);
-}
-
-//===----------------------------------------------------------------------===//
-// length builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn T length(T x)
-/// \brief Returns the length of the specified floating-point vector.
-/// \param x [in] The vector of floats, or a scalar float.
-///
-/// Length is based on the following formula: sqrt(x[0]^2 + x[1]^2 + ...).
-
-template <typename T>
-_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
-const inline __detail::enable_if_t<__detail::is_arithmetic<T>::Value &&
- __detail::is_same<half, T>::value,
- T> length(T X) {
- return __detail::length_impl(X);
-}
-
-template <typename T>
-const inline __detail::enable_if_t<
- __detail::is_arithmetic<T>::Value && __detail::is_same<float, T>::value, T>
-length(T X) {
- return __detail::length_impl(X);
-}
-
-template <int N>
-_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
-const inline half length(__detail::HLSL_FIXED_VECTOR<half, N> X) {
- return __detail::length_vec_impl(X);
-}
-
-template <int N>
-const inline float length(__detail::HLSL_FIXED_VECTOR<float, N> X) {
- return __detail::length_vec_impl(X);
-}
-
-//===----------------------------------------------------------------------===//
-// lit builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn vector<T, 4> lit(T NDotL, T NDotH, T M)
-/// \brief Returns a lighting coefficient vector.
-/// \param NDotL The dot product of the normalized surface normal and the
-/// light vector.
-/// \param NDotH The dot product of the half-angle vector and the surface
-/// normal.
-/// \param M A specular exponent.
-///
-/// This function returns a lighting coefficient vector (ambient, diffuse,
-/// specular, 1).
-
-_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
-const inline half4 lit(half NDotL, half NDotH, half M) {
- return __detail::lit_impl(NDotL, NDotH, M);
-}
-
-const inline float4 lit(float NDotL, float NDotH, float M) {
- return __detail::lit_impl(NDotL, NDotH, M);
-}
-
-//===----------------------------------------------------------------------===//
-// D3DCOLORtoUBYTE4 builtin
-//===----------------------------------------------------------------------===//
-
-/// \fn T D3DCOLORtoUBYTE4(T x)
-/// \brief Converts a floating-point, 4D vector set by a D3DCOLOR to a UBYTE4.
-/// \param x [in] The floating-point vector4 to convert.
-///
-/// The return value is the UBYTE4 representation of the \a x parameter.
-///
-/// This function swizzles and scales components of the \a x parameter. Use this
-/// function to compensate for the lack of UBYTE4 support in some hardware.
-
-constexpr int4 D3DCOLORtoUBYTE4(float4 V) {
- return __detail::d3d_color_to_ubyte4_impl(V);
-}
-
-//===----------------------------------------------------------------------===//
-// NonUniformResourceIndex builtin
-//===----------------------------------------------------------------------===//
-
-/// \fn uint NonUniformResourceIndex(uint I)
-/// \brief A compiler hint to indicate that a resource index varies across
-/// threads within a wave (i.e., it is non-uniform).
-/// \param I [in] Resource array index
-///
-/// The return value is the \Index parameter.
-///
-/// When indexing into an array of shader resources (e.g., textures, buffers),
-/// some GPU hardware and drivers require the compiler to know whether the index
-/// is uniform (same for all threads) or non-uniform (varies per thread).
-///
-/// Using NonUniformResourceIndex explicitly marks an index as non-uniform,
-/// disabling certain assumptions or optimizations that could lead to incorrect
-/// behavior when dynamically accessing resource arrays with non-uniform
-/// indices.
-
-constexpr uint32_t NonUniformResourceIndex(uint32_t Index) {
- return __builtin_hlsl_resource_nonuniformindex(Index);
-}
-
-//===----------------------------------------------------------------------===//
-// reflect builtin
-//===----------------------------------------------------------------------===//
-
-/// \fn T reflect(T I, T N)
-/// \brief Returns a reflection using an incident ray, \a I, and a surface
-/// normal, \a N.
-/// \param I The incident ray.
-/// \param N The surface normal.
-///
-/// The return value is a floating-point vector that represents the reflection
-/// of the incident ray, \a I, off a surface with the normal \a N.
-///
-/// This function calculates the reflection vector using the following formula:
-/// V = I - 2 * N * dot(I N) .
-///
-/// N must already be normalized in order to achieve the desired result.
-///
-/// The operands must all be a scalar or vector whose component type is
-/// floating-point.
-///
-/// Result type and the type of all operands must be the same type.
-
-template <typename T>
-_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
-const inline __detail::enable_if_t<__detail::is_arithmetic<T>::Value &&
- __detail::is_same<half, T>::value,
- T> reflect(T I, T N) {
- return __detail::reflect_impl(I, N);
-}
-
-template <typename T>
-const inline __detail::enable_if_t<
- __detail::is_arithmetic<T>::Value && __detail::is_same<float, T>::value, T>
-reflect(T I, T N) {
- return __detail::reflect_impl(I, N);
-}
-
-template <int L>
-_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
-const inline __detail::HLSL_FIXED_VECTOR<half, L> reflect(
- __detail::HLSL_FIXED_VECTOR<half, L> I,
- __detail::HLSL_FIXED_VECTOR<half, L> N) {
- return __detail::reflect_vec_impl(I, N);
-}
-
-template <int L>
-const inline __detail::HLSL_FIXED_VECTOR<float, L>
-reflect(__detail::HLSL_FIXED_VECTOR<float, L> I,
- __detail::HLSL_FIXED_VECTOR<float, L> N) {
- return __detail::reflect_vec_impl(I, N);
-}
-
-//===----------------------------------------------------------------------===//
-// smoothstep builtin
-//===----------------------------------------------------------------------===//
-
-/// \fn T smoothstep(T Min, T Max, T X)
-/// \brief Returns a smooth Hermite interpolation between 0 and 1, if \a X is in
-/// the range [\a Min, \a Max].
-/// \param Min The minimum range of the x parameter.
-/// \param Max The maximum range of the x parameter.
-/// \param X The specified value to be interpolated.
-///
-/// The return value is 0.0 if \a X ≤ \a Min and 1.0 if \a X ≥ \a Max. When \a
-/// Min < \a X < \a Max, the function performs smooth Hermite interpolation
-/// between 0 and 1.
-
-template <typename T>
-_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
-const inline __detail::enable_if_t<__detail::is_arithmetic<T>::Value &&
- __detail::is_same<half, T>::value,
- T> smoothstep(T Min, T Max, T X) {
- return __detail::smoothstep_impl(Min, Max, X);
-}
-
-template <typename T>
-const inline __detail::enable_if_t<
- __detail::is_arithmetic<T>::Value && __detail::is_same<float, T>::value, T>
-smoothstep(T Min, T Max, T X) {
- return __detail::smoothstep_impl(Min, Max, X);
-}
-
-template <int N>
-_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
-const inline __detail::HLSL_FIXED_VECTOR<half, N> smoothstep(
- __detail::HLSL_FIXED_VECTOR<half, N> Min,
- __detail::HLSL_FIXED_VECTOR<half, N> Max,
- __detail::HLSL_FIXED_VECTOR<half, N> X) {
- return __detail::smoothstep_vec_impl(Min, Max, X);
-}
-
-template <int N>
-const inline __detail::HLSL_FIXED_VECTOR<float, N>
-smoothstep(__detail::HLSL_FIXED_VECTOR<float, N> Min,
- __detail::HLSL_FIXED_VECTOR<float, N> Max,
- __detail::HLSL_FIXED_VECTOR<float, N> X) {
- return __detail::smoothstep_vec_impl(Min, Max, X);
-}
-
-inline bool CheckAccessFullyMapped(uint Status) {
- return static_cast<bool>(Status);
-}
-
-//===----------------------------------------------------------------------===//
-// ddx builtin
-//===----------------------------------------------------------------------===//
-
-/// \fn T ddx(T x)
-/// \brief Computes the sum of the absolute values of the partial derivatives
-/// with regard to the x screen space coordinate.
-/// \param x [in] The floating-point scalar or vector to process.
-///
-/// The return value is a floating-point scalar or vector where each element
-/// holds the computation of the matching element in the input.
-
-template <typename T>
-_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
-const inline __detail::enable_if_t<__detail::is_arithmetic<T>::Value &&
- __detail::is_same<half, T>::value,
- T> ddx(T input) {
- return __detail::ddx_impl(input);
-}
-
-template <typename T>
-const inline __detail::enable_if_t<
- __detail::is_arithmetic<T>::Value && __detail::is_same<float, T>::value, T>
-ddx(T input) {
- return __detail::ddx_impl(input);
-}
-
-template <int N>
-_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
-const inline __detail::HLSL_FIXED_VECTOR<half, N> ddx(
- __detail::HLSL_FIXED_VECTOR<half, N> input) {
- return __detail::ddx_impl(input);
-}
-
-template <int N>
-const inline __detail::HLSL_FIXED_VECTOR<float, N>
-ddx(__detail::HLSL_FIXED_VECTOR<float, N> input) {
- return __detail::ddx_impl(input);
-}
-
-//===----------------------------------------------------------------------===//
-// ddy builtin
-//===----------------------------------------------------------------------===//
-
-/// \fn T ddy(T x)
-/// \brief Computes the sum of the absolute values of the partial derivatives
-/// with regard to the y screen space coordinate.
-/// \param x [in] The floating-point scalar or vector to process.
-///
-/// The return value is a floating-point scalar or vector where each element
-/// holds the computation of the matching element in the input.
-
-template <typename T>
-_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
-const inline __detail::enable_if_t<__detail::is_arithmetic<T>::Value &&
- __detail::is_same<half, T>::value,
- T> ddy(T input) {
- return __detail::ddy_impl(input);
-}
-
-template <typename T>
-const inline __detail::enable_if_t<
- __detail::is_arithmetic<T>::Value && __detail::is_same<float, T>::value, T>
-ddy(T input) {
- return __detail::ddy_impl(input);
-}
-
-template <int N>
-_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
-const inline __detail::HLSL_FIXED_VECTOR<half, N> ddy(
- __detail::HLSL_FIXED_VECTOR<half, N> input) {
- return __detail::ddy_impl(input);
-}
-
-template <int N>
-const inline __detail::HLSL_FIXED_VECTOR<float, N>
-ddy(__detail::HLSL_FIXED_VECTOR<float, N> input) {
- return __detail::ddy_impl(input);
-}
-
-//===----------------------------------------------------------------------===//
-// fwidth builtin
-//===----------------------------------------------------------------------===//
-
-/// \fn T fwidth(T x)
-/// \brief Computes the sum of the absolute values of the partial derivatives
-/// with regard to the x and y screen space coordinates.
-/// \param x [in] The floating-point scalar or vector to process.
-///
-/// The return value is a floating-point scalar or vector where each element
-/// holds the computation of the matching element in the input.
-
-template <typename T>
-_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
-const inline __detail::enable_if_t<__detail::is_arithmetic<T>::Value &&
- __detail::is_same<half, T>::value,
- T> fwidth(T input) {
- return __detail::fwidth_impl(input);
-}
-
-template <typename T>
-const inline __detail::enable_if_t<
- __detail::is_arithmetic<T>::Value && __detail::is_same<float, T>::value, T>
-fwidth(T input) {
- return __detail::fwidth_impl(input);
-}
-
-template <int N>
-_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
-const inline __detail::HLSL_FIXED_VECTOR<half, N> fwidth(
- __detail::HLSL_FIXED_VECTOR<half, N> input) {
- return __detail::fwidth_impl(input);
-}
-
-template <int N>
-const inline __detail::HLSL_FIXED_VECTOR<float, N>
-fwidth(__detail::HLSL_FIXED_VECTOR<float, N> input) {
- return __detail::fwidth_impl(input);
-}
-
//===----------------------------------------------------------------------===//
// mul builtins
//===----------------------------------------------------------------------===//
diff --git a/clang/test/CodeGenHLSL/builtins/distance.hlsl b/clang/test/CodeGenHLSL/builtins/distance.hlsl
index efe546bfdc5cf..5036ff8281238 100644
--- a/clang/test/CodeGenHLSL/builtins/distance.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/distance.hlsl
@@ -10,14 +10,14 @@
// CHECK-SAME: half noundef nofpclass(nan inf) [[X:%.*]], half noundef nofpclass(nan inf) [[Y:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
// CHECK-NEXT: [[ENTRY:.*:]]
// CHECK-NEXT: [[SUB_I:%.*]] = fsub reassoc nnan ninf nsz arcp afn half [[X]], [[Y]]
-// CHECK-NEXT: [[ELT_ABS_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn noundef nofpclass(nan inf) half @llvm.fabs.f16(half nofpclass(nan inf) [[SUB_I]])
+// CHECK-NEXT: [[ELT_ABS_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn noundef nofpclass(nan inf) half @llvm.fabs.f16(half [[SUB_I]])
// CHECK-NEXT: ret half [[ELT_ABS_I]]
//
// SPVCHECK-LABEL: define hidden spir_func noundef nofpclass(nan inf) half @_Z18test_distance_halfDhDh(
// SPVCHECK-SAME: half noundef nofpclass(nan inf) [[X:%.*]], half noundef nofpclass(nan inf) [[Y:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
// SPVCHECK-NEXT: [[ENTRY:.*:]]
// SPVCHECK-NEXT: [[SUB_I:%.*]] = fsub reassoc nnan ninf nsz arcp afn half [[X]], [[Y]]
-// SPVCHECK-NEXT: [[ELT_ABS_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn noundef nofpclass(nan inf) half @llvm.fabs.f16(half nofpclass(nan inf) [[SUB_I]])
+// SPVCHECK-NEXT: [[ELT_ABS_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn noundef nofpclass(nan inf) half @llvm.fabs.f16(half [[SUB_I]])
// SPVCHECK-NEXT: ret half [[ELT_ABS_I]]
//
half test_distance_half(half X, half Y) { return distance(X, Y); }
@@ -77,14 +77,14 @@ half test_distance_half4(half4 X, half4 Y) { return distance(X, Y); }
// CHECK-SAME: float noundef nofpclass(nan inf) [[X:%.*]], float noundef nofpclass(nan inf) [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] {
// CHECK-NEXT: [[ENTRY:.*:]]
// CHECK-NEXT: [[SUB_I:%.*]] = fsub reassoc nnan ninf nsz arcp afn float [[X]], [[Y]]
-// CHECK-NEXT: [[ELT_ABS_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn noundef nofpclass(nan inf) float @llvm.fabs.f32(float nofpclass(nan inf) [[SUB_I]])
+// CHECK-NEXT: [[ELT_ABS_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn noundef nofpclass(nan inf) float @llvm.fabs.f32(float [[SUB_I]])
// CHECK-NEXT: ret float [[ELT_ABS_I]]
//
// SPVCHECK-LABEL: define hidden spir_func noundef nofpclass(nan inf) float @_Z19test_distance_floatff(
// SPVCHECK-SAME: float noundef nofpclass(nan inf) [[X:%.*]], float noundef nofpclass(nan inf) [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] {
// SPVCHECK-NEXT: [[ENTRY:.*:]]
// SPVCHECK-NEXT: [[SUB_I:%.*]] = fsub reassoc nnan ninf nsz arcp afn float [[X]], [[Y]]
-// SPVCHECK-NEXT: [[ELT_ABS_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn noundef nofpclass(nan inf) float @llvm.fabs.f32(float nofpclass(nan inf) [[SUB_I]])
+// SPVCHECK-NEXT: [[ELT_ABS_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn noundef nofpclass(nan inf) float @llvm.fabs.f32(float [[SUB_I]])
// SPVCHECK-NEXT: ret float [[ELT_ABS_I]]
//
float test_distance_float(float X, float Y) { return distance(X, Y); }
diff --git a/clang/test/CodeGenHLSL/builtins/dst.hlsl b/clang/test/CodeGenHLSL/builtins/dst.hlsl
index d8292d31fba7c..681eb65fb7a48 100644
--- a/clang/test/CodeGenHLSL/builtins/dst.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/dst.hlsl
@@ -1,8 +1,8 @@
// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple dxil-pc-shadermodel6.2-library %s -fnative-half-type -fnative-int16-type -emit-llvm -disable-llvm-passes -o - | FileCheck %s
-// CHECK-LABEL: define {{.*}} <4 x float> @{{[A-Za-z1-9_]+}}dst_impl{{[A-Za-z1-9_]*}}(
-// CHECK-SAME: <4 x float> {{[A-Za-z )(]*}} [[P:%.*]], <4 x float> {{[A-Za-z )(]*}} [[Q:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-LABEL: define {{.*}} <4 x float> @{{[A-Za-z1-9_]+}}dstWithFloat{{[A-Za-z1-9_]*}}(
+// CHECK-SAME: <4 x float> {{[A-Za-z )(]*}} [[P:%.*]], <4 x float> {{[A-Za-z )(]*}} [[Q:%.*]]) #[[ATTR0:[0-9]+]] {
// CHECK: [[VECEXT:%.*]] = extractelement <4 x float> [[PADDR:%.*]], i32 1
// CHECK: [[VECEXT1:%.*]] = extractelement <4 x float> [[QADDR:%.*]], i32 1
// CHECK: [[MULRES:%.*]] = fmul {{[A-Za-z ]*}} float [[VECEXT]], [[VECEXT1]]
@@ -17,7 +17,7 @@ float4 dstWithFloat(float4 p1, float4 p2)
return dst(p1, p2);
}
-// CHECK-LABEL: define {{.*}} <4 x half> @{{[A-Za-z1-9_]+}}dst_impl{{[A-Za-z1-9_]*}}(
+// CHECK-LABEL: define {{.*}} <4 x half> @{{[A-Za-z1-9_]+}}dstwithHalf{{[A-Za-z1-9_]*}}(
// CHECK-SAME: <4 x half> {{[A-Za-z )(]*}} [[P:%.*]], <4 x half> {{[A-Za-z )(]*}} [[Q:%.*]]) #[[ATTR0]] {
// CHECK: [[VECEXT:%.*]] = extractelement <4 x half> [[PADDR:%.*]], i32 1
// CHECK: [[VECEXT1:%.*]] = extractelement <4 x half> [[QADDR:%.*]], i32 1
@@ -33,8 +33,8 @@ half4 dstwithHalf(half4 p1, half4 p2)
return dst(p1, p2);
}
-// CHECK-LABEL: define {{.*}} <4 x double> @{{[A-Za-z1-9_]+}}dst_impl{{[A-Za-z1-9_]*}}(
-// CHECK-SAME: <4 x double> {{[A-Za-z )(]*}} [[P:%.*]], <4 x double> {{[A-Za-z )(]*}} [[Q:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-LABEL: define {{.*}} <4 x double> @{{[A-Za-z1-9_]+}}dstWithDouble{{[A-Za-z1-9_]*}}(
+// CHECK-SAME: <4 x double> {{[A-Za-z )(]*}} [[P:%.*]], <4 x double> {{[A-Za-z )(]*}} [[Q:%.*]]) #[[ATTR0]] {
// CHECK: [[VECEXT:%.*]] = extractelement <4 x double> [[PADDR:%.*]], i32 1
// CHECK: [[VECEXT1:%.*]] = extractelement <4 x double> [[QADDR:%.*]], i32 1
// CHECK: [[MULRES:%.*]] = fmul {{[A-Za-z ]*}} double [[VECEXT]], [[VECEXT1]]
@@ -48,4 +48,3 @@ double4 dstWithDouble(double4 p1, double4 p2)
{
return dst(p1, p2);
}
-
diff --git a/clang/test/CodeGenHLSL/builtins/ldexp.hlsl b/clang/test/CodeGenHLSL/builtins/ldexp.hlsl
index 2dec126788956..2c0458d079027 100644
--- a/clang/test/CodeGenHLSL/builtins/ldexp.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/ldexp.hlsl
@@ -1,49 +1,49 @@
// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple dxil-pc-shadermodel6.3-library %s -fnative-half-type -fnative-int16-type -emit-llvm -disable-llvm-passes -o - | FileCheck %s
-// CHECK-LABEL: define linkonce_odr hidden noundef nofpclass(nan inf) half @_ZN4hlsl8__detail10ldexp_implIDhEET_S2_S2_
+// CHECK-LABEL: define linkonce_odr hidden noundef nofpclass(nan inf) half @_ZN4hlsl5ldexpEDhDh
// CHECK: [[EXP2:%.*]] = call reassoc nnan ninf nsz arcp afn half @llvm.exp2.f16(half %{{.*}})
-// CHECK: %mul = fmul reassoc nnan ninf nsz arcp afn half [[EXP2]], %{{.*}}
-// CHECK: ret half %mul
+// CHECK: [[MUL:%.*]] = fmul reassoc nnan ninf nsz arcp afn half [[EXP2]], %{{.*}}
+// CHECK: ret half [[MUL]]
half test_ldexp_half(half X, half Exp) { return ldexp(X, Exp); }
-// CHECK-LABEL: define linkonce_odr hidden noundef nofpclass(nan inf) <2 x half> @_ZN4hlsl8__detail10ldexp_implIDv2_DhEET_S3_S3_
+// CHECK-LABEL: define linkonce_odr hidden noundef nofpclass(nan inf) <2 x half> @_ZN4hlsl5ldexpEDv2_DhS0_
// CHECK: [[EXP2:%.*]] = call reassoc nnan ninf nsz arcp afn <2 x half> @llvm.exp2.v2f16(<2 x half> %{{.*}})
-// CHECK: %mul = fmul reassoc nnan ninf nsz arcp afn <2 x half> [[EXP2]], %{{.*}}
-// CHECK: ret <2 x half> %mul
+// CHECK: [[MUL:%.*]] = fmul reassoc nnan ninf nsz arcp afn <2 x half> [[EXP2]], %{{.*}}
+// CHECK: ret <2 x half> [[MUL]]
half2 test_ldexp_half2(half2 X, half2 Exp) { return ldexp(X, Exp); }
-// CHECK-LABEL: define linkonce_odr hidden noundef nofpclass(nan inf) <3 x half> @_ZN4hlsl8__detail10ldexp_implIDv3_DhEET_S3_S3_
+// CHECK-LABEL: define linkonce_odr hidden noundef nofpclass(nan inf) <3 x half> @_ZN4hlsl5ldexpEDv3_DhS0_
// CHECK: [[EXP2:%.*]] = call reassoc nnan ninf nsz arcp afn <3 x half> @llvm.exp2.v3f16(<3 x half> %{{.*}})
-// CHECK: %mul = fmul reassoc nnan ninf nsz arcp afn <3 x half> [[EXP2]], %{{.*}}
-// CHECK: ret <3 x half> %mul
+// CHECK: [[MUL:%.*]] = fmul reassoc nnan ninf nsz arcp afn <3 x half> [[EXP2]], %{{.*}}
+// CHECK: ret <3 x half> [[MUL]]
half3 test_ldexp_half3(half3 X, half3 Exp) { return ldexp(X, Exp); }
-// CHECK-LABEL: define linkonce_odr hidden noundef nofpclass(nan inf) <4 x half> @_ZN4hlsl8__detail10ldexp_implIDv4_DhEET_S3_S3_
+// CHECK-LABEL: define linkonce_odr hidden noundef nofpclass(nan inf) <4 x half> @_ZN4hlsl5ldexpEDv4_DhS0_
// CHECK: [[EXP2:%.*]] = call reassoc nnan ninf nsz arcp afn <4 x half> @llvm.exp2.v4f16(<4 x half> %{{.*}})
-// CHECK: %mul = fmul reassoc nnan ninf nsz arcp afn <4 x half> [[EXP2]], %{{.*}}
-// CHECK: ret <4 x half> %mul
+// CHECK: [[MUL:%.*]] = fmul reassoc nnan ninf nsz arcp afn <4 x half> [[EXP2]], %{{.*}}
+// CHECK: ret <4 x half> [[MUL]]
half4 test_ldexp_half4(half4 X, half4 Exp) { return ldexp(X, Exp); }
-// CHECK-LABEL: define linkonce_odr hidden noundef nofpclass(nan inf) float @_ZN4hlsl8__detail10ldexp_implIfEET_S2_S2_
+// CHECK-LABEL: define linkonce_odr hidden noundef nofpclass(nan inf) float @_ZN4hlsl5ldexpEff
// CHECK: [[EXP2:%.*]] = call reassoc nnan ninf nsz arcp afn float @llvm.exp2.f32(float %{{.*}})
-// CHECK: %mul = fmul reassoc nnan ninf nsz arcp afn float [[EXP2]], %{{.*}}
-// CHECK: ret float %mul
+// CHECK: [[MUL:%.*]] = fmul reassoc nnan ninf nsz arcp afn float [[EXP2]], %{{.*}}
+// CHECK: ret float [[MUL]]
float test_ldexp_float(float X, float Exp) { return ldexp(X, Exp); }
-// CHECK-LABEL: define linkonce_odr hidden noundef nofpclass(nan inf) <2 x float> @_ZN4hlsl8__detail10ldexp_implIDv2_fEET_S3_S3_
+// CHECK-LABEL: define linkonce_odr hidden noundef nofpclass(nan inf) <2 x float> @_ZN4hlsl5ldexpEDv2_fS0_
// CHECK: [[EXP2:%.*]] = call reassoc nnan ninf nsz arcp afn <2 x float> @llvm.exp2.v2f32(<2 x float> %{{.*}})
-// CHECK: %mul = fmul reassoc nnan ninf nsz arcp afn <2 x float> [[EXP2]], %{{.*}}
-// CHECK: ret <2 x float> %mul
+// CHECK: [[MUL:%.*]] = fmul reassoc nnan ninf nsz arcp afn <2 x float> [[EXP2]], %{{.*}}
+// CHECK: ret <2 x float> [[MUL]]
float2 test_ldexp_float2(float2 X, float2 Exp) { return ldexp(X, Exp); }
-// CHECK-LABEL: define linkonce_odr hidden noundef nofpclass(nan inf) <3 x float> @_ZN4hlsl8__detail10ldexp_implIDv3_fEET_S3_S3_
+// CHECK-LABEL: define linkonce_odr hidden noundef nofpclass(nan inf) <3 x float> @_ZN4hlsl5ldexpEDv3_fS0_
// CHECK: [[EXP2:%.*]] = call reassoc nnan ninf nsz arcp afn <3 x float> @llvm.exp2.v3f32(<3 x float> %{{.*}})
-// CHECK: %mul = fmul reassoc nnan ninf nsz arcp afn <3 x float> [[EXP2]], %{{.*}}
-// CHECK: ret <3 x float> %mul
+// CHECK: [[MUL:%.*]] = fmul reassoc nnan ninf nsz arcp afn <3 x float> [[EXP2]], %{{.*}}
+// CHECK: ret <3 x float> [[MUL]]
float3 test_ldexp_float3(float3 X, float3 Exp) { return ldexp(X, Exp); }
-// CHECK-LABEL: define linkonce_odr hidden noundef nofpclass(nan inf) <4 x float> @_ZN4hlsl8__detail10ldexp_implIDv4_fEET_S3_S3_
+// CHECK-LABEL: define linkonce_odr hidden noundef nofpclass(nan inf) <4 x float> @_ZN4hlsl5ldexpEDv4_fS0_
// CHECK: [[EXP2:%.*]] = call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.exp2.v4f32(<4 x float> %{{.*}})
-// CHECK: %mul = fmul reassoc nnan ninf nsz arcp afn <4 x float> [[EXP2]], %{{.*}}
-// CHECK: ret <4 x float> %mul
+// CHECK: [[MUL:%.*]] = fmul reassoc nnan ninf nsz arcp afn <4 x float> [[EXP2]], %{{.*}}
+// CHECK: ret <4 x float> [[MUL]]
float4 test_ldexp_float4(float4 X, float4 Exp) { return ldexp(X, Exp); }
diff --git a/clang/test/CodeGenHLSL/resources/NonUniformResourceIndex.hlsl b/clang/test/CodeGenHLSL/resources/NonUniformResourceIndex.hlsl
index ab512ce111d19..cb3c6d46f77c5 100644
--- a/clang/test/CodeGenHLSL/resources/NonUniformResourceIndex.hlsl
+++ b/clang/test/CodeGenHLSL/resources/NonUniformResourceIndex.hlsl
@@ -8,21 +8,24 @@ RWBuffer<float> A[10];
[numthreads(4,1,1)]
void main(uint GI : SV_GroupID) {
// CHECK: %[[GI:.*]] = load i32, ptr %GI.addr
- // CHECK: %[[NURI_1:.*]] = call {{.*}} i32 @hlsl::NonUniformResourceIndex(unsigned int)(i32 noundef %[[GI]])
+ // DXIL: %[[NURI_1:.*]] = call i32 @llvm.dx.resource.nonuniformindex(i32 %[[GI]])
+ // SPV: %[[NURI_1:.*]] = call i32 @llvm.spv.resource.nonuniformindex(i32 %[[GI]])
// CHECK: call void @hlsl::RWBuffer<float>::__createFromImplicitBinding(unsigned int, unsigned int, int, unsigned int, char const*)
// CHECK-SAME: (ptr {{.*}}, i32 noundef 0, i32 noundef 0, i32 noundef 10, i32 noundef %[[NURI_1]], ptr noundef @A.str)
float a = A[NonUniformResourceIndex(GI)][0];
// CHECK: %[[GI:.*]] = load i32, ptr %GI.addr
// CHECK: %[[ADD:.*]] = add i32 %[[GI]], 1
- // CHECK: %[[NURI_2:.*]] = call {{.*}} i32 @hlsl::NonUniformResourceIndex(unsigned int)(i32 noundef %[[ADD]])
+ // DXIL: %[[NURI_2:.*]] = call i32 @llvm.dx.resource.nonuniformindex(i32 %[[ADD]])
+ // SPV: %[[NURI_2:.*]] = call i32 @llvm.spv.resource.nonuniformindex(i32 %[[ADD]])
// CHECK: %[[MOD:.*]] = urem i32 %[[NURI_2]], 10
// CHECK: call void @hlsl::RWBuffer<float>::__createFromImplicitBinding(unsigned int, unsigned int, int, unsigned int, char const*)
// CHECK-SAME: (ptr {{.*}}, i32 noundef 0, i32 noundef 0, i32 noundef 10, i32 noundef %[[MOD]], ptr noundef @A.str)
float b = A[NonUniformResourceIndex(GI + 1) % 10][0];
// CHECK: %[[GI:.*]] = load i32, ptr %GI.addr
- // CHECK: %[[NURI_3:.*]] = call {{.*}} i32 @hlsl::NonUniformResourceIndex(unsigned int)(i32 noundef %[[GI]])
+ // DXIL: %[[NURI_3:.*]] = call i32 @llvm.dx.resource.nonuniformindex(i32 %[[GI]])
+ // SPV: %[[NURI_3:.*]] = call i32 @llvm.spv.resource.nonuniformindex(i32 %[[GI]])
// CHECK: %[[MUL:.*]] = mul i32 3, %[[NURI_3]]
// CHECK: %[[ADD2:.*]] = add i32 10, %[[MUL]]
// CHECK: call void @hlsl::RWBuffer<float>::__createFromImplicitBinding(unsigned int, unsigned int, int, unsigned int, char const*)
@@ -30,9 +33,3 @@ void main(uint GI : SV_GroupID) {
float c = A[10 + 3 * NonUniformResourceIndex(GI)][0];
A[0][0] = a + b + c;
}
-
-// CHECK: define {{.*}} i32 @hlsl::NonUniformResourceIndex(unsigned int)(i32 noundef %Index)
-// CHECK: %[[INDEX1:.*]] = load i32, ptr %Index.addr, align 4
-// DXIL: %[[INDEX2:.*]] = call i32 @llvm.dx.resource.nonuniformindex(i32 %[[INDEX1]])
-// SPV: %[[INDEX2:.*]] = call i32 @llvm.spv.resource.nonuniformindex(i32 %[[INDEX1]])
-// CHECK: ret i32 %[[INDEX2]]
diff --git a/clang/test/SemaHLSL/BuiltIns/D3DCOLORtoUBYTE4-errors.hlsl b/clang/test/SemaHLSL/BuiltIns/D3DCOLORtoUBYTE4-errors.hlsl
index e9bf4c91bd140..a970885b9821d 100644
--- a/clang/test/SemaHLSL/BuiltIns/D3DCOLORtoUBYTE4-errors.hlsl
+++ b/clang/test/SemaHLSL/BuiltIns/D3DCOLORtoUBYTE4-errors.hlsl
@@ -3,19 +3,19 @@
int4 test_too_few_arg() {
return D3DCOLORtoUBYTE4();
// expected-error at -1 {{no matching function for call to 'D3DCOLORtoUBYTE4'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function not viable: requires single argument 'V', but no arguments were provided}}
+ // expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* {{candidate function not viable: requires single argument 'V', but no arguments were provided}}
}
int4 test_too_many_arg(float4 v) {
return D3DCOLORtoUBYTE4(v, v);
// expected-error at -1 {{no matching function for call to 'D3DCOLORtoUBYTE4'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function not viable: requires single argument 'V', but 2 arguments were provided}}
+ // expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* {{candidate function not viable: requires single argument 'V', but 2 arguments were provided}}
}
int4 float2_arg(float2 v) {
return D3DCOLORtoUBYTE4(v);
// expected-error at -1 {{no matching function for call to 'D3DCOLORtoUBYTE4'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function not viable: no known conversion from 'vector<[...], 2>' to 'vector<[...], 4>' for 1st argument}}
+ // expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* {{candidate function not viable: no known conversion from 'vector<[...], 2>' to 'vector<[...], 4>' for 1st argument}}
}
struct S {
@@ -25,5 +25,5 @@ struct S {
int4 struct_arg(S v) {
return D3DCOLORtoUBYTE4(v);
// expected-error at -1 {{no matching function for call to 'D3DCOLORtoUBYTE4'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function not viable: no known conversion from 'S' to 'float4' (aka 'vector<float, 4>') for 1st argument}}
+ // expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* {{candidate function not viable: no known conversion from 'S' to 'float4' (aka 'vector<float, 4>') for 1st argument}}
}
diff --git a/clang/test/SemaHLSL/BuiltIns/cross-errors.hlsl b/clang/test/SemaHLSL/BuiltIns/cross-errors.hlsl
index c9bd1bdd3cb8e..2c3e8d1560c87 100644
--- a/clang/test/SemaHLSL/BuiltIns/cross-errors.hlsl
+++ b/clang/test/SemaHLSL/BuiltIns/cross-errors.hlsl
@@ -4,8 +4,8 @@ void test_too_few_arg()
{
return cross();
// expected-error at -1 {{no matching function for call to 'cross'}}
- // expected-note at hlsl/hlsl_alias_intrinsics_gen.inc:* {{candidate function not viable: requires 2 arguments, but 0 were provided}}
- // expected-note at hlsl/hlsl_alias_intrinsics_gen.inc:* {{candidate function not viable: requires 2 arguments, but 0 were provided}}
+ // expected-note at hlsl/hlsl_alias_intrinsics.h:* {{candidate function not viable: requires 2 arguments, but 0 were provided}}
+ // expected-note at hlsl/hlsl_alias_intrinsics.h:* {{candidate function not viable: requires 2 arguments, but 0 were provided}}
}
void test_too_few_arg_f32()
@@ -24,8 +24,8 @@ void test_too_many_arg(float3 p0)
{
return cross(p0, p0, p0);
// expected-error at -1 {{no matching function for call to 'cross'}}
- // expected-note at hlsl/hlsl_alias_intrinsics_gen.inc:* {{candidate function not viable: requires 2 arguments, but 3 were provided}}
- // expected-note at hlsl/hlsl_alias_intrinsics_gen.inc:* {{candidate function not viable: requires 2 arguments, but 3 were provided}}
+ // expected-note at hlsl/hlsl_alias_intrinsics.h:* {{candidate function not viable: requires 2 arguments, but 3 were provided}}
+ // expected-note at hlsl/hlsl_alias_intrinsics.h:* {{candidate function not viable: requires 2 arguments, but 3 were provided}}
}
void test_too_many_arg_f32(float3 p0)
@@ -56,6 +56,6 @@ void test_ambiguous(int p0)
{
return cross(p0,p0);
// expected-error at -1 {{call to 'cross' is ambiguous}}
- // expected-note at hlsl/hlsl_alias_intrinsics_gen.inc:* {{candidate function}}
- // expected-note at hlsl/hlsl_alias_intrinsics_gen.inc:* {{candidate function}}
+ // expected-note at hlsl/hlsl_alias_intrinsics.h:* {{candidate function}}
+ // expected-note at hlsl/hlsl_alias_intrinsics.h:* {{candidate function}}
}
diff --git a/clang/test/SemaHLSL/BuiltIns/distance-errors.hlsl b/clang/test/SemaHLSL/BuiltIns/distance-errors.hlsl
index 4ec1bcef2b6fc..cbd4456a39905 100644
--- a/clang/test/SemaHLSL/BuiltIns/distance-errors.hlsl
+++ b/clang/test/SemaHLSL/BuiltIns/distance-errors.hlsl
@@ -3,55 +3,36 @@
float test_no_second_arg(float2 p0) {
return distance(p0);
// expected-error at -1 {{no matching function for call to 'distance'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 2 arguments, but 1 was provided}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 2 arguments, but 1 was provided}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 2 arguments, but 1 was provided}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 2 arguments, but 1 was provided}}
+ // expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* 8 {{candidate function not viable: requires 2 arguments, but 1 was provided}}
}
float test_too_many_arg(float2 p0) {
return distance(p0, p0, p0);
// expected-error at -1 {{no matching function for call to 'distance'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 2 arguments, but 3 were provided}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 2 arguments, but 3 were provided}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 2 arguments, but 3 were provided}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 2 arguments, but 3 were provided}}
+ // expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* 8 {{candidate function not viable: requires 2 arguments, but 3 were provided}}
}
float test_double_inputs(double p0, double p1) {
return distance(p0, p1);
- // expected-error at -1 {{no matching function for call to 'distance'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
+ // expected-error at -1 {{call to 'distance' is ambiguous}}
+ // expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* 2 {{candidate function}}
}
float test_int_inputs(int p0, int p1) {
return distance(p0, p1);
- // expected-error at -1 {{no matching function for call to 'distance'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
+ // expected-error at -1 {{call to 'distance' is ambiguous}}
+ // expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* 2 {{candidate function}}
}
float1 test_vec1_inputs(float1 p0, float1 p1) {
return distance(p0, p1);
- // expected-error at -1 {{no matching function for call to 'distance'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = float1]: no type named 'Type' in 'hlsl::__detail::enable_if<false, vector<float, 1>>'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = float1]: no type named 'Type' in 'hlsl::__detail::enable_if<false, vector<float, 1>>'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with N = 1]: no type named 'Type' in 'hlsl::__detail::enable_if<false, half>'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with N = 1]: no type named 'Type' in 'hlsl::__detail::enable_if<false, float>'}}
+ // expected-warning at -1 2 {{implicit conversion turns vector to scalar: 'float1' (aka 'vector<float, 1>') to 'float'}}
}
typedef float float5 __attribute__((ext_vector_type(5)));
float5 test_vec5_inputs(float5 p0, float5 p1) {
return distance(p0, p1);
- // expected-error at -1 {{no matching function for call to 'distance'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = float5]: no type named 'Type' in 'hlsl::__detail::enable_if<false, vector<float, 5>>'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = float5]: no type named 'Type' in 'hlsl::__detail::enable_if<false, vector<float, 5>>'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with N = 5]: no type named 'Type' in 'hlsl::__detail::enable_if<false, half>'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with N = 5]: no type named 'Type' in 'hlsl::__detail::enable_if<false, float>'}}
+ // expected-error at -1 {{call to 'distance' is ambiguous}}
+ // expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* 4 {{candidate function}}
}
diff --git a/clang/test/SemaHLSL/BuiltIns/faceforward-errors.hlsl b/clang/test/SemaHLSL/BuiltIns/faceforward-errors.hlsl
index 01261a00295b1..658d1d3426c10 100644
--- a/clang/test/SemaHLSL/BuiltIns/faceforward-errors.hlsl
+++ b/clang/test/SemaHLSL/BuiltIns/faceforward-errors.hlsl
@@ -2,38 +2,25 @@
float test_double_inputs(double p0, double p1, double p2) {
return faceforward(p0, p1, p2);
- // expected-error at -1 {{no matching function for call to 'faceforward'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
+ // expected-error at -1 {{call to 'faceforward' is ambiguous}}
+ // expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* 2 {{candidate function}}
}
float test_int_inputs(int p0, int p1, int p2) {
return faceforward(p0, p1, p2);
- // expected-error at -1 {{no matching function for call to 'faceforward'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
+ // expected-error at -1 {{call to 'faceforward' is ambiguous}}
+ // expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* 2 {{candidate function}}
}
float1 test_vec1_inputs(float1 p0, float1 p1, float1 p2) {
return faceforward(p0, p1, p2);
- // expected-error at -1 {{no matching function for call to 'faceforward'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = float1]: no type named 'Type' in 'hlsl::__detail::enable_if<false, vector<float, 1>>'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = float1]: no type named 'Type' in 'hlsl::__detail::enable_if<false, vector<float, 1>>'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with L = 1]: no type named 'Type' in 'hlsl::__detail::enable_if<false, half>'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with L = 1]: no type named 'Type' in 'hlsl::__detail::enable_if<false, float>'}}
+ // expected-warning at -1 3 {{implicit conversion turns vector to scalar: 'float1' (aka 'vector<float, 1>') to 'float'}}
}
typedef float float5 __attribute__((ext_vector_type(5)));
float5 test_vec5_inputs(float5 p0, float5 p1, float5 p2) {
return faceforward(p0, p1, p2);
- // expected-error at -1 {{no matching function for call to 'faceforward'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = float5]: no type named 'Type' in 'hlsl::__detail::enable_if<false, vector<float, 5>>'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = float5]: no type named 'Type' in 'hlsl::__detail::enable_if<false, vector<float, 5>>'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with L = 5]: no type named 'Type' in 'hlsl::__detail::enable_if<false, half>'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with L = 5]: no type named 'Type' in 'hlsl::__detail::enable_if<false, float>'}}
+ // expected-error at -1 {{call to 'faceforward' is ambiguous}}
+ // expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* 4 {{candidate function}}
}
diff --git a/clang/test/SemaHLSL/BuiltIns/fmod-errors.hlsl b/clang/test/SemaHLSL/BuiltIns/fmod-errors.hlsl
index eceac9be8d7d1..5985105138e81 100644
--- a/clang/test/SemaHLSL/BuiltIns/fmod-errors.hlsl
+++ b/clang/test/SemaHLSL/BuiltIns/fmod-errors.hlsl
@@ -3,55 +3,36 @@
float test_no_second_arg(float2 p0) {
return fmod(p0);
// expected-error at -1 {{no matching function for call to 'fmod'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 2 arguments, but 1 was provided}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 2 arguments, but 1 was provided}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 2 arguments, but 1 was provided}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 2 arguments, but 1 was provided}}
+ // expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* 8 {{candidate function not viable: requires 2 arguments, but 1 was provided}}
}
float test_too_many_arg(float2 p0) {
return fmod(p0, p0, p0);
// expected-error at -1 {{no matching function for call to 'fmod'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 2 arguments, but 3 were provided}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 2 arguments, but 3 were provided}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 2 arguments, but 3 were provided}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 2 arguments, but 3 were provided}}
+ // expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* 8 {{candidate function not viable: requires 2 arguments, but 3 were provided}}
}
float test_double_inputs(double p0, double p1) {
return fmod(p0, p1);
- // expected-error at -1 {{no matching function for call to 'fmod'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
+ // expected-error at -1 {{call to 'fmod' is ambiguous}}
+ // expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* 2 {{candidate function}}
}
float test_int_inputs(int p0, int p1) {
return fmod(p0, p1);
- // expected-error at -1 {{no matching function for call to 'fmod'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
+ // expected-error at -1 {{call to 'fmod' is ambiguous}}
+ // expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* 2 {{candidate function}}
}
float1 test_vec1_inputs(float1 p0, float1 p1) {
return fmod(p0, p1);
- // expected-error at -1 {{no matching function for call to 'fmod'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = float1]: no type named 'Type' in 'hlsl::__detail::enable_if<false, vector<float, 1>>'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = float1]: no type named 'Type' in 'hlsl::__detail::enable_if<false, vector<float, 1>>'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with N = 1]: no type named 'Type' in 'hlsl::__detail::enable_if<false, half>'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with N = 1]: no type named 'Type' in 'hlsl::__detail::enable_if<false, float>'}}
+ // expected-warning at -1 2 {{implicit conversion turns vector to scalar: 'float1' (aka 'vector<float, 1>') to 'float'}}
}
typedef float float5 __attribute__((ext_vector_type(5)));
float5 test_vec5_inputs(float5 p0, float5 p1) {
return fmod(p0, p1);
- // expected-error at -1 {{no matching function for call to 'fmod'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = float5]: no type named 'Type' in 'hlsl::__detail::enable_if<false, vector<float, 5>>'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = float5]: no type named 'Type' in 'hlsl::__detail::enable_if<false, vector<float, 5>>'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with N = 5]: no type named 'Type' in 'hlsl::__detail::enable_if<false, half>'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with N = 5]: no type named 'Type' in 'hlsl::__detail::enable_if<false, float>'}}
+ // expected-error at -1 {{call to 'fmod' is ambiguous}}
+ // expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* 4 {{candidate function}}
}
diff --git a/clang/test/SemaHLSL/BuiltIns/ldexp-errors.hlsl b/clang/test/SemaHLSL/BuiltIns/ldexp-errors.hlsl
index fa146a5bce525..ce15550d7884b 100644
--- a/clang/test/SemaHLSL/BuiltIns/ldexp-errors.hlsl
+++ b/clang/test/SemaHLSL/BuiltIns/ldexp-errors.hlsl
@@ -2,38 +2,25 @@
float test_double_inputs(double p0, double p1) {
return ldexp(p0, p1);
- // expected-error at -1 {{no matching function for call to 'ldexp'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
+ // expected-error at -1 {{call to 'ldexp' is ambiguous}}
+ // expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* 2 {{candidate function}}
}
float test_int_inputs(int p0, int p1, int p2) {
return ldexp(p0, p1);
- // expected-error at -1 {{no matching function for call to 'ldexp'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
+ // expected-error at -1 {{call to 'ldexp' is ambiguous}}
+ // expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* 2 {{candidate function}}
}
float1 test_vec1_inputs(float1 p0, float1 p1) {
return ldexp(p0, p1);
- // expected-error at -1 {{no matching function for call to 'ldexp'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = float1]: no type named 'Type' in 'hlsl::__detail::enable_if<false, vector<float, 1>>'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = float1]: no type named 'Type' in 'hlsl::__detail::enable_if<false, vector<float, 1>>'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with N = 1]: no type named 'Type' in 'hlsl::__detail::enable_if<false, half>'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with N = 1]: no type named 'Type' in 'hlsl::__detail::enable_if<false, float>'}}
+ // expected-warning at -1 2 {{implicit conversion turns vector to scalar: 'float1' (aka 'vector<float, 1>') to 'float'}}
}
typedef float float5 __attribute__((ext_vector_type(5)));
float5 test_vec5_inputs(float5 p0, float5 p1) {
return ldexp(p0, p1);
- // expected-error at -1 {{no matching function for call to 'ldexp'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = float5]: no type named 'Type' in 'hlsl::__detail::enable_if<false, vector<float, 5>>'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = float5]: no type named 'Type' in 'hlsl::__detail::enable_if<false, vector<float, 5>>'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with N = 5]: no type named 'Type' in 'hlsl::__detail::enable_if<false, half>'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with N = 5]: no type named 'Type' in 'hlsl::__detail::enable_if<false, float>'}}
+ // expected-error at -1 {{call to 'ldexp' is ambiguous}}
+ // expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* 4 {{candidate function}}
}
diff --git a/clang/test/SemaHLSL/BuiltIns/length-errors.hlsl b/clang/test/SemaHLSL/BuiltIns/length-errors.hlsl
index 8c5c9a4a0d22a..e408e64c0dd4c 100644
--- a/clang/test/SemaHLSL/BuiltIns/length-errors.hlsl
+++ b/clang/test/SemaHLSL/BuiltIns/length-errors.hlsl
@@ -4,78 +4,53 @@ void test_too_few_arg()
{
return length();
// expected-error at -1 {{no matching function for call to 'length'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires single argument 'X', but no arguments were provided}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires single argument 'X', but no arguments were provided}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires single argument 'X', but no arguments were provided}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires single argument 'X', but no arguments were provided}}
+ // expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* 8 {{candidate function not viable: requires single argument 'X', but no arguments were provided}}
}
void test_too_many_arg(float2 p0)
{
return length(p0, p0);
// expected-error at -1 {{no matching function for call to 'length'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires single argument 'X', but 2 arguments were provided}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires single argument 'X', but 2 arguments were provided}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires single argument 'X', but 2 arguments were provided}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires single argument 'X', but 2 arguments were provided}}
+ // expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* 8 {{candidate function not viable: requires single argument 'X', but 2 arguments were provided}}
}
float double_to_float_type(double p0) {
return length(p0);
- // expected-error at -1 {{no matching function for call to 'length'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = double]: no type named 'Type' in 'hlsl::__detail::enable_if<false, double>'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = double]: no type named 'Type' in 'hlsl::__detail::enable_if<false, double>'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: could not match '__detail::HLSL_FIXED_VECTOR<half, N>' (aka 'vector<__detail::enable_if_t<(N > 1 && N <= 4), half>, N>') against 'double'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: could not match '__detail::HLSL_FIXED_VECTOR<float, N>' (aka 'vector<__detail::enable_if_t<(N > 1 && N <= 4), float>, N>') against 'double'}}
+ // expected-error at -1 {{call to 'length' is ambiguous}}
+ // expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* 2 {{candidate function}}
}
float bool_to_float_type_promotion(bool p1)
{
return length(p1);
- // expected-error at -1 {{no matching function for call to 'length'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{andidate template ignored: substitution failure [with T = bool]: no type named 'Type' in 'hlsl::__detail::enable_if<false, bool>'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{andidate template ignored: substitution failure [with T = bool]: no type named 'Type' in 'hlsl::__detail::enable_if<false, bool>'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: could not match '__detail::HLSL_FIXED_VECTOR<half, N>' (aka 'vector<__detail::enable_if_t<(N > 1 && N <= 4), half>, N>') against 'bool'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: could not match '__detail::HLSL_FIXED_VECTOR<float, N>' (aka 'vector<__detail::enable_if_t<(N > 1 && N <= 4), float>, N>') against 'bool'}}
+ // expected-error at -1 {{call to 'length' is ambiguous}}
+ // expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* 2 {{candidate function}}
}
float length_int_to_float_promotion(int p1)
{
return length(p1);
- // expected-error at -1 {{no matching function for call to 'length'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = int]: no type named 'Type' in 'hlsl::__detail::enable_if<false, int>'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = int]: no type named 'Type' in 'hlsl::__detail::enable_if<false, int>'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: could not match '__detail::HLSL_FIXED_VECTOR<half, N>' (aka 'vector<__detail::enable_if_t<(N > 1 && N <= 4), half>, N>') against 'int'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: could not match '__detail::HLSL_FIXED_VECTOR<float, N>' (aka 'vector<__detail::enable_if_t<(N > 1 && N <= 4), float>, N>') against 'int'}}
+ // expected-error at -1 {{call to 'length' is ambiguous}}
+ // expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* 2 {{candidate function}}
}
float2 length_int2_to_float2_promotion(int2 p1)
{
return length(p1);
- // expected-error at -1 {{no matching function for call to 'length'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = int2]}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = int2]}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{1st parameter does not match adjusted type 'vector<int, [...]>' of argument [with N = 2]}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{1st parameter does not match adjusted type 'vector<int, [...]>' of argument [with N = 2]}}
+ // expected-error at -1 {{call to 'length' is ambiguous}}
+ // expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* 2 {{candidate function}}
}
float1 test_vec1_inputs(float1 p0) {
return length(p0);
- // expected-error at -1 {{no matching function for call to 'length'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = float1]: no type named 'Type' in 'hlsl::__detail::enable_if<false, vector<float, 1>>'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = float1]: no type named 'Type' in 'hlsl::__detail::enable_if<false, vector<float, 1>>'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with N = 1]: no type named 'Type' in 'hlsl::__detail::enable_if<false, half>'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with N = 1]: no type named 'Type' in 'hlsl::__detail::enable_if<false, float>'}}
+ // expected-warning at -1 {{implicit conversion turns vector to scalar: 'float1' (aka 'vector<float, 1>') to 'float'}}
}
typedef float float5 __attribute__((ext_vector_type(5)));
float5 test_vec5_inputs(float5 p0) {
return length(p0);
- // expected-error at -1 {{no matching function for call to 'length'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = float5]: no type named 'Type' in 'hlsl::__detail::enable_if<false, vector<float, 5>>'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = float5]: no type named 'Type' in 'hlsl::__detail::enable_if<false, vector<float, 5>>'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with N = 5]: no type named 'Type' in 'hlsl::__detail::enable_if<false, half>'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with N = 5]: no type named 'Type' in 'hlsl::__detail::enable_if<false, float>'}}
+ // expected-error at -1 {{call to 'length' is ambiguous}}
+ // expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* 4 {{candidate function}}
}
diff --git a/clang/test/SemaHLSL/BuiltIns/reflect-errors.hlsl b/clang/test/SemaHLSL/BuiltIns/reflect-errors.hlsl
index b0ae770f49f20..a60e4c403811c 100644
--- a/clang/test/SemaHLSL/BuiltIns/reflect-errors.hlsl
+++ b/clang/test/SemaHLSL/BuiltIns/reflect-errors.hlsl
@@ -3,55 +3,36 @@
float test_no_second_arg(float2 p0) {
return reflect(p0);
// expected-error at -1 {{no matching function for call to 'reflect'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 2 arguments, but 1 was provided}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 2 arguments, but 1 was provided}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 2 arguments, but 1 was provided}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 2 arguments, but 1 was provided}}
+ // expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* 8 {{candidate function not viable: requires 2 arguments, but 1 was provided}}
}
float test_too_many_arg(float2 p0) {
return reflect(p0, p0, p0);
// expected-error at -1 {{no matching function for call to 'reflect'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 2 arguments, but 3 were provided}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 2 arguments, but 3 were provided}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 2 arguments, but 3 were provided}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 2 arguments, but 3 were provided}}
+ // expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* 8 {{candidate function not viable: requires 2 arguments, but 3 were provided}}
}
float test_double_inputs(double p0, double p1) {
return reflect(p0, p1);
- // expected-error at -1 {{no matching function for call to 'reflect'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
+ // expected-error at -1 {{call to 'reflect' is ambiguous}}
+ // expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* 2 {{candidate function}}
}
float test_int_inputs(int p0, int p1) {
return reflect(p0, p1);
- // expected-error at -1 {{no matching function for call to 'reflect'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
+ // expected-error at -1 {{call to 'reflect' is ambiguous}}
+ // expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* 2 {{candidate function}}
}
float1 test_vec1_inputs(float1 p0, float1 p1) {
return reflect(p0, p1);
- // expected-error at -1 {{no matching function for call to 'reflect'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = float1]: no type named 'Type' in 'hlsl::__detail::enable_if<false, vector<float, 1>>'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = float1]: no type named 'Type' in 'hlsl::__detail::enable_if<false, vector<float, 1>>'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with L = 1]: no type named 'Type' in 'hlsl::__detail::enable_if<false, half>'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with L = 1]: no type named 'Type' in 'hlsl::__detail::enable_if<false, float>'}}
+ // expected-warning at -1 2 {{implicit conversion turns vector to scalar: 'float1' (aka 'vector<float, 1>') to 'float'}}
}
typedef float float5 __attribute__((ext_vector_type(5)));
float5 test_vec5_inputs(float5 p0, float5 p1) {
return reflect(p0, p1);
- // expected-error at -1 {{no matching function for call to 'reflect'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = float5]: no type named 'Type' in 'hlsl::__detail::enable_if<false, vector<float, 5>>'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = float5]: no type named 'Type' in 'hlsl::__detail::enable_if<false, vector<float, 5>>'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with L = 5]: no type named 'Type' in 'hlsl::__detail::enable_if<false, half>'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with L = 5]: no type named 'Type' in 'hlsl::__detail::enable_if<false, float>'}}
+ // expected-error at -1 {{call to 'reflect' is ambiguous}}
+ // expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* 4 {{candidate function}}
}
diff --git a/clang/test/SemaHLSL/BuiltIns/smoothstep-errors.hlsl b/clang/test/SemaHLSL/BuiltIns/smoothstep-errors.hlsl
index 4c6bea8f02411..2c56bd98035a1 100644
--- a/clang/test/SemaHLSL/BuiltIns/smoothstep-errors.hlsl
+++ b/clang/test/SemaHLSL/BuiltIns/smoothstep-errors.hlsl
@@ -3,64 +3,42 @@
float test_no_second_arg(float2 p0) {
return smoothstep(p0);
// expected-error at -1 {{no matching function for call to 'smoothstep'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 3 arguments, but 1 was provided}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 3 arguments, but 1 was provided}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 3 arguments, but 1 was provided}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 3 arguments, but 1 was provided}}
+ // expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* 8 {{candidate function not viable: requires 3 arguments, but 1 was provided}}
}
float test_no_third_arg(float2 p0) {
return smoothstep(p0, p0);
// expected-error at -1 {{no matching function for call to 'smoothstep'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 3 arguments, but 2 were provided}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 3 arguments, but 2 were provided}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 3 arguments, but 2 were provided}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 3 arguments, but 2 were provided}}
+ // expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* 8 {{candidate function not viable: requires 3 arguments, but 2 were provided}}
}
float test_too_many_arg(float2 p0) {
return smoothstep(p0, p0, p0, p0);
// expected-error at -1 {{no matching function for call to 'smoothstep'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 3 arguments, but 4 were provided}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 3 arguments, but 4 were provided}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 3 arguments, but 4 were provided}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 3 arguments, but 4 were provided}}
+ // expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* 8 {{candidate function not viable: requires 3 arguments, but 4 were provided}}
}
float test_double_inputs(double p0, double p1, double p2) {
return smoothstep(p0, p1, p2);
- // expected-error at -1 {{no matching function for call to 'smoothstep'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
+ // expected-error at -1 {{call to 'smoothstep' is ambiguous}}
+ // expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* 2 {{candidate function}}
}
float test_int_inputs(int p0, int p1, int p2) {
return smoothstep(p0, p1, p2);
- // expected-error at -1 {{no matching function for call to 'smoothstep'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
+ // expected-error at -1 {{call to 'smoothstep' is ambiguous}}
+ // expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* 2 {{candidate function}}
}
float1 test_vec1_inputs(float1 p0, float1 p1, float1 p2) {
return smoothstep(p0, p1, p2);
- // expected-error at -1 {{no matching function for call to 'smoothstep'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = float1]: no type named 'Type' in 'hlsl::__detail::enable_if<false, vector<float, 1>>'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = float1]: no type named 'Type' in 'hlsl::__detail::enable_if<false, vector<float, 1>>'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with N = 1]: no type named 'Type' in 'hlsl::__detail::enable_if<false, half>'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with N = 1]: no type named 'Type' in 'hlsl::__detail::enable_if<false, float>'}}
+ // expected-warning at -1 3 {{implicit conversion turns vector to scalar: 'float1' (aka 'vector<float, 1>') to 'float'}}
}
typedef float float5 __attribute__((ext_vector_type(5)));
float5 test_vec5_inputs(float5 p0, float5 p1, float5 p2) {
return smoothstep(p0, p1, p2);
- // expected-error at -1 {{no matching function for call to 'smoothstep'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = float5]: no type named 'Type' in 'hlsl::__detail::enable_if<false, vector<float, 5>>'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = float5]: no type named 'Type' in 'hlsl::__detail::enable_if<false, vector<float, 5>>'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with N = 5]: no type named 'Type' in 'hlsl::__detail::enable_if<false, half>'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with N = 5]: no type named 'Type' in 'hlsl::__detail::enable_if<false, float>'}}
+ // expected-error at -1 {{call to 'smoothstep' is ambiguous}}
+ // expected-note at hlsl/hlsl_inline_intrinsics_gen.inc:* 4 {{candidate function}}
}
>From 29eed025da1544cb0c869cfd693840038c21e16c Mon Sep 17 00:00:00 2001
From: Deric Cheung <cheung.deric at gmail.com>
Date: Thu, 26 Mar 2026 10:01:44 -0700
Subject: [PATCH 03/12] Remove unused HLSL_FIXED_VECTOR
---
clang/lib/Headers/hlsl/hlsl_detail.h | 4 ----
1 file changed, 4 deletions(-)
diff --git a/clang/lib/Headers/hlsl/hlsl_detail.h b/clang/lib/Headers/hlsl/hlsl_detail.h
index 80c4900121dfb..c691d85283de4 100644
--- a/clang/lib/Headers/hlsl/hlsl_detail.h
+++ b/clang/lib/Headers/hlsl/hlsl_detail.h
@@ -45,10 +45,6 @@ template <typename T> struct is_arithmetic {
static const bool Value = __is_arithmetic(T);
};
-template <typename T, int N>
-using HLSL_FIXED_VECTOR =
- vector<__detail::enable_if_t<(N > 1 && N <= 4), T>, N>;
-
} // namespace __detail
} // namespace hlsl
#endif //_HLSL_HLSL_DETAILS_H_
>From de6937f7340cf6a26acb876136e161050b4d6871 Mon Sep 17 00:00:00 2001
From: Deric Cheung <cheung.deric at gmail.com>
Date: Thu, 26 Mar 2026 10:18:28 -0700
Subject: [PATCH 04/12] Simplify length and distance overload definitions
---
clang/include/clang/Basic/HLSLIntrinsics.td | 35 +++++--------------
.../lib/Headers/hlsl/hlsl_intrinsic_helpers.h | 18 ++++++++--
clang/test/CodeGenHLSL/builtins/distance.hlsl | 8 ++---
3 files changed, 27 insertions(+), 34 deletions(-)
diff --git a/clang/include/clang/Basic/HLSLIntrinsics.td b/clang/include/clang/Basic/HLSLIntrinsics.td
index 57a612caaba74..f8fa710f69ab7 100644
--- a/clang/include/clang/Basic/HLSLIntrinsics.td
+++ b/clang/include/clang/Basic/HLSLIntrinsics.td
@@ -405,8 +405,8 @@ the screen-space y-coordinate.
let VaryingMatDims = [];
}
-// Returns a distance scalar between X and Y (scalar overloads).
-// Scalar distance is equivalent to abs(X - Y).
+// Returns a distance scalar between X and Y.
+// The distance between X and Y is length(X - Y).
def hlsl_distance : HLSLBuiltin<"distance"> {
let Doc = [{
\fn K distance(T X, T Y)
@@ -414,22 +414,12 @@ def hlsl_distance : HLSLBuiltin<"distance"> {
\param X The X input value.
\param Y The Y input value.
}];
- let ParamNames = ["X", "Y"];
- let Body = "return abs(X - Y);";
- let Args = [Varying, Varying];
- let ReturnType = Varying;
- let VaryingTypes = [HalfTy, FloatTy];
- let VaryingScalar = 1;
- let VaryingMatDims = [];
-}
-
-// Returns a distance scalar between X and Y (vector overloads).
-def hlsl_distance_vec : HLSLBuiltin<"distance"> {
- let DetailFunc = "distance_vec_impl";
+ let DetailFunc = "distance_impl";
let ParamNames = ["X", "Y"];
let Args = [Varying, Varying];
let ReturnType = VaryingElemType;
let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingScalar = 1;
let VaryingVecSizes = [2, 3, 4];
let VaryingMatDims = [];
}
@@ -565,8 +555,9 @@ This function uses the following formula: X * 2^Exp
let VaryingMatDims = [];
}
-// Returns the length of the specified floating-point vector (scalar overloads).
+// Returns the length of the specified floating-point vector.
// Scalar length is equivalent to abs(X).
+// Vector length is equivalent to sqrt(dot(X, X)).
def hlsl_length : HLSLBuiltin<"length"> {
let Doc = [{
\fn T length(T x)
@@ -575,22 +566,12 @@ def hlsl_length : HLSLBuiltin<"length"> {
Length is based on the following formula: sqrt(x[0]^2 + x[1]^2 + ...).
}];
- let ParamNames = ["X"];
- let Body = "return abs(X);";
- let Args = [Varying];
- let ReturnType = Varying;
- let VaryingTypes = [HalfTy, FloatTy];
- let VaryingScalar = 1;
- let VaryingMatDims = [];
-}
-
-// Returns the length of the specified floating-point vector (vector overloads).
-def hlsl_length_vec : HLSLBuiltin<"length"> {
- let DetailFunc = "length_vec_impl";
+ let DetailFunc = "length_impl";
let ParamNames = ["X"];
let Args = [Varying];
let ReturnType = VaryingElemType;
let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingScalar = 1;
let VaryingVecSizes = [2, 3, 4];
let VaryingMatDims = [];
}
diff --git a/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h b/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h
index ef6eacc5c8cc6..074aa85dca531 100644
--- a/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h
+++ b/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h
@@ -12,9 +12,15 @@
namespace hlsl {
namespace __detail {
+template <typename T>
+constexpr enable_if_t<is_same<float, T>::value || is_same<half, T>::value, T>
+length_impl(T X) {
+ return abs(X);
+}
+
template <typename T, int N>
constexpr enable_if_t<is_same<float, T>::value || is_same<half, T>::value, T>
-length_vec_impl(vector<T, N> X) {
+length_impl(vector<T, N> X) {
#if (__has_builtin(__builtin_spirv_length))
return __builtin_spirv_length(X);
#else
@@ -22,10 +28,16 @@ length_vec_impl(vector<T, N> X) {
#endif
}
+template <typename T>
+constexpr enable_if_t<is_same<float, T>::value || is_same<half, T>::value, T>
+distance_impl(T X, T Y) {
+ return length_impl(X - Y);
+}
+
template <typename T, int N>
constexpr enable_if_t<is_same<float, T>::value || is_same<half, T>::value, T>
-distance_vec_impl(vector<T, N> X, vector<T, N> Y) {
- return length_vec_impl(X - Y);
+distance_impl(vector<T, N> X, vector<T, N> Y) {
+ return length_impl(X - Y);
}
constexpr float dot2add_impl(half2 a, half2 b, float c) {
diff --git a/clang/test/CodeGenHLSL/builtins/distance.hlsl b/clang/test/CodeGenHLSL/builtins/distance.hlsl
index 5036ff8281238..efe546bfdc5cf 100644
--- a/clang/test/CodeGenHLSL/builtins/distance.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/distance.hlsl
@@ -10,14 +10,14 @@
// CHECK-SAME: half noundef nofpclass(nan inf) [[X:%.*]], half noundef nofpclass(nan inf) [[Y:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
// CHECK-NEXT: [[ENTRY:.*:]]
// CHECK-NEXT: [[SUB_I:%.*]] = fsub reassoc nnan ninf nsz arcp afn half [[X]], [[Y]]
-// CHECK-NEXT: [[ELT_ABS_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn noundef nofpclass(nan inf) half @llvm.fabs.f16(half [[SUB_I]])
+// CHECK-NEXT: [[ELT_ABS_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn noundef nofpclass(nan inf) half @llvm.fabs.f16(half nofpclass(nan inf) [[SUB_I]])
// CHECK-NEXT: ret half [[ELT_ABS_I]]
//
// SPVCHECK-LABEL: define hidden spir_func noundef nofpclass(nan inf) half @_Z18test_distance_halfDhDh(
// SPVCHECK-SAME: half noundef nofpclass(nan inf) [[X:%.*]], half noundef nofpclass(nan inf) [[Y:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
// SPVCHECK-NEXT: [[ENTRY:.*:]]
// SPVCHECK-NEXT: [[SUB_I:%.*]] = fsub reassoc nnan ninf nsz arcp afn half [[X]], [[Y]]
-// SPVCHECK-NEXT: [[ELT_ABS_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn noundef nofpclass(nan inf) half @llvm.fabs.f16(half [[SUB_I]])
+// SPVCHECK-NEXT: [[ELT_ABS_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn noundef nofpclass(nan inf) half @llvm.fabs.f16(half nofpclass(nan inf) [[SUB_I]])
// SPVCHECK-NEXT: ret half [[ELT_ABS_I]]
//
half test_distance_half(half X, half Y) { return distance(X, Y); }
@@ -77,14 +77,14 @@ half test_distance_half4(half4 X, half4 Y) { return distance(X, Y); }
// CHECK-SAME: float noundef nofpclass(nan inf) [[X:%.*]], float noundef nofpclass(nan inf) [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] {
// CHECK-NEXT: [[ENTRY:.*:]]
// CHECK-NEXT: [[SUB_I:%.*]] = fsub reassoc nnan ninf nsz arcp afn float [[X]], [[Y]]
-// CHECK-NEXT: [[ELT_ABS_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn noundef nofpclass(nan inf) float @llvm.fabs.f32(float [[SUB_I]])
+// CHECK-NEXT: [[ELT_ABS_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn noundef nofpclass(nan inf) float @llvm.fabs.f32(float nofpclass(nan inf) [[SUB_I]])
// CHECK-NEXT: ret float [[ELT_ABS_I]]
//
// SPVCHECK-LABEL: define hidden spir_func noundef nofpclass(nan inf) float @_Z19test_distance_floatff(
// SPVCHECK-SAME: float noundef nofpclass(nan inf) [[X:%.*]], float noundef nofpclass(nan inf) [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] {
// SPVCHECK-NEXT: [[ENTRY:.*:]]
// SPVCHECK-NEXT: [[SUB_I:%.*]] = fsub reassoc nnan ninf nsz arcp afn float [[X]], [[Y]]
-// SPVCHECK-NEXT: [[ELT_ABS_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn noundef nofpclass(nan inf) float @llvm.fabs.f32(float [[SUB_I]])
+// SPVCHECK-NEXT: [[ELT_ABS_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn noundef nofpclass(nan inf) float @llvm.fabs.f32(float nofpclass(nan inf) [[SUB_I]])
// SPVCHECK-NEXT: ret float [[ELT_ABS_I]]
//
float test_distance_float(float X, float Y) { return distance(X, Y); }
>From 7e60b83d688c76643f509068a5271ab98d954adf Mon Sep 17 00:00:00 2001
From: Deric Cheung <cheung.deric at gmail.com>
Date: Thu, 26 Mar 2026 10:21:37 -0700
Subject: [PATCH 05/12] Combine scalar and vector overloads of reflect
---
clang/include/clang/Basic/HLSLIntrinsics.td | 14 ++------------
clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h | 8 +++++++-
2 files changed, 9 insertions(+), 13 deletions(-)
diff --git a/clang/include/clang/Basic/HLSLIntrinsics.td b/clang/include/clang/Basic/HLSLIntrinsics.td
index f8fa710f69ab7..7d09f0f056d8c 100644
--- a/clang/include/clang/Basic/HLSLIntrinsics.td
+++ b/clang/include/clang/Basic/HLSLIntrinsics.td
@@ -603,7 +603,7 @@ def hlsl_lit_float : HLSLBuiltin<"lit"> {
let ReturnType = VectorType<FloatTy, 4>;
}
-// Returns a reflection vector (scalar overloads).
+// Returns a reflection vector.
// Scalar reflect: V = I - 2 * N * I * N (dot product is just multiplication
// for scalars).
def hlsl_reflect : HLSLBuiltin<"reflect"> {
@@ -622,22 +622,12 @@ V = I - 2 * N * dot(I N) .
N must already be normalized in order to achieve the desired result.
}];
+ let DetailFunc = "reflect_impl";
let ParamNames = ["I", "N"];
- let Body = "return I - 2 * N * I * N;";
let Args = [Varying, Varying];
let ReturnType = Varying;
let VaryingTypes = [HalfTy, FloatTy];
let VaryingScalar = 1;
- let VaryingMatDims = [];
-}
-
-// Returns a reflection vector (vector overloads).
-def hlsl_reflect_vec : HLSLBuiltin<"reflect"> {
- let DetailFunc = "reflect_vec_impl";
- let ParamNames = ["I", "N"];
- let Args = [Varying, Varying];
- let ReturnType = Varying;
- let VaryingTypes = [HalfTy, FloatTy];
let VaryingVecSizes = [2, 3, 4];
let VaryingMatDims = [];
}
diff --git a/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h b/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h
index 074aa85dca531..e87b00c8f3fec 100644
--- a/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h
+++ b/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h
@@ -63,8 +63,14 @@ enable_if_t<is_same<double, T>::value, T> mul_vec_impl(vector<T, N> x,
return sum;
}
+template <typename T>
+constexpr enable_if_t<is_same<float, T>::value || is_same<half, T>::value, T>
+reflect_impl(T I, T N) {
+ return I - 2 * N * I * N;
+}
+
template <typename T, int L>
-constexpr vector<T, L> reflect_vec_impl(vector<T, L> I, vector<T, L> N) {
+constexpr vector<T, L> reflect_impl(vector<T, L> I, vector<T, L> N) {
#if (__has_builtin(__builtin_spirv_reflect))
return __builtin_spirv_reflect(I, N);
#else
>From d8da31fbce6611792222a54f1db53b16ff8bcb01 Mon Sep 17 00:00:00 2001
From: Deric Cheung <cheung.deric at gmail.com>
Date: Thu, 26 Mar 2026 10:45:41 -0700
Subject: [PATCH 06/12] Use HLSLDetail helper subclasses. Combine smoothstep
scalar and vector implementations.
---
clang/include/clang/Basic/HLSLIntrinsics.td | 54 +++----------------
.../lib/Headers/hlsl/hlsl_intrinsic_helpers.h | 11 ----
2 files changed, 7 insertions(+), 58 deletions(-)
diff --git a/clang/include/clang/Basic/HLSLIntrinsics.td b/clang/include/clang/Basic/HLSLIntrinsics.td
index 7d09f0f056d8c..9e096b2e81254 100644
--- a/clang/include/clang/Basic/HLSLIntrinsics.td
+++ b/clang/include/clang/Basic/HLSLIntrinsics.td
@@ -370,38 +370,28 @@ function to compensate for the lack of UBYTE4 support in some hardware.
}
// Computes the partial derivative with regard to the x screen space coordinate.
-def hlsl_ddx : HLSLBuiltin<"ddx"> {
+def hlsl_ddx : HLSLOneArgDetail<"ddx", "ddx_impl"> {
let Doc = [{
\fn T ddx(T x)
\brief Computes the partial derivative of the specified value with regard to
the screen-space x-coordinate.
\param x [in] The floating-point scalar or vector to process.
}];
- let DetailFunc = "ddx_impl";
let ParamNames = ["input"];
- let Args = [Varying];
- let ReturnType = Varying;
let VaryingTypes = [HalfTy, FloatTy];
- let VaryingScalar = 1;
- let VaryingVecSizes = [2, 3, 4];
let VaryingMatDims = [];
}
// Computes the partial derivative with regard to the y screen space coordinate.
-def hlsl_ddy : HLSLBuiltin<"ddy"> {
+def hlsl_ddy : HLSLOneArgDetail<"ddy", "ddy_impl"> {
let Doc = [{
\fn T ddy(T x)
\brief Computes the partial derivative of the specified value with regard to
the screen-space y-coordinate.
\param x [in] The floating-point scalar or vector to process.
}];
- let DetailFunc = "ddy_impl";
let ParamNames = ["input"];
- let Args = [Varying];
- let ReturnType = Varying;
let VaryingTypes = [HalfTy, FloatTy];
- let VaryingScalar = 1;
- let VaryingVecSizes = [2, 3, 4];
let VaryingMatDims = [];
}
@@ -460,7 +450,7 @@ Return the computed distance vector.
}
// Flips the surface-normal to face in a direction opposite to I.
-def hlsl_faceforward : HLSLBuiltin<"faceforward"> {
+def hlsl_faceforward : HLSLThreeArgDetail<"faceforward", "faceforward_impl"> {
let Doc = [{
\fn T faceforward(T N, T I, T Ng)
\brief Flips the surface-normal (if needed) to face in a direction opposite
@@ -473,13 +463,8 @@ position to the shading position.
Return a floating-point, surface normal vector that is facing the view
direction.
}];
- let DetailFunc = "faceforward_impl";
let ParamNames = ["N", "I", "Ng"];
- let Args = [Varying, Varying, Varying];
- let ReturnType = Varying;
let VaryingTypes = [HalfTy, FloatTy];
- let VaryingScalar = 1;
- let VaryingVecSizes = [2, 3, 4];
let VaryingMatDims = [];
}
@@ -515,20 +500,15 @@ def hlsl_fmod_vec : HLSLBuiltin<"fmod"> {
}
// Computes the sum of the absolute values of the partial derivatives.
-def hlsl_fwidth : HLSLBuiltin<"fwidth"> {
+def hlsl_fwidth : HLSLOneArgDetail<"fwidth", "fwidth_impl"> {
let Doc = [{
\fn T fwidth(T x)
\brief Computes the sum of the absolute values of the partial derivatives
with regard to the x and y screen space coordinates.
\param x [in] The floating-point scalar or vector to process.
}];
- let DetailFunc = "fwidth_impl";
let ParamNames = ["input"];
- let Args = [Varying];
- let ReturnType = Varying;
let VaryingTypes = [HalfTy, FloatTy];
- let VaryingScalar = 1;
- let VaryingVecSizes = [2, 3, 4];
let VaryingMatDims = [];
}
@@ -606,7 +586,7 @@ def hlsl_lit_float : HLSLBuiltin<"lit"> {
// Returns a reflection vector.
// Scalar reflect: V = I - 2 * N * I * N (dot product is just multiplication
// for scalars).
-def hlsl_reflect : HLSLBuiltin<"reflect"> {
+def hlsl_reflect : HLSLTwoArgDetail<"reflect", "reflect_impl"> {
let Doc = [{
\fn T reflect(T I, T N)
\brief Returns a reflection using an incident ray, \a I, and a surface
@@ -622,13 +602,8 @@ V = I - 2 * N * dot(I N) .
N must already be normalized in order to achieve the desired result.
}];
- let DetailFunc = "reflect_impl";
let ParamNames = ["I", "N"];
- let Args = [Varying, Varying];
- let ReturnType = Varying;
let VaryingTypes = [HalfTy, FloatTy];
- let VaryingScalar = 1;
- let VaryingVecSizes = [2, 3, 4];
let VaryingMatDims = [];
}
@@ -672,8 +647,8 @@ Result type, the type of I, and the type of N must all be the same type.
}
-// Returns a smooth Hermite interpolation between 0 and 1 (scalar overloads).
-def hlsl_smoothstep : HLSLBuiltin<"smoothstep"> {
+// Returns a smooth Hermite interpolation between 0 and 1.
+def hlsl_smoothstep : HLSLThreeArgDetail<"smoothstep", "smoothstep_impl"> {
let Doc = [{
\fn T smoothstep(T Min, T Max, T X)
\brief Returns a smooth Hermite interpolation between 0 and 1, if \a X is in
@@ -686,22 +661,7 @@ The return value is 0.0 if \a X <= \a Min and 1.0 if \a X >= \a Max. When \a
Min < \a X < \a Max, the function performs smooth Hermite interpolation
between 0 and 1.
}];
- let DetailFunc = "smoothstep_impl";
let ParamNames = ["Min", "Max", "X"];
- let Args = [Varying, Varying, Varying];
- let ReturnType = Varying;
let VaryingTypes = [HalfTy, FloatTy];
- let VaryingScalar = 1;
- let VaryingMatDims = [];
-}
-
-// Returns a smooth Hermite interpolation between 0 and 1 (vector overloads).
-def hlsl_smoothstep_vec : HLSLBuiltin<"smoothstep"> {
- let DetailFunc = "smoothstep_vec_impl";
- let ParamNames = ["Min", "Max", "X"];
- let Args = [Varying, Varying, Varying];
- let ReturnType = Varying;
- let VaryingTypes = [HalfTy, FloatTy];
- let VaryingVecSizes = [2, 3, 4];
let VaryingMatDims = [];
}
diff --git a/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h b/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h
index e87b00c8f3fec..e541b0ffeda07 100644
--- a/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h
+++ b/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h
@@ -120,17 +120,6 @@ template <typename T> constexpr T smoothstep_impl(T Min, T Max, T X) {
#endif
}
-template <typename T, int N>
-constexpr vector<T, N> smoothstep_vec_impl(vector<T, N> Min, vector<T, N> Max,
- vector<T, N> X) {
-#if (__has_builtin(__builtin_spirv_smoothstep))
- return __builtin_spirv_smoothstep(Min, Max, X);
-#else
- vector<T, N> S = saturate((X - Min) / (Max - Min));
- return (3 - 2 * S) * S * S;
-#endif
-}
-
template <typename T> constexpr vector<T, 4> lit_impl(T NDotL, T NDotH, T M) {
bool DiffuseCond = NDotL < 0;
T Diffuse = select<T>(DiffuseCond, 0, NDotL);
>From d1457a2c26a36a47f69162227cd8b941da043d11 Mon Sep 17 00:00:00 2001
From: Deric Cheung <cheung.deric at gmail.com>
Date: Thu, 26 Mar 2026 10:52:01 -0700
Subject: [PATCH 07/12] Make distance use HLSLTwoArgDetail helper subclass
---
clang/include/clang/Basic/HLSLIntrinsics.td | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/clang/include/clang/Basic/HLSLIntrinsics.td b/clang/include/clang/Basic/HLSLIntrinsics.td
index 9e096b2e81254..9db242c739d08 100644
--- a/clang/include/clang/Basic/HLSLIntrinsics.td
+++ b/clang/include/clang/Basic/HLSLIntrinsics.td
@@ -397,7 +397,7 @@ the screen-space y-coordinate.
// Returns a distance scalar between X and Y.
// The distance between X and Y is length(X - Y).
-def hlsl_distance : HLSLBuiltin<"distance"> {
+def hlsl_distance : HLSLTwoArgDetail<"distance", "distance_impl"> {
let Doc = [{
\fn K distance(T X, T Y)
\brief Returns a distance scalar between \a X and \a Y.
@@ -406,11 +406,8 @@ def hlsl_distance : HLSLBuiltin<"distance"> {
}];
let DetailFunc = "distance_impl";
let ParamNames = ["X", "Y"];
- let Args = [Varying, Varying];
let ReturnType = VaryingElemType;
let VaryingTypes = [HalfTy, FloatTy];
- let VaryingScalar = 1;
- let VaryingVecSizes = [2, 3, 4];
let VaryingMatDims = [];
}
>From 2150ebf04136c0ae34f2694492b6324bef6840ac Mon Sep 17 00:00:00 2001
From: Deric Cheung <cheung.deric at gmail.com>
Date: Thu, 26 Mar 2026 09:29:42 -0700
Subject: [PATCH 08/12] Rewrite HLSL alias intrinsics into TableGen
Assisted-by: GitHub Copilot
---
clang/include/clang/Basic/HLSLIntrinsics.td | 1137 ++++-
.../lib/Headers/hlsl/hlsl_alias_intrinsics.h | 3968 +----------------
.../test/SemaHLSL/BuiltIns/cross-errors.hlsl | 12 +-
.../SemaHLSL/BuiltIns/f16tof32-errors.hlsl | 4 +-
.../SemaHLSL/BuiltIns/f32tof16-errors.hlsl | 4 +-
.../SemaHLSL/WaveBuiltinAvailability.hlsl | 2 +-
6 files changed, 1276 insertions(+), 3851 deletions(-)
diff --git a/clang/include/clang/Basic/HLSLIntrinsics.td b/clang/include/clang/Basic/HLSLIntrinsics.td
index 9db242c739d08..e2eb4db3bfc3e 100644
--- a/clang/include/clang/Basic/HLSLIntrinsics.td
+++ b/clang/include/clang/Basic/HLSLIntrinsics.td
@@ -313,6 +313,17 @@ class HLSLOneArgInlineBuiltin<string name> : HLSLBuiltin<name> {
// Intrinsic definitions (sorted alphabetically by function name)
//===----------------------------------------------------------------------===//
+// Returns the absolute value of the input value, Val.
+def hlsl_abs : HLSLOneArgBuiltin<"abs", "__builtin_elementwise_abs"> {
+ let Doc = [{
+\fn T abs(T Val)
+\brief Returns the absolute value of the input value, \a Val.
+\param Val The input value.
+}];
+ let VaryingTypes = SignedTypes;
+ let VaryingMatDims = [];
+}
+
// Unsigned abs is a constexpr identity — unsigned values are already non-negative.
def hlsl_abs_unsigned : HLSLOneArgInlineBuiltin<"abs"> {
let Doc = [{
@@ -330,6 +341,138 @@ function returns its input unchanged.
let VaryingMatDims = [];
}
+// Returns the arccosine of the input value, Val.
+def hlsl_acos : HLSLOneArgBuiltin<"acos", "__builtin_elementwise_acos"> {
+ let Doc = [{
+\fn T acos(T Val)
+\brief Returns the arccosine of the input value, \a Val.
+\param Val The input value.
+}];
+ let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingMatDims = [];
+}
+
+// Implements unsigned 64-bit integer addition using pairs of unsigned 32-bit
+// integers.
+def hlsl_adduint64 : HLSLBuiltin<"AddUint64", "__builtin_hlsl_adduint64"> {
+ let Doc = [{
+\fn T AddUint64(T a, T b)
+\brief Implements unsigned 64-bit integer addition using pairs of unsigned
+32-bit integers.
+\param x [in] The first unsigned 32-bit integer pair(s)
+\param y [in] The second unsigned 32-bit integer pair(s)
+
+This function takes one or two pairs (low, high) of unsigned 32-bit integer
+values and returns pairs (low, high) of unsigned 32-bit integer
+values representing the result of unsigned 64-bit integer addition.
+}];
+ let Args = [Varying, Varying];
+ let ReturnType = Varying;
+ let VaryingTypes = [UIntTy];
+ let VaryingVecSizes = [2, 4];
+ let Availability = SM6_0;
+}
+
+// Returns True if all components of the x parameter are non-zero;
+// otherwise, false.
+def hlsl_all : HLSLOneArgBuiltin<"all", "__builtin_hlsl_all"> {
+ let Doc = [{
+\fn bool all(T x)
+\brief Returns True if all components of the \a x parameter are non-zero;
+otherwise, false.
+\param x The input value.
+}];
+ let ReturnType = BoolTy;
+ let VaryingTypes = AllTypesWithBool;
+ let VaryingMatDims = [];
+}
+
+// Returns the boolean AND of two bool values or vectors.
+def hlsl_and : HLSLTwoArgBuiltin<"and", "__builtin_hlsl_and"> {
+ let Doc = [{
+\fn bool and(bool x, bool y)
+\brief Logically ands two boolean vectors or matrices elementwise and
+produces a bool vector or matrix output.
+}];
+ let VaryingTypes = [BoolTy];
+}
+
+// Returns True if any components of the x parameter are non-zero;
+// otherwise, false.
+def hlsl_any : HLSLOneArgBuiltin<"any", "__builtin_hlsl_any"> {
+ let Doc = [{
+\fn bool any(T x)
+\brief Returns True if any components of the \a x parameter are non-zero;
+otherwise, false.
+\param x The input value.
+}];
+ let ReturnType = BoolTy;
+ let VaryingTypes = AllTypesWithBool;
+ let VaryingMatDims = [];
+}
+
+// Reinterprets a cast value (two 32-bit values) into a double.
+def hlsl_asdouble : HLSLTwoArgBuiltin<"asdouble", "__builtin_hlsl_asdouble"> {
+ let Doc = [{
+\fn double asdouble(uint LowBits, uint HighBits)
+\brief Reinterprets a cast value (two 32-bit values) into a double.
+\param LowBits The low 32-bit pattern of the input value.
+\param HighBits The high 32-bit pattern of the input value.
+}];
+ let ReturnType = VaryingShape<DoubleTy>;
+ let VaryingTypes = [UIntTy];
+ let VaryingMatDims = [];
+}
+
+// Returns the arcsine of the input value, Val.
+def hlsl_asin : HLSLOneArgBuiltin<"asin", "__builtin_elementwise_asin"> {
+ let Doc = [{
+\fn T asin(T Val)
+\brief Returns the arcsine of the input value, \a Val.
+\param Val The input value.
+}];
+ let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingMatDims = [];
+}
+
+// Returns the arctangent of the input value, Val.
+def hlsl_atan : HLSLOneArgBuiltin<"atan", "__builtin_elementwise_atan"> {
+ let Doc = [{
+\fn T atan(T Val)
+\brief Returns the arctangent of the input value, \a Val.
+\param Val The input value.
+}];
+ let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingMatDims = [];
+}
+
+// Returns the arctangent of y/x, using the signs of the arguments to determine
+// the correct quadrant.
+def hlsl_atan2 : HLSLTwoArgBuiltin<"atan2", "__builtin_elementwise_atan2"> {
+ let Doc = [{
+\fn T atan2(T y, T x)
+\brief Returns the arctangent of y/x, using the signs of the arguments to
+determine the correct quadrant.
+\param y The y-coordinate.
+\param x The x-coordinate.
+}];
+ let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingMatDims = [];
+}
+
+// Returns the smallest integer value that is greater than or equal to the
+// input value, Val.
+def hlsl_ceil : HLSLOneArgBuiltin<"ceil", "__builtin_elementwise_ceil"> {
+ let Doc = [{
+\fn T ceil(T Val)
+\brief Returns the smallest integer value that is greater than or equal to
+the input value, \a Val.
+\param Val The input value.
+}];
+ let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingMatDims = [];
+}
+
// Checks whether the value is fully mapped.
def hlsl_check_access_fully_mapped : HLSLBuiltin<"CheckAccessFullyMapped"> {
let Doc = [{
@@ -343,6 +486,99 @@ def hlsl_check_access_fully_mapped : HLSLBuiltin<"CheckAccessFullyMapped"> {
let ReturnType = BoolTy;
}
+// Clamps the specified value X to the specified minimum (Min) and maximum (Max)
+// range.
+def hlsl_clamp : HLSLThreeArgBuiltin<"clamp", "__builtin_hlsl_elementwise_clamp"> {
+ let Doc = [{
+\fn T clamp(T X, T Min, T Max)
+\brief Clamps the specified value \a X to the specified
+minimum ( \a Min) and maximum ( \a Max) range.
+\param X A value to clamp.
+\param Min The specified minimum range.
+\param Max The specified maximum range.
+
+Returns The clamped value for the \a X parameter.
+For values of -INF or INF, clamp will behave as expected.
+However for values of NaN, the results are undefined.
+}];
+ let VaryingTypes = AllNumericTypes;
+ let VaryingMatDims = [];
+}
+
+// Discards the current pixel if the specified value is less than zero.
+def hlsl_clip : HLSLOneArgBuiltin<"clip", "__builtin_hlsl_elementwise_clip"> {
+ let Doc = [{
+\fn void clip(T Val)
+\brief Discards the current pixel if the specified value is less than zero.
+\param Val The input value.
+}];
+ let ReturnType = VoidTy;
+ let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingMatDims = [];
+}
+
+// Returns the cosine of the input value, Val.
+def hlsl_cos : HLSLOneArgBuiltin<"cos", "__builtin_elementwise_cos"> {
+ let Doc = [{
+\fn T cos(T Val)
+\brief Returns the cosine of the input value, \a Val.
+\param Val The input value.
+}];
+ let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingMatDims = [];
+}
+
+// Returns the hyperbolic cosine of the input value, Val.
+def hlsl_cosh : HLSLOneArgBuiltin<"cosh", "__builtin_elementwise_cosh"> {
+ let Doc = [{
+\fn T cosh(T Val)
+\brief Returns the hyperbolic cosine of the input value, \a Val.
+\param Val The input value.
+}];
+ let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingMatDims = [];
+}
+
+// Returns the number of bits (per component) set in the input integer.
+def hlsl_countbits : HLSLBuiltin<"countbits"> {
+ let Doc = [{
+\fn T countbits(T Val)
+\brief Return the number of bits (per component) set in the input integer.
+\param Val The input value.
+}];
+ let ParamNames = ["x"];
+ let Body = "return __builtin_elementwise_popcount(x);";
+ let Args = [Varying];
+ let ReturnType = VaryingShape<UIntTy>;
+ let VaryingTypes = AllIntTypes;
+ let VaryingScalar = 1;
+ let VaryingVecSizes = [2, 3, 4];
+}
+
+// Returns the cross product of two floating-point, 3D vectors.
+def hlsl_cross_float : HLSLBuiltin<"cross", "__builtin_hlsl_crossf32"> {
+ let Args = [VectorType<FloatTy, 3>, VectorType<FloatTy, 3>];
+ let ReturnType = VectorType<FloatTy, 3>;
+}
+
+def hlsl_cross_half : HLSLBuiltin<"cross", "__builtin_hlsl_crossf16"> {
+ let Doc = [{
+\fn T cross(T x, T y)
+\brief Returns the cross product of two floating-point, 3D vectors.
+\param x [in] The first floating-point, 3D vector.
+\param y [in] The second floating-point, 3D vector.
+
+Result is the cross product of x and y, i.e., the resulting
+components are, in order :
+x[1] * y[2] - y[1] * x[2]
+x[2] * y[0] - y[2] * x[0]
+x[0] * y[1] - y[0] * x[1]
+}];
+ let Args = [VectorType<HalfTy, 3>, VectorType<HalfTy, 3>];
+ let ReturnType = VectorType<HalfTy, 3>;
+ let Availability = SM6_2;
+}
+
// Converts a floating-point, 4D vector set by a D3DCOLOR to a UBYTE4.
def hlsl_d3d_color_to_ubyte4 : HLSLBuiltin<"D3DCOLORtoUBYTE4"> {
let Doc = [{
@@ -382,6 +618,40 @@ the screen-space x-coordinate.
let VaryingMatDims = [];
}
+// Computes a low precision partial derivative with respect to the screen-space
+// x-coordinate.
+def hlsl_ddx_coarse : HLSLOneArgBuiltin<"ddx_coarse",
+ "__builtin_hlsl_elementwise_ddx_coarse"> {
+ let Doc = [{
+\fn T ddx_coarse(T value)
+\brief Computes a low precision partial derivative with respect to the
+screen-space x-coordinate.
+\param value The input value.
+
+The return value is a floating point scalar or vector containing the low
+prevision partial derivative of the input value.
+}];
+ let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingMatDims = [];
+}
+
+// Computes a high precision partial derivative with respect to the screen-space
+// x-coordinate.
+def hlsl_ddx_fine : HLSLOneArgBuiltin<"ddx_fine",
+ "__builtin_hlsl_elementwise_ddx_fine"> {
+ let Doc = [{
+\fn T ddx_fine(T value)
+\brief Computes a high precision partial derivative with respect to the
+screen-space x-coordinate.
+\param value The input value.
+
+The return value is a floating point scalar or vector containing the high
+prevision partial derivative of the input value.
+}];
+ let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingMatDims = [];
+}
+
// Computes the partial derivative with regard to the y screen space coordinate.
def hlsl_ddy : HLSLOneArgDetail<"ddy", "ddy_impl"> {
let Doc = [{
@@ -395,6 +665,51 @@ the screen-space y-coordinate.
let VaryingMatDims = [];
}
+// Computes a low precision partial derivative with respect to the screen-space
+// y-coordinate.
+def hlsl_ddy_coarse : HLSLOneArgBuiltin<"ddy_coarse",
+ "__builtin_hlsl_elementwise_ddy_coarse"> {
+ let Doc = [{
+\fn T ddy_coarse(T value)
+\brief Computes a low precision partial derivative with respect to the
+screen-space y-coordinate.
+\param value The input value.
+
+The return value is a floating point scalar or vector containing the low
+prevision partial derivative of the input value.
+}];
+ let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingMatDims = [];
+}
+
+// Computes a high precision partial derivative with respect to the screen-space
+// y-coordinate.
+def hlsl_ddy_fine : HLSLOneArgBuiltin<"ddy_fine",
+ "__builtin_hlsl_elementwise_ddy_fine"> {
+ let Doc = [{
+\fn T ddy_fine(T value)
+\brief Computes a high precision partial derivative with respect to the
+screen-space y-coordinate.
+\param value The input value.
+
+The return value is a floating point scalar or vector containing the high
+prevision partial derivative of the input value.
+}];
+ let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingMatDims = [];
+}
+
+// Converts the specified value from radians to degrees.
+def hlsl_degrees : HLSLOneArgBuiltin<"degrees", "__builtin_hlsl_elementwise_degrees"> {
+ let Doc = [{
+\fn T degrees(T x)
+\brief Converts the specified value from radians to degrees.
+\param x The specified input value.
+}];
+ let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingMatDims = [];
+}
+
// Returns a distance scalar between X and Y.
// The distance between X and Y is length(X - Y).
def hlsl_distance : HLSLTwoArgDetail<"distance", "distance_impl"> {
@@ -411,6 +726,27 @@ def hlsl_distance : HLSLTwoArgDetail<"distance", "distance_impl"> {
let VaryingMatDims = [];
}
+// Returns the dot product (a scalar value) of X and Y.
+def hlsl_dot : HLSLTwoArgBuiltin<"dot", "__builtin_hlsl_dot"> {
+ let Doc = [{
+\fn K dot(T X, T Y)
+\brief Return the dot product (a scalar value) of \a X and \a Y.
+\param X The X input value.
+\param Y The Y input value.
+}];
+ let ReturnType = VaryingElemType;
+ let VaryingTypes = NumericTypesNoDbl;
+ let VaryingMatDims = [];
+}
+
+// double dot only has scalar overload (no vectors).
+def hlsl_dot_double : HLSLBuiltin<"dot", "__builtin_hlsl_dot"> {
+ let Args = [Varying, Varying];
+ let ReturnType = VaryingElemType;
+ let VaryingTypes = [DoubleTy];
+ let VaryingScalar = 1;
+}
+
// Dot product of 2 half vectors plus a float scalar.
def hlsl_dot2add : HLSLBuiltin<"dot2add"> {
let Doc = [{
@@ -427,6 +763,34 @@ def hlsl_dot2add : HLSLBuiltin<"dot2add"> {
let Availability = SM6_4;
}
+// Dot product of two packed 8-bit signed integer vectors, accumulated with a
+// 32-bit signed integer.
+def hlsl_dot4add_i8packed :
+ HLSLBuiltin<"dot4add_i8packed", "__builtin_hlsl_dot4add_i8packed"> {
+ let Doc = [{
+\fn int dot4add_i8packed(uint A, uint B, int C)
+\brief Dot product of two packed 8-bit signed integer vectors, accumulated
+with a 32-bit signed integer.
+}];
+ let Args = [UIntTy, UIntTy, IntTy];
+ let ReturnType = IntTy;
+ let Availability = SM6_4;
+}
+
+// Dot product of two packed 8-bit unsigned integer vectors, accumulated with a
+// 32-bit unsigned integer.
+def hlsl_dot4add_u8packed :
+ HLSLBuiltin<"dot4add_u8packed", "__builtin_hlsl_dot4add_u8packed"> {
+ let Doc = [{
+\fn uint dot4add_u8packed(uint A, uint B, uint C)
+\brief Dot product of two packed 8-bit unsigned integer vectors, accumulated
+with a 32-bit unsigned integer.
+}];
+ let Args = [UIntTy, UIntTy, UIntTy];
+ let ReturnType = UIntTy;
+ let Availability = SM6_4;
+}
+
// Calculates a distance vector.
def hlsl_dst : HLSLBuiltin<"dst"> {
let Doc = [{
@@ -446,6 +810,68 @@ Return the computed distance vector.
let VaryingMatDims = [];
}
+// Returns the base-e exponential, or e**x, of the specified value.
+def hlsl_exp : HLSLOneArgBuiltin<"exp", "__builtin_elementwise_exp"> {
+ let Doc = [{
+\fn T exp(T x)
+\brief Returns the base-e exponential, or \a e**x, of the specified value.
+\param x The specified input value.
+
+The return value is the base-e exponential of the \a x parameter.
+}];
+ let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingMatDims = [];
+}
+
+// Returns the base 2 exponential, or 2**x, of the specified value.
+def hlsl_exp2 : HLSLOneArgBuiltin<"exp2", "__builtin_elementwise_exp2"> {
+ let Doc = [{
+\fn T exp2(T x)
+\brief Returns the base 2 exponential, or \a 2**x, of the specified value.
+\param x The specified input value.
+
+The base 2 exponential of the \a x parameter.
+}];
+ let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingMatDims = [];
+}
+
+// Returns the half value stored in the low 16 bits of the uint arg converted
+// to a float.
+def hlsl_f16tof32 : HLSLOneArgBuiltin<"f16tof32",
+ "__builtin_hlsl_elementwise_f16tof32"> {
+ let Doc = [{
+\fn float f16tof32(uint x)
+\brief Returns the half value stored in the low 16 bits of the uint arg
+converted to a float.
+\param x The uint containing two half values.
+
+The float value of the half value found in the low 16 bits of the \a x
+parameter.
+}];
+ let ReturnType = VaryingShape<FloatTy>;
+ let VaryingTypes = [UIntTy];
+ let VaryingMatDims = [];
+}
+
+// Returns the float arg value converted to half in the low 16 bits of the uint
+// return value.
+def hlsl_f32tof16 : HLSLOneArgBuiltin<"f32tof16",
+ "__builtin_hlsl_elementwise_f32tof16"> {
+ let Doc = [{
+\fn uint f32tof16(float x)
+\brief Returns the float arg value converted to half in the low 16 bits of
+the uint return value.
+\param x The float to be converted to half.
+
+The return value is a uint containing the converted half value in the low
+16 bits.
+}];
+ let ReturnType = VaryingShape<UIntTy>;
+ let VaryingTypes = [FloatTy];
+ let VaryingMatDims = [];
+}
+
// Flips the surface-normal to face in a direction opposite to I.
def hlsl_faceforward : HLSLThreeArgDetail<"faceforward", "faceforward_impl"> {
let Doc = [{
@@ -465,6 +891,34 @@ direction.
let VaryingMatDims = [];
}
+// Returns the location of the first set bit starting from the lowest order bit
+// and working upward, per component.
+def hlsl_firstbitlow : HLSLOneArgBuiltin<"firstbitlow",
+ "__builtin_hlsl_elementwise_firstbitlow"> {
+ let Doc = [{
+\fn T firstbitlow(T Val)
+\brief Returns the location of the first set bit starting from the lowest
+order bit and working upward, per component.
+\param Val the input value.
+}];
+ let ReturnType = VaryingShape<UIntTy>;
+ let VaryingTypes = AllIntTypes;
+ let VaryingMatDims = [];
+}
+
+// Returns the largest integer that is less than or equal to the input
+// value, Val.
+def hlsl_floor : HLSLOneArgBuiltin<"floor", "__builtin_elementwise_floor"> {
+ let Doc = [{
+\fn T floor(T Val)
+\brief Returns the largest integer that is less than or equal to the input
+value, \a Val.
+\param Val The input value.
+}];
+ let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingMatDims = [];
+}
+
// Returns the floating-point remainder of x/y (scalar overloads).
def hlsl_fmod : HLSLBuiltin<"fmod"> {
let Doc = [{
@@ -496,6 +950,19 @@ def hlsl_fmod_vec : HLSLBuiltin<"fmod"> {
let VaryingMatDims = [];
}
+// Returns the fractional (or decimal) part of x.
+def hlsl_frac : HLSLOneArgBuiltin<"frac", "__builtin_hlsl_elementwise_frac"> {
+ let Doc = [{
+\fn T frac(T x)
+\brief Returns the fractional (or decimal) part of x. \a x parameter.
+\param x The specified input value.
+
+If \a the return value is greater than or equal to 0 and less than 1.
+}];
+ let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingMatDims = [];
+}
+
// Computes the sum of the absolute values of the partial derivatives.
def hlsl_fwidth : HLSLOneArgDetail<"fwidth", "fwidth_impl"> {
let Doc = [{
@@ -509,6 +976,50 @@ with regard to the x and y screen space coordinates.
let VaryingMatDims = [];
}
+// Blocks execution of all threads in a group until all group shared accesses
+// have been completed and all threads in the group have reached this call.
+def hlsl_group_memory_barrier_with_group_sync :
+ HLSLBuiltin<"GroupMemoryBarrierWithGroupSync",
+ "__builtin_hlsl_group_memory_barrier_with_group_sync"> {
+ let Doc = [{
+\fn void GroupMemoryBarrierWithGroupSync(void)
+\brief Blocks execution of all threads in a group until all group shared
+accesses have been completed and all threads in the group have reached this
+call.
+}];
+ let IsConvergent = 1;
+}
+
+// Determines if the specified value x is infinite.
+def hlsl_isinf : HLSLOneArgBuiltin<"isinf", "__builtin_hlsl_elementwise_isinf"> {
+ let Doc = [{
+\fn T isinf(T x)
+\brief Determines if the specified value \a x is infinite.
+\param x The specified input value.
+
+Returns a value of the same size as the input, with a value set
+to True if the x parameter is +INF or -INF. Otherwise, False.
+}];
+ let ReturnType = VaryingShape<BoolTy>;
+ let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingMatDims = [];
+}
+
+// Determines if the specified value x is Not a Number.
+def hlsl_isnan : HLSLOneArgBuiltin<"isnan", "__builtin_hlsl_elementwise_isnan"> {
+ let Doc = [{
+\fn T isnan(T x)
+\brief Determines if the specified value \a x is Not a Number.
+\param x The specified input value.
+
+Returns a value of the same size as the input, with a value set
+to True if the x parameter is NaN or QNaN. Otherwise, False.
+}];
+ let ReturnType = VaryingShape<BoolTy>;
+ let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingMatDims = [];
+}
+
// Returns the result of multiplying the specified value by two raised
// to the power of the specified exponent.
def hlsl_ldexp : HLSLBuiltin<"ldexp"> {
@@ -553,6 +1064,30 @@ Length is based on the following formula: sqrt(x[0]^2 + x[1]^2 + ...).
let VaryingMatDims = [];
}
+// Returns the linear interpolation of x to y by s.
+def hlsl_lerp : HLSLThreeArgBuiltin<"lerp", "__builtin_hlsl_lerp"> {
+ let Doc = [{
+\fn T lerp(T x, T y, T s)
+\brief Returns the linear interpolation of x to y by s.
+\param x [in] The first-floating point value.
+\param y [in] The second-floating point value.
+\param s [in] A value that linearly interpolates between the x parameter and
+the y parameter.
+
+Linear interpolation is based on the following formula: x*(1-s) + y*s which
+can equivalently be written as x + s(y-x).
+}];
+ let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingMatDims = [];
+}
+
+def hlsl_lit_float : HLSLBuiltin<"lit"> {
+ let DetailFunc = "lit_impl";
+ let ParamNames = ["NDotL", "NDotH", "M"];
+ let Args = [FloatTy, FloatTy, FloatTy];
+ let ReturnType = VectorType<FloatTy, 4>;
+}
+
// Returns a lighting coefficient vector.
def hlsl_lit_half : HLSLBuiltin<"lit"> {
let Doc = [{
@@ -573,15 +1108,175 @@ specular, 1).
let ReturnType = VectorType<HalfTy, 4>;
}
-def hlsl_lit_float : HLSLBuiltin<"lit"> {
- let DetailFunc = "lit_impl";
- let ParamNames = ["NDotL", "NDotH", "M"];
- let Args = [FloatTy, FloatTy, FloatTy];
- let ReturnType = VectorType<FloatTy, 4>;
+// Returns the base-e logarithm of the input value, Val.
+def hlsl_log : HLSLOneArgBuiltin<"log", "__builtin_elementwise_log"> {
+ let Doc = [{
+\fn T log(T Val)
+\brief The base-e logarithm of the input value, \a Val parameter.
+\param Val The input value.
+
+If \a Val is negative, this result is undefined. If \a Val is 0, this
+function returns negative infinity.
+}];
+ let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingMatDims = [];
}
-// Returns a reflection vector.
-// Scalar reflect: V = I - 2 * N * I * N (dot product is just multiplication
+// Returns the base-10 logarithm of the input value, Val.
+def hlsl_log10 : HLSLOneArgBuiltin<"log10", "__builtin_elementwise_log10"> {
+ let Doc = [{
+\fn T log10(T Val)
+\brief The base-10 logarithm of the input value, \a Val parameter.
+\param Val The input value.
+
+If \a Val is negative, this result is undefined. If \a Val is 0, this
+function returns negative infinity.
+}];
+ let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingMatDims = [];
+}
+
+// Returns the base-2 logarithm of the input value, Val.
+def hlsl_log2 : HLSLOneArgBuiltin<"log2", "__builtin_elementwise_log2"> {
+ let Doc = [{
+\fn T log2(T Val)
+\brief The base-2 logarithm of the input value, \a Val parameter.
+\param Val The input value.
+
+If \a Val is negative, this result is undefined. If \a Val is 0, this
+function returns negative infinity.
+}];
+ let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingMatDims = [];
+}
+
+// Returns the result of M * A + B (multiply-add).
+def hlsl_mad : HLSLThreeArgBuiltin<"mad", "__builtin_hlsl_mad"> {
+ let Doc = [{
+\fn T mad(T M, T A, T B)
+\brief The result of \a M * \a A + \a B.
+\param M The multiplication value.
+\param A The first addition value.
+\param B The second addition value.
+}];
+ let VaryingTypes = AllNumericTypes;
+ let VaryingMatDims = [];
+}
+
+// Returns the greater of X and Y.
+def hlsl_max : HLSLTwoArgBuiltin<"max", "__builtin_elementwise_max"> {
+ let Doc = [{
+\fn T max(T X, T Y)
+\brief Return the greater of \a X and \a Y.
+\param X The X input value.
+\param Y The Y input value.
+}];
+ let VaryingTypes = AllNumericTypes;
+ let VaryingMatDims = [];
+}
+
+// Returns the lesser of X and Y.
+def hlsl_min : HLSLTwoArgBuiltin<"min", "__builtin_elementwise_min"> {
+ let Doc = [{
+\fn T min(T X, T Y)
+\brief Return the lesser of \a X and \a Y.
+\param X The X input value.
+\param Y The Y input value.
+}];
+ let VaryingTypes = AllNumericTypes;
+ let VaryingMatDims = [];
+}
+
+// Marks a resource index as non-uniform (varying across wave threads).
+def hlsl_non_uniform_resource_index :
+ HLSLBuiltin<"NonUniformResourceIndex",
+ "__builtin_hlsl_resource_nonuniformindex"> {
+ let Doc = [{
+\fn uint NonUniformResourceIndex(uint I)
+\brief A compiler hint to indicate that a resource index varies across
+threads within a wave (i.e., it is non-uniform).
+\param I [in] Resource array index
+
+The return value is the \a I parameter.
+}];
+ let Args = [UIntTy];
+ let ReturnType = UIntTy;
+}
+
+// Returns the normalized unit vector of the specified floating-point vector.
+def hlsl_normalize : HLSLOneArgBuiltin<"normalize", "__builtin_hlsl_normalize"> {
+ let Doc = [{
+\fn T normalize(T x)
+\brief Returns the normalized unit vector of the specified floating-point
+vector.
+\param x [in] The vector of floats.
+
+Normalize is based on the following formula: x / length(x).
+}];
+ let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingMatDims = [];
+}
+
+// Returns the boolean OR of two bool values or vectors.
+def hlsl_or : HLSLTwoArgBuiltin<"or", "__builtin_hlsl_or"> {
+ let Doc = [{
+\fn bool or(bool x, bool y)
+\brief Logically ors two boolean vectors or matrices elementwise and
+ produces a bool vector or matrix output.
+}];
+ let VaryingTypes = [BoolTy];
+}
+
+// Returns the value Val, raised to the power Pow.
+def hlsl_pow : HLSLTwoArgBuiltin<"pow", "__builtin_elementwise_pow"> {
+ let Doc = [{
+\fn T pow(T Val, T Pow)
+\brief Return the value \a Val, raised to the power \a Pow.
+\param Val The input value.
+\param Pow The specified power.
+}];
+ let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingMatDims = [];
+}
+
+// Reads the value from the lane across the X axis of the quad.
+def hlsl_quad_read_across_x :
+ HLSLOneArgBuiltin<"QuadReadAcrossX",
+ "__builtin_hlsl_quad_read_across_x"> {
+ let Doc = [{
+\brief Reads the value from the lane across the X axis of the quad.
+\param Val The input value.
+}];
+ let VaryingTypes = AllNumericTypes;
+ let IsConvergent = 1;
+ let VaryingMatDims = [];
+}
+
+// Converts the specified value from degrees to radians.
+def hlsl_radians : HLSLOneArgBuiltin<"radians", "__builtin_hlsl_elementwise_radians"> {
+ let Doc = [{
+\fn T radians(T Val)
+\brief Converts the specified value from degrees to radians.
+}];
+ let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingMatDims = [];
+}
+
+// Calculates a fast, approximate, per-component reciprocal ie 1 / x.
+def hlsl_rcp : HLSLOneArgBuiltin<"rcp", "__builtin_hlsl_elementwise_rcp"> {
+ let Doc = [{
+\fn T rcp(T x)
+\brief Calculates a fast, approximate, per-component reciprocal ie 1 / \a x.
+\param x The specified input value.
+
+The return value is the reciprocal of the \a x parameter.
+}];
+ let VaryingTypes = AllFloatTypes;
+ let VaryingMatDims = [];
+}
+
+// Returns a reflection vector.
+// Scalar reflect: V = I - 2 * N * I * N (dot product is just multiplication
// for scalars).
def hlsl_reflect : HLSLTwoArgDetail<"reflect", "reflect_impl"> {
let Doc = [{
@@ -643,6 +1338,94 @@ Result type, the type of I, and the type of N must all be the same type.
let VaryingMatDims = [];
}
+// Returns the value Val with the bit order reversed.
+def hlsl_reversebits : HLSLOneArgBuiltin<"reversebits", "__builtin_elementwise_bitreverse"> {
+ let Doc = [{
+\fn T reversebits(T Val)
+\brief Return the value \a Val with the bit order reversed.
+\param Val The input value.
+}];
+ let VaryingTypes = AllIntTypes;
+ let VaryingMatDims = [];
+}
+
+// Rounds the specified value x to the nearest integer.
+def hlsl_round : HLSLOneArgBuiltin<"round", "__builtin_elementwise_roundeven"> {
+ let Doc = [{
+\fn T round(T x)
+\brief Rounds the specified value \a x to the nearest integer.
+\param x The specified input value.
+
+The return value is the \a x parameter, rounded to the nearest integer
+within a floating-point type. Halfway cases are
+rounded to the nearest even value.
+}];
+ let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingMatDims = [];
+}
+
+// Returns the reciprocal of the square root of the specified value,
+// ie 1 / sqrt(x).
+def hlsl_rsqrt : HLSLOneArgBuiltin<"rsqrt", "__builtin_hlsl_elementwise_rsqrt"> {
+ let Doc = [{
+\fn T rsqrt(T x)
+\brief Returns the reciprocal of the square root of the specified value.
+ie 1 / sqrt( \a x).
+\param x The specified input value.
+
+This function uses the following formula: 1 / sqrt(x).
+}];
+ let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingMatDims = [];
+}
+
+// Returns input value, Val, clamped within the range of 0.0f to 1.0f.
+def hlsl_saturate : HLSLOneArgBuiltin<"saturate", "__builtin_hlsl_elementwise_saturate"> {
+ let Doc = [{
+\fn T saturate(T Val)
+\brief Returns input value, \a Val, clamped within the range of 0.0f
+to 1.0f.
+\param Val The input value.
+}];
+ let VaryingTypes = AllFloatTypes;
+ let VaryingMatDims = [];
+}
+
+// Returns -1 if Val is less than zero; 0 if Val equals zero; and 1 if Val is
+// greater than zero.
+def hlsl_sign : HLSLOneArgBuiltin<"sign", "__builtin_hlsl_elementwise_sign"> {
+ let Doc = [{
+\fn T sign(T Val)
+\brief Returns -1 if \a Val is less than zero; 0 if \a Val equals zero; and
+1 if \a Val is greater than zero.
+\param Val The input value.
+}];
+ let ReturnType = VaryingShape<IntTy>;
+ let VaryingTypes = AllNumericTypes;
+ let VaryingMatDims = [];
+}
+
+// Returns the sine of the input value, Val.
+def hlsl_sin : HLSLOneArgBuiltin<"sin", "__builtin_elementwise_sin"> {
+ let Doc = [{
+\fn T sin(T Val)
+\brief Returns the sine of the input value, \a Val.
+\param Val The input value.
+}];
+ let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingMatDims = [];
+}
+
+// Returns the hyperbolic sine of the input value, Val.
+def hlsl_sinh : HLSLOneArgBuiltin<"sinh", "__builtin_elementwise_sinh"> {
+ let Doc = [{
+\fn T sinh(T Val)
+\brief Returns the hyperbolic sine of the input value, \a Val.
+\param Val The input value.
+}];
+ let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingMatDims = [];
+}
// Returns a smooth Hermite interpolation between 0 and 1.
def hlsl_smoothstep : HLSLThreeArgDetail<"smoothstep", "smoothstep_impl"> {
@@ -662,3 +1445,343 @@ between 0 and 1.
let VaryingTypes = [HalfTy, FloatTy];
let VaryingMatDims = [];
}
+
+// Returns the square root of the input value, Val.
+def hlsl_sqrt : HLSLOneArgBuiltin<"sqrt", "__builtin_elementwise_sqrt"> {
+ let Doc = [{
+\fn T sqrt(T Val)
+\brief Returns the square root of the input value, \a Val.
+\param Val The input value.
+}];
+ let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingMatDims = [];
+}
+
+// Returns 1 if the x parameter is greater than or equal to the y parameter;
+// otherwise, 0.
+def hlsl_step : HLSLTwoArgBuiltin<"step", "__builtin_hlsl_step"> {
+ let Doc = [{
+\fn T step(T y, T x)
+\brief Returns 1 if the x parameter is greater than or equal to the y
+parameter; otherwise, 0.
+\param y [in] The first floating-point value to compare.
+\param x [in] The second floating-point value to compare.
+
+Step is based on the following formula: (x >= y) ? 1 : 0
+}];
+ let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingMatDims = [];
+}
+
+// Returns the tangent of the input value, Val.
+def hlsl_tan : HLSLOneArgBuiltin<"tan", "__builtin_elementwise_tan"> {
+ let Doc = [{
+\fn T tan(T Val)
+\brief Returns the tangent of the input value, \a Val.
+\param Val The input value.
+}];
+ let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingMatDims = [];
+}
+
+// Returns the hyperbolic tangent of the input value, Val.
+def hlsl_tanh : HLSLOneArgBuiltin<"tanh", "__builtin_elementwise_tanh"> {
+ let Doc = [{
+\fn T tanh(T Val)
+\brief Returns the hyperbolic tangent of the input value, \a Val.
+\param Val The input value.
+}];
+ let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingMatDims = [];
+}
+
+// Returns the truncated integer value of the input value, Val.
+def hlsl_trunc : HLSLOneArgBuiltin<"trunc", "__builtin_elementwise_trunc"> {
+ let Doc = [{
+\fn T trunc(T Val)
+\brief Returns the truncated integer value of the input value, \a Val.
+\param Val The input value.
+}];
+ let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingMatDims = [];
+}
+
+// Evaluates a value for all active invocations in the group. The result is true
+// if Value is equal for all active invocations in the group.
+def hlsl_wave_active_all_equal :
+ HLSLOneArgBuiltin<"WaveActiveAllEqual",
+ "__builtin_hlsl_wave_active_all_equal"> {
+ let Doc = [{
+\brief Evaluates a value for all active invocations in the group. The
+result is true if Value is equal for all active invocations in the
+group. Otherwise, the result is false.
+\param Value The value to compare with
+\return True if all values across all lanes are equal, false otherwise
+}];
+ let ReturnType = VaryingShape<BoolTy>;
+ let VaryingTypes = [IntTy, UIntTy, FloatTy, Int64Ty, UInt64Ty, DoubleTy];
+ let IsConvergent = 1;
+ let Availability = SM6_0;
+ let VaryingMatDims = [];
+}
+
+// WaveActiveAllEqual — half and 16-bit integer types (no SM6.0 availability;
+// _HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT() is emitted automatically).
+def hlsl_wave_active_all_equal_16bit :
+ HLSLOneArgBuiltin<"WaveActiveAllEqual",
+ "__builtin_hlsl_wave_active_all_equal"> {
+ let ReturnType = VaryingShape<BoolTy>;
+ let VaryingTypes = [HalfTy, Int16Ty, UInt16Ty];
+ let IsConvergent = 1;
+ let VaryingMatDims = [];
+}
+
+// Returns true if the expression is true in all active lanes in the current
+// wave.
+def hlsl_wave_active_all_true :
+ HLSLBuiltin<"WaveActiveAllTrue", "__builtin_hlsl_wave_active_all_true"> {
+ let Doc = [{
+\brief Returns true if the expression is true in all active lanes in the
+current wave.
+\param Val The boolean expression to evaluate.
+\return True if the expression is true in all lanes.
+}];
+ let Args = [Varying];
+ let ReturnType = Varying;
+ let VaryingTypes = [BoolTy];
+ let VaryingScalar = 1;
+ let IsConvergent = 1;
+ let Availability = SM6_0;
+}
+
+// Returns true if the expression is true in any active lane in the current
+// wave.
+def hlsl_wave_active_any_true :
+ HLSLBuiltin<"WaveActiveAnyTrue", "__builtin_hlsl_wave_active_any_true"> {
+ let Doc = [{
+\brief Returns true if the expression is true in any active lane in the
+current wave.
+\param Val The boolean expression to evaluate.
+\return True if the expression is true in any lane.
+}];
+ let Args = [Varying];
+ let ReturnType = Varying;
+ let VaryingTypes = [BoolTy];
+ let VaryingScalar = 1;
+ let IsConvergent = 1;
+ let Availability = SM6_0;
+}
+
+// Returns a uint4 containing a bitmask of the evaluation of the boolean
+// expression for all active lanes in the current wave.
+def hlsl_wave_active_ballot :
+ HLSLBuiltin<"WaveActiveBallot", "__builtin_hlsl_wave_active_ballot"> {
+ let Doc = [{
+\brief Returns a uint4 containing a bitmask of the evaluation of the
+boolean expression for all active lanes in the current wave.
+The least-significant bit corresponds to the lane with index zero.
+The bits corresponding to inactive lanes will be zero. The bits that
+are greater than or equal to WaveGetLaneCount will be zero.
+\param Val The boolean expression to evaluate.
+\return uint4 bitmask
+}];
+ let Args = [Varying];
+ let ReturnType = VectorType<UIntTy, 4>;
+ let VaryingTypes = [BoolTy];
+ let VaryingScalar = 1;
+ let IsConvergent = 1;
+ let Availability = SM6_0;
+}
+
+// Returns the bitwise AND of all values across all active non-helper lanes.
+def hlsl_wave_active_bit_and :
+ HLSLOneArgBuiltin<"WaveActiveBitAnd",
+ "__builtin_hlsl_wave_active_bit_and"> {
+ let VaryingTypes = [UIntTy, UInt64Ty];
+ let IsConvergent = 1;
+ let Availability = SM6_0;
+ let VaryingMatDims = [];
+}
+
+// Returns the bitwise OR of all values across all active non-helper lanes.
+def hlsl_wave_active_bit_or :
+ HLSLOneArgBuiltin<"WaveActiveBitOr",
+ "__builtin_hlsl_wave_active_bit_or"> {
+ let Doc = [{
+\brief Returns the bitwise OR of all the values of <expr> across all active
+non-helper lanes in the current wave, and replicates it back to
+all active non-helper lanes.
+}];
+ let VaryingTypes = [UIntTy, UInt64Ty];
+ let IsConvergent = 1;
+ let Availability = SM6_0;
+ let VaryingMatDims = [];
+}
+
+// Returns the bitwise XOR of all values across all active non-helper lanes.
+def hlsl_wave_active_bit_xor :
+ HLSLOneArgBuiltin<"WaveActiveBitXor",
+ "__builtin_hlsl_wave_active_bit_xor"> {
+ let VaryingTypes = [UIntTy, UInt64Ty];
+ let IsConvergent = 1;
+ let Availability = SM6_0;
+ let VaryingMatDims = [];
+}
+
+// Counts the number of boolean variables which evaluate to true across all
+// active lanes in the current wave.
+def hlsl_wave_active_count_bits :
+ HLSLBuiltin<"WaveActiveCountBits",
+ "__builtin_hlsl_wave_active_count_bits"> {
+ let Doc = [{
+\brief Counts the number of boolean variables which evaluate to true across
+all active lanes in the current wave.
+\param Val The input boolean value.
+\return The number of lanes for which the boolean variable evaluates to
+true, across all active lanes in the current wave.
+}];
+ let Args = [Varying];
+ let ReturnType = VaryingShape<UIntTy>;
+ let VaryingTypes = [BoolTy];
+ let VaryingScalar = 1;
+ let IsConvergent = 1;
+ let Availability = SM6_0;
+}
+
+// Returns the maximum value across all active lanes in the wave.
+def hlsl_wave_active_max :
+ HLSLOneArgBuiltin<"WaveActiveMax", "__builtin_hlsl_wave_active_max"> {
+ let Doc = [{
+\brief Returns the maximum value across all active lanes in the wave.
+\param Val The input value.
+}];
+ let VaryingTypes = AllNumericTypes;
+ let IsConvergent = 1;
+ let VaryingMatDims = [];
+}
+
+// Returns the minimum value across all active lanes in the wave.
+def hlsl_wave_active_min :
+ HLSLOneArgBuiltin<"WaveActiveMin", "__builtin_hlsl_wave_active_min"> {
+ let Doc = [{
+\brief Returns the minimum value across all active lanes in the wave.
+\param Val The input value.
+}];
+ let VaryingTypes = AllNumericTypes;
+ let IsConvergent = 1;
+ let VaryingMatDims = [];
+}
+
+// Returns the product of values across all active lanes in the wave.
+def hlsl_wave_active_product :
+ HLSLOneArgBuiltin<"WaveActiveProduct",
+ "__builtin_hlsl_wave_active_product"> {
+ let Doc = [{
+\brief Returns the product of values across all active lanes in the wave.
+\param Val The input value.
+}];
+ let VaryingTypes = AllNumericTypes;
+ let IsConvergent = 1;
+ let VaryingMatDims = [];
+}
+
+// Returns the sum of values across all active lanes in the wave.
+def hlsl_wave_active_sum :
+ HLSLOneArgBuiltin<"WaveActiveSum", "__builtin_hlsl_wave_active_sum"> {
+ let Doc = [{
+\brief Returns the sum of values across all active lanes in the wave.
+\param Val The input value.
+}];
+ let VaryingTypes = AllNumericTypes;
+ let IsConvergent = 1;
+ let VaryingMatDims = [];
+}
+
+// Returns the number of lanes in the current wave.
+def hlsl_wave_get_lane_count :
+ HLSLBuiltin<"WaveGetLaneCount", "__builtin_hlsl_wave_get_lane_count"> {
+ let Doc = [{
+\brief Returns the number of lanes in the current wave.
+}];
+ let ReturnType = UIntTy;
+ let IsConvergent = 1;
+ let Availability = SM6_0;
+}
+
+// Returns the index of the current lane within the current wave.
+def hlsl_wave_get_lane_index :
+ HLSLBuiltin<"WaveGetLaneIndex", "__builtin_hlsl_wave_get_lane_index"> {
+ let Doc = [{
+\brief Returns the index of the current lane within the current wave.
+}];
+ let ReturnType = UIntTy;
+ let IsConvergent = 1;
+ let Availability = SM6_0;
+}
+
+// Returns true if the current lane is the first active lane in the wave.
+def hlsl_wave_is_first_lane :
+ HLSLBuiltin<"WaveIsFirstLane", "__builtin_hlsl_wave_is_first_lane"> {
+ let Doc = [{
+\brief Returns true if the current lane is the first active lane in the wave.
+}];
+ let ReturnType = BoolTy;
+ let IsConvergent = 1;
+ let Availability = SM6_0;
+}
+
+// Returns the count of bits set to 1 on prior lanes.
+def hlsl_wave_prefix_count_bits :
+ HLSLBuiltin<"WavePrefixCountBits",
+ "__builtin_hlsl_wave_prefix_count_bits"> {
+ let Doc = [{
+\brief Returns the count of bits of Expr set to 1 on prior lanes.
+\param Expr The boolean expression to evaluate.
+\return the count of bits set to 1 on prior lanes.
+}];
+ let Args = [Varying];
+ let ReturnType = VaryingShape<UIntTy>;
+ let VaryingTypes = [BoolTy];
+ let VaryingScalar = 1;
+ let IsConvergent = 1;
+ let Availability = SM6_0;
+}
+
+// Returns the product of values across lanes with smaller indices in the wave.
+def hlsl_wave_prefix_product :
+ HLSLOneArgBuiltin<"WavePrefixProduct", "__builtin_hlsl_wave_prefix_product"> {
+ let Doc = [{
+\brief Returns the product of values across lanes with smaller indices in the wave.
+\param Val The input value.
+}];
+ let VaryingTypes = AllNumericTypes;
+ let IsConvergent = 1;
+ let VaryingMatDims = [];
+}
+
+// Returns the sum of values across lanes with smaller indices in the wave.
+def hlsl_wave_prefix_sum :
+ HLSLOneArgBuiltin<"WavePrefixSum", "__builtin_hlsl_wave_prefix_sum"> {
+ let Doc = [{
+\brief Returns the sum of values across lanes with smaller indices in the wave.
+\param Val The input value.
+}];
+ let VaryingTypes = AllNumericTypes;
+ let IsConvergent = 1;
+ let VaryingMatDims = [];
+}
+
+// Reads the value from the specified lane index in the wave.
+def hlsl_wave_read_lane_at :
+ HLSLTwoArgBuiltin<"WaveReadLaneAt", "__builtin_hlsl_wave_read_lane_at"> {
+ let Doc = [{
+\brief Returns the value of the expression for the given lane index within
+the specified wave.
+\param Val The value to read.
+\param Index The lane index.
+}];
+ let Args = [Varying, UIntTy];
+ let VaryingTypes = AllTypesWithBool;
+ let IsConvergent = 1;
+ let VaryingMatDims = [];
+}
diff --git a/clang/lib/Headers/hlsl/hlsl_alias_intrinsics.h b/clang/lib/Headers/hlsl/hlsl_alias_intrinsics.h
index ea4353b5eb042..26f792d8b932d 100644
--- a/clang/lib/Headers/hlsl/hlsl_alias_intrinsics.h
+++ b/clang/lib/Headers/hlsl/hlsl_alias_intrinsics.h
@@ -42,3879 +42,181 @@ namespace hlsl {
#include "hlsl_alias_intrinsics_gen.inc"
//===----------------------------------------------------------------------===//
-// abs builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn T abs(T Val)
-/// \brief Returns the absolute value of the input value, \a Val.
-/// \param Val The input value.
-
-#ifdef __HLSL_ENABLE_16_BIT
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
-int16_t abs(int16_t);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
-int16_t2 abs(int16_t2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
-int16_t3 abs(int16_t3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
-int16_t4 abs(int16_t4);
-#endif
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
-half abs(half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
-half2 abs(half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
-half3 abs(half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
-half4 abs(half4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
-int abs(int);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
-int2 abs(int2);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
-int3 abs(int3);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
-int4 abs(int4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
-float abs(float);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
-float2 abs(float2);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
-float3 abs(float3);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
-float4 abs(float4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
-int64_t abs(int64_t);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
-int64_t2 abs(int64_t2);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
-int64_t3 abs(int64_t3);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
-int64_t4 abs(int64_t4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
-double abs(double);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
-double2 abs(double2);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
-double3 abs(double3);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
-double4 abs(double4);
-
-//===----------------------------------------------------------------------===//
-// acos builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn T acos(T Val)
-/// \brief Returns the arccosine of the input value, \a Val.
-/// \param Val The input value.
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_acos)
-half acos(half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_acos)
-half2 acos(half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_acos)
-half3 acos(half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_acos)
-half4 acos(half4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_acos)
-float acos(float);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_acos)
-float2 acos(float2);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_acos)
-float3 acos(float3);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_acos)
-float4 acos(float4);
-
-//===----------------------------------------------------------------------===//
-// AddUint64 builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn T AddUint64(T a, T b)
-/// \brief Implements unsigned 64-bit integer addition using pairs of unsigned
-/// 32-bit integers.
-/// \param x [in] The first unsigned 32-bit integer pair(s)
-/// \param y [in] The second unsigned 32-bit integer pair(s)
-///
-/// This function takes one or two pairs (low, high) of unsigned 32-bit integer
-/// values and returns pairs (low, high) of unsigned 32-bit integer
-/// values representing the result of unsigned 64-bit integer addition.
-
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_adduint64)
-uint32_t2 AddUint64(uint32_t2, uint32_t2);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_adduint64)
-uint32_t4 AddUint64(uint32_t4, uint32_t4);
-
-//===----------------------------------------------------------------------===//
-// all builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn bool all(T x)
-/// \brief Returns True if all components of the \a x parameter are non-zero;
-/// otherwise, false. \param x The input value.
-
-#ifdef __HLSL_ENABLE_16_BIT
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
-bool all(int16_t);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
-bool all(int16_t2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
-bool all(int16_t3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
-bool all(int16_t4);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
-bool all(uint16_t);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
-bool all(uint16_t2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
-bool all(uint16_t3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
-bool all(uint16_t4);
-#endif
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
-bool all(half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
-bool all(half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
-bool all(half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
-bool all(half4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
-bool all(bool);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
-bool all(bool2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
-bool all(bool3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
-bool all(bool4);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
-bool all(int);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
-bool all(int2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
-bool all(int3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
-bool all(int4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
-bool all(uint);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
-bool all(uint2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
-bool all(uint3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
-bool all(uint4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
-bool all(float);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
-bool all(float2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
-bool all(float3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
-bool all(float4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
-bool all(int64_t);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
-bool all(int64_t2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
-bool all(int64_t3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
-bool all(int64_t4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
-bool all(uint64_t);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
-bool all(uint64_t2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
-bool all(uint64_t3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
-bool all(uint64_t4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
-bool all(double);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
-bool all(double2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
-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 or matrices elementwise and
-/// produces a bool vector or matrix output.
-
-// 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);
-
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
-bool1x2 and(bool1x2 x, bool1x2 y);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
-bool1x3 and(bool1x3 x, bool1x3 y);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
-bool1x4 and(bool1x4 x, bool1x4 y);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
-bool2x1 and(bool2x1 x, bool2x1 y);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
-bool2x2 and(bool2x2 x, bool2x2 y);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
-bool2x3 and(bool2x3 x, bool2x3 y);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
-bool2x4 and(bool2x4 x, bool2x4 y);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
-bool3x1 and(bool3x1 x, bool3x1 y);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
-bool3x2 and(bool3x2 x, bool3x2 y);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
-bool3x3 and(bool3x3 x, bool3x3 y);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
-bool3x4 and(bool3x4 x, bool3x4 y);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
-bool4x1 and(bool4x1 x, bool4x1 y);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
-bool4x2 and(bool4x2 x, bool4x2 y);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
-bool4x3 and(bool4x3 x, bool4x3 y);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_and)
-bool4x4 and(bool4x4 x, bool4x4 y);
-// clang-format on
-
-//===----------------------------------------------------------------------===//
-// any builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn bool any(T x)
-/// \brief Returns True if any components of the \a x parameter are non-zero;
-/// otherwise, false. \param x The input value.
-
-#ifdef __HLSL_ENABLE_16_BIT
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
-bool any(int16_t);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
-bool any(int16_t2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
-bool any(int16_t3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
-bool any(int16_t4);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
-bool any(uint16_t);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
-bool any(uint16_t2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
-bool any(uint16_t3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
-bool any(uint16_t4);
-#endif
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
-bool any(half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
-bool any(half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
-bool any(half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
-bool any(half4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
-bool any(bool);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
-bool any(bool2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
-bool any(bool3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
-bool any(bool4);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
-bool any(int);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
-bool any(int2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
-bool any(int3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
-bool any(int4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
-bool any(uint);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
-bool any(uint2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
-bool any(uint3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
-bool any(uint4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
-bool any(float);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
-bool any(float2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
-bool any(float3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
-bool any(float4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
-bool any(int64_t);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
-bool any(int64_t2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
-bool any(int64_t3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
-bool any(int64_t4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
-bool any(uint64_t);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
-bool any(uint64_t2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
-bool any(uint64_t3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
-bool any(uint64_t4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
-bool any(double);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
-bool any(double2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
-bool any(double3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
-bool any(double4);
-
-//===----------------------------------------------------------------------===//
-// asdouble builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn double asdouble(uint LowBits, uint HighBits)
-/// \brief Reinterprets a cast value (two 32-bit values) into a double.
-/// \param LowBits The low 32-bit pattern of the input value.
-/// \param HighBits The high 32-bit pattern of the input value.
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_asdouble)
-double asdouble(uint, uint);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_asdouble)
-double2 asdouble(uint2, uint2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_asdouble)
-double3 asdouble(uint3, uint3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_asdouble)
-double4 asdouble(uint4, uint4);
-
-//===----------------------------------------------------------------------===//
-// asin builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn T asin(T Val)
-/// \brief Returns the arcsine of the input value, \a Val.
-/// \param Val The input value.
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_asin)
-half asin(half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_asin)
-half2 asin(half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_asin)
-half3 asin(half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_asin)
-half4 asin(half4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_asin)
-float asin(float);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_asin)
-float2 asin(float2);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_asin)
-float3 asin(float3);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_asin)
-float4 asin(float4);
-
-//===----------------------------------------------------------------------===//
-// atan builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn T atan(T Val)
-/// \brief Returns the arctangent of the input value, \a Val.
-/// \param Val The input value.
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan)
-half atan(half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan)
-half2 atan(half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan)
-half3 atan(half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan)
-half4 atan(half4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan)
-float atan(float);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan)
-float2 atan(float2);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan)
-float3 atan(float3);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan)
-float4 atan(float4);
-
-//===----------------------------------------------------------------------===//
-// atan2 builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn T atan2(T y, T x)
-/// \brief Returns the arctangent of y/x, using the signs of the arguments to
-/// determine the correct quadrant.
-/// \param y The y-coordinate.
-/// \param x The x-coordinate.
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan2)
-half atan2(half y, half x);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan2)
-half2 atan2(half2 y, half2 x);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan2)
-half3 atan2(half3 y, half3 x);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan2)
-half4 atan2(half4 y, half4 x);
-
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan2)
-float atan2(float y, float x);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan2)
-float2 atan2(float2 y, float2 x);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan2)
-float3 atan2(float3 y, float3 x);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan2)
-float4 atan2(float4 y, float4 x);
-
-//===----------------------------------------------------------------------===//
-// ceil builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn T ceil(T Val)
-/// \brief Returns the smallest integer value that is greater than or equal to
-/// the input value, \a Val.
-/// \param Val The input value.
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_ceil)
-half ceil(half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_ceil)
-half2 ceil(half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_ceil)
-half3 ceil(half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_ceil)
-half4 ceil(half4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_ceil)
-float ceil(float);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_ceil)
-float2 ceil(float2);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_ceil)
-float3 ceil(float3);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_ceil)
-float4 ceil(float4);
-
-//===----------------------------------------------------------------------===//
-// clamp builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn T clamp(T X, T Min, T Max)
-/// \brief Clamps the specified value \a X to the specified
-/// minimum ( \a Min) and maximum ( \a Max) range.
-/// \param X A value to clamp.
-/// \param Min The specified minimum range.
-/// \param Max The specified maximum range.
-///
-/// Returns The clamped value for the \a X parameter.
-/// For values of -INF or INF, clamp will behave as expected.
-/// However for values of NaN, the results are undefined.
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
-half clamp(half, half, half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
-half2 clamp(half2, half2, half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
-half3 clamp(half3, half3, half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
-half4 clamp(half4, half4, half4);
-
-#ifdef __HLSL_ENABLE_16_BIT
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
-int16_t clamp(int16_t, int16_t, int16_t);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
-int16_t2 clamp(int16_t2, int16_t2, int16_t2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
-int16_t3 clamp(int16_t3, int16_t3, int16_t3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
-int16_t4 clamp(int16_t4, int16_t4, int16_t4);
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
-uint16_t clamp(uint16_t, uint16_t, uint16_t);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
-uint16_t2 clamp(uint16_t2, uint16_t2, uint16_t2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
-uint16_t3 clamp(uint16_t3, uint16_t3, uint16_t3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
-uint16_t4 clamp(uint16_t4, uint16_t4, uint16_t4);
-#endif
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
-int clamp(int, int, int);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
-int2 clamp(int2, int2, int2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
-int3 clamp(int3, int3, int3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
-int4 clamp(int4, int4, int4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
-uint clamp(uint, uint, uint);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
-uint2 clamp(uint2, uint2, uint2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
-uint3 clamp(uint3, uint3, uint3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
-uint4 clamp(uint4, uint4, uint4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
-int64_t clamp(int64_t, int64_t, int64_t);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
-int64_t2 clamp(int64_t2, int64_t2, int64_t2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
-int64_t3 clamp(int64_t3, int64_t3, int64_t3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
-int64_t4 clamp(int64_t4, int64_t4, int64_t4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
-uint64_t clamp(uint64_t, uint64_t, uint64_t);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
-uint64_t2 clamp(uint64_t2, uint64_t2, uint64_t2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
-uint64_t3 clamp(uint64_t3, uint64_t3, uint64_t3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
-uint64_t4 clamp(uint64_t4, uint64_t4, uint64_t4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
-float clamp(float, float, float);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
-float2 clamp(float2, float2, float2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
-float3 clamp(float3, float3, float3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
-float4 clamp(float4, float4, float4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
-double clamp(double, double, double);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
-double2 clamp(double2, double2, double2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
-double3 clamp(double3, double3, double3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
-double4 clamp(double4, double4, double4);
-
-//===----------------------------------------------------------------------===//
-// clip builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn void clip(T Val)
-/// \brief Discards the current pixel if the specified value is less than zero.
-/// \param Val The input value.
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clip)
-void clip(float);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clip)
-void clip(float2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clip)
-void clip(float3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clip)
-void clip(float4);
-
-//===----------------------------------------------------------------------===//
-// cos builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn T cos(T Val)
-/// \brief Returns the cosine of the input value, \a Val.
-/// \param Val The input value.
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_cos)
-half cos(half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_cos)
-half2 cos(half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_cos)
-half3 cos(half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_cos)
-half4 cos(half4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_cos)
-float cos(float);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_cos)
-float2 cos(float2);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_cos)
-float3 cos(float3);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_cos)
-float4 cos(float4);
-
-//===----------------------------------------------------------------------===//
-// cosh builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn T cosh(T Val)
-/// \brief Returns the hyperbolic cosine of the input value, \a Val.
-/// \param Val The input value.
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_cosh)
-half cosh(half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_cosh)
-half2 cosh(half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_cosh)
-half3 cosh(half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_cosh)
-half4 cosh(half4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_cosh)
-float cosh(float);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_cosh)
-float2 cosh(float2);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_cosh)
-float3 cosh(float3);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_cosh)
-float4 cosh(float4);
-
-//===----------------------------------------------------------------------===//
-// count bits builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn T countbits(T Val)
-/// \brief Return the number of bits (per component) set in the input integer.
-/// \param Val The input value.
-
-#ifdef __HLSL_ENABLE_16_BIT
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-const inline uint countbits(int16_t x) {
- return __builtin_elementwise_popcount(x);
-}
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-const inline uint2 countbits(int16_t2 x) {
- return __builtin_elementwise_popcount(x);
-}
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-const inline uint3 countbits(int16_t3 x) {
- return __builtin_elementwise_popcount(x);
-}
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-const inline uint4 countbits(int16_t4 x) {
- return __builtin_elementwise_popcount(x);
-}
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-const inline uint countbits(uint16_t x) {
- return __builtin_elementwise_popcount(x);
-}
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-const inline uint2 countbits(uint16_t2 x) {
- return __builtin_elementwise_popcount(x);
-}
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-const inline uint3 countbits(uint16_t3 x) {
- return __builtin_elementwise_popcount(x);
-}
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-const inline uint4 countbits(uint16_t4 x) {
- return __builtin_elementwise_popcount(x);
-}
-#endif
-
-const inline uint countbits(int x) { return __builtin_elementwise_popcount(x); }
-const inline uint2 countbits(int2 x) {
- return __builtin_elementwise_popcount(x);
-}
-const inline uint3 countbits(int3 x) {
- return __builtin_elementwise_popcount(x);
-}
-const inline uint4 countbits(int4 x) {
- return __builtin_elementwise_popcount(x);
-}
-
-const inline uint countbits(uint x) {
- return __builtin_elementwise_popcount(x);
-}
-const inline uint2 countbits(uint2 x) {
- return __builtin_elementwise_popcount(x);
-}
-const inline uint3 countbits(uint3 x) {
- return __builtin_elementwise_popcount(x);
-}
-const inline uint4 countbits(uint4 x) {
- return __builtin_elementwise_popcount(x);
-}
-
-const inline uint countbits(int64_t x) {
- return __builtin_elementwise_popcount(x);
-}
-const inline uint2 countbits(int64_t2 x) {
- return __builtin_elementwise_popcount(x);
-}
-const inline uint3 countbits(int64_t3 x) {
- return __builtin_elementwise_popcount(x);
-}
-const inline uint4 countbits(int64_t4 x) {
- return __builtin_elementwise_popcount(x);
-}
-
-const inline uint countbits(uint64_t x) {
- return __builtin_elementwise_popcount(x);
-}
-const inline uint2 countbits(uint64_t2 x) {
- return __builtin_elementwise_popcount(x);
-}
-const inline uint3 countbits(uint64_t3 x) {
- return __builtin_elementwise_popcount(x);
-}
-const inline uint4 countbits(uint64_t4 x) {
- return __builtin_elementwise_popcount(x);
-}
-
-//===----------------------------------------------------------------------===//
-// degrees builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn T degrees(T x)
-/// \brief Converts the specified value from radians to degrees.
-/// \param x The specified input value.
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_degrees)
-half degrees(half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_degrees)
-half2 degrees(half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_degrees)
-half3 degrees(half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_degrees)
-half4 degrees(half4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_degrees)
-float degrees(float);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_degrees)
-float2 degrees(float2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_degrees)
-float3 degrees(float3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_degrees)
-float4 degrees(float4);
-
-//===----------------------------------------------------------------------===//
-// dot product builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn K dot(T X, T Y)
-/// \brief Return the dot product (a scalar value) of \a X and \a Y.
-/// \param X The X input value.
-/// \param Y The Y input value.
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-half dot(half, half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-half dot(half2, half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-half dot(half3, half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-half dot(half4, half4);
-
-#ifdef __HLSL_ENABLE_16_BIT
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-int16_t dot(int16_t, int16_t);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-int16_t dot(int16_t2, int16_t2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-int16_t dot(int16_t3, int16_t3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-int16_t dot(int16_t4, int16_t4);
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-uint16_t dot(uint16_t, uint16_t);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-uint16_t dot(uint16_t2, uint16_t2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-uint16_t dot(uint16_t3, uint16_t3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-uint16_t dot(uint16_t4, uint16_t4);
-#endif
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-float dot(float, float);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-float dot(float2, float2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-float dot(float3, float3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-float dot(float4, float4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-double dot(double, double);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-int dot(int, int);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-int dot(int2, int2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-int dot(int3, int3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-int dot(int4, int4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-uint dot(uint, uint);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-uint dot(uint2, uint2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-uint dot(uint3, uint3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-uint dot(uint4, uint4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-int64_t dot(int64_t, int64_t);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-int64_t dot(int64_t2, int64_t2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-int64_t dot(int64_t3, int64_t3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-int64_t dot(int64_t4, int64_t4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-uint64_t dot(uint64_t, uint64_t);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-uint64_t dot(uint64_t2, uint64_t2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-uint64_t dot(uint64_t3, uint64_t3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
-uint64_t dot(uint64_t4, uint64_t4);
-
-//===----------------------------------------------------------------------===//
-// dot4add builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn int dot4add_i8packed(uint A, uint B, int C)
-
-_HLSL_AVAILABILITY(shadermodel, 6.4)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot4add_i8packed)
-int dot4add_i8packed(uint, uint, int);
-
-/// \fn uint dot4add_u8packed(uint A, uint B, uint C)
-
-_HLSL_AVAILABILITY(shadermodel, 6.4)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot4add_u8packed)
-uint dot4add_u8packed(uint, uint, uint);
-
-//===----------------------------------------------------------------------===//
-// exp builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn T exp(T x)
-/// \brief Returns the base-e exponential, or \a e**x, of the specified value.
-/// \param x The specified input value.
-///
-/// The return value is the base-e exponential of the \a x parameter.
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_exp)
-half exp(half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_exp)
-half2 exp(half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_exp)
-half3 exp(half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_exp)
-half4 exp(half4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_exp)
-float exp(float);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_exp)
-float2 exp(float2);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_exp)
-float3 exp(float3);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_exp)
-float4 exp(float4);
-
-//===----------------------------------------------------------------------===//
-// exp2 builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn T exp2(T x)
-/// \brief Returns the base 2 exponential, or \a 2**x, of the specified value.
-/// \param x The specified input value.
-///
-/// The base 2 exponential of the \a x parameter.
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_exp2)
-half exp2(half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_exp2)
-half2 exp2(half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_exp2)
-half3 exp2(half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_exp2)
-half4 exp2(half4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_exp2)
-float exp2(float);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_exp2)
-float2 exp2(float2);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_exp2)
-float3 exp2(float3);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_exp2)
-float4 exp2(float4);
-
-//===----------------------------------------------------------------------===//
-// f16tof32 builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn float f16tof32(uint x)
-/// \brief Returns the half value stored in the low 16 bits of the uint arg
-/// converted to a float.
-/// \param x The uint containing two half values.
-///
-/// The float value of the half value found in the low 16 bits of the \a xi
-/// parameter.
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_f16tof32)
-float f16tof32(uint);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_f16tof32)
-float2 f16tof32(uint2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_f16tof32)
-float3 f16tof32(uint3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_f16tof32)
-float4 f16tof32(uint4);
-
-//===----------------------------------------------------------------------===//
-// f32tof16 builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn uint f32tof16(float x)
-/// \brief Returns the float arg value converted to half in the low 16 bits of
-/// the uint return value
-/// \param x The float to be converted to half.
-///
-/// The return value is a uint containing the converted half value in the low
-/// 16 bits.
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_f32tof16)
-uint f32tof16(float);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_f32tof16)
-uint2 f32tof16(float2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_f32tof16)
-uint3 f32tof16(float3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_f32tof16)
-uint4 f32tof16(float4);
-
-//===----------------------------------------------------------------------===//
-// firstbitlow builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn T firstbitlow(T Val)
-/// \brief Returns the location of the first set bit starting from the lowest
-/// order bit and working upward, per component.
-/// \param Val the input value.
-
-#ifdef __HLSL_ENABLE_16_BIT
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbitlow)
-uint firstbitlow(int16_t);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbitlow)
-uint2 firstbitlow(int16_t2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbitlow)
-uint3 firstbitlow(int16_t3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbitlow)
-uint4 firstbitlow(int16_t4);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbitlow)
-uint firstbitlow(uint16_t);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbitlow)
-uint2 firstbitlow(uint16_t2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbitlow)
-uint3 firstbitlow(uint16_t3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbitlow)
-uint4 firstbitlow(uint16_t4);
-#endif
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbitlow)
-uint firstbitlow(int);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbitlow)
-uint2 firstbitlow(int2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbitlow)
-uint3 firstbitlow(int3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbitlow)
-uint4 firstbitlow(int4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbitlow)
-uint firstbitlow(uint);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbitlow)
-uint2 firstbitlow(uint2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbitlow)
-uint3 firstbitlow(uint3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbitlow)
-uint4 firstbitlow(uint4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbitlow)
-uint firstbitlow(int64_t);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbitlow)
-uint2 firstbitlow(int64_t2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbitlow)
-uint3 firstbitlow(int64_t3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbitlow)
-uint4 firstbitlow(int64_t4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbitlow)
-uint firstbitlow(uint64_t);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbitlow)
-uint2 firstbitlow(uint64_t2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbitlow)
-uint3 firstbitlow(uint64_t3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbitlow)
-uint4 firstbitlow(uint64_t4);
-
-//===----------------------------------------------------------------------===//
-// floor builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn T floor(T Val)
-/// \brief Returns the largest integer that is less than or equal to the input
-/// value, \a Val.
-/// \param Val The input value.
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_floor)
-half floor(half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_floor)
-half2 floor(half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_floor)
-half3 floor(half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_floor)
-half4 floor(half4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_floor)
-float floor(float);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_floor)
-float2 floor(float2);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_floor)
-float3 floor(float3);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_floor)
-float4 floor(float4);
-
-//===----------------------------------------------------------------------===//
-// frac builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn T frac(T x)
-/// \brief Returns the fractional (or decimal) part of x. \a x parameter.
-/// \param x The specified input value.
-///
-/// If \a the return value is greater than or equal to 0 and less than 1.
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_frac)
-half frac(half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_frac)
-half2 frac(half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_frac)
-half3 frac(half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_frac)
-half4 frac(half4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_frac)
-float frac(float);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_frac)
-float2 frac(float2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_frac)
-float3 frac(float3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_frac)
-float4 frac(float4);
-
-//===----------------------------------------------------------------------===//
-// isinf builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn T isinf(T x)
-/// \brief Determines if the specified value \a x is infinite.
-/// \param x The specified input value.
-///
-/// Returns a value of the same size as the input, with a value set
-/// to True if the x parameter is +INF or -INF. Otherwise, False.
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_isinf)
-bool isinf(half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_isinf)
-bool2 isinf(half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_isinf)
-bool3 isinf(half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_isinf)
-bool4 isinf(half4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_isinf)
-bool isinf(float);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_isinf)
-bool2 isinf(float2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_isinf)
-bool3 isinf(float3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_isinf)
-bool4 isinf(float4);
-
-//===----------------------------------------------------------------------===//
-// isnan builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn T isnan(T x)
-/// \brief Determines if the specified value \a x is Not a Number.
-/// \param x The specified input value.
-///
-/// Returns a value of the same size as the input, with a value set
-/// to True if the x parameter is NaN or QNaN. Otherwise, False.
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_isnan)
-bool isnan(half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_isnan)
-bool2 isnan(half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_isnan)
-bool3 isnan(half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_isnan)
-bool4 isnan(half4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_isnan)
-bool isnan(float);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_isnan)
-bool2 isnan(float2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_isnan)
-bool3 isnan(float3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_isnan)
-bool4 isnan(float4);
-
-//===----------------------------------------------------------------------===//
-// lerp builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn T lerp(T x, T y, T s)
-/// \brief Returns the linear interpolation of x to y by s.
-/// \param x [in] The first-floating point value.
-/// \param y [in] The second-floating point value.
-/// \param s [in] A value that linearly interpolates between the x parameter and
-/// the y parameter.
-///
-/// Linear interpolation is based on the following formula: x*(1-s) + y*s which
-/// can equivalently be written as x + s(y-x).
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_lerp)
-half lerp(half, half, half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_lerp)
-half2 lerp(half2, half2, half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_lerp)
-half3 lerp(half3, half3, half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_lerp)
-half4 lerp(half4, half4, half4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_lerp)
-float lerp(float, float, float);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_lerp)
-float2 lerp(float2, float2, float2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_lerp)
-float3 lerp(float3, float3, float3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_lerp)
-float4 lerp(float4, float4, float4);
-
-//===----------------------------------------------------------------------===//
-// log builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn T log(T Val)
-/// \brief The base-e logarithm of the input value, \a Val parameter.
-/// \param Val The input value.
-///
-/// If \a Val is negative, this result is undefined. If \a Val is 0, this
-/// function returns negative infinity.
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log)
-half log(half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log)
-half2 log(half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log)
-half3 log(half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log)
-half4 log(half4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log)
-float log(float);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log)
-float2 log(float2);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log)
-float3 log(float3);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log)
-float4 log(float4);
-
-//===----------------------------------------------------------------------===//
-// log10 builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn T log10(T Val)
-/// \brief The base-10 logarithm of the input value, \a Val parameter.
-/// \param Val The input value.
-///
-/// If \a Val is negative, this result is undefined. If \a Val is 0, this
-/// function returns negative infinity.
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log10)
-half log10(half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log10)
-half2 log10(half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log10)
-half3 log10(half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log10)
-half4 log10(half4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log10)
-float log10(float);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log10)
-float2 log10(float2);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log10)
-float3 log10(float3);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log10)
-float4 log10(float4);
-
-//===----------------------------------------------------------------------===//
-// log2 builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn T log2(T Val)
-/// \brief The base-2 logarithm of the input value, \a Val parameter.
-/// \param Val The input value.
-///
-/// If \a Val is negative, this result is undefined. If \a Val is 0, this
-/// function returns negative infinity.
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log2)
-half log2(half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log2)
-half2 log2(half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log2)
-half3 log2(half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log2)
-half4 log2(half4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log2)
-float log2(float);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log2)
-float2 log2(float2);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log2)
-float3 log2(float3);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log2)
-float4 log2(float4);
-
-//===----------------------------------------------------------------------===//
-// mad builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn T mad(T M, T A, T B)
-/// \brief The result of \a M * \a A + \a B.
-/// \param M The multiplication value.
-/// \param A The first addition value.
-/// \param B The second addition value.
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
-half mad(half, half, half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
-half2 mad(half2, half2, half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
-half3 mad(half3, half3, half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
-half4 mad(half4, half4, half4);
-
-#ifdef __HLSL_ENABLE_16_BIT
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
-int16_t mad(int16_t, int16_t, int16_t);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
-int16_t2 mad(int16_t2, int16_t2, int16_t2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
-int16_t3 mad(int16_t3, int16_t3, int16_t3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
-int16_t4 mad(int16_t4, int16_t4, int16_t4);
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
-uint16_t mad(uint16_t, uint16_t, uint16_t);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
-uint16_t2 mad(uint16_t2, uint16_t2, uint16_t2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
-uint16_t3 mad(uint16_t3, uint16_t3, uint16_t3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
-uint16_t4 mad(uint16_t4, uint16_t4, uint16_t4);
-#endif
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
-int mad(int, int, int);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
-int2 mad(int2, int2, int2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
-int3 mad(int3, int3, int3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
-int4 mad(int4, int4, int4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
-uint mad(uint, uint, uint);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
-uint2 mad(uint2, uint2, uint2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
-uint3 mad(uint3, uint3, uint3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
-uint4 mad(uint4, uint4, uint4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
-int64_t mad(int64_t, int64_t, int64_t);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
-int64_t2 mad(int64_t2, int64_t2, int64_t2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
-int64_t3 mad(int64_t3, int64_t3, int64_t3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
-int64_t4 mad(int64_t4, int64_t4, int64_t4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
-uint64_t mad(uint64_t, uint64_t, uint64_t);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
-uint64_t2 mad(uint64_t2, uint64_t2, uint64_t2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
-uint64_t3 mad(uint64_t3, uint64_t3, uint64_t3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
-uint64_t4 mad(uint64_t4, uint64_t4, uint64_t4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
-float mad(float, float, float);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
-float2 mad(float2, float2, float2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
-float3 mad(float3, float3, float3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
-float4 mad(float4, float4, float4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
-double mad(double, double, double);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
-double2 mad(double2, double2, double2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
-double3 mad(double3, double3, double3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
-double4 mad(double4, double4, double4);
-
-//===----------------------------------------------------------------------===//
-// max builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn T max(T X, T Y)
-/// \brief Return the greater of \a X and \a Y.
-/// \param X The X input value.
-/// \param Y The Y input value.
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
-half max(half, half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
-half2 max(half2, half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
-half3 max(half3, half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
-half4 max(half4, half4);
-
-#ifdef __HLSL_ENABLE_16_BIT
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
-int16_t max(int16_t, int16_t);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
-int16_t2 max(int16_t2, int16_t2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
-int16_t3 max(int16_t3, int16_t3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
-int16_t4 max(int16_t4, int16_t4);
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
-uint16_t max(uint16_t, uint16_t);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
-uint16_t2 max(uint16_t2, uint16_t2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
-uint16_t3 max(uint16_t3, uint16_t3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
-uint16_t4 max(uint16_t4, uint16_t4);
-#endif
-
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
-int max(int, int);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
-int2 max(int2, int2);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
-int3 max(int3, int3);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
-int4 max(int4, int4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
-uint max(uint, uint);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
-uint2 max(uint2, uint2);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
-uint3 max(uint3, uint3);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
-uint4 max(uint4, uint4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
-int64_t max(int64_t, int64_t);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
-int64_t2 max(int64_t2, int64_t2);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
-int64_t3 max(int64_t3, int64_t3);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
-int64_t4 max(int64_t4, int64_t4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
-uint64_t max(uint64_t, uint64_t);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
-uint64_t2 max(uint64_t2, uint64_t2);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
-uint64_t3 max(uint64_t3, uint64_t3);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
-uint64_t4 max(uint64_t4, uint64_t4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
-float max(float, float);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
-float2 max(float2, float2);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
-float3 max(float3, float3);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
-float4 max(float4, float4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
-double max(double, double);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
-double2 max(double2, double2);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
-double3 max(double3, double3);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
-double4 max(double4, double4);
-
-//===----------------------------------------------------------------------===//
-// min builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn T min(T X, T Y)
-/// \brief Return the lesser of \a X and \a Y.
-/// \param X The X input value.
-/// \param Y The Y input value.
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
-half min(half, half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
-half2 min(half2, half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
-half3 min(half3, half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
-half4 min(half4, half4);
-
-#ifdef __HLSL_ENABLE_16_BIT
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
-int16_t min(int16_t, int16_t);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
-int16_t2 min(int16_t2, int16_t2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
-int16_t3 min(int16_t3, int16_t3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
-int16_t4 min(int16_t4, int16_t4);
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
-uint16_t min(uint16_t, uint16_t);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
-uint16_t2 min(uint16_t2, uint16_t2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
-uint16_t3 min(uint16_t3, uint16_t3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
-uint16_t4 min(uint16_t4, uint16_t4);
-#endif
-
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
-int min(int, int);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
-int2 min(int2, int2);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
-int3 min(int3, int3);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
-int4 min(int4, int4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
-uint min(uint, uint);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
-uint2 min(uint2, uint2);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
-uint3 min(uint3, uint3);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
-uint4 min(uint4, uint4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
-float min(float, float);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
-float2 min(float2, float2);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
-float3 min(float3, float3);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
-float4 min(float4, float4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
-int64_t min(int64_t, int64_t);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
-int64_t2 min(int64_t2, int64_t2);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
-int64_t3 min(int64_t3, int64_t3);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
-int64_t4 min(int64_t4, int64_t4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
-uint64_t min(uint64_t, uint64_t);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
-uint64_t2 min(uint64_t2, uint64_t2);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
-uint64_t3 min(uint64_t3, uint64_t3);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
-uint64_t4 min(uint64_t4, uint64_t4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
-double min(double, double);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
-double2 min(double2, double2);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
-double3 min(double3, double3);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
-double4 min(double4, double4);
-
-//===----------------------------------------------------------------------===//
-// mul builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn R mul(X x, Y y)
-/// \brief Multiplies x and y using matrix math.
-/// \param x [in] The first input value. If x is a vector, it is treated as a
-/// row vector.
-/// \param y [in] The second input value. If y is a vector, it is treated as a
-/// column vector.
-///
-/// The inner dimension x-columns and y-rows must be equal. The result has the
-/// dimension x-rows x y-columns. When both x and y are vectors, the result is
-/// a dot product (scalar). Scalar operands are multiplied element-wise.
-///
-/// This function supports 9 overloaded forms:
-/// 1. scalar * scalar -> scalar
-/// 2. scalar * vector -> vector
-/// 3. scalar * matrix -> matrix
-/// 4. vector * scalar -> vector
-/// 5. vector * vector -> scalar (dot product)
-/// 6. vector * matrix -> vector
-/// 7. matrix * scalar -> matrix
-/// 8. matrix * vector -> vector
-/// 9. matrix * matrix -> matrix
-
-// Cases 1, 2, 3, 4, 5, and 7 of mul are defined in hlsl_intrinsics.h as
-// header-only implementations because they are elementwise operations and dot
-// products easily expressed in HLSL.
-
-// Cases 6, 8, and 9 are defined below to alias the mul builtin so that they can
-// be lowered to the llvm.matrix.multiply intrinsic which is not exposed
-// directly to HLSL.
-
-// Case 6: vector * matrix -> vector
-template <int R, int C>
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mul) vector<half, C> mul(vector<half, R>,
- matrix<half, R, C>);
-
-template <typename T, int R, int C>
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mul)
-vector<T, C> mul(vector<T, R>, matrix<T, R, C>);
-
-// Case 8: matrix * vector -> vector
-template <int R, int C>
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mul) vector<half, R> mul(matrix<half, R, C>,
- vector<half, C>);
-
-template <typename T, int R, int C>
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mul)
-vector<T, R> mul(matrix<T, R, C>, vector<T, C>);
-
-// Case 9: matrix * matrix -> matrix
-template <int R, int K, int C>
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mul) matrix<half, R, C> mul(
- matrix<half, R, K>, matrix<half, K, C>);
-
-template <typename T, int R, int K, int C>
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mul)
-matrix<T, R, C> mul(matrix<T, R, K>, matrix<T, K, C>);
-
-//===----------------------------------------------------------------------===//
-// transpose builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn matrix<T, C, R> transpose(matrix<T, R, C> x)
-/// \brief Returns the transpose of the input matrix.
-/// \param x [in] The input matrix.
-
-template <int R, int C>
-_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_transpose) matrix<half, C, R> transpose(
- matrix<half, R, C>);
-
-template <typename T, int R, int C>
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_transpose)
-matrix<T, C, R> transpose(matrix<T, R, C>);
-
-//===----------------------------------------------------------------------===//
-// normalize builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn T normalize(T x)
-/// \brief Returns the normalized unit vector of the specified floating-point
-/// vector. \param x [in] The vector of floats.
-///
-/// Normalize is based on the following formula: x / length(x).
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_normalize)
-half normalize(half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_normalize)
-half2 normalize(half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_normalize)
-half3 normalize(half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_normalize)
-half4 normalize(half4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_normalize)
-float normalize(float);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_normalize)
-float2 normalize(float2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_normalize)
-float3 normalize(float3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_normalize)
-float4 normalize(float4);
-
-//===----------------------------------------------------------------------===//
-// NonUniformResourceIndex builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn uint NonUniformResourceIndex(uint I)
-/// \brief A compiler hint to indicate that a resource index varies across
-/// threads within a wave (i.e., it is non-uniform).
-/// \param I [in] Resource array index.
-///
-/// The return value is the \a I parameter.
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_resource_nonuniformindex)
-uint NonUniformResourceIndex(uint);
-
-//===----------------------------------------------------------------------===//
-// or builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn bool or(bool x, bool y)
-/// \brief Logically ors two boolean vectors or matrices elementwise and
-/// produces a bool vector or matrix output.
-
-// 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_or)
-bool or(bool, bool);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_or)
-bool2 or(bool2, bool2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_or)
-bool3 or(bool3, bool3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_or)
-bool4 or(bool4, bool4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_or)
-bool1x2 or(bool1x2 x, bool1x2 y);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_or)
-bool1x3 or(bool1x3 x, bool1x3 y);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_or)
-bool1x4 or(bool1x4 x, bool1x4 y);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_or)
-bool2x1 or(bool2x1 x, bool2x1 y);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_or)
-bool2x2 or(bool2x2 x, bool2x2 y);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_or)
-bool2x3 or(bool2x3 x, bool2x3 y);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_or)
-bool2x4 or(bool2x4 x, bool2x4 y);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_or)
-bool3x1 or(bool3x1 x, bool3x1 y);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_or)
-bool3x2 or(bool3x2 x, bool3x2 y);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_or)
-bool3x3 or(bool3x3 x, bool3x3 y);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_or)
-bool3x4 or(bool3x4 x, bool3x4 y);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_or)
-bool4x1 or(bool4x1 x, bool4x1 y);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_or)
-bool4x2 or(bool4x2 x, bool4x2 y);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_or)
-bool4x3 or(bool4x3 x, bool4x3 y);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_or)
-bool4x4 or(bool4x4 x, bool4x4 y);
-// clang-format on
-
-//===----------------------------------------------------------------------===//
-// pow builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn T pow(T Val, T Pow)
-/// \brief Return the value \a Val, raised to the power \a Pow.
-/// \param Val The input value.
-/// \param Pow The specified power.
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_pow)
-half pow(half, half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_pow)
-half2 pow(half2, half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_pow)
-half3 pow(half3, half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_pow)
-half4 pow(half4, half4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_pow)
-float pow(float, float);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_pow)
-float2 pow(float2, float2);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_pow)
-float3 pow(float3, float3);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_pow)
-float4 pow(float4, float4);
-
-//===----------------------------------------------------------------------===//
-// reversebits builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn T reversebits(T Val)
-/// \brief Return the value \a Val with the bit order reversed.
-/// \param Val The input value.
-
-#ifdef __HLSL_ENABLE_16_BIT
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_bitreverse)
-uint16_t reversebits(uint16_t);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_bitreverse)
-uint16_t2 reversebits(uint16_t2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_bitreverse)
-uint16_t3 reversebits(uint16_t3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_bitreverse)
-uint16_t4 reversebits(uint16_t4);
-#endif
-
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_bitreverse)
-uint reversebits(uint);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_bitreverse)
-uint2 reversebits(uint2);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_bitreverse)
-uint3 reversebits(uint3);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_bitreverse)
-uint4 reversebits(uint4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_bitreverse)
-uint64_t reversebits(uint64_t);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_bitreverse)
-uint64_t2 reversebits(uint64_t2);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_bitreverse)
-uint64_t3 reversebits(uint64_t3);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_bitreverse)
-uint64_t4 reversebits(uint64_t4);
-
-//===----------------------------------------------------------------------===//
-// cross builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn T cross(T x, T y)
-/// \brief Returns the cross product of two floating-point, 3D vectors.
-/// \param x [in] The first floating-point, 3D vector.
-/// \param y [in] The second floating-point, 3D vector.
-///
-/// Result is the cross product of x and y, i.e., the resulting
-/// components are, in order :
-/// x[1] * y[2] - y[1] * x[2]
-/// x[2] * y[0] - y[2] * x[0]
-/// x[0] * y[1] - y[0] * x[1]
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_crossf16)
-half3 cross(half3, half3);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_crossf32)
-float3 cross(float3, float3);
-
-//===----------------------------------------------------------------------===//
-// rcp builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn T rcp(T x)
-/// \brief Calculates a fast, approximate, per-component reciprocal ie 1 / \a x.
-/// \param x The specified input value.
-///
-/// The return value is the reciprocal of the \a x parameter.
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rcp)
-half rcp(half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rcp)
-half2 rcp(half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rcp)
-half3 rcp(half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rcp)
-half4 rcp(half4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rcp)
-float rcp(float);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rcp)
-float2 rcp(float2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rcp)
-float3 rcp(float3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rcp)
-float4 rcp(float4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rcp)
-double rcp(double);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rcp)
-double2 rcp(double2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rcp)
-double3 rcp(double3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rcp)
-double4 rcp(double4);
-
-//===----------------------------------------------------------------------===//
-// rsqrt builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn T rsqrt(T x)
-/// \brief Returns the reciprocal of the square root of the specified value.
-/// ie 1 / sqrt( \a x).
-/// \param x The specified input value.
-///
-/// This function uses the following formula: 1 / sqrt(x).
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rsqrt)
-half rsqrt(half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rsqrt)
-half2 rsqrt(half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rsqrt)
-half3 rsqrt(half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rsqrt)
-half4 rsqrt(half4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rsqrt)
-float rsqrt(float);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rsqrt)
-float2 rsqrt(float2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rsqrt)
-float3 rsqrt(float3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rsqrt)
-float4 rsqrt(float4);
-
-//===----------------------------------------------------------------------===//
-// round builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn T round(T x)
-/// \brief Rounds the specified value \a x to the nearest integer.
-/// \param x The specified input value.
-///
-/// The return value is the \a x parameter, rounded to the nearest integer
-/// within a floating-point type. Halfway cases are
-/// rounded to the nearest even value.
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_roundeven)
-half round(half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_roundeven)
-half2 round(half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_roundeven)
-half3 round(half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_roundeven)
-half4 round(half4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_roundeven)
-float round(float);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_roundeven)
-float2 round(float2);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_roundeven)
-float3 round(float3);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_roundeven)
-float4 round(float4);
-
-//===----------------------------------------------------------------------===//
-// saturate builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn T saturate(T Val)
-/// \brief Returns input value, \a Val, clamped within the range of 0.0f
-/// to 1.0f. \param Val The input value.
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_saturate)
-half saturate(half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_saturate)
-half2 saturate(half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_saturate)
-half3 saturate(half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_saturate)
-half4 saturate(half4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_saturate)
-float saturate(float);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_saturate)
-float2 saturate(float2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_saturate)
-float3 saturate(float3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_saturate)
-float4 saturate(float4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_saturate)
-double saturate(double);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_saturate)
-double2 saturate(double2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_saturate)
-double3 saturate(double3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_saturate)
-double4 saturate(double4);
-
-//===----------------------------------------------------------------------===//
-// select builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn T select(bool Cond, T TrueVal, T FalseVal)
-/// \brief ternary operator.
-/// \param Cond The Condition input value.
-/// \param TrueVal The Value returned if Cond is true.
-/// \param FalseVal The Value returned if Cond is false.
-
-template <typename T>
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_select)
-T select(bool, T, T);
-
-/// \fn vector<T,Sz> select(vector<bool,Sz> Conds, vector<T,Sz> TrueVals,
-/// vector<T,Sz> FalseVals)
-/// \brief ternary operator for vectors. All vectors must be the same size.
-/// \param Conds The Condition input values.
-/// \param TrueVals The vector values are chosen from when conditions are true.
-/// \param FalseVals The vector values are chosen from when conditions are
-/// false.
-
-template <typename T>
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_select)
-vector<T, 2> select(vector<bool, 2>, vector<T, 2>, vector<T, 2>);
-
-template <typename T>
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_select)
-vector<T, 3> select(vector<bool, 3>, vector<T, 3>, vector<T, 3>);
-
-template <typename T>
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_select)
-vector<T, 4> select(vector<bool, 4>, vector<T, 4>, vector<T, 4>);
-
-/// \fn vector<T,Sz> select(vector<bool,Sz> Conds, T TrueVal,
-/// vector<T,Sz> FalseVals)
-/// \brief ternary operator for vectors. All vectors must be the same size.
-/// \param Conds The Condition input values.
-/// \param TrueVal The scalar value to splat from when conditions are true.
-/// \param FalseVals The vector values are chosen from when conditions are
-/// false.
-
-template <typename T>
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_select)
-vector<T, 2> select(vector<bool, 2>, T, vector<T, 2>);
-
-template <typename T>
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_select)
-vector<T, 3> select(vector<bool, 3>, T, vector<T, 3>);
-
-template <typename T>
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_select)
-vector<T, 4> select(vector<bool, 4>, T, vector<T, 4>);
-
-/// \fn vector<T,Sz> select(vector<bool,Sz> Conds, vector<T,Sz> TrueVals,
-/// T FalseVal)
-/// \brief ternary operator for vectors. All vectors must be the same size.
-/// \param Conds The Condition input values.
-/// \param TrueVals The vector values are chosen from when conditions are true.
-/// \param FalseVal The scalar value to splat from when conditions are false.
-
-template <typename T>
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_select)
-vector<T, 2> select(vector<bool, 2>, vector<T, 2>, T);
-
-template <typename T>
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_select)
-vector<T, 3> select(vector<bool, 3>, vector<T, 3>, T);
-
-template <typename T>
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_select)
-vector<T, 4> select(vector<bool, 4>, vector<T, 4>, T);
-
-/// \fn vector<T,Sz> select(vector<bool,Sz> Conds, vector<T,Sz> TrueVals,
-/// T FalseVal)
-/// \brief ternary operator for vectors. All vectors must be the same size.
-/// \param Conds The Condition input values.
-/// \param TrueVal The scalar value to splat from when conditions are true.
-/// \param FalseVal The scalar value to splat from when conditions are false.
-
-template <typename T>
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_select)
-__detail::enable_if_t<__detail::is_arithmetic<T>::Value, vector<T, 2>> select(
- vector<bool, 2>, T, T);
-
-template <typename T>
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_select)
-__detail::enable_if_t<__detail::is_arithmetic<T>::Value, vector<T, 3>> select(
- vector<bool, 3>, T, T);
-
-template <typename T>
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_select)
-__detail::enable_if_t<__detail::is_arithmetic<T>::Value, vector<T, 4>> select(
- vector<bool, 4>, T, T);
-
-//===----------------------------------------------------------------------===//
-// sin builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn T sin(T Val)
-/// \brief Returns the sine of the input value, \a Val.
-/// \param Val The input value.
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sin)
-half sin(half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sin)
-half2 sin(half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sin)
-half3 sin(half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sin)
-half4 sin(half4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sin)
-float sin(float);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sin)
-float2 sin(float2);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sin)
-float3 sin(float3);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sin)
-float4 sin(float4);
-
-//===----------------------------------------------------------------------===//
-// sinh builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn T sinh(T Val)
-/// \brief Returns the hyperbolic sine of the input value, \a Val.
-/// \param Val The input value.
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sinh)
-half sinh(half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sinh)
-half2 sinh(half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sinh)
-half3 sinh(half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sinh)
-half4 sinh(half4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sinh)
-float sinh(float);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sinh)
-float2 sinh(float2);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sinh)
-float3 sinh(float3);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sinh)
-float4 sinh(float4);
-
-//===----------------------------------------------------------------------===//
-// sqrt builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn T sqrt(T Val)
-/// \brief Returns the square root of the input value, \a Val.
-/// \param Val The input value.
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sqrt)
-half sqrt(half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sqrt)
-half2 sqrt(half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sqrt)
-half3 sqrt(half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sqrt)
-half4 sqrt(half4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sqrt)
-float sqrt(float);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sqrt)
-float2 sqrt(float2);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sqrt)
-float3 sqrt(float3);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sqrt)
-float4 sqrt(float4);
-
-//===----------------------------------------------------------------------===//
-// step builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn T step(T y, T x)
-/// \brief Returns 1 if the x parameter is greater than or equal to the y
-/// parameter; otherwise, 0. vector. \param y [in] The first floating-point
-/// value to compare. \param x [in] The second floating-point value to compare.
-///
-/// Step is based on the following formula: (x >= y) ? 1 : 0
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_step)
-half step(half, half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_step)
-half2 step(half2, half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_step)
-half3 step(half3, half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_step)
-half4 step(half4, half4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_step)
-float step(float, float);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_step)
-float2 step(float2, float2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_step)
-float3 step(float3, float3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_step)
-float4 step(float4, float4);
-
-//===----------------------------------------------------------------------===//
-// tan builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn T tan(T Val)
-/// \brief Returns the tangent of the input value, \a Val.
-/// \param Val The input value.
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tan)
-half tan(half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tan)
-half2 tan(half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tan)
-half3 tan(half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tan)
-half4 tan(half4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tan)
-float tan(float);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tan)
-float2 tan(float2);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tan)
-float3 tan(float3);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tan)
-float4 tan(float4);
-
-//===----------------------------------------------------------------------===//
-// tanh builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn T tanh(T Val)
-/// \brief Returns the hyperbolic tangent of the input value, \a Val.
-/// \param Val The input value.
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tanh)
-half tanh(half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tanh)
-half2 tanh(half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tanh)
-half3 tanh(half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tanh)
-half4 tanh(half4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tanh)
-float tanh(float);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tanh)
-float2 tanh(float2);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tanh)
-float3 tanh(float3);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tanh)
-float4 tanh(float4);
-
-//===----------------------------------------------------------------------===//
-// trunc builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn T trunc(T Val)
-/// \brief Returns the truncated integer value of the input value, \a Val.
-/// \param Val The input value.
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_trunc)
-half trunc(half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_trunc)
-half2 trunc(half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_trunc)
-half3 trunc(half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_trunc)
-half4 trunc(half4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_trunc)
-float trunc(float);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_trunc)
-float2 trunc(float2);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_trunc)
-float3 trunc(float3);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_trunc)
-float4 trunc(float4);
-
-//===----------------------------------------------------------------------===//
-// Wave* builtins
-//===----------------------------------------------------------------------===//
-
-/// \brief Evaluates a value for all active invocations in the group. The
-/// result is true if Value is equal for all active invocations in the
-/// group. Otherwise, the result is false.
-/// \param Value The value to compare with
-/// \return True if all values across all lanes are equal, false otherwise
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_all_equal)
-__attribute__((convergent)) bool WaveActiveAllEqual(half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_all_equal)
-__attribute__((convergent)) bool2 WaveActiveAllEqual(half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_all_equal)
-__attribute__((convergent)) bool3 WaveActiveAllEqual(half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_all_equal)
-__attribute__((convergent)) bool4 WaveActiveAllEqual(half4);
-
-#ifdef __HLSL_ENABLE_16_BIT
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_all_equal)
-__attribute__((convergent)) bool WaveActiveAllEqual(int16_t);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_all_equal)
-__attribute__((convergent)) bool2 WaveActiveAllEqual(int16_t2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_all_equal)
-__attribute__((convergent)) bool3 WaveActiveAllEqual(int16_t3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_all_equal)
-__attribute__((convergent)) bool4 WaveActiveAllEqual(int16_t4);
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_all_equal)
-__attribute__((convergent)) bool WaveActiveAllEqual(uint16_t);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_all_equal)
-__attribute__((convergent)) bool2 WaveActiveAllEqual(uint16_t2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_all_equal)
-__attribute__((convergent)) bool3 WaveActiveAllEqual(uint16_t3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_all_equal)
-__attribute__((convergent)) bool4 WaveActiveAllEqual(uint16_t4);
-#endif
-
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_all_equal)
-__attribute__((convergent)) bool WaveActiveAllEqual(int);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_all_equal)
-__attribute__((convergent)) bool2 WaveActiveAllEqual(int2);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_all_equal)
-__attribute__((convergent)) bool3 WaveActiveAllEqual(int3);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_all_equal)
-__attribute__((convergent)) bool4 WaveActiveAllEqual(int4);
-
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_all_equal)
-__attribute__((convergent)) bool WaveActiveAllEqual(uint);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_all_equal)
-__attribute__((convergent)) bool2 WaveActiveAllEqual(uint2);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_all_equal)
-__attribute__((convergent)) bool3 WaveActiveAllEqual(uint3);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_all_equal)
-__attribute__((convergent)) bool4 WaveActiveAllEqual(uint4);
-
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_all_equal)
-__attribute__((convergent)) bool WaveActiveAllEqual(int64_t);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_all_equal)
-__attribute__((convergent)) bool2 WaveActiveAllEqual(int64_t2);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_all_equal)
-__attribute__((convergent)) bool3 WaveActiveAllEqual(int64_t3);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_all_equal)
-__attribute__((convergent)) bool4 WaveActiveAllEqual(int64_t4);
-
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_all_equal)
-__attribute__((convergent)) bool WaveActiveAllEqual(uint64_t);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_all_equal)
-__attribute__((convergent)) bool2 WaveActiveAllEqual(uint64_t2);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_all_equal)
-__attribute__((convergent)) bool3 WaveActiveAllEqual(uint64_t3);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_all_equal)
-__attribute__((convergent)) bool4 WaveActiveAllEqual(uint64_t4);
-
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_all_equal)
-__attribute__((convergent)) bool WaveActiveAllEqual(float);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_all_equal)
-__attribute__((convergent)) bool2 WaveActiveAllEqual(float2);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_all_equal)
-__attribute__((convergent)) bool3 WaveActiveAllEqual(float3);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_all_equal)
-__attribute__((convergent)) bool4 WaveActiveAllEqual(float4);
-
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_all_equal)
-__attribute__((convergent)) bool WaveActiveAllEqual(double);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_all_equal)
-__attribute__((convergent)) bool2 WaveActiveAllEqual(double2);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_all_equal)
-__attribute__((convergent)) bool3 WaveActiveAllEqual(double3);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_all_equal)
-__attribute__((convergent)) bool4 WaveActiveAllEqual(double4);
-
-/// \brief Returns true if the expression is true in all active lanes in the
-/// current wave.
-///
-/// \param Val The boolean expression to evaluate.
-/// \return True if the expression is true in all lanes.
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_all_true)
-__attribute__((convergent)) bool WaveActiveAllTrue(bool Val);
-
-/// \brief Returns true if the expression is true in any active lane in the
-/// current wave.
-///
-/// \param Val The boolean expression to evaluate.
-/// \return True if the expression is true in any lane.
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_any_true)
-__attribute__((convergent)) bool WaveActiveAnyTrue(bool Val);
-
-/// \brief Returns a uint4 containing a bitmask of the evaluation of the
-/// boolean expression for all active lanes in the current wave.
-/// The least-significant bit corresponds to the lane with index zero.
-/// The bits corresponding to inactive lanes will be zero. The bits that
-/// are greater than or equal to WaveGetLaneCount will be zero.
-///
-/// \param Val The boolean expression to evaluate.
-/// \return uint4 bitmask
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_ballot)
-__attribute__((convergent)) uint4 WaveActiveBallot(bool Val);
-
-/// \brief Counts the number of boolean variables which evaluate to true across
-/// all active lanes in the current wave.
-///
-/// \param Val The input boolean value.
-/// \return The number of lanes for which the boolean variable evaluates to
-/// true, across all active lanes in the current wave.
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_count_bits)
-__attribute__((convergent)) uint WaveActiveCountBits(bool Val);
-
-/// \brief Returns the index of the current lane within the current wave.
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_get_lane_index)
-__attribute__((convergent)) uint WaveGetLaneIndex();
-
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_is_first_lane)
-__attribute__((convergent)) bool WaveIsFirstLane();
-
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_get_lane_count)
-__attribute__((convergent)) uint WaveGetLaneCount();
-
-//===----------------------------------------------------------------------===//
-// WavePrefixOp builtins
-//===----------------------------------------------------------------------===//
-/// \brief Returns the count of bits of Expr set to 1 on prior lanes.
-/// \param Expr The boolean expression to evaluate.
-/// \return the count of bits set to 1 on prior lanes.
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_count_bits)
-__attribute__((convergent)) uint WavePrefixCountBits(bool Expr);
-
-//===----------------------------------------------------------------------===//
-// WaveReadLaneAt builtins
-//===----------------------------------------------------------------------===//
-
-// \brief Returns the value of the expression for the given lane index within
-// the specified wave.
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
-__attribute__((convergent)) bool WaveReadLaneAt(bool, uint32_t);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
-__attribute__((convergent)) bool2 WaveReadLaneAt(bool2, uint32_t);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
-__attribute__((convergent)) bool3 WaveReadLaneAt(bool3, uint32_t);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
-__attribute__((convergent)) bool4 WaveReadLaneAt(bool4, uint32_t);
-
-#ifdef __HLSL_ENABLE_16_BIT
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
-__attribute__((convergent)) int16_t WaveReadLaneAt(int16_t, uint32_t);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
-__attribute__((convergent)) int16_t2 WaveReadLaneAt(int16_t2, uint32_t);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
-__attribute__((convergent)) int16_t3 WaveReadLaneAt(int16_t3, uint32_t);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
-__attribute__((convergent)) int16_t4 WaveReadLaneAt(int16_t4, uint32_t);
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
-__attribute__((convergent)) uint16_t WaveReadLaneAt(uint16_t, uint32_t);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
-__attribute__((convergent)) uint16_t2 WaveReadLaneAt(uint16_t2, uint32_t);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
-__attribute__((convergent)) uint16_t3 WaveReadLaneAt(uint16_t3, uint32_t);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
-__attribute__((convergent)) uint16_t4 WaveReadLaneAt(uint16_t4, uint32_t);
-#endif
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
-__attribute__((convergent)) half WaveReadLaneAt(half, uint32_t);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
-__attribute__((convergent)) half2 WaveReadLaneAt(half2, uint32_t);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
-__attribute__((convergent)) half3 WaveReadLaneAt(half3, uint32_t);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
-__attribute__((convergent)) half4 WaveReadLaneAt(half4, uint32_t);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
-__attribute__((convergent)) int WaveReadLaneAt(int, uint32_t);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
-__attribute__((convergent)) int2 WaveReadLaneAt(int2, uint32_t);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
-__attribute__((convergent)) int3 WaveReadLaneAt(int3, uint32_t);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
-__attribute__((convergent)) int4 WaveReadLaneAt(int4, uint32_t);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
-__attribute__((convergent)) uint WaveReadLaneAt(uint, uint32_t);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
-__attribute__((convergent)) uint2 WaveReadLaneAt(uint2, uint32_t);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
-__attribute__((convergent)) uint3 WaveReadLaneAt(uint3, uint32_t);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
-__attribute__((convergent)) uint4 WaveReadLaneAt(uint4, uint32_t);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
-__attribute__((convergent)) float WaveReadLaneAt(float, uint32_t);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
-__attribute__((convergent)) float2 WaveReadLaneAt(float2, uint32_t);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
-__attribute__((convergent)) float3 WaveReadLaneAt(float3, uint32_t);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
-__attribute__((convergent)) float4 WaveReadLaneAt(float4, uint32_t);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
-__attribute__((convergent)) int64_t WaveReadLaneAt(int64_t, uint32_t);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
-__attribute__((convergent)) int64_t2 WaveReadLaneAt(int64_t2, uint32_t);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
-__attribute__((convergent)) int64_t3 WaveReadLaneAt(int64_t3, uint32_t);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
-__attribute__((convergent)) int64_t4 WaveReadLaneAt(int64_t4, uint32_t);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
-__attribute__((convergent)) uint64_t WaveReadLaneAt(uint64_t, uint32_t);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
-__attribute__((convergent)) uint64_t2 WaveReadLaneAt(uint64_t2, uint32_t);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
-__attribute__((convergent)) uint64_t3 WaveReadLaneAt(uint64_t3, uint32_t);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
-__attribute__((convergent)) uint64_t4 WaveReadLaneAt(uint64_t4, uint32_t);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
-__attribute__((convergent)) double WaveReadLaneAt(double, uint32_t);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
-__attribute__((convergent)) double2 WaveReadLaneAt(double2, uint32_t);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
-__attribute__((convergent)) double3 WaveReadLaneAt(double3, uint32_t);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
-__attribute__((convergent)) double4 WaveReadLaneAt(double4, uint32_t);
-
-//===----------------------------------------------------------------------===//
-// WaveActiveBitOr builtins
-//===----------------------------------------------------------------------===//
-
-// \brief Returns the bitwise OR of all the values of <expr> across all active
-// non-helper lanes in the current wave, and replicates it back to
-// all active non-helper lanes.
-
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_bit_or)
-__attribute__((convergent)) uint WaveActiveBitOr(uint);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_bit_or)
-__attribute__((convergent)) uint2 WaveActiveBitOr(uint2);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_bit_or)
-__attribute__((convergent)) uint3 WaveActiveBitOr(uint3);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_bit_or)
-__attribute__((convergent)) uint4 WaveActiveBitOr(uint4);
-
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_bit_or)
-__attribute__((convergent)) uint64_t WaveActiveBitOr(uint64_t);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_bit_or)
-__attribute__((convergent)) uint64_t2 WaveActiveBitOr(uint64_t2);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_bit_or)
-__attribute__((convergent)) uint64_t3 WaveActiveBitOr(uint64_t3);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_bit_or)
-__attribute__((convergent)) uint64_t4 WaveActiveBitOr(uint64_t4);
-
-//===----------------------------------------------------------------------===//
-// WaveActiveBitXor builtins
-//===----------------------------------------------------------------------===//
-
-// \brief Returns the bitwise XOR of all the values of <expr> across all active
-// non-helper lanes in the current wave, and replicates it back to
-// all active non-helper lanes.
-
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_bit_xor)
-__attribute__((convergent)) uint WaveActiveBitXor(uint);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_bit_xor)
-__attribute__((convergent)) uint2 WaveActiveBitXor(uint2);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_bit_xor)
-__attribute__((convergent)) uint3 WaveActiveBitXor(uint3);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_bit_xor)
-__attribute__((convergent)) uint4 WaveActiveBitXor(uint4);
-
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_bit_xor)
-__attribute__((convergent)) uint64_t WaveActiveBitXor(uint64_t);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_bit_xor)
-__attribute__((convergent)) uint64_t2 WaveActiveBitXor(uint64_t2);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_bit_xor)
-__attribute__((convergent)) uint64_t3 WaveActiveBitXor(uint64_t3);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_bit_xor)
-__attribute__((convergent)) uint64_t4 WaveActiveBitXor(uint64_t4);
-
-//===----------------------------------------------------------------------===//
-// WaveActiveBitAnd builtins
-//===----------------------------------------------------------------------===//
-
-// \brief Returns the bitwise And of all the values of <expr> across all active
-// non-helper lanes in the current wave, and replicates it back to
-// all active non-helper lanes.
-
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_bit_and)
-__attribute__((convergent)) uint WaveActiveBitAnd(uint);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_bit_and)
-__attribute__((convergent)) uint2 WaveActiveBitAnd(uint2);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_bit_and)
-__attribute__((convergent)) uint3 WaveActiveBitAnd(uint3);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_bit_and)
-__attribute__((convergent)) uint4 WaveActiveBitAnd(uint4);
-
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_bit_and)
-__attribute__((convergent)) uint64_t WaveActiveBitAnd(uint64_t);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_bit_and)
-__attribute__((convergent)) uint64_t2 WaveActiveBitAnd(uint64_t2);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_bit_and)
-__attribute__((convergent)) uint64_t3 WaveActiveBitAnd(uint64_t3);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_bit_and)
-__attribute__((convergent)) uint64_t4 WaveActiveBitAnd(uint64_t4);
-
-//===----------------------------------------------------------------------===//
-// WaveActiveMax builtins
-//===----------------------------------------------------------------------===//
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max)
-__attribute__((convergent)) half WaveActiveMax(half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max)
-__attribute__((convergent)) half2 WaveActiveMax(half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max)
-__attribute__((convergent)) half3 WaveActiveMax(half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max)
-__attribute__((convergent)) half4 WaveActiveMax(half4);
-
-#ifdef __HLSL_ENABLE_16_BIT
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max)
-__attribute__((convergent)) int16_t WaveActiveMax(int16_t);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max)
-__attribute__((convergent)) int16_t2 WaveActiveMax(int16_t2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max)
-__attribute__((convergent)) int16_t3 WaveActiveMax(int16_t3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max)
-__attribute__((convergent)) int16_t4 WaveActiveMax(int16_t4);
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max)
-__attribute__((convergent)) uint16_t WaveActiveMax(uint16_t);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max)
-__attribute__((convergent)) uint16_t2 WaveActiveMax(uint16_t2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max)
-__attribute__((convergent)) uint16_t3 WaveActiveMax(uint16_t3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max)
-__attribute__((convergent)) uint16_t4 WaveActiveMax(uint16_t4);
-#endif
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max)
-__attribute__((convergent)) int WaveActiveMax(int);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max)
-__attribute__((convergent)) int2 WaveActiveMax(int2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max)
-__attribute__((convergent)) int3 WaveActiveMax(int3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max)
-__attribute__((convergent)) int4 WaveActiveMax(int4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max)
-__attribute__((convergent)) uint WaveActiveMax(uint);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max)
-__attribute__((convergent)) uint2 WaveActiveMax(uint2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max)
-__attribute__((convergent)) uint3 WaveActiveMax(uint3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max)
-__attribute__((convergent)) uint4 WaveActiveMax(uint4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max)
-__attribute__((convergent)) int64_t WaveActiveMax(int64_t);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max)
-__attribute__((convergent)) int64_t2 WaveActiveMax(int64_t2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max)
-__attribute__((convergent)) int64_t3 WaveActiveMax(int64_t3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max)
-__attribute__((convergent)) int64_t4 WaveActiveMax(int64_t4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max)
-__attribute__((convergent)) uint64_t WaveActiveMax(uint64_t);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max)
-__attribute__((convergent)) uint64_t2 WaveActiveMax(uint64_t2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max)
-__attribute__((convergent)) uint64_t3 WaveActiveMax(uint64_t3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max)
-__attribute__((convergent)) uint64_t4 WaveActiveMax(uint64_t4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max)
-__attribute__((convergent)) float WaveActiveMax(float);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max)
-__attribute__((convergent)) float2 WaveActiveMax(float2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max)
-__attribute__((convergent)) float3 WaveActiveMax(float3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max)
-__attribute__((convergent)) float4 WaveActiveMax(float4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max)
-__attribute__((convergent)) double WaveActiveMax(double);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max)
-__attribute__((convergent)) double2 WaveActiveMax(double2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max)
-__attribute__((convergent)) double3 WaveActiveMax(double3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max)
-__attribute__((convergent)) double4 WaveActiveMax(double4);
-
-//===----------------------------------------------------------------------===//
-// WaveActiveMin builtins
-//===----------------------------------------------------------------------===//
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_min)
-__attribute__((convergent)) half WaveActiveMin(half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_min)
-__attribute__((convergent)) half2 WaveActiveMin(half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_min)
-__attribute__((convergent)) half3 WaveActiveMin(half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_min)
-__attribute__((convergent)) half4 WaveActiveMin(half4);
-
-#ifdef __HLSL_ENABLE_16_BIT
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_min)
-__attribute__((convergent)) int16_t WaveActiveMin(int16_t);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_min)
-__attribute__((convergent)) int16_t2 WaveActiveMin(int16_t2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_min)
-__attribute__((convergent)) int16_t3 WaveActiveMin(int16_t3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_min)
-__attribute__((convergent)) int16_t4 WaveActiveMin(int16_t4);
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_min)
-__attribute__((convergent)) uint16_t WaveActiveMin(uint16_t);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_min)
-__attribute__((convergent)) uint16_t2 WaveActiveMin(uint16_t2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_min)
-__attribute__((convergent)) uint16_t3 WaveActiveMin(uint16_t3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_min)
-__attribute__((convergent)) uint16_t4 WaveActiveMin(uint16_t4);
-#endif
-
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_min)
-__attribute__((convergent)) int WaveActiveMin(int);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_min)
-__attribute__((convergent)) int2 WaveActiveMin(int2);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_min)
-__attribute__((convergent)) int3 WaveActiveMin(int3);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_min)
-__attribute__((convergent)) int4 WaveActiveMin(int4);
-
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_min)
-__attribute__((convergent)) uint WaveActiveMin(uint);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_min)
-__attribute__((convergent)) uint2 WaveActiveMin(uint2);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_min)
-__attribute__((convergent)) uint3 WaveActiveMin(uint3);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_min)
-__attribute__((convergent)) uint4 WaveActiveMin(uint4);
-
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_min)
-__attribute__((convergent)) int64_t WaveActiveMin(int64_t);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_min)
-__attribute__((convergent)) int64_t2 WaveActiveMin(int64_t2);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_min)
-__attribute__((convergent)) int64_t3 WaveActiveMin(int64_t3);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_min)
-__attribute__((convergent)) int64_t4 WaveActiveMin(int64_t4);
-
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_min)
-__attribute__((convergent)) uint64_t WaveActiveMin(uint64_t);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_min)
-__attribute__((convergent)) uint64_t2 WaveActiveMin(uint64_t2);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_min)
-__attribute__((convergent)) uint64_t3 WaveActiveMin(uint64_t3);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_min)
-__attribute__((convergent)) uint64_t4 WaveActiveMin(uint64_t4);
-
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_min)
-__attribute__((convergent)) float WaveActiveMin(float);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_min)
-__attribute__((convergent)) float2 WaveActiveMin(float2);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_min)
-__attribute__((convergent)) float3 WaveActiveMin(float3);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_min)
-__attribute__((convergent)) float4 WaveActiveMin(float4);
-
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_min)
-__attribute__((convergent)) double WaveActiveMin(double);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_min)
-__attribute__((convergent)) double2 WaveActiveMin(double2);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_min)
-__attribute__((convergent)) double3 WaveActiveMin(double3);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_min)
-__attribute__((convergent)) double4 WaveActiveMin(double4);
-
-//===----------------------------------------------------------------------===//
-// WaveActiveSum builtins
-//===----------------------------------------------------------------------===//
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
-__attribute__((convergent)) half WaveActiveSum(half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
-__attribute__((convergent)) half2 WaveActiveSum(half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
-__attribute__((convergent)) half3 WaveActiveSum(half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
-__attribute__((convergent)) half4 WaveActiveSum(half4);
-
-#ifdef __HLSL_ENABLE_16_BIT
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
-__attribute__((convergent)) int16_t WaveActiveSum(int16_t);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
-__attribute__((convergent)) int16_t2 WaveActiveSum(int16_t2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
-__attribute__((convergent)) int16_t3 WaveActiveSum(int16_t3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
-__attribute__((convergent)) int16_t4 WaveActiveSum(int16_t4);
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
-__attribute__((convergent)) uint16_t WaveActiveSum(uint16_t);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
-__attribute__((convergent)) uint16_t2 WaveActiveSum(uint16_t2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
-__attribute__((convergent)) uint16_t3 WaveActiveSum(uint16_t3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
-__attribute__((convergent)) uint16_t4 WaveActiveSum(uint16_t4);
-#endif
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
-__attribute__((convergent)) int WaveActiveSum(int);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
-__attribute__((convergent)) int2 WaveActiveSum(int2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
-__attribute__((convergent)) int3 WaveActiveSum(int3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
-__attribute__((convergent)) int4 WaveActiveSum(int4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
-__attribute__((convergent)) uint WaveActiveSum(uint);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
-__attribute__((convergent)) uint2 WaveActiveSum(uint2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
-__attribute__((convergent)) uint3 WaveActiveSum(uint3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
-__attribute__((convergent)) uint4 WaveActiveSum(uint4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
-__attribute__((convergent)) int64_t WaveActiveSum(int64_t);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
-__attribute__((convergent)) int64_t2 WaveActiveSum(int64_t2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
-__attribute__((convergent)) int64_t3 WaveActiveSum(int64_t3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
-__attribute__((convergent)) int64_t4 WaveActiveSum(int64_t4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
-__attribute__((convergent)) uint64_t WaveActiveSum(uint64_t);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
-__attribute__((convergent)) uint64_t2 WaveActiveSum(uint64_t2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
-__attribute__((convergent)) uint64_t3 WaveActiveSum(uint64_t3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
-__attribute__((convergent)) uint64_t4 WaveActiveSum(uint64_t4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
-__attribute__((convergent)) float WaveActiveSum(float);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
-__attribute__((convergent)) float2 WaveActiveSum(float2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
-__attribute__((convergent)) float3 WaveActiveSum(float3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
-__attribute__((convergent)) float4 WaveActiveSum(float4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
-__attribute__((convergent)) double WaveActiveSum(double);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
-__attribute__((convergent)) double2 WaveActiveSum(double2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
-__attribute__((convergent)) double3 WaveActiveSum(double3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
-__attribute__((convergent)) double4 WaveActiveSum(double4);
-
-//===----------------------------------------------------------------------===//
-// WaveActiveProduct builtins
-//===----------------------------------------------------------------------===//
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_product)
-__attribute__((convergent)) half WaveActiveProduct(half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_product)
-__attribute__((convergent)) half2 WaveActiveProduct(half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_product)
-__attribute__((convergent)) half3 WaveActiveProduct(half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_product)
-__attribute__((convergent)) half4 WaveActiveProduct(half4);
-
-#ifdef __HLSL_ENABLE_16_BIT
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_product)
-__attribute__((convergent)) int16_t WaveActiveProduct(int16_t);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_product)
-__attribute__((convergent)) int16_t2 WaveActiveProduct(int16_t2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_product)
-__attribute__((convergent)) int16_t3 WaveActiveProduct(int16_t3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_product)
-__attribute__((convergent)) int16_t4 WaveActiveProduct(int16_t4);
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_product)
-__attribute__((convergent)) uint16_t WaveActiveProduct(uint16_t);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_product)
-__attribute__((convergent)) uint16_t2 WaveActiveProduct(uint16_t2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_product)
-__attribute__((convergent)) uint16_t3 WaveActiveProduct(uint16_t3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_product)
-__attribute__((convergent)) uint16_t4 WaveActiveProduct(uint16_t4);
-#endif
-
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_product)
-__attribute__((convergent)) int WaveActiveProduct(int);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_product)
-__attribute__((convergent)) int2 WaveActiveProduct(int2);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_product)
-__attribute__((convergent)) int3 WaveActiveProduct(int3);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_product)
-__attribute__((convergent)) int4 WaveActiveProduct(int4);
-
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_product)
-__attribute__((convergent)) uint WaveActiveProduct(uint);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_product)
-__attribute__((convergent)) uint2 WaveActiveProduct(uint2);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_product)
-__attribute__((convergent)) uint3 WaveActiveProduct(uint3);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_product)
-__attribute__((convergent)) uint4 WaveActiveProduct(uint4);
-
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_product)
-__attribute__((convergent)) int64_t WaveActiveProduct(int64_t);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_product)
-__attribute__((convergent)) int64_t2 WaveActiveProduct(int64_t2);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_product)
-__attribute__((convergent)) int64_t3 WaveActiveProduct(int64_t3);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_product)
-__attribute__((convergent)) int64_t4 WaveActiveProduct(int64_t4);
-
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_product)
-__attribute__((convergent)) uint64_t WaveActiveProduct(uint64_t);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_product)
-__attribute__((convergent)) uint64_t2 WaveActiveProduct(uint64_t2);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_product)
-__attribute__((convergent)) uint64_t3 WaveActiveProduct(uint64_t3);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_product)
-__attribute__((convergent)) uint64_t4 WaveActiveProduct(uint64_t4);
-
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_product)
-__attribute__((convergent)) float WaveActiveProduct(float);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_product)
-__attribute__((convergent)) float2 WaveActiveProduct(float2);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_product)
-__attribute__((convergent)) float3 WaveActiveProduct(float3);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_product)
-__attribute__((convergent)) float4 WaveActiveProduct(float4);
-
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_product)
-__attribute__((convergent)) double WaveActiveProduct(double);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_product)
-__attribute__((convergent)) double2 WaveActiveProduct(double2);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_product)
-__attribute__((convergent)) double3 WaveActiveProduct(double3);
-_HLSL_AVAILABILITY(shadermodel, 6.0)
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_product)
-__attribute__((convergent)) double4 WaveActiveProduct(double4);
-
-//===----------------------------------------------------------------------===//
-// WavePrefixSum builtins
-//===----------------------------------------------------------------------===//
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_sum)
-__attribute__((convergent)) half WavePrefixSum(half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_sum)
-__attribute__((convergent)) half2 WavePrefixSum(half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_sum)
-__attribute__((convergent)) half3 WavePrefixSum(half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_sum)
-__attribute__((convergent)) half4 WavePrefixSum(half4);
-
-#ifdef __HLSL_ENABLE_16_BIT
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_sum)
-__attribute__((convergent)) int16_t WavePrefixSum(int16_t);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_sum)
-__attribute__((convergent)) int16_t2 WavePrefixSum(int16_t2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_sum)
-__attribute__((convergent)) int16_t3 WavePrefixSum(int16_t3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_sum)
-__attribute__((convergent)) int16_t4 WavePrefixSum(int16_t4);
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_sum)
-__attribute__((convergent)) uint16_t WavePrefixSum(uint16_t);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_sum)
-__attribute__((convergent)) uint16_t2 WavePrefixSum(uint16_t2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_sum)
-__attribute__((convergent)) uint16_t3 WavePrefixSum(uint16_t3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_sum)
-__attribute__((convergent)) uint16_t4 WavePrefixSum(uint16_t4);
-#endif
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_sum)
-__attribute__((convergent)) int WavePrefixSum(int);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_sum)
-__attribute__((convergent)) int2 WavePrefixSum(int2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_sum)
-__attribute__((convergent)) int3 WavePrefixSum(int3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_sum)
-__attribute__((convergent)) int4 WavePrefixSum(int4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_sum)
-__attribute__((convergent)) uint WavePrefixSum(uint);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_sum)
-__attribute__((convergent)) uint2 WavePrefixSum(uint2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_sum)
-__attribute__((convergent)) uint3 WavePrefixSum(uint3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_sum)
-__attribute__((convergent)) uint4 WavePrefixSum(uint4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_sum)
-__attribute__((convergent)) int64_t WavePrefixSum(int64_t);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_sum)
-__attribute__((convergent)) int64_t2 WavePrefixSum(int64_t2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_sum)
-__attribute__((convergent)) int64_t3 WavePrefixSum(int64_t3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_sum)
-__attribute__((convergent)) int64_t4 WavePrefixSum(int64_t4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_sum)
-__attribute__((convergent)) uint64_t WavePrefixSum(uint64_t);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_sum)
-__attribute__((convergent)) uint64_t2 WavePrefixSum(uint64_t2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_sum)
-__attribute__((convergent)) uint64_t3 WavePrefixSum(uint64_t3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_sum)
-__attribute__((convergent)) uint64_t4 WavePrefixSum(uint64_t4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_sum)
-__attribute__((convergent)) float WavePrefixSum(float);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_sum)
-__attribute__((convergent)) float2 WavePrefixSum(float2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_sum)
-__attribute__((convergent)) float3 WavePrefixSum(float3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_sum)
-__attribute__((convergent)) float4 WavePrefixSum(float4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_sum)
-__attribute__((convergent)) double WavePrefixSum(double);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_sum)
-__attribute__((convergent)) double2 WavePrefixSum(double2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_sum)
-__attribute__((convergent)) double3 WavePrefixSum(double3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_sum)
-__attribute__((convergent)) double4 WavePrefixSum(double4);
-
-//===----------------------------------------------------------------------===//
-// WavePrefixProduct builtins
+// mul builtins
//===----------------------------------------------------------------------===//
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_product)
-__attribute__((convergent)) half WavePrefixProduct(half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_product)
-__attribute__((convergent)) half2 WavePrefixProduct(half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_product)
-__attribute__((convergent)) half3 WavePrefixProduct(half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_product)
-__attribute__((convergent)) half4 WavePrefixProduct(half4);
-
-#ifdef __HLSL_ENABLE_16_BIT
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_product)
-__attribute__((convergent)) int16_t WavePrefixProduct(int16_t);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_product)
-__attribute__((convergent)) int16_t2 WavePrefixProduct(int16_t2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_product)
-__attribute__((convergent)) int16_t3 WavePrefixProduct(int16_t3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_product)
-__attribute__((convergent)) int16_t4 WavePrefixProduct(int16_t4);
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_product)
-__attribute__((convergent)) uint16_t WavePrefixProduct(uint16_t);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_product)
-__attribute__((convergent)) uint16_t2 WavePrefixProduct(uint16_t2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_product)
-__attribute__((convergent)) uint16_t3 WavePrefixProduct(uint16_t3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_product)
-__attribute__((convergent)) uint16_t4 WavePrefixProduct(uint16_t4);
-#endif
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_product)
-__attribute__((convergent)) int WavePrefixProduct(int);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_product)
-__attribute__((convergent)) int2 WavePrefixProduct(int2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_product)
-__attribute__((convergent)) int3 WavePrefixProduct(int3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_product)
-__attribute__((convergent)) int4 WavePrefixProduct(int4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_product)
-__attribute__((convergent)) uint WavePrefixProduct(uint);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_product)
-__attribute__((convergent)) uint2 WavePrefixProduct(uint2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_product)
-__attribute__((convergent)) uint3 WavePrefixProduct(uint3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_product)
-__attribute__((convergent)) uint4 WavePrefixProduct(uint4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_product)
-__attribute__((convergent)) int64_t WavePrefixProduct(int64_t);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_product)
-__attribute__((convergent)) int64_t2 WavePrefixProduct(int64_t2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_product)
-__attribute__((convergent)) int64_t3 WavePrefixProduct(int64_t3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_product)
-__attribute__((convergent)) int64_t4 WavePrefixProduct(int64_t4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_product)
-__attribute__((convergent)) uint64_t WavePrefixProduct(uint64_t);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_product)
-__attribute__((convergent)) uint64_t2 WavePrefixProduct(uint64_t2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_product)
-__attribute__((convergent)) uint64_t3 WavePrefixProduct(uint64_t3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_product)
-__attribute__((convergent)) uint64_t4 WavePrefixProduct(uint64_t4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_product)
-__attribute__((convergent)) float WavePrefixProduct(float);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_product)
-__attribute__((convergent)) float2 WavePrefixProduct(float2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_product)
-__attribute__((convergent)) float3 WavePrefixProduct(float3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_product)
-__attribute__((convergent)) float4 WavePrefixProduct(float4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_product)
-__attribute__((convergent)) double WavePrefixProduct(double);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_product)
-__attribute__((convergent)) double2 WavePrefixProduct(double2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_product)
-__attribute__((convergent)) double3 WavePrefixProduct(double3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_prefix_product)
-__attribute__((convergent)) double4 WavePrefixProduct(double4);
-
-//===----------------------------------------------------------------------===//
-// QuadReadAcrossX builtins
-//===----------------------------------------------------------------------===//
+/// \fn R mul(X x, Y y)
+/// \brief Multiplies x and y using matrix math.
+/// \param x [in] The first input value. If x is a vector, it is treated as a
+/// row vector.
+/// \param y [in] The second input value. If y is a vector, it is treated as a
+/// column vector.
+///
+/// The inner dimension x-columns and y-rows must be equal. The result has the
+/// dimension x-rows x y-columns. When both x and y are vectors, the result is
+/// a dot product (scalar). Scalar operands are multiplied element-wise.
+///
+/// This function supports 9 overloaded forms:
+/// 1. scalar * scalar -> scalar
+/// 2. scalar * vector -> vector
+/// 3. scalar * matrix -> matrix
+/// 4. vector * scalar -> vector
+/// 5. vector * vector -> scalar (dot product)
+/// 6. vector * matrix -> vector
+/// 7. matrix * scalar -> matrix
+/// 8. matrix * vector -> vector
+/// 9. matrix * matrix -> matrix
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_x)
-__attribute__((convergent)) half QuadReadAcrossX(half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_x)
-__attribute__((convergent)) half2 QuadReadAcrossX(half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_x)
-__attribute__((convergent)) half3 QuadReadAcrossX(half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_x)
-__attribute__((convergent)) half4 QuadReadAcrossX(half4);
+// Cases 1, 2, 3, 4, 5, and 7 of mul are defined in hlsl_intrinsics.h as
+// header-only implementations because they are elementwise operations and dot
+// products easily expressed in HLSL.
-#ifdef __HLSL_ENABLE_16_BIT
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_x)
-__attribute__((convergent)) int16_t QuadReadAcrossX(int16_t);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_x)
-__attribute__((convergent)) int16_t2 QuadReadAcrossX(int16_t2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_x)
-__attribute__((convergent)) int16_t3 QuadReadAcrossX(int16_t3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_x)
-__attribute__((convergent)) int16_t4 QuadReadAcrossX(int16_t4);
+// Cases 6, 8, and 9 are defined below to alias the mul builtin so that they can
+// be lowered to the llvm.matrix.multiply intrinsic which is not exposed
+// directly to HLSL.
+// Case 6: vector * matrix -> vector
+template <int R, int C>
_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_x)
-__attribute__((convergent)) uint16_t QuadReadAcrossX(uint16_t);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_x)
-__attribute__((convergent)) uint16_t2 QuadReadAcrossX(uint16_t2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_x)
-__attribute__((convergent)) uint16_t3 QuadReadAcrossX(uint16_t3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_x)
-__attribute__((convergent)) uint16_t4 QuadReadAcrossX(uint16_t4);
-#endif
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_x)
-__attribute__((convergent)) int QuadReadAcrossX(int);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_x)
-__attribute__((convergent)) int2 QuadReadAcrossX(int2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_x)
-__attribute__((convergent)) int3 QuadReadAcrossX(int3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_x)
-__attribute__((convergent)) int4 QuadReadAcrossX(int4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_x)
-__attribute__((convergent)) uint QuadReadAcrossX(uint);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_x)
-__attribute__((convergent)) uint2 QuadReadAcrossX(uint2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_x)
-__attribute__((convergent)) uint3 QuadReadAcrossX(uint3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_x)
-__attribute__((convergent)) uint4 QuadReadAcrossX(uint4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_x)
-__attribute__((convergent)) int64_t QuadReadAcrossX(int64_t);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_x)
-__attribute__((convergent)) int64_t2 QuadReadAcrossX(int64_t2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_x)
-__attribute__((convergent)) int64_t3 QuadReadAcrossX(int64_t3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_x)
-__attribute__((convergent)) int64_t4 QuadReadAcrossX(int64_t4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_x)
-__attribute__((convergent)) uint64_t QuadReadAcrossX(uint64_t);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_x)
-__attribute__((convergent)) uint64_t2 QuadReadAcrossX(uint64_t2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_x)
-__attribute__((convergent)) uint64_t3 QuadReadAcrossX(uint64_t3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_x)
-__attribute__((convergent)) uint64_t4 QuadReadAcrossX(uint64_t4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_x)
-__attribute__((convergent)) float QuadReadAcrossX(float);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_x)
-__attribute__((convergent)) float2 QuadReadAcrossX(float2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_x)
-__attribute__((convergent)) float3 QuadReadAcrossX(float3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_x)
-__attribute__((convergent)) float4 QuadReadAcrossX(float4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_x)
-__attribute__((convergent)) double QuadReadAcrossX(double);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_x)
-__attribute__((convergent)) double2 QuadReadAcrossX(double2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_x)
-__attribute__((convergent)) double3 QuadReadAcrossX(double3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_x)
-__attribute__((convergent)) double4 QuadReadAcrossX(double4);
-
-//===----------------------------------------------------------------------===//
-// sign builtins
-//===----------------------------------------------------------------------===//
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mul) vector<half, C> mul(vector<half, R>,
+ matrix<half, R, C>);
-/// \fn T sign(T Val)
-/// \brief Returns -1 if \a Val is less than zero; 0 if \a Val equals zero; and
-/// 1 if \a Val is greater than zero. \param Val The input value.
+template <typename T, int R, int C>
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mul)
+vector<T, C> mul(vector<T, R>, matrix<T, R, C>);
-#ifdef __HLSL_ENABLE_16_BIT
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
-int sign(int16_t);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
-int2 sign(int16_t2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
-int3 sign(int16_t3);
+// Case 8: matrix * vector -> vector
+template <int R, int C>
_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
-int4 sign(int16_t4);
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mul) vector<half, R> mul(matrix<half, R, C>,
+ vector<half, C>);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
-int sign(uint16_t);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
-int2 sign(uint16_t2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
-int3 sign(uint16_t3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
-int4 sign(uint16_t4);
-#endif
+template <typename T, int R, int C>
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mul)
+vector<T, R> mul(matrix<T, R, C>, vector<T, C>);
+// Case 9: matrix * matrix -> matrix
+template <int R, int K, int C>
_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
-int sign(half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
-int2 sign(half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
-int3 sign(half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
-int4 sign(half4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
-int sign(int);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
-int2 sign(int2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
-int3 sign(int3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
-int4 sign(int4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
-int sign(uint);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
-int2 sign(uint2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
-int3 sign(uint3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
-int4 sign(uint4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
-int sign(float);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
-int2 sign(float2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
-int3 sign(float3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
-int4 sign(float4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
-int sign(int64_t);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
-int2 sign(int64_t2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
-int3 sign(int64_t3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
-int4 sign(int64_t4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
-int sign(uint64_t);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
-int2 sign(uint64_t2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
-int3 sign(uint64_t3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
-int4 sign(uint64_t4);
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mul) matrix<half, R, C> mul(
+ matrix<half, R, K>, matrix<half, K, C>);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
-int sign(double);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
-int2 sign(double2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
-int3 sign(double3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
-int4 sign(double4);
+template <typename T, int R, int K, int C>
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mul)
+matrix<T, R, C> mul(matrix<T, R, K>, matrix<T, K, C>);
//===----------------------------------------------------------------------===//
-// radians builtins
+// transpose builtins
//===----------------------------------------------------------------------===//
-/// \fn T radians(T Val)
-/// \brief Converts the specified value from degrees to radians.
+/// \fn matrix<T, C, R> transpose(matrix<T, R, C> x)
+/// \brief Returns the transpose of the input matrix.
+/// \param x [in] The input matrix.
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_radians)
-half radians(half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_radians)
-half2 radians(half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_radians)
-half3 radians(half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_radians)
-half4 radians(half4);
+template <int R, int C>
+_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_transpose) matrix<half, C, R> transpose(
+ matrix<half, R, C>);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_radians)
-float radians(float);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_radians)
-float2 radians(float2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_radians)
-float3 radians(float3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_radians)
-float4 radians(float4);
+template <typename T, int R, int C>
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_transpose)
+matrix<T, C, R> transpose(matrix<T, R, C>);
//===----------------------------------------------------------------------===//
-// GroupMemoryBarrierWithGroupSync builtins
+// select builtins
//===----------------------------------------------------------------------===//
-/// \fn void GroupMemoryBarrierWithGroupSync(void)
-/// \brief Blocks execution of all threads in a group until all group shared
-/// accesses have been completed and all threads in the group have reached this
-/// call.
+/// \fn T select(bool Cond, T TrueVal, T FalseVal)
+/// \brief ternary operator.
+/// \param Cond The Condition input value.
+/// \param TrueVal The Value returned if Cond is true.
+/// \param FalseVal The Value returned if Cond is false.
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_group_memory_barrier_with_group_sync)
-__attribute__((convergent)) void GroupMemoryBarrierWithGroupSync(void);
+template <typename T>
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_select)
+T select(bool, T, T);
-//===----------------------------------------------------------------------===//
-// ddx_coarse builtin
-//===----------------------------------------------------------------------===//
+/// \fn vector<T,Sz> select(vector<bool,Sz> Conds, vector<T,Sz> TrueVals,
+/// vector<T,Sz> FalseVals)
+/// \brief ternary operator for vectors. All vectors must be the same size.
+/// \param Conds The Condition input values.
+/// \param TrueVals The vector values are chosen from when conditions are true.
+/// \param FalseVals The vector values are chosen from when conditions are
+/// false.
-/// \fn T ddx_coarse(T value)
-/// \brief Computes a low precision partial derivative with respect to the
-/// screen-space x-coordinate.
-/// \param value The input value.
-///
-/// The return value is a floating point scalar or vector containing the low
-/// prevision partial derivative of the input value.
+template <typename T>
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_select)
+vector<T, 2> select(vector<bool, 2>, vector<T, 2>, vector<T, 2>);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_ddx_coarse)
-half ddx_coarse(half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_ddx_coarse)
-half2 ddx_coarse(half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_ddx_coarse)
-half3 ddx_coarse(half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_ddx_coarse)
-half4 ddx_coarse(half4);
+template <typename T>
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_select)
+vector<T, 3> select(vector<bool, 3>, vector<T, 3>, vector<T, 3>);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_ddx_coarse)
-float ddx_coarse(float);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_ddx_coarse)
-float2 ddx_coarse(float2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_ddx_coarse)
-float3 ddx_coarse(float3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_ddx_coarse)
-float4 ddx_coarse(float4);
+template <typename T>
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_select)
+vector<T, 4> select(vector<bool, 4>, vector<T, 4>, vector<T, 4>);
-//===----------------------------------------------------------------------===//
-// ddy_coarse builtin
-//===----------------------------------------------------------------------===//
+/// \fn vector<T,Sz> select(vector<bool,Sz> Conds, T TrueVal,
+/// vector<T,Sz> FalseVals)
+/// \brief ternary operator for vectors. All vectors must be the same size.
+/// \param Conds The Condition input values.
+/// \param TrueVal The scalar value to splat from when conditions are true.
+/// \param FalseVals The vector values are chosen from when conditions are
+/// false.
-/// \fn T ddy_coarse(T value)
-/// \brief Computes a low precision partial derivative with respect to the
-/// screen-space y-coordinate.
-/// \param value The input value.
-///
-/// The return value is a floating point scalar or vector containing the low
-/// prevision partial derivative of the input value.
+template <typename T>
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_select)
+vector<T, 2> select(vector<bool, 2>, T, vector<T, 2>);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_ddy_coarse)
-half ddy_coarse(half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_ddy_coarse)
-half2 ddy_coarse(half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_ddy_coarse)
-half3 ddy_coarse(half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_ddy_coarse)
-half4 ddy_coarse(half4);
+template <typename T>
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_select)
+vector<T, 3> select(vector<bool, 3>, T, vector<T, 3>);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_ddy_coarse)
-float ddy_coarse(float);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_ddy_coarse)
-float2 ddy_coarse(float2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_ddy_coarse)
-float3 ddy_coarse(float3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_ddy_coarse)
-float4 ddy_coarse(float4);
+template <typename T>
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_select)
+vector<T, 4> select(vector<bool, 4>, T, vector<T, 4>);
-//===----------------------------------------------------------------------===//
-// ddx_fine builtin
-//===----------------------------------------------------------------------===//
+/// \fn vector<T,Sz> select(vector<bool,Sz> Conds, vector<T,Sz> TrueVals,
+/// T FalseVal)
+/// \brief ternary operator for vectors. All vectors must be the same size.
+/// \param Conds The Condition input values.
+/// \param TrueVals The vector values are chosen from when conditions are true.
+/// \param FalseVal The scalar value to splat from when conditions are false.
-/// \fn T ddx_fine(T value)
-/// \brief Computes a high precision partial derivative with respect to the
-/// screen-space x-coordinate.
-/// \param value The input value.
-///
-/// The return value is a floating point scalar or vector containing the high
-/// prevision partial derivative of the input value.
+template <typename T>
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_select)
+vector<T, 2> select(vector<bool, 2>, vector<T, 2>, T);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_ddx_fine)
-half ddx_fine(half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_ddx_fine)
-half2 ddx_fine(half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_ddx_fine)
-half3 ddx_fine(half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_ddx_fine)
-half4 ddx_fine(half4);
+template <typename T>
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_select)
+vector<T, 3> select(vector<bool, 3>, vector<T, 3>, T);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_ddx_fine)
-float ddx_fine(float);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_ddx_fine)
-float2 ddx_fine(float2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_ddx_fine)
-float3 ddx_fine(float3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_ddx_fine)
-float4 ddx_fine(float4);
+template <typename T>
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_select)
+vector<T, 4> select(vector<bool, 4>, vector<T, 4>, T);
-//===----------------------------------------------------------------------===//
-// ddy_fine builtin
-//===----------------------------------------------------------------------===//
+/// \fn vector<T,Sz> select(vector<bool,Sz> Conds, vector<T,Sz> TrueVals,
+/// T FalseVal)
+/// \brief ternary operator for vectors. All vectors must be the same size.
+/// \param Conds The Condition input values.
+/// \param TrueVal The scalar value to splat from when conditions are true.
+/// \param FalseVal The scalar value to splat from when conditions are false.
-/// \fn T ddy_fine(T value)
-/// \brief Computes a high precision partial derivative with respect to the
-/// screen-space y-coordinate.
-/// \param value The input value.
-///
-/// The return value is a floating point scalar or vector containing the high
-/// prevision partial derivative of the input value.
+template <typename T>
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_select)
+__detail::enable_if_t<__detail::is_arithmetic<T>::Value, vector<T, 2>> select(
+ vector<bool, 2>, T, T);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_ddy_fine)
-half ddy_fine(half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_ddy_fine)
-half2 ddy_fine(half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_ddy_fine)
-half3 ddy_fine(half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_ddy_fine)
-half4 ddy_fine(half4);
+template <typename T>
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_select)
+__detail::enable_if_t<__detail::is_arithmetic<T>::Value, vector<T, 3>> select(
+ vector<bool, 3>, T, T);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_ddy_fine)
-float ddy_fine(float);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_ddy_fine)
-float2 ddy_fine(float2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_ddy_fine)
-float3 ddy_fine(float3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_ddy_fine)
-float4 ddy_fine(float4);
+template <typename T>
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_select)
+__detail::enable_if_t<__detail::is_arithmetic<T>::Value, vector<T, 4>> select(
+ vector<bool, 4>, T, T);
} // namespace hlsl
#endif //_HLSL_HLSL_ALIAS_INTRINSICS_H_
+
diff --git a/clang/test/SemaHLSL/BuiltIns/cross-errors.hlsl b/clang/test/SemaHLSL/BuiltIns/cross-errors.hlsl
index 2c3e8d1560c87..c9bd1bdd3cb8e 100644
--- a/clang/test/SemaHLSL/BuiltIns/cross-errors.hlsl
+++ b/clang/test/SemaHLSL/BuiltIns/cross-errors.hlsl
@@ -4,8 +4,8 @@ void test_too_few_arg()
{
return cross();
// expected-error at -1 {{no matching function for call to 'cross'}}
- // expected-note at hlsl/hlsl_alias_intrinsics.h:* {{candidate function not viable: requires 2 arguments, but 0 were provided}}
- // expected-note at hlsl/hlsl_alias_intrinsics.h:* {{candidate function not viable: requires 2 arguments, but 0 were provided}}
+ // expected-note at hlsl/hlsl_alias_intrinsics_gen.inc:* {{candidate function not viable: requires 2 arguments, but 0 were provided}}
+ // expected-note at hlsl/hlsl_alias_intrinsics_gen.inc:* {{candidate function not viable: requires 2 arguments, but 0 were provided}}
}
void test_too_few_arg_f32()
@@ -24,8 +24,8 @@ void test_too_many_arg(float3 p0)
{
return cross(p0, p0, p0);
// expected-error at -1 {{no matching function for call to 'cross'}}
- // expected-note at hlsl/hlsl_alias_intrinsics.h:* {{candidate function not viable: requires 2 arguments, but 3 were provided}}
- // expected-note at hlsl/hlsl_alias_intrinsics.h:* {{candidate function not viable: requires 2 arguments, but 3 were provided}}
+ // expected-note at hlsl/hlsl_alias_intrinsics_gen.inc:* {{candidate function not viable: requires 2 arguments, but 3 were provided}}
+ // expected-note at hlsl/hlsl_alias_intrinsics_gen.inc:* {{candidate function not viable: requires 2 arguments, but 3 were provided}}
}
void test_too_many_arg_f32(float3 p0)
@@ -56,6 +56,6 @@ void test_ambiguous(int p0)
{
return cross(p0,p0);
// expected-error at -1 {{call to 'cross' is ambiguous}}
- // expected-note at hlsl/hlsl_alias_intrinsics.h:* {{candidate function}}
- // expected-note at hlsl/hlsl_alias_intrinsics.h:* {{candidate function}}
+ // expected-note at hlsl/hlsl_alias_intrinsics_gen.inc:* {{candidate function}}
+ // expected-note at hlsl/hlsl_alias_intrinsics_gen.inc:* {{candidate function}}
}
diff --git a/clang/test/SemaHLSL/BuiltIns/f16tof32-errors.hlsl b/clang/test/SemaHLSL/BuiltIns/f16tof32-errors.hlsl
index 8f2f9308ed966..32abf5113fdd4 100644
--- a/clang/test/SemaHLSL/BuiltIns/f16tof32-errors.hlsl
+++ b/clang/test/SemaHLSL/BuiltIns/f16tof32-errors.hlsl
@@ -3,13 +3,13 @@
float builtin_f16tof32_too_few_arg() {
return __builtin_hlsl_elementwise_f16tof32();
// expected-error at -1 {{too few arguments to function call, expected 1, have 0}}
- // expected-note at hlsl/hlsl_alias_intrinsics.h:* 4 {{candidate function not viable: requires 1 argument, but 0 were provided}}
+ // expected-note at hlsl/hlsl_alias_intrinsics_gen.inc:* 4 {{candidate function not viable: requires 1 argument, but 0 were provided}}
}
float builtin_f16tof32_too_many_arg(uint p0) {
return __builtin_hlsl_elementwise_f16tof32(p0, p0);
// expected-error at -1 {{too many arguments to function call, expected 1, have 2}}
- // expected-note at hlsl/hlsl_alias_intrinsics.h:* 4 {{candidate function not viable: requires 1 argument, but 2 were provided}}
+ // expected-note at hlsl/hlsl_alias_intrinsics_gen.inc:* 4 {{candidate function not viable: requires 1 argument, but 2 were provided}}
}
float builtin_f16tof32_bool(bool p0) {
diff --git a/clang/test/SemaHLSL/BuiltIns/f32tof16-errors.hlsl b/clang/test/SemaHLSL/BuiltIns/f32tof16-errors.hlsl
index cd95602b413c5..04479935754a6 100644
--- a/clang/test/SemaHLSL/BuiltIns/f32tof16-errors.hlsl
+++ b/clang/test/SemaHLSL/BuiltIns/f32tof16-errors.hlsl
@@ -3,13 +3,13 @@
uint builtin_f32tof16_too_few_arg() {
return __builtin_hlsl_elementwise_f32tof16();
// expected-error at -1 {{too few arguments to function call, expected 1, have 0}}
- // expected-note at hlsl/hlsl_alias_intrinsics.h:* 4 {{candidate function not viable: requires 1 argument, but 0 were provided}}
+ // expected-note at hlsl/hlsl_alias_intrinsics_gen.inc:* 4 {{candidate function not viable: requires 1 argument, but 0 were provided}}
}
uint builtin_f32tof16_too_many_arg(uint p0) {
return __builtin_hlsl_elementwise_f32tof16(p0, p0);
// expected-error at -1 {{too many arguments to function call, expected 1, have 2}}
- // expected-note at hlsl/hlsl_alias_intrinsics.h:* 4 {{candidate function not viable: requires 1 argument, but 2 were provided}}
+ // expected-note at hlsl/hlsl_alias_intrinsics_gen.inc:* 4 {{candidate function not viable: requires 1 argument, but 2 were provided}}
}
uint builtin_f32tof16_bool(bool p0) {
diff --git a/clang/test/SemaHLSL/WaveBuiltinAvailability.hlsl b/clang/test/SemaHLSL/WaveBuiltinAvailability.hlsl
index e7cb59bea8cf5..9c136ae497424 100644
--- a/clang/test/SemaHLSL/WaveBuiltinAvailability.hlsl
+++ b/clang/test/SemaHLSL/WaveBuiltinAvailability.hlsl
@@ -5,6 +5,6 @@
[numthreads(8,8,1)]
void foo() {
// expected-error@#site {{'WaveActiveCountBits' is only available on Shader Model 6.0 or newer}}
- // expected-note at hlsl/hlsl_alias_intrinsics.h:* {{'WaveActiveCountBits' has been marked as being introduced in Shader Model 6.0 here, but the deployment target is Shader Model 5.0}}
+ // expected-note at hlsl/hlsl_alias_intrinsics_gen.inc:* {{'WaveActiveCountBits' has been marked as being introduced in Shader Model 6.0 here, but the deployment target is Shader Model 5.0}}
unsigned tmp = hlsl::WaveActiveCountBits(1); // #site
}
>From 4160c18dd87106785e2b9ec725d820b410c94ba3 Mon Sep 17 00:00:00 2001
From: Deric Cheung <cheung.deric at gmail.com>
Date: Thu, 26 Mar 2026 11:22:08 -0700
Subject: [PATCH 09/12] Apply clang-format
---
clang/lib/Headers/hlsl/hlsl_alias_intrinsics.h | 1 -
1 file changed, 1 deletion(-)
diff --git a/clang/lib/Headers/hlsl/hlsl_alias_intrinsics.h b/clang/lib/Headers/hlsl/hlsl_alias_intrinsics.h
index 26f792d8b932d..de1bbfc9ba442 100644
--- a/clang/lib/Headers/hlsl/hlsl_alias_intrinsics.h
+++ b/clang/lib/Headers/hlsl/hlsl_alias_intrinsics.h
@@ -219,4 +219,3 @@ __detail::enable_if_t<__detail::is_arithmetic<T>::Value, vector<T, 4>> select(
} // namespace hlsl
#endif //_HLSL_HLSL_ALIAS_INTRINSICS_H_
-
>From cca6d7434a1e20703063521ffbdff04d7aa2b4c3 Mon Sep 17 00:00:00 2001
From: Deric Cheung <cheung.deric at gmail.com>
Date: Fri, 27 Mar 2026 10:36:18 -0700
Subject: [PATCH 10/12] Make distance be defined by an inline Body call to
length_impl. Remove distance_impl helper.
---
clang/include/clang/Basic/HLSLIntrinsics.td | 7 +++++--
clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h | 12 ------------
2 files changed, 5 insertions(+), 14 deletions(-)
diff --git a/clang/include/clang/Basic/HLSLIntrinsics.td b/clang/include/clang/Basic/HLSLIntrinsics.td
index 9db242c739d08..d0fc48bc917c5 100644
--- a/clang/include/clang/Basic/HLSLIntrinsics.td
+++ b/clang/include/clang/Basic/HLSLIntrinsics.td
@@ -397,17 +397,20 @@ the screen-space y-coordinate.
// Returns a distance scalar between X and Y.
// The distance between X and Y is length(X - Y).
-def hlsl_distance : HLSLTwoArgDetail<"distance", "distance_impl"> {
+def hlsl_distance : HLSLBuiltin<"distance"> {
let Doc = [{
\fn K distance(T X, T Y)
\brief Returns a distance scalar between \a X and \a Y.
\param X The X input value.
\param Y The Y input value.
}];
- let DetailFunc = "distance_impl";
+ let Body = "return __detail::length_impl(X - Y);";
let ParamNames = ["X", "Y"];
+ let Args = [Varying, Varying];
let ReturnType = VaryingElemType;
let VaryingTypes = [HalfTy, FloatTy];
+ let VaryingScalar = 1;
+ let VaryingVecSizes = [2, 3, 4];
let VaryingMatDims = [];
}
diff --git a/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h b/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h
index e541b0ffeda07..45a066833afa2 100644
--- a/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h
+++ b/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h
@@ -28,18 +28,6 @@ length_impl(vector<T, N> X) {
#endif
}
-template <typename T>
-constexpr enable_if_t<is_same<float, T>::value || is_same<half, T>::value, T>
-distance_impl(T X, T Y) {
- return length_impl(X - Y);
-}
-
-template <typename T, int N>
-constexpr enable_if_t<is_same<float, T>::value || is_same<half, T>::value, T>
-distance_impl(vector<T, N> X, vector<T, N> Y) {
- return length_impl(X - Y);
-}
-
constexpr float dot2add_impl(half2 a, half2 b, float c) {
#if (__has_builtin(__builtin_dx_dot2add))
return __builtin_dx_dot2add(a, b, c);
>From 8cb65fe6128467df8d6ab9eccbd2541df16ec858 Mon Sep 17 00:00:00 2001
From: Deric Cheung <cheung.deric at gmail.com>
Date: Fri, 27 Mar 2026 11:58:20 -0700
Subject: [PATCH 11/12] Fix comments on and, or, and WaveActiveAllEqual
---
clang/include/clang/Basic/HLSLIntrinsics.td | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/clang/include/clang/Basic/HLSLIntrinsics.td b/clang/include/clang/Basic/HLSLIntrinsics.td
index e2eb4db3bfc3e..dcce5c6d0d38e 100644
--- a/clang/include/clang/Basic/HLSLIntrinsics.td
+++ b/clang/include/clang/Basic/HLSLIntrinsics.td
@@ -387,7 +387,7 @@ otherwise, false.
let VaryingMatDims = [];
}
-// Returns the boolean AND of two bool values or vectors.
+// Returns the boolean AND of two boolean scalars, vectors, or matrices.
def hlsl_and : HLSLTwoArgBuiltin<"and", "__builtin_hlsl_and"> {
let Doc = [{
\fn bool and(bool x, bool y)
@@ -1217,7 +1217,7 @@ Normalize is based on the following formula: x / length(x).
let VaryingMatDims = [];
}
-// Returns the boolean OR of two bool values or vectors.
+// Returns the boolean OR of two boolean scalars, vectors, or matrices.
def hlsl_or : HLSLTwoArgBuiltin<"or", "__builtin_hlsl_or"> {
let Doc = [{
\fn bool or(bool x, bool y)
@@ -1525,8 +1525,8 @@ group. Otherwise, the result is false.
let VaryingMatDims = [];
}
-// WaveActiveAllEqual — half and 16-bit integer types (no SM6.0 availability;
-// _HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT() is emitted automatically).
+// WaveActiveAllEqual — half and 16-bit integer types. The 6.2 availability
+// annotations for the half and 16-bit types are emitted automatically.
def hlsl_wave_active_all_equal_16bit :
HLSLOneArgBuiltin<"WaveActiveAllEqual",
"__builtin_hlsl_wave_active_all_equal"> {
>From b8c0d440978b70a49616d8ac33ca6ca895c089aa Mon Sep 17 00:00:00 2001
From: Deric Cheung <cheung.deric at gmail.com>
Date: Fri, 27 Mar 2026 12:49:12 -0700
Subject: [PATCH 12/12] Rewrite fma, GroupMemoryBarrier, and QuadReadAcrossY
into TableGen
---
clang/include/clang/Basic/HLSLIntrinsics.td | 38 ++++
.../lib/Headers/hlsl/hlsl_alias_intrinsics.h | 164 ------------------
2 files changed, 38 insertions(+), 164 deletions(-)
diff --git a/clang/include/clang/Basic/HLSLIntrinsics.td b/clang/include/clang/Basic/HLSLIntrinsics.td
index d59880de1ccb5..7d148b18198fc 100644
--- a/clang/include/clang/Basic/HLSLIntrinsics.td
+++ b/clang/include/clang/Basic/HLSLIntrinsics.td
@@ -894,6 +894,18 @@ direction.
let VaryingMatDims = [];
}
+// Return fused multiply-add of double-precision arguments: a * b + c.
+def hlsl_fma : HLSLThreeArgBuiltin<"fma", "__builtin_elementwise_fma"> {
+ let Doc = [{
+\fn double fma(double a, double b, double c)
+\brief Returns the double-precision fused multiply-addition of a * b + c.
+\param a The first value in the fused multiply-addition.
+\param b The second value in the fused multiply-addition.
+\param c The third value in the fused multiply-addition.
+}];
+ let VaryingTypes = [DoubleTy];
+}
+
// Returns the location of the first set bit starting from the lowest order bit
// and working upward, per component.
def hlsl_firstbitlow : HLSLOneArgBuiltin<"firstbitlow",
@@ -979,6 +991,19 @@ with regard to the x and y screen space coordinates.
let VaryingMatDims = [];
}
+// Blocks execution of all threads in a group until all group shared accesses
+// have been completed and all threads in the group have reached this call.
+def hlsl_group_memory_barrier :
+ HLSLBuiltin<"GroupMemoryBarrier",
+ "__builtin_hlsl_group_memory_barrier"> {
+ let Doc = [{
+\fn void GroupMemoryBarrier(void)
+\brief Blocks execution of all threads in a group until all group shared
+accesses have been completed.
+}];
+ let IsConvergent = 1;
+}
+
// Blocks execution of all threads in a group until all group shared accesses
// have been completed and all threads in the group have reached this call.
def hlsl_group_memory_barrier_with_group_sync :
@@ -1255,6 +1280,19 @@ def hlsl_quad_read_across_x :
let VaryingMatDims = [];
}
+// Reads the value from the lane across the X axis of the quad.
+def hlsl_quad_read_across_y :
+ HLSLOneArgBuiltin<"QuadReadAcrossY",
+ "__builtin_hlsl_quad_read_across_y"> {
+ let Doc = [{
+\brief Reads the value from the lane across the Y axis of the quad.
+\param Val The input value.
+}];
+ let VaryingTypes = AllNumericTypes;
+ let IsConvergent = 1;
+ let VaryingMatDims = [];
+}
+
// Converts the specified value from degrees to radians.
def hlsl_radians : HLSLOneArgBuiltin<"radians", "__builtin_hlsl_elementwise_radians"> {
let Doc = [{
diff --git a/clang/lib/Headers/hlsl/hlsl_alias_intrinsics.h b/clang/lib/Headers/hlsl/hlsl_alias_intrinsics.h
index 709f3984a74a9..b2480b30f4a26 100644
--- a/clang/lib/Headers/hlsl/hlsl_alias_intrinsics.h
+++ b/clang/lib/Headers/hlsl/hlsl_alias_intrinsics.h
@@ -41,71 +41,6 @@ namespace hlsl {
// Generated by clang-tblgen from HLSLIntrinsics.td (alias intrinsics).
#include "hlsl_alias_intrinsics_gen.inc"
-//===----------------------------------------------------------------------===//
-// fused multiply-add builtins
-//===----------------------------------------------------------------------===//
-
-/// \fn double fma(double a, double b, double c)
-/// \brief Returns the double-precision fused multiply-addition of a * b + c.
-/// \param a The first value in the fused multiply-addition.
-/// \param b The second value in the fused multiply-addition.
-/// \param c The third value in the fused multiply-addition.
-
-// double scalars and vectors
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_fma)
-double fma(double, double, double);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_fma)
-double2 fma(double2, double2, double2);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_fma)
-double3 fma(double3, double3, double3);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_fma)
-double4 fma(double4, double4, double4);
-
-// double matrices
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_fma)
-double1x1 fma(double1x1, double1x1, double1x1);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_fma)
-double1x2 fma(double1x2, double1x2, double1x2);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_fma)
-double1x3 fma(double1x3, double1x3, double1x3);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_fma)
-double1x4 fma(double1x4, double1x4, double1x4);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_fma)
-double2x1 fma(double2x1, double2x1, double2x1);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_fma)
-double2x2 fma(double2x2, double2x2, double2x2);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_fma)
-double2x3 fma(double2x3, double2x3, double2x3);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_fma)
-double2x4 fma(double2x4, double2x4, double2x4);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_fma)
-double3x1 fma(double3x1, double3x1, double3x1);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_fma)
-double3x2 fma(double3x2, double3x2, double3x2);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_fma)
-double3x3 fma(double3x3, double3x3, double3x3);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_fma)
-double3x4 fma(double3x4, double3x4, double3x4);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_fma)
-double4x1 fma(double4x1, double4x1, double4x1);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_fma)
-double4x2 fma(double4x2, double4x2, double4x2);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_fma)
-double4x3 fma(double4x3, double4x3, double4x3);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_fma)
-double4x4 fma(double4x4, double4x4, double4x4);
-
-//===----------------------------------------------------------------------===//
-// GroupMemoryBarrierbuiltins
-//===----------------------------------------------------------------------===//
-
-/// \fn void GroupMemoryBarrier(void)
-/// \brief Blocks execution of all threads in a group until all group shared
-/// accesses have been completed.
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_group_memory_barrier)
-__attribute__((convergent)) void GroupMemoryBarrier(void);
-
//===----------------------------------------------------------------------===//
// mul builtins
//===----------------------------------------------------------------------===//
@@ -170,105 +105,6 @@ template <typename T, int R, int K, int C>
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mul)
matrix<T, R, C> mul(matrix<T, R, K>, matrix<T, K, C>);
-//===----------------------------------------------------------------------===//
-// QuadReadAcrossY builtins
-//===----------------------------------------------------------------------===//
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_y)
-__attribute__((convergent)) half QuadReadAcrossY(half);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_y)
-__attribute__((convergent)) half2 QuadReadAcrossY(half2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_y)
-__attribute__((convergent)) half3 QuadReadAcrossY(half3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_y)
-__attribute__((convergent)) half4 QuadReadAcrossY(half4);
-
-#ifdef __HLSL_ENABLE_16_BIT
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_y)
-__attribute__((convergent)) int16_t QuadReadAcrossY(int16_t);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_y)
-__attribute__((convergent)) int16_t2 QuadReadAcrossY(int16_t2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_y)
-__attribute__((convergent)) int16_t3 QuadReadAcrossY(int16_t3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_y)
-__attribute__((convergent)) int16_t4 QuadReadAcrossY(int16_t4);
-
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_y)
-__attribute__((convergent)) uint16_t QuadReadAcrossY(uint16_t);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_y)
-__attribute__((convergent)) uint16_t2 QuadReadAcrossY(uint16_t2);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_y)
-__attribute__((convergent)) uint16_t3 QuadReadAcrossY(uint16_t3);
-_HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT()
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_y)
-__attribute__((convergent)) uint16_t4 QuadReadAcrossY(uint16_t4);
-#endif
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_y)
-__attribute__((convergent)) int QuadReadAcrossY(int);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_y)
-__attribute__((convergent)) int2 QuadReadAcrossY(int2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_y)
-__attribute__((convergent)) int3 QuadReadAcrossY(int3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_y)
-__attribute__((convergent)) int4 QuadReadAcrossY(int4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_y)
-__attribute__((convergent)) uint QuadReadAcrossY(uint);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_y)
-__attribute__((convergent)) uint2 QuadReadAcrossY(uint2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_y)
-__attribute__((convergent)) uint3 QuadReadAcrossY(uint3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_y)
-__attribute__((convergent)) uint4 QuadReadAcrossY(uint4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_y)
-__attribute__((convergent)) int64_t QuadReadAcrossY(int64_t);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_y)
-__attribute__((convergent)) int64_t2 QuadReadAcrossY(int64_t2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_y)
-__attribute__((convergent)) int64_t3 QuadReadAcrossY(int64_t3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_y)
-__attribute__((convergent)) int64_t4 QuadReadAcrossY(int64_t4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_y)
-__attribute__((convergent)) uint64_t QuadReadAcrossY(uint64_t);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_y)
-__attribute__((convergent)) uint64_t2 QuadReadAcrossY(uint64_t2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_y)
-__attribute__((convergent)) uint64_t3 QuadReadAcrossY(uint64_t3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_y)
-__attribute__((convergent)) uint64_t4 QuadReadAcrossY(uint64_t4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_y)
-__attribute__((convergent)) float QuadReadAcrossY(float);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_y)
-__attribute__((convergent)) float2 QuadReadAcrossY(float2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_y)
-__attribute__((convergent)) float3 QuadReadAcrossY(float3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_y)
-__attribute__((convergent)) float4 QuadReadAcrossY(float4);
-
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_y)
-__attribute__((convergent)) double QuadReadAcrossY(double);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_y)
-__attribute__((convergent)) double2 QuadReadAcrossY(double2);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_y)
-__attribute__((convergent)) double3 QuadReadAcrossY(double3);
-_HLSL_BUILTIN_ALIAS(__builtin_hlsl_quad_read_across_y)
-__attribute__((convergent)) double4 QuadReadAcrossY(double4);
-
//===----------------------------------------------------------------------===//
// transpose builtins
//===----------------------------------------------------------------------===//
More information about the cfe-commits
mailing list