xref: /freebsd/contrib/llvm-project/clang/lib/Headers/hlsl/hlsl_intrinsics.h (revision 7ef62cebc2f965b0f640263e179276928885e33d)
1 //===----- hlsl_intrinsics.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_INTRINSICS_H_
10 #define _HLSL_HLSL_INTRINSICS_H_
11 
12 namespace hlsl {
13 
14 __attribute__((availability(shadermodel, introduced = 6.0)))
15 __attribute__((clang_builtin_alias(__builtin_hlsl_wave_active_count_bits))) uint
16 WaveActiveCountBits(bool bBit);
17 
18 // abs builtins
19 #ifdef __HLSL_ENABLE_16_BIT
20 __attribute__((clang_builtin_alias(__builtin_elementwise_abs)))
21 int16_t abs(int16_t);
22 __attribute__((clang_builtin_alias(__builtin_elementwise_abs)))
23 int16_t2 abs(int16_t2);
24 __attribute__((clang_builtin_alias(__builtin_elementwise_abs)))
25 int16_t3 abs(int16_t3);
26 __attribute__((clang_builtin_alias(__builtin_elementwise_abs)))
27 int16_t4 abs(int16_t4);
28 __attribute__((clang_builtin_alias(__builtin_elementwise_abs))) half abs(half);
29 __attribute__((clang_builtin_alias(__builtin_elementwise_abs)))
30 half2 abs(half2);
31 __attribute__((clang_builtin_alias(__builtin_elementwise_abs)))
32 half3 abs(half3);
33 __attribute__((clang_builtin_alias(__builtin_elementwise_abs)))
34 half4 abs(half4);
35 #endif
36 
37 __attribute__((clang_builtin_alias(__builtin_elementwise_abs))) int abs(int);
38 __attribute__((clang_builtin_alias(__builtin_elementwise_abs))) int2 abs(int2);
39 __attribute__((clang_builtin_alias(__builtin_elementwise_abs))) int3 abs(int3);
40 __attribute__((clang_builtin_alias(__builtin_elementwise_abs))) int4 abs(int4);
41 __attribute__((clang_builtin_alias(__builtin_elementwise_abs))) float
42 abs(float);
43 __attribute__((clang_builtin_alias(__builtin_elementwise_abs)))
44 float2 abs(float2);
45 __attribute__((clang_builtin_alias(__builtin_elementwise_abs)))
46 float3 abs(float3);
47 __attribute__((clang_builtin_alias(__builtin_elementwise_abs)))
48 float4 abs(float4);
49 __attribute__((clang_builtin_alias(__builtin_elementwise_abs)))
50 int64_t abs(int64_t);
51 __attribute__((clang_builtin_alias(__builtin_elementwise_abs)))
52 int64_t2 abs(int64_t2);
53 __attribute__((clang_builtin_alias(__builtin_elementwise_abs)))
54 int64_t3 abs(int64_t3);
55 __attribute__((clang_builtin_alias(__builtin_elementwise_abs)))
56 int64_t4 abs(int64_t4);
57 __attribute__((clang_builtin_alias(__builtin_elementwise_abs))) double
58 abs(double);
59 __attribute__((clang_builtin_alias(__builtin_elementwise_abs)))
60 double2 abs(double2);
61 __attribute__((clang_builtin_alias(__builtin_elementwise_abs)))
62 double3 abs(double3);
63 __attribute__((clang_builtin_alias(__builtin_elementwise_abs)))
64 double4 abs(double4);
65 
66 // sqrt builtins
67 __attribute__((clang_builtin_alias(__builtin_sqrt))) double sqrt(double In);
68 __attribute__((clang_builtin_alias(__builtin_sqrtf))) float sqrt(float In);
69 
70 #ifdef __HLSL_ENABLE_16_BIT
71 __attribute__((clang_builtin_alias(__builtin_sqrtf16))) half sqrt(half In);
72 #endif
73 
74 // ceil builtins
75 #ifdef __HLSL_ENABLE_16_BIT
76 __attribute__((clang_builtin_alias(__builtin_elementwise_ceil)))
77 half ceil(half);
78 __attribute__((clang_builtin_alias(__builtin_elementwise_ceil)))
79 half2 ceil(half2);
80 __attribute__((clang_builtin_alias(__builtin_elementwise_ceil)))
81 half3 ceil(half3);
82 __attribute__((clang_builtin_alias(__builtin_elementwise_ceil)))
83 half4 ceil(half4);
84 #endif
85 
86 __attribute__((clang_builtin_alias(__builtin_elementwise_ceil))) float
87 ceil(float);
88 __attribute__((clang_builtin_alias(__builtin_elementwise_ceil)))
89 float2 ceil(float2);
90 __attribute__((clang_builtin_alias(__builtin_elementwise_ceil)))
91 float3 ceil(float3);
92 __attribute__((clang_builtin_alias(__builtin_elementwise_ceil)))
93 float4 ceil(float4);
94 
95 __attribute__((clang_builtin_alias(__builtin_elementwise_ceil))) double
96 ceil(double);
97 __attribute__((clang_builtin_alias(__builtin_elementwise_ceil)))
98 double2 ceil(double2);
99 __attribute__((clang_builtin_alias(__builtin_elementwise_ceil)))
100 double3 ceil(double3);
101 __attribute__((clang_builtin_alias(__builtin_elementwise_ceil)))
102 double4 ceil(double4);
103 
104 // floor builtins
105 #ifdef __HLSL_ENABLE_16_BIT
106 __attribute__((clang_builtin_alias(__builtin_elementwise_floor)))
107 half floor(half);
108 __attribute__((clang_builtin_alias(__builtin_elementwise_floor)))
109 half2 floor(half2);
110 __attribute__((clang_builtin_alias(__builtin_elementwise_floor)))
111 half3 floor(half3);
112 __attribute__((clang_builtin_alias(__builtin_elementwise_floor)))
113 half4 floor(half4);
114 #endif
115 
116 __attribute__((clang_builtin_alias(__builtin_elementwise_floor))) float
117 floor(float);
118 __attribute__((clang_builtin_alias(__builtin_elementwise_floor)))
119 float2 floor(float2);
120 __attribute__((clang_builtin_alias(__builtin_elementwise_floor)))
121 float3 floor(float3);
122 __attribute__((clang_builtin_alias(__builtin_elementwise_floor)))
123 float4 floor(float4);
124 
125 __attribute__((clang_builtin_alias(__builtin_elementwise_floor))) double
126 floor(double);
127 __attribute__((clang_builtin_alias(__builtin_elementwise_floor)))
128 double2 floor(double2);
129 __attribute__((clang_builtin_alias(__builtin_elementwise_floor)))
130 double3 floor(double3);
131 __attribute__((clang_builtin_alias(__builtin_elementwise_floor)))
132 double4 floor(double4);
133 
134 // cos builtins
135 #ifdef __HLSL_ENABLE_16_BIT
136 __attribute__((clang_builtin_alias(__builtin_elementwise_cos))) half cos(half);
137 __attribute__((clang_builtin_alias(__builtin_elementwise_cos)))
138 half2 cos(half2);
139 __attribute__((clang_builtin_alias(__builtin_elementwise_cos)))
140 half3 cos(half3);
141 __attribute__((clang_builtin_alias(__builtin_elementwise_cos)))
142 half4 cos(half4);
143 #endif
144 
145 __attribute__((clang_builtin_alias(__builtin_elementwise_cos))) float
146 cos(float);
147 __attribute__((clang_builtin_alias(__builtin_elementwise_cos)))
148 float2 cos(float2);
149 __attribute__((clang_builtin_alias(__builtin_elementwise_cos)))
150 float3 cos(float3);
151 __attribute__((clang_builtin_alias(__builtin_elementwise_cos)))
152 float4 cos(float4);
153 
154 __attribute__((clang_builtin_alias(__builtin_elementwise_cos))) double
155 cos(double);
156 __attribute__((clang_builtin_alias(__builtin_elementwise_cos)))
157 double2 cos(double2);
158 __attribute__((clang_builtin_alias(__builtin_elementwise_cos)))
159 double3 cos(double3);
160 __attribute__((clang_builtin_alias(__builtin_elementwise_cos)))
161 double4 cos(double4);
162 
163 // sin builtins
164 #ifdef __HLSL_ENABLE_16_BIT
165 __attribute__((clang_builtin_alias(__builtin_elementwise_sin))) half sin(half);
166 __attribute__((clang_builtin_alias(__builtin_elementwise_sin)))
167 half2 sin(half2);
168 __attribute__((clang_builtin_alias(__builtin_elementwise_sin)))
169 half3 sin(half3);
170 __attribute__((clang_builtin_alias(__builtin_elementwise_sin)))
171 half4 sin(half4);
172 #endif
173 
174 __attribute__((clang_builtin_alias(__builtin_elementwise_sin))) float
175 sin(float);
176 __attribute__((clang_builtin_alias(__builtin_elementwise_sin)))
177 float2 sin(float2);
178 __attribute__((clang_builtin_alias(__builtin_elementwise_sin)))
179 float3 sin(float3);
180 __attribute__((clang_builtin_alias(__builtin_elementwise_sin)))
181 float4 sin(float4);
182 
183 __attribute__((clang_builtin_alias(__builtin_elementwise_sin))) double
184 sin(double);
185 __attribute__((clang_builtin_alias(__builtin_elementwise_sin)))
186 double2 sin(double2);
187 __attribute__((clang_builtin_alias(__builtin_elementwise_sin)))
188 double3 sin(double3);
189 __attribute__((clang_builtin_alias(__builtin_elementwise_sin)))
190 double4 sin(double4);
191 
192 // trunc builtins
193 #ifdef __HLSL_ENABLE_16_BIT
194 __attribute__((clang_builtin_alias(__builtin_elementwise_trunc)))
195 half trunc(half);
196 __attribute__((clang_builtin_alias(__builtin_elementwise_trunc)))
197 half2 trunc(half2);
198 __attribute__((clang_builtin_alias(__builtin_elementwise_trunc)))
199 half3 trunc(half3);
200 __attribute__((clang_builtin_alias(__builtin_elementwise_trunc)))
201 half4 trunc(half4);
202 #endif
203 
204 __attribute__((clang_builtin_alias(__builtin_elementwise_trunc))) float
205 trunc(float);
206 __attribute__((clang_builtin_alias(__builtin_elementwise_trunc)))
207 float2 trunc(float2);
208 __attribute__((clang_builtin_alias(__builtin_elementwise_trunc)))
209 float3 trunc(float3);
210 __attribute__((clang_builtin_alias(__builtin_elementwise_trunc)))
211 float4 trunc(float4);
212 
213 __attribute__((clang_builtin_alias(__builtin_elementwise_trunc))) double
214 trunc(double);
215 __attribute__((clang_builtin_alias(__builtin_elementwise_trunc)))
216 double2 trunc(double2);
217 __attribute__((clang_builtin_alias(__builtin_elementwise_trunc)))
218 double3 trunc(double3);
219 __attribute__((clang_builtin_alias(__builtin_elementwise_trunc)))
220 double4 trunc(double4);
221 
222 } // namespace hlsl
223 #endif //_HLSL_HLSL_INTRINSICS_H_
224