1 //===----- hlsl_intrinsics.h - HLSL definitions for intrinsics ----------===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef _HLSL_HLSL_INTRINSICS_H_
10 #define _HLSL_HLSL_INTRINSICS_H_
14 __attribute__((availability(shadermodel
, introduced
= 6.0)))
15 __attribute__((clang_builtin_alias(__builtin_hlsl_wave_active_count_bits
))) uint
16 WaveActiveCountBits(bool bBit
);
19 #ifdef __HLSL_ENABLE_16_BIT
20 __attribute__((clang_builtin_alias(__builtin_elementwise_abs
)))
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
)))
31 __attribute__((clang_builtin_alias(__builtin_elementwise_abs
)))
33 __attribute__((clang_builtin_alias(__builtin_elementwise_abs
)))
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
43 __attribute__((clang_builtin_alias(__builtin_elementwise_abs
)))
45 __attribute__((clang_builtin_alias(__builtin_elementwise_abs
)))
47 __attribute__((clang_builtin_alias(__builtin_elementwise_abs
)))
49 __attribute__((clang_builtin_alias(__builtin_elementwise_abs
)))
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
59 __attribute__((clang_builtin_alias(__builtin_elementwise_abs
)))
61 __attribute__((clang_builtin_alias(__builtin_elementwise_abs
)))
63 __attribute__((clang_builtin_alias(__builtin_elementwise_abs
)))
67 __attribute__((clang_builtin_alias(__builtin_sqrt
))) double sqrt(double In
);
68 __attribute__((clang_builtin_alias(__builtin_sqrtf
))) float sqrt(float In
);
70 #ifdef __HLSL_ENABLE_16_BIT
71 __attribute__((clang_builtin_alias(__builtin_sqrtf16
))) half
sqrt(half In
);
75 #ifdef __HLSL_ENABLE_16_BIT
76 __attribute__((clang_builtin_alias(__builtin_elementwise_ceil
)))
78 __attribute__((clang_builtin_alias(__builtin_elementwise_ceil
)))
80 __attribute__((clang_builtin_alias(__builtin_elementwise_ceil
)))
82 __attribute__((clang_builtin_alias(__builtin_elementwise_ceil
)))
86 __attribute__((clang_builtin_alias(__builtin_elementwise_ceil
))) float
88 __attribute__((clang_builtin_alias(__builtin_elementwise_ceil
)))
90 __attribute__((clang_builtin_alias(__builtin_elementwise_ceil
)))
92 __attribute__((clang_builtin_alias(__builtin_elementwise_ceil
)))
95 __attribute__((clang_builtin_alias(__builtin_elementwise_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
);
105 #ifdef __HLSL_ENABLE_16_BIT
106 __attribute__((clang_builtin_alias(__builtin_elementwise_floor
)))
108 __attribute__((clang_builtin_alias(__builtin_elementwise_floor
)))
110 __attribute__((clang_builtin_alias(__builtin_elementwise_floor
)))
112 __attribute__((clang_builtin_alias(__builtin_elementwise_floor
)))
116 __attribute__((clang_builtin_alias(__builtin_elementwise_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
);
125 __attribute__((clang_builtin_alias(__builtin_elementwise_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
);
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
)))
139 __attribute__((clang_builtin_alias(__builtin_elementwise_cos
)))
141 __attribute__((clang_builtin_alias(__builtin_elementwise_cos
)))
145 __attribute__((clang_builtin_alias(__builtin_elementwise_cos
))) float
147 __attribute__((clang_builtin_alias(__builtin_elementwise_cos
)))
149 __attribute__((clang_builtin_alias(__builtin_elementwise_cos
)))
151 __attribute__((clang_builtin_alias(__builtin_elementwise_cos
)))
154 __attribute__((clang_builtin_alias(__builtin_elementwise_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
);
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
)))
168 __attribute__((clang_builtin_alias(__builtin_elementwise_sin
)))
170 __attribute__((clang_builtin_alias(__builtin_elementwise_sin
)))
174 __attribute__((clang_builtin_alias(__builtin_elementwise_sin
))) float
176 __attribute__((clang_builtin_alias(__builtin_elementwise_sin
)))
178 __attribute__((clang_builtin_alias(__builtin_elementwise_sin
)))
180 __attribute__((clang_builtin_alias(__builtin_elementwise_sin
)))
183 __attribute__((clang_builtin_alias(__builtin_elementwise_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
);
193 #ifdef __HLSL_ENABLE_16_BIT
194 __attribute__((clang_builtin_alias(__builtin_elementwise_trunc
)))
196 __attribute__((clang_builtin_alias(__builtin_elementwise_trunc
)))
198 __attribute__((clang_builtin_alias(__builtin_elementwise_trunc
)))
200 __attribute__((clang_builtin_alias(__builtin_elementwise_trunc
)))
204 __attribute__((clang_builtin_alias(__builtin_elementwise_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
);
213 __attribute__((clang_builtin_alias(__builtin_elementwise_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
);
223 #ifdef __HLSL_ENABLE_16_BIT
224 __attribute__((clang_builtin_alias(__builtin_elementwise_log
))) half
log(half
);
225 __attribute__((clang_builtin_alias(__builtin_elementwise_log
)))
227 __attribute__((clang_builtin_alias(__builtin_elementwise_log
)))
229 __attribute__((clang_builtin_alias(__builtin_elementwise_log
)))
233 __attribute__((clang_builtin_alias(__builtin_elementwise_log
))) float
235 __attribute__((clang_builtin_alias(__builtin_elementwise_log
)))
237 __attribute__((clang_builtin_alias(__builtin_elementwise_log
)))
239 __attribute__((clang_builtin_alias(__builtin_elementwise_log
)))
242 __attribute__((clang_builtin_alias(__builtin_elementwise_log
))) double
244 __attribute__((clang_builtin_alias(__builtin_elementwise_log
)))
245 double2
log(double2
);
246 __attribute__((clang_builtin_alias(__builtin_elementwise_log
)))
247 double3
log(double3
);
248 __attribute__((clang_builtin_alias(__builtin_elementwise_log
)))
249 double4
log(double4
);
252 #ifdef __HLSL_ENABLE_16_BIT
253 __attribute__((clang_builtin_alias(__builtin_elementwise_log2
)))
255 __attribute__((clang_builtin_alias(__builtin_elementwise_log2
)))
257 __attribute__((clang_builtin_alias(__builtin_elementwise_log2
)))
259 __attribute__((clang_builtin_alias(__builtin_elementwise_log2
)))
263 __attribute__((clang_builtin_alias(__builtin_elementwise_log2
))) float
265 __attribute__((clang_builtin_alias(__builtin_elementwise_log2
)))
267 __attribute__((clang_builtin_alias(__builtin_elementwise_log2
)))
269 __attribute__((clang_builtin_alias(__builtin_elementwise_log2
)))
272 __attribute__((clang_builtin_alias(__builtin_elementwise_log2
))) double
274 __attribute__((clang_builtin_alias(__builtin_elementwise_log2
)))
275 double2
log2(double2
);
276 __attribute__((clang_builtin_alias(__builtin_elementwise_log2
)))
277 double3
log2(double3
);
278 __attribute__((clang_builtin_alias(__builtin_elementwise_log2
)))
279 double4
log2(double4
);
282 #ifdef __HLSL_ENABLE_16_BIT
283 __attribute__((clang_builtin_alias(__builtin_elementwise_log10
)))
285 __attribute__((clang_builtin_alias(__builtin_elementwise_log10
)))
287 __attribute__((clang_builtin_alias(__builtin_elementwise_log10
)))
289 __attribute__((clang_builtin_alias(__builtin_elementwise_log10
)))
293 __attribute__((clang_builtin_alias(__builtin_elementwise_log10
))) float
295 __attribute__((clang_builtin_alias(__builtin_elementwise_log10
)))
296 float2
log10(float2
);
297 __attribute__((clang_builtin_alias(__builtin_elementwise_log10
)))
298 float3
log10(float3
);
299 __attribute__((clang_builtin_alias(__builtin_elementwise_log10
)))
300 float4
log10(float4
);
302 __attribute__((clang_builtin_alias(__builtin_elementwise_log10
))) double
304 __attribute__((clang_builtin_alias(__builtin_elementwise_log10
)))
305 double2
log10(double2
);
306 __attribute__((clang_builtin_alias(__builtin_elementwise_log10
)))
307 double3
log10(double3
);
308 __attribute__((clang_builtin_alias(__builtin_elementwise_log10
)))
309 double4
log10(double4
);
312 #ifdef __HLSL_ENABLE_16_BIT
313 __attribute__((clang_builtin_alias(__builtin_elementwise_max
)))
314 half
max(half
, half
);
315 __attribute__((clang_builtin_alias(__builtin_elementwise_max
)))
316 half2
max(half2
, half2
);
317 __attribute__((clang_builtin_alias(__builtin_elementwise_max
)))
318 half3
max(half3
, half3
);
319 __attribute__((clang_builtin_alias(__builtin_elementwise_max
)))
320 half4
max(half4
, half4
);
322 __attribute__((clang_builtin_alias(__builtin_elementwise_max
)))
323 int16_t max(int16_t, int16_t);
324 __attribute__((clang_builtin_alias(__builtin_elementwise_max
)))
325 int16_t2
max(int16_t2
, int16_t2
);
326 __attribute__((clang_builtin_alias(__builtin_elementwise_max
)))
327 int16_t3
max(int16_t3
, int16_t3
);
328 __attribute__((clang_builtin_alias(__builtin_elementwise_max
)))
329 int16_t4
max(int16_t4
, int16_t4
);
331 __attribute__((clang_builtin_alias(__builtin_elementwise_max
)))
332 uint16_t max(uint16_t, uint16_t);
333 __attribute__((clang_builtin_alias(__builtin_elementwise_max
)))
334 uint16_t2
max(uint16_t2
, uint16_t2
);
335 __attribute__((clang_builtin_alias(__builtin_elementwise_max
)))
336 uint16_t3
max(uint16_t3
, uint16_t3
);
337 __attribute__((clang_builtin_alias(__builtin_elementwise_max
)))
338 uint16_t4
max(uint16_t4
, uint16_t4
);
341 __attribute__((clang_builtin_alias(__builtin_elementwise_max
))) int max(int,
343 __attribute__((clang_builtin_alias(__builtin_elementwise_max
)))
344 int2
max(int2
, int2
);
345 __attribute__((clang_builtin_alias(__builtin_elementwise_max
)))
346 int3
max(int3
, int3
);
347 __attribute__((clang_builtin_alias(__builtin_elementwise_max
)))
348 int4
max(int4
, int4
);
350 __attribute__((clang_builtin_alias(__builtin_elementwise_max
)))
351 uint
max(uint
, uint
);
352 __attribute__((clang_builtin_alias(__builtin_elementwise_max
)))
353 uint2
max(uint2
, uint2
);
354 __attribute__((clang_builtin_alias(__builtin_elementwise_max
)))
355 uint3
max(uint3
, uint3
);
356 __attribute__((clang_builtin_alias(__builtin_elementwise_max
)))
357 uint4
max(uint4
, uint4
);
359 __attribute__((clang_builtin_alias(__builtin_elementwise_max
)))
360 int64_t max(int64_t, int64_t);
361 __attribute__((clang_builtin_alias(__builtin_elementwise_max
)))
362 int64_t2
max(int64_t2
, int64_t2
);
363 __attribute__((clang_builtin_alias(__builtin_elementwise_max
)))
364 int64_t3
max(int64_t3
, int64_t3
);
365 __attribute__((clang_builtin_alias(__builtin_elementwise_max
)))
366 int64_t4
max(int64_t4
, int64_t4
);
368 __attribute__((clang_builtin_alias(__builtin_elementwise_max
)))
369 uint64_t max(uint64_t, uint64_t);
370 __attribute__((clang_builtin_alias(__builtin_elementwise_max
)))
371 uint64_t2
max(uint64_t2
, uint64_t2
);
372 __attribute__((clang_builtin_alias(__builtin_elementwise_max
)))
373 uint64_t3
max(uint64_t3
, uint64_t3
);
374 __attribute__((clang_builtin_alias(__builtin_elementwise_max
)))
375 uint64_t4
max(uint64_t4
, uint64_t4
);
377 __attribute__((clang_builtin_alias(__builtin_elementwise_max
))) float
379 __attribute__((clang_builtin_alias(__builtin_elementwise_max
)))
380 float2
max(float2
, float2
);
381 __attribute__((clang_builtin_alias(__builtin_elementwise_max
)))
382 float3
max(float3
, float3
);
383 __attribute__((clang_builtin_alias(__builtin_elementwise_max
)))
384 float4
max(float4
, float4
);
386 __attribute__((clang_builtin_alias(__builtin_elementwise_max
))) double
388 __attribute__((clang_builtin_alias(__builtin_elementwise_max
)))
389 double2
max(double2
, double2
);
390 __attribute__((clang_builtin_alias(__builtin_elementwise_max
)))
391 double3
max(double3
, double3
);
392 __attribute__((clang_builtin_alias(__builtin_elementwise_max
)))
393 double4
max(double4
, double4
);
396 #ifdef __HLSL_ENABLE_16_BIT
397 __attribute__((clang_builtin_alias(__builtin_elementwise_min
)))
398 half
min(half
, half
);
399 __attribute__((clang_builtin_alias(__builtin_elementwise_min
)))
400 half2
min(half2
, half2
);
401 __attribute__((clang_builtin_alias(__builtin_elementwise_min
)))
402 half3
min(half3
, half3
);
403 __attribute__((clang_builtin_alias(__builtin_elementwise_min
)))
404 half4
min(half4
, half4
);
406 __attribute__((clang_builtin_alias(__builtin_elementwise_min
)))
407 int16_t min(int16_t, int16_t);
408 __attribute__((clang_builtin_alias(__builtin_elementwise_min
)))
409 int16_t2
min(int16_t2
, int16_t2
);
410 __attribute__((clang_builtin_alias(__builtin_elementwise_min
)))
411 int16_t3
min(int16_t3
, int16_t3
);
412 __attribute__((clang_builtin_alias(__builtin_elementwise_min
)))
413 int16_t4
min(int16_t4
, int16_t4
);
415 __attribute__((clang_builtin_alias(__builtin_elementwise_min
)))
416 uint16_t min(uint16_t, uint16_t);
417 __attribute__((clang_builtin_alias(__builtin_elementwise_min
)))
418 uint16_t2
min(uint16_t2
, uint16_t2
);
419 __attribute__((clang_builtin_alias(__builtin_elementwise_min
)))
420 uint16_t3
min(uint16_t3
, uint16_t3
);
421 __attribute__((clang_builtin_alias(__builtin_elementwise_min
)))
422 uint16_t4
min(uint16_t4
, uint16_t4
);
425 __attribute__((clang_builtin_alias(__builtin_elementwise_min
))) int min(int,
427 __attribute__((clang_builtin_alias(__builtin_elementwise_min
)))
428 int2
min(int2
, int2
);
429 __attribute__((clang_builtin_alias(__builtin_elementwise_min
)))
430 int3
min(int3
, int3
);
431 __attribute__((clang_builtin_alias(__builtin_elementwise_min
)))
432 int4
min(int4
, int4
);
434 __attribute__((clang_builtin_alias(__builtin_elementwise_min
)))
435 uint
min(uint
, uint
);
436 __attribute__((clang_builtin_alias(__builtin_elementwise_min
)))
437 uint2
min(uint2
, uint2
);
438 __attribute__((clang_builtin_alias(__builtin_elementwise_min
)))
439 uint3
min(uint3
, uint3
);
440 __attribute__((clang_builtin_alias(__builtin_elementwise_min
)))
441 uint4
min(uint4
, uint4
);
443 __attribute__((clang_builtin_alias(__builtin_elementwise_min
)))
444 int64_t min(int64_t, int64_t);
445 __attribute__((clang_builtin_alias(__builtin_elementwise_min
)))
446 int64_t2
min(int64_t2
, int64_t2
);
447 __attribute__((clang_builtin_alias(__builtin_elementwise_min
)))
448 int64_t3
min(int64_t3
, int64_t3
);
449 __attribute__((clang_builtin_alias(__builtin_elementwise_min
)))
450 int64_t4
min(int64_t4
, int64_t4
);
452 __attribute__((clang_builtin_alias(__builtin_elementwise_min
)))
453 uint64_t min(uint64_t, uint64_t);
454 __attribute__((clang_builtin_alias(__builtin_elementwise_min
)))
455 uint64_t2
min(uint64_t2
, uint64_t2
);
456 __attribute__((clang_builtin_alias(__builtin_elementwise_min
)))
457 uint64_t3
min(uint64_t3
, uint64_t3
);
458 __attribute__((clang_builtin_alias(__builtin_elementwise_min
)))
459 uint64_t4
min(uint64_t4
, uint64_t4
);
461 __attribute__((clang_builtin_alias(__builtin_elementwise_min
))) float
463 __attribute__((clang_builtin_alias(__builtin_elementwise_min
)))
464 float2
min(float2
, float2
);
465 __attribute__((clang_builtin_alias(__builtin_elementwise_min
)))
466 float3
min(float3
, float3
);
467 __attribute__((clang_builtin_alias(__builtin_elementwise_min
)))
468 float4
min(float4
, float4
);
470 __attribute__((clang_builtin_alias(__builtin_elementwise_min
))) double
472 __attribute__((clang_builtin_alias(__builtin_elementwise_min
)))
473 double2
min(double2
, double2
);
474 __attribute__((clang_builtin_alias(__builtin_elementwise_min
)))
475 double3
min(double3
, double3
);
476 __attribute__((clang_builtin_alias(__builtin_elementwise_min
)))
477 double4
min(double4
, double4
);
480 #endif //_HLSL_HLSL_INTRINSICS_H_