clang 24.0.0git
hlsl_detail.h
Go to the documentation of this file.
1//===----- hlsl_detail.h - HLSL definitions for intrinsics ----------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _HLSL_HLSL_DETAILS_H_
10#define _HLSL_HLSL_DETAILS_H_
11
12namespace hlsl {
13
14namespace __detail {
15
16constexpr double Pi = 3.14159265358979323846L;
17
18template <typename T, typename U> struct is_same {
19 static const bool value = false;
20};
21
22template <typename T> struct is_same<T, T> {
23 static const bool value = true;
24};
25
26template <bool B, typename T> struct enable_if {};
27
28template <typename T> struct enable_if<true, T> {
29 using Type = T;
30};
31
32template <bool B, class T = void>
34
35template <typename T> struct type_identity {
36 using Type = T;
37};
38
39template <typename T> using type_identity_t = typename type_identity<T>::Type;
40
41template <typename U, typename T, int R, int C>
42constexpr enable_if_t<sizeof(U) == sizeof(T), matrix<U, R, C>>
43bit_cast(matrix<T, R, C> M) {
44 return __builtin_bit_cast(matrix<U, R, C>, M);
45}
46
47template <typename U, typename T, int N>
48constexpr enable_if_t<sizeof(U) == sizeof(T), vector<U, N>>
49bit_cast(vector<T, N> V) {
50 return __builtin_bit_cast(vector<U, N>, V);
51}
52
53template <typename U, typename T>
54constexpr enable_if_t<sizeof(U) == sizeof(T), U> bit_cast(T F) {
55 return __builtin_bit_cast(U, F);
56}
57
58template <typename T> struct is_arithmetic {
59 static const bool Value = __is_arithmetic(T);
60};
61
62template <typename T> struct elem_type {
63 using Type = T;
64};
65template <typename T, int N> struct elem_type<vector<T, N>> {
66 using Type = T;
67};
68template <typename T, int R, int C> struct elem_type<matrix<T, R, C>> {
69 using Type = T;
70};
71template <typename T> using elem_type_t = typename elem_type<T>::Type;
72
73} // namespace __detail
74} // namespace hlsl
75#endif //_HLSL_HLSL_DETAILS_H_
#define V(N, I)
constexpr double Pi
Definition hlsl_detail.h:16
typename type_identity< T >::Type type_identity_t
Definition hlsl_detail.h:39
typename elem_type< T >::Type elem_type_t
Definition hlsl_detail.h:71
typename enable_if< B, T >::Type enable_if_t
Definition hlsl_detail.h:33
constexpr enable_if_t< sizeof(U)==sizeof(T), matrix< U, R, C > > bit_cast(matrix< T, R, C > M)
Definition hlsl_detail.h:43
#define true
Definition stdbool.h:25
static const bool value
Definition hlsl_detail.h:19