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 // log builtins 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))) 226 half2 log(half2); 227 __attribute__((clang_builtin_alias(__builtin_elementwise_log))) 228 half3 log(half3); 229 __attribute__((clang_builtin_alias(__builtin_elementwise_log))) 230 half4 log(half4); 231 #endif 232 233 __attribute__((clang_builtin_alias(__builtin_elementwise_log))) float 234 log(float); 235 __attribute__((clang_builtin_alias(__builtin_elementwise_log))) 236 float2 log(float2); 237 __attribute__((clang_builtin_alias(__builtin_elementwise_log))) 238 float3 log(float3); 239 __attribute__((clang_builtin_alias(__builtin_elementwise_log))) 240 float4 log(float4); 241 242 __attribute__((clang_builtin_alias(__builtin_elementwise_log))) double 243 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); 250 251 // log2 builtins 252 #ifdef __HLSL_ENABLE_16_BIT 253 __attribute__((clang_builtin_alias(__builtin_elementwise_log2))) 254 half log2(half); 255 __attribute__((clang_builtin_alias(__builtin_elementwise_log2))) 256 half2 log2(half2); 257 __attribute__((clang_builtin_alias(__builtin_elementwise_log2))) 258 half3 log2(half3); 259 __attribute__((clang_builtin_alias(__builtin_elementwise_log2))) 260 half4 log2(half4); 261 #endif 262 263 __attribute__((clang_builtin_alias(__builtin_elementwise_log2))) float 264 log2(float); 265 __attribute__((clang_builtin_alias(__builtin_elementwise_log2))) 266 float2 log2(float2); 267 __attribute__((clang_builtin_alias(__builtin_elementwise_log2))) 268 float3 log2(float3); 269 __attribute__((clang_builtin_alias(__builtin_elementwise_log2))) 270 float4 log2(float4); 271 272 __attribute__((clang_builtin_alias(__builtin_elementwise_log2))) double 273 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); 280 281 // log10 builtins 282 #ifdef __HLSL_ENABLE_16_BIT 283 __attribute__((clang_builtin_alias(__builtin_elementwise_log10))) 284 half log10(half); 285 __attribute__((clang_builtin_alias(__builtin_elementwise_log10))) 286 half2 log10(half2); 287 __attribute__((clang_builtin_alias(__builtin_elementwise_log10))) 288 half3 log10(half3); 289 __attribute__((clang_builtin_alias(__builtin_elementwise_log10))) 290 half4 log10(half4); 291 #endif 292 293 __attribute__((clang_builtin_alias(__builtin_elementwise_log10))) float 294 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); 301 302 __attribute__((clang_builtin_alias(__builtin_elementwise_log10))) double 303 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); 310 311 // max builtins 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); 321 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); 330 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); 339 #endif 340 341 __attribute__((clang_builtin_alias(__builtin_elementwise_max))) int max(int, 342 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); 349 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); 358 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); 367 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); 376 377 __attribute__((clang_builtin_alias(__builtin_elementwise_max))) float 378 max(float, 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); 385 386 __attribute__((clang_builtin_alias(__builtin_elementwise_max))) double 387 max(double, 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); 394 395 // min builtins 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); 405 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); 414 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); 423 #endif 424 425 __attribute__((clang_builtin_alias(__builtin_elementwise_min))) int min(int, 426 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); 433 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); 442 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); 451 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); 460 461 __attribute__((clang_builtin_alias(__builtin_elementwise_min))) float 462 min(float, 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); 469 470 __attribute__((clang_builtin_alias(__builtin_elementwise_min))) double 471 min(double, 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); 478 479 } // namespace hlsl 480 #endif //_HLSL_HLSL_INTRINSICS_H_ 481