1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350
|
/*========================== begin_copyright_notice ============================
Copyright (C) 2017-2021 Intel Corporation
SPDX-License-Identifier: MIT
============================= end_copyright_notice ===========================*/
// Arithmetic Instructions
half __attribute__((overloadable)) __spirv_Dot(half2 Vector1, half2 Vector2)
{
return __spirv_ocl_fma(Vector1.x, Vector2.x, (Vector1.y * Vector2.y));
}
half __attribute__((overloadable)) __spirv_Dot(half3 Vector1, half3 Vector2)
{
return __spirv_ocl_fma(Vector1.x, Vector2.x,
__spirv_ocl_fma(Vector1.y, Vector2.y, (Vector1.z * Vector2.z)));
}
half __attribute__((overloadable)) __spirv_Dot(half4 Vector1, half4 Vector2)
{
return __spirv_ocl_fma(Vector1.x, Vector2.x,
__spirv_ocl_fma(Vector1.y, Vector2.y,
__spirv_ocl_fma(Vector1.z, Vector2.z,
(Vector1.w * Vector2.w))));
}
// TODO: should we support beyond vec4 which is what OCL is limited to?
#if 0
half __attribute__((overloadable)) __spirv_Dot(half8 Vector1, half8 Vector2)
{
}
half __attribute__((overloadable)) __spirv_Dot(half16 Vector1, half16 Vector2)
{
}
#endif
float __attribute__((overloadable)) __spirv_Dot(float2 Vector1, float2 Vector2)
{
return __spirv_ocl_fma(Vector1.x, Vector2.x, (Vector1.y * Vector2.y));
}
float __attribute__((overloadable)) __spirv_Dot(float3 Vector1, float3 Vector2)
{
return __spirv_ocl_fma(Vector1.x, Vector2.x,
__spirv_ocl_fma(Vector1.y, Vector2.y, (Vector1.z * Vector2.z)));
}
float __attribute__((overloadable)) __spirv_Dot(float4 Vector1, float4 Vector2)
{
return __spirv_ocl_fma(Vector1.x, Vector2.x,
__spirv_ocl_fma(Vector1.y, Vector2.y,
__spirv_ocl_fma(Vector1.z, Vector2.z,
(Vector1.w * Vector2.w))));
}
#if 0
float __attribute__((overloadable)) __spirv_Dot(float8 Vector1, float8 Vector2)
{
}
float __attribute__((overloadable)) __spirv_Dot(float16 Vector1, float16 Vector2)
{
}
#endif
#if defined(cl_khr_fp64)
double __attribute__((overloadable)) __spirv_Dot(double2 Vector1, double2 Vector2)
{
return __spirv_ocl_fma(Vector1.x, Vector2.x, (Vector1.y * Vector2.y));
}
double __attribute__((overloadable)) __spirv_Dot(double3 Vector1, double3 Vector2)
{
return __spirv_ocl_fma(Vector1.x, Vector2.x,
__spirv_ocl_fma(Vector1.y, Vector2.y, (Vector1.z * Vector2.z)));
}
double __attribute__((overloadable)) __spirv_Dot(double4 Vector1, double4 Vector2)
{
return __spirv_ocl_fma(Vector1.x, Vector2.x,
__spirv_ocl_fma(Vector1.y, Vector2.y,
__spirv_ocl_fma(Vector1.z, Vector2.z,
(Vector1.w * Vector2.w))));
}
#endif
#if 0
#if defined(cl_khr_fp64)
double __attribute__((overloadable)) __spirv_Dot(double8 Vector1, double8 Vector2)
{
}
double __attribute__((overloadable)) __spirv_Dot(double16 Vector1, double16 Vector2)
{
}
#endif
#endif
// unsigned
TwoOp_i8 __attribute__((overloadable)) __spirv_UMulExtended(uchar Operand1, uchar Operand2)
{
return (TwoOp_i8) { Operand1 * Operand2, __spirv_ocl_u_mul_hi(Operand1, Operand2) };
}
TwoOp_v2i8 __attribute__((overloadable)) __spirv_UMulExtended(uchar2 Operand1, uchar2 Operand2)
{
return (TwoOp_v2i8) { Operand1 * Operand2, __spirv_ocl_u_mul_hi(Operand1, Operand2) };
}
TwoOp_v3i8 __attribute__((overloadable)) __spirv_UMulExtended(uchar3 Operand1, uchar3 Operand2)
{
return (TwoOp_v3i8) { Operand1 * Operand2, __spirv_ocl_u_mul_hi(Operand1, Operand2) };
}
TwoOp_v4i8 __attribute__((overloadable)) __spirv_UMulExtended(uchar4 Operand1, uchar4 Operand2)
{
return (TwoOp_v4i8) { Operand1 * Operand2, __spirv_ocl_u_mul_hi(Operand1, Operand2) };
}
TwoOp_v8i8 __attribute__((overloadable)) __spirv_UMulExtended(uchar8 Operand1, uchar8 Operand2)
{
return (TwoOp_v8i8) { Operand1 * Operand2, __spirv_ocl_u_mul_hi(Operand1, Operand2) };
}
TwoOp_v16i8 __attribute__((overloadable)) __spirv_UMulExtended(uchar16 Operand1, uchar16 Operand2)
{
return (TwoOp_v16i8) { Operand1 * Operand2, __spirv_ocl_u_mul_hi(Operand1, Operand2) };
}
TwoOp_i16 __attribute__((overloadable)) __spirv_UMulExtended(ushort Operand1, ushort Operand2)
{
return (TwoOp_i16) { Operand1 * Operand2, __spirv_ocl_u_mul_hi(Operand1, Operand2) };
}
TwoOp_v2i16 __attribute__((overloadable)) __spirv_UMulExtended(ushort2 Operand1, ushort2 Operand2)
{
return (TwoOp_v2i16) { Operand1 * Operand2, __spirv_ocl_u_mul_hi(Operand1, Operand2) };
}
TwoOp_v3i16 __attribute__((overloadable)) __spirv_UMulExtended(ushort3 Operand1, ushort3 Operand2)
{
return (TwoOp_v3i16) { Operand1 * Operand2, __spirv_ocl_u_mul_hi(Operand1, Operand2) };
}
TwoOp_v4i16 __attribute__((overloadable)) __spirv_UMulExtended(ushort4 Operand1, ushort4 Operand2)
{
return (TwoOp_v4i16) { Operand1 * Operand2, __spirv_ocl_u_mul_hi(Operand1, Operand2) };
}
TwoOp_v8i16 __attribute__((overloadable)) __spirv_UMulExtended(ushort8 Operand1, ushort8 Operand2)
{
return (TwoOp_v8i16) { Operand1 * Operand2, __spirv_ocl_u_mul_hi(Operand1, Operand2) };
}
TwoOp_v16i16 __attribute__((overloadable)) __spirv_UMulExtended(ushort16 Operand1, ushort16 Operand2)
{
return (TwoOp_v16i16) { Operand1 * Operand2, __spirv_ocl_u_mul_hi(Operand1, Operand2) };
}
TwoOp_i32 __attribute__((overloadable)) __spirv_UMulExtended(uint Operand1, uint Operand2)
{
return (TwoOp_i32) { Operand1 * Operand2, __spirv_ocl_u_mul_hi(Operand1, Operand2) };
}
TwoOp_v2i32 __attribute__((overloadable)) __spirv_UMulExtended(uint2 Operand1, uint2 Operand2)
{
return (TwoOp_v2i32) { Operand1 * Operand2, __spirv_ocl_u_mul_hi(Operand1, Operand2) };
}
TwoOp_v3i32 __attribute__((overloadable)) __spirv_UMulExtended(uint3 Operand1, uint3 Operand2)
{
return (TwoOp_v3i32) { Operand1 * Operand2, __spirv_ocl_u_mul_hi(Operand1, Operand2) };
}
TwoOp_v4i32 __attribute__((overloadable)) __spirv_UMulExtended(uint4 Operand1, uint4 Operand2)
{
return (TwoOp_v4i32) { Operand1 * Operand2, __spirv_ocl_u_mul_hi(Operand1, Operand2) };
}
TwoOp_v8i32 __attribute__((overloadable)) __spirv_UMulExtended(uint8 Operand1, uint8 Operand2)
{
return (TwoOp_v8i32) { Operand1 * Operand2, __spirv_ocl_u_mul_hi(Operand1, Operand2) };
}
TwoOp_v16i32 __attribute__((overloadable)) __spirv_UMulExtended(uint16 Operand1, uint16 Operand2)
{
return (TwoOp_v16i32) { Operand1 * Operand2, __spirv_ocl_u_mul_hi(Operand1, Operand2) };
}
TwoOp_i64 __attribute__((overloadable)) __spirv_UMulExtended(ulong Operand1, ulong Operand2)
{
return (TwoOp_i64) { Operand1 * Operand2, __spirv_ocl_u_mul_hi(Operand1, Operand2) };
}
TwoOp_v2i64 __attribute__((overloadable)) __spirv_UMulExtended(ulong2 Operand1, ulong2 Operand2)
{
return (TwoOp_v2i64) { Operand1 * Operand2, __spirv_ocl_u_mul_hi(Operand1, Operand2) };
}
TwoOp_v3i64 __attribute__((overloadable)) __spirv_UMulExtended(ulong3 Operand1, ulong3 Operand2)
{
return (TwoOp_v3i64) { Operand1 * Operand2, __spirv_ocl_u_mul_hi(Operand1, Operand2) };
}
TwoOp_v4i64 __attribute__((overloadable)) __spirv_UMulExtended(ulong4 Operand1, ulong4 Operand2)
{
return (TwoOp_v4i64) { Operand1 * Operand2, __spirv_ocl_u_mul_hi(Operand1, Operand2) };
}
TwoOp_v8i64 __attribute__((overloadable)) __spirv_UMulExtended(ulong8 Operand1, ulong8 Operand2)
{
return (TwoOp_v8i64) { Operand1 * Operand2, __spirv_ocl_u_mul_hi(Operand1, Operand2) };
}
TwoOp_v16i64 __attribute__((overloadable)) __spirv_UMulExtended(ulong16 Operand1, ulong16 Operand2)
{
return (TwoOp_v16i64) { Operand1 * Operand2, __spirv_ocl_u_mul_hi(Operand1, Operand2) };
}
// signed
TwoOp_i8 __attribute__((overloadable)) __spirv_SMulExtended(char Operand1, char Operand2)
{
return (TwoOp_i8) { as_uchar((char)(Operand1 * Operand2)), as_uchar(__spirv_ocl_s_mul_hi(Operand1, Operand2)) };
}
TwoOp_v2i8 __attribute__((overloadable)) __spirv_SMulExtended(char2 Operand1, char2 Operand2)
{
return (TwoOp_v2i8) { as_uchar2(Operand1 * Operand2), as_uchar2(__spirv_ocl_s_mul_hi(Operand1, Operand2)) };
}
TwoOp_v3i8 __attribute__((overloadable)) __spirv_SMulExtended(char3 Operand1, char3 Operand2)
{
return (TwoOp_v3i8) { as_uchar3(Operand1 * Operand2), as_uchar3(__spirv_ocl_s_mul_hi(Operand1, Operand2)) };
}
TwoOp_v4i8 __attribute__((overloadable)) __spirv_SMulExtended(char4 Operand1, char4 Operand2)
{
return (TwoOp_v4i8) { as_uchar4(Operand1 * Operand2), as_uchar4(__spirv_ocl_s_mul_hi(Operand1, Operand2)) };
}
TwoOp_v8i8 __attribute__((overloadable)) __spirv_SMulExtended(char8 Operand1, char8 Operand2)
{
return (TwoOp_v8i8) { as_uchar8(Operand1 * Operand2), as_uchar8(__spirv_ocl_s_mul_hi(Operand1, Operand2)) };
}
TwoOp_v16i8 __attribute__((overloadable)) __spirv_SMulExtended(char16 Operand1, char16 Operand2)
{
return (TwoOp_v16i8) { as_uchar16(Operand1 * Operand2), as_uchar16(__spirv_ocl_s_mul_hi(Operand1, Operand2)) };
}
TwoOp_i16 __attribute__((overloadable)) __spirv_SMulExtended(short Operand1, short Operand2)
{
return (TwoOp_i16) { as_ushort((short)(Operand1 * Operand2)), as_ushort(__spirv_ocl_s_mul_hi(Operand1, Operand2)) };
}
TwoOp_v2i16 __attribute__((overloadable)) __spirv_SMulExtended(short2 Operand1, short2 Operand2)
{
return (TwoOp_v2i16) { as_ushort2(Operand1 * Operand2), as_ushort2(__spirv_ocl_s_mul_hi(Operand1, Operand2)) };
}
TwoOp_v3i16 __attribute__((overloadable)) __spirv_SMulExtended(short3 Operand1, short3 Operand2)
{
return (TwoOp_v3i16) { as_ushort3(Operand1 * Operand2), as_ushort3(__spirv_ocl_s_mul_hi(Operand1, Operand2)) };
}
TwoOp_v4i16 __attribute__((overloadable)) __spirv_SMulExtended(short4 Operand1, short4 Operand2)
{
return (TwoOp_v4i16) { as_ushort4(Operand1 * Operand2), as_ushort4(__spirv_ocl_s_mul_hi(Operand1, Operand2)) };
}
TwoOp_v8i16 __attribute__((overloadable)) __spirv_SMulExtended(short8 Operand1, short8 Operand2)
{
return (TwoOp_v8i16) { as_ushort8(Operand1 * Operand2), as_ushort8(__spirv_ocl_s_mul_hi(Operand1, Operand2)) };
}
TwoOp_v16i16 __attribute__((overloadable)) __spirv_SMulExtended(short16 Operand1, short16 Operand2)
{
return (TwoOp_v16i16) { as_ushort16(Operand1 * Operand2), as_ushort16(__spirv_ocl_s_mul_hi(Operand1, Operand2)) };
}
TwoOp_i32 __attribute__((overloadable)) __spirv_SMulExtended(int Operand1, int Operand2)
{
return (TwoOp_i32) { as_uint(Operand1 * Operand2), as_uint(__spirv_ocl_s_mul_hi(Operand1, Operand2)) };
}
TwoOp_v2i32 __attribute__((overloadable)) __spirv_SMulExtended(int2 Operand1, int2 Operand2)
{
return (TwoOp_v2i32) { as_uint2(Operand1 * Operand2), as_uint2(__spirv_ocl_s_mul_hi(Operand1, Operand2)) };
}
TwoOp_v3i32 __attribute__((overloadable)) __spirv_SMulExtended(int3 Operand1, int3 Operand2)
{
return (TwoOp_v3i32) { as_uint3(Operand1 * Operand2), as_uint3(__spirv_ocl_s_mul_hi(Operand1, Operand2)) };
}
TwoOp_v4i32 __attribute__((overloadable)) __spirv_SMulExtended(int4 Operand1, int4 Operand2)
{
return (TwoOp_v4i32) { as_uint4(Operand1 * Operand2), as_uint4(__spirv_ocl_s_mul_hi(Operand1, Operand2)) };
}
TwoOp_v8i32 __attribute__((overloadable)) __spirv_SMulExtended(int8 Operand1, int8 Operand2)
{
return (TwoOp_v8i32) { as_uint8(Operand1 * Operand2), as_uint8(__spirv_ocl_s_mul_hi(Operand1, Operand2)) };
}
TwoOp_v16i32 __attribute__((overloadable)) __spirv_SMulExtended(int16 Operand1, int16 Operand2)
{
return (TwoOp_v16i32) { as_uint16(Operand1 * Operand2), as_uint16(__spirv_ocl_s_mul_hi(Operand1, Operand2)) };
}
TwoOp_i64 __attribute__((overloadable)) __spirv_SMulExtended(long Operand1, long Operand2)
{
return (TwoOp_i64) { as_ulong(Operand1 * Operand2), as_ulong(__spirv_ocl_s_mul_hi(Operand1, Operand2)) };
}
TwoOp_v2i64 __attribute__((overloadable)) __spirv_SMulExtended(long2 Operand1, long2 Operand2)
{
return (TwoOp_v2i64) { as_ulong2(Operand1 * Operand2), as_ulong2(__spirv_ocl_s_mul_hi(Operand1, Operand2)) };
}
TwoOp_v3i64 __attribute__((overloadable)) __spirv_SMulExtended(long3 Operand1, long3 Operand2)
{
return (TwoOp_v3i64) { as_ulong3(Operand1 * Operand2), as_ulong3(__spirv_ocl_s_mul_hi(Operand1, Operand2)) };
}
TwoOp_v4i64 __attribute__((overloadable)) __spirv_SMulExtended(long4 Operand1, long4 Operand2)
{
return (TwoOp_v4i64) { as_ulong4(Operand1 * Operand2), as_ulong4(__spirv_ocl_s_mul_hi(Operand1, Operand2)) };
}
TwoOp_v8i64 __attribute__((overloadable)) __spirv_SMulExtended(long8 Operand1, long8 Operand2)
{
return (TwoOp_v8i64) { as_ulong8(Operand1 * Operand2), as_ulong8(__spirv_ocl_s_mul_hi(Operand1, Operand2)) };
}
TwoOp_v16i64 __attribute__((overloadable)) __spirv_SMulExtended(long16 Operand1, long16 Operand2)
{
return (TwoOp_v16i64) { as_ulong16(Operand1 * Operand2), as_ulong16(__spirv_ocl_s_mul_hi(Operand1, Operand2)) };
}
|