//===--- hlsl_alias_intrinsics.h - HLSL alias definitions for intrinsics --===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef _HLSL_HLSL_ALIAS_INTRINSICS_H_ #define _HLSL_HLSL_ALIAS_INTRINSICS_H_ namespace hlsl { // Note: Functions in this file are sorted alphabetically, then grouped by base // element type, and the element types are sorted by size, then singed integer, // unsigned integer and floating point. Keeping this ordering consistent will // help keep this file manageable as it grows. #define _HLSL_BUILTIN_ALIAS(builtin) \ __attribute__((clang_builtin_alias(builtin))) #define _HLSL_AVAILABILITY(platform, version) \ __attribute__((availability(platform, introduced = version))) #define _HLSL_AVAILABILITY_STAGE(platform, version, stage) \ __attribute__(( \ availability(platform, introduced = version, environment = stage))) #ifdef __HLSL_ENABLE_16_BIT #define _HLSL_16BIT_AVAILABILITY(platform, version, ...) \ __attribute__((availability(platform, introduced = version))) #define _HLSL_16BIT_AVAILABILITY_STAGE(platform, version, stage) \ __attribute__(( \ availability(platform, introduced = version, environment = stage))) #define _HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT() \ _HLSL_16BIT_AVAILABILITY(shadermodel, 6.2) #else #define _HLSL_16BIT_AVAILABILITY(platform, version, ...) \ __VA_OPT__(_HLSL_AVAILABILITY(platform, __VA_ARGS__)) #define _HLSL_16BIT_AVAILABILITY_STAGE(environment, version, stage) #define _HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT() #endif // Generated by clang-tblgen from HLSLIntrinsics.td (alias intrinsics). #include "hlsl_alias_intrinsics_gen.inc" //===----------------------------------------------------------------------===// // 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 _HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT() _HLSL_BUILTIN_ALIAS(__builtin_hlsl_mul) vector mul(vector, matrix); template _HLSL_BUILTIN_ALIAS(__builtin_hlsl_mul) vector mul(vector, matrix); // Case 8: matrix * vector -> vector template _HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT() _HLSL_BUILTIN_ALIAS(__builtin_hlsl_mul) vector mul(matrix, vector); template _HLSL_BUILTIN_ALIAS(__builtin_hlsl_mul) vector mul(matrix, vector); // Case 9: matrix * matrix -> matrix template _HLSL_16BIT_AVAILABILITY_SHADERMODEL_DEFAULT() _HLSL_BUILTIN_ALIAS(__builtin_hlsl_mul) matrix mul( matrix, matrix); template _HLSL_BUILTIN_ALIAS(__builtin_hlsl_mul) matrix mul(matrix, matrix); //===----------------------------------------------------------------------===// // transpose builtins //===----------------------------------------------------------------------===// /// \fn matrix transpose(matrix x) /// \brief Returns the transpose of the input matrix. /// \param x [in] The input matrix. template _HLSL_16BIT_AVAILABILITY(shadermodel, 6.2) _HLSL_BUILTIN_ALIAS(__builtin_hlsl_transpose) matrix transpose( matrix); template _HLSL_BUILTIN_ALIAS(__builtin_hlsl_transpose) matrix transpose(matrix); //===----------------------------------------------------------------------===// // 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 _HLSL_BUILTIN_ALIAS(__builtin_hlsl_select) T select(bool, T, T); /// \fn vector select(vector Conds, vector TrueVals, /// vector 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 _HLSL_BUILTIN_ALIAS(__builtin_hlsl_select) vector select(vector, vector, vector); template _HLSL_BUILTIN_ALIAS(__builtin_hlsl_select) vector select(vector, vector, vector); template _HLSL_BUILTIN_ALIAS(__builtin_hlsl_select) vector select(vector, vector, vector); /// \fn vector select(vector Conds, T TrueVal, /// vector 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 _HLSL_BUILTIN_ALIAS(__builtin_hlsl_select) vector select(vector, T, vector); template _HLSL_BUILTIN_ALIAS(__builtin_hlsl_select) vector select(vector, T, vector); template _HLSL_BUILTIN_ALIAS(__builtin_hlsl_select) vector select(vector, T, vector); /// \fn vector select(vector Conds, vector 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 _HLSL_BUILTIN_ALIAS(__builtin_hlsl_select) vector select(vector, vector, T); template _HLSL_BUILTIN_ALIAS(__builtin_hlsl_select) vector select(vector, vector, T); template _HLSL_BUILTIN_ALIAS(__builtin_hlsl_select) vector select(vector, vector, T); /// \fn vector select(vector Conds, vector 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 _HLSL_BUILTIN_ALIAS(__builtin_hlsl_select) __detail::enable_if_t<__detail::is_arithmetic::Value, vector> select( vector, T, T); template _HLSL_BUILTIN_ALIAS(__builtin_hlsl_select) __detail::enable_if_t<__detail::is_arithmetic::Value, vector> select( vector, T, T); template _HLSL_BUILTIN_ALIAS(__builtin_hlsl_select) __detail::enable_if_t<__detail::is_arithmetic::Value, vector> select( vector, T, T); } // namespace hlsl #endif //_HLSL_HLSL_ALIAS_INTRINSICS_H_