rs_cl.c revision 54cd5d1771ea5c95e181befc66ef8e2a2c1b78cd
1be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouillet#include "rs_core.rsh" 25a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 35a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float2 __attribute__((overloadable)) convert_float2(int2 c); 45a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float3 __attribute__((overloadable)) convert_float3(int3 c); 55a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float4 __attribute__((overloadable)) convert_float4(int4 c); 65a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 75a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern int2 __attribute__((overloadable)) convert_int2(float2 c); 85a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern int3 __attribute__((overloadable)) convert_int3(float3 c); 95a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern int4 __attribute__((overloadable)) convert_int4(float4 c); 105a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 115a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 125a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) fmin(float v, float v2); 135a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float2 __attribute__((overloadable)) fmin(float2 v, float v2); 145a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float3 __attribute__((overloadable)) fmin(float3 v, float v2); 155a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float4 __attribute__((overloadable)) fmin(float4 v, float v2); 165a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 175a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) fmax(float v, float v2); 185a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float2 __attribute__((overloadable)) fmax(float2 v, float v2); 195a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float3 __attribute__((overloadable)) fmax(float3 v, float v2); 205a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float4 __attribute__((overloadable)) fmax(float4 v, float v2); 215a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 225a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines// Float ops, 6.11.2 235a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 245a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines#define FN_FUNC_FN(fnc) \ 255a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float2 __attribute__((overloadable)) fnc(float2 v) { \ 265a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float2 r; \ 275a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.x = fnc(v.x); \ 285a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.y = fnc(v.y); \ 295a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return r; \ 305a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} \ 315a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float3 __attribute__((overloadable)) fnc(float3 v) { \ 325a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float3 r; \ 335a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.x = fnc(v.x); \ 345a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.y = fnc(v.y); \ 355a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.z = fnc(v.z); \ 365a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return r; \ 375a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} \ 385a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float4 __attribute__((overloadable)) fnc(float4 v) { \ 395a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float4 r; \ 405a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.x = fnc(v.x); \ 415a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.y = fnc(v.y); \ 425a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.z = fnc(v.z); \ 435a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.w = fnc(v.w); \ 445a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return r; \ 455a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 465a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 475a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines#define IN_FUNC_FN(fnc) \ 485a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern int2 __attribute__((overloadable)) fnc(float2 v) { \ 495a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines int2 r; \ 505a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.x = fnc(v.x); \ 515a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.y = fnc(v.y); \ 525a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return r; \ 535a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} \ 545a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern int3 __attribute__((overloadable)) fnc(float3 v) { \ 555a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines int3 r; \ 565a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.x = fnc(v.x); \ 575a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.y = fnc(v.y); \ 585a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.z = fnc(v.z); \ 595a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return r; \ 605a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} \ 615a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern int4 __attribute__((overloadable)) fnc(float4 v) { \ 625a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines int4 r; \ 635a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.x = fnc(v.x); \ 645a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.y = fnc(v.y); \ 655a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.z = fnc(v.z); \ 665a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.w = fnc(v.w); \ 675a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return r; \ 685a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 695a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 705a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines#define FN_FUNC_FN_FN(fnc) \ 715a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float2 __attribute__((overloadable)) fnc(float2 v1, float2 v2) { \ 725a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float2 r; \ 735a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.x = fnc(v1.x, v2.x); \ 745a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.y = fnc(v1.y, v2.y); \ 755a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return r; \ 765a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} \ 775a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float3 __attribute__((overloadable)) fnc(float3 v1, float3 v2) { \ 785a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float3 r; \ 795a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.x = fnc(v1.x, v2.x); \ 805a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.y = fnc(v1.y, v2.y); \ 815a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.z = fnc(v1.z, v2.z); \ 825a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return r; \ 835a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} \ 845a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float4 __attribute__((overloadable)) fnc(float4 v1, float4 v2) { \ 855a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float4 r; \ 865a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.x = fnc(v1.x, v2.x); \ 875a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.y = fnc(v1.y, v2.y); \ 885a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.z = fnc(v1.z, v2.z); \ 895a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.w = fnc(v1.w, v2.w); \ 905a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return r; \ 915a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 925a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 935a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines#define FN_FUNC_FN_F(fnc) \ 945a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float2 __attribute__((overloadable)) fnc(float2 v1, float v2) { \ 955a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float2 r; \ 965a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.x = fnc(v1.x, v2); \ 975a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.y = fnc(v1.y, v2); \ 985a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return r; \ 995a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} \ 1005a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float3 __attribute__((overloadable)) fnc(float3 v1, float v2) { \ 1015a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float3 r; \ 1025a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.x = fnc(v1.x, v2); \ 1035a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.y = fnc(v1.y, v2); \ 1045a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.z = fnc(v1.z, v2); \ 1055a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return r; \ 1065a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} \ 1075a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float4 __attribute__((overloadable)) fnc(float4 v1, float v2) { \ 1085a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float4 r; \ 1095a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.x = fnc(v1.x, v2); \ 1105a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.y = fnc(v1.y, v2); \ 1115a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.z = fnc(v1.z, v2); \ 1125a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.w = fnc(v1.w, v2); \ 1135a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return r; \ 1145a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 1155a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 1165a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines#define FN_FUNC_FN_IN(fnc) \ 1175a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float2 __attribute__((overloadable)) fnc(float2 v1, int2 v2) { \ 1185a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float2 r; \ 1195a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.x = fnc(v1.x, v2.x); \ 1205a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.y = fnc(v1.y, v2.y); \ 1215a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return r; \ 1225a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} \ 1235a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float3 __attribute__((overloadable)) fnc(float3 v1, int3 v2) { \ 1245a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float3 r; \ 1255a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.x = fnc(v1.x, v2.x); \ 1265a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.y = fnc(v1.y, v2.y); \ 1275a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.z = fnc(v1.z, v2.z); \ 1285a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return r; \ 1295a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} \ 1305a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float4 __attribute__((overloadable)) fnc(float4 v1, int4 v2) { \ 1315a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float4 r; \ 1325a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.x = fnc(v1.x, v2.x); \ 1335a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.y = fnc(v1.y, v2.y); \ 1345a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.z = fnc(v1.z, v2.z); \ 1355a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.w = fnc(v1.w, v2.w); \ 1365a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return r; \ 1375a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 1385a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 1395a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines#define FN_FUNC_FN_I(fnc) \ 1405a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float2 __attribute__((overloadable)) fnc(float2 v1, int v2) { \ 1415a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float2 r; \ 1425a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.x = fnc(v1.x, v2); \ 1435a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.y = fnc(v1.y, v2); \ 1445a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return r; \ 1455a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} \ 1465a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float3 __attribute__((overloadable)) fnc(float3 v1, int v2) { \ 1475a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float3 r; \ 1485a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.x = fnc(v1.x, v2); \ 1495a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.y = fnc(v1.y, v2); \ 1505a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.z = fnc(v1.z, v2); \ 1515a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return r; \ 1525a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} \ 1535a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float4 __attribute__((overloadable)) fnc(float4 v1, int v2) { \ 1545a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float4 r; \ 1555a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.x = fnc(v1.x, v2); \ 1565a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.y = fnc(v1.y, v2); \ 1575a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.z = fnc(v1.z, v2); \ 1585a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.w = fnc(v1.w, v2); \ 1595a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return r; \ 1605a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 1615a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 1625a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines#define FN_FUNC_FN_PFN(fnc) \ 1635a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float2 __attribute__((overloadable)) \ 1645a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines fnc(float2 v1, float2 *v2) { \ 1655a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float2 r; \ 1665a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float t[2]; \ 1675a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.x = fnc(v1.x, &t[0]); \ 1685a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.y = fnc(v1.y, &t[1]); \ 1695a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines v2->x = t[0]; \ 1705a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines v2->y = t[1]; \ 1715a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return r; \ 1725a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} \ 1735a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float3 __attribute__((overloadable)) \ 1745a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines fnc(float3 v1, float3 *v2) { \ 1755a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float3 r; \ 1765a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float t[3]; \ 1775a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.x = fnc(v1.x, &t[0]); \ 1785a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.y = fnc(v1.y, &t[1]); \ 1795a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.z = fnc(v1.z, &t[2]); \ 1805a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines v2->x = t[0]; \ 1815a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines v2->y = t[1]; \ 1825a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines v2->z = t[2]; \ 1835a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return r; \ 1845a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} \ 1855a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float4 __attribute__((overloadable)) \ 1865a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines fnc(float4 v1, float4 *v2) { \ 1875a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float4 r; \ 1885a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float t[4]; \ 1895a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.x = fnc(v1.x, &t[0]); \ 1905a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.y = fnc(v1.y, &t[1]); \ 1915a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.z = fnc(v1.z, &t[2]); \ 1925a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.w = fnc(v1.w, &t[3]); \ 1935a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines v2->x = t[0]; \ 1945a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines v2->y = t[1]; \ 1955a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines v2->z = t[2]; \ 1965a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines v2->w = t[3]; \ 1975a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return r; \ 1985a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 1995a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 2005a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines#define FN_FUNC_FN_PIN(fnc) \ 2015a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float2 __attribute__((overloadable)) fnc(float2 v1, int2 *v2) { \ 2025a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float2 r; \ 2035a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines int t[2]; \ 2045a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.x = fnc(v1.x, &t[0]); \ 2055a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.y = fnc(v1.y, &t[1]); \ 2065a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines v2->x = t[0]; \ 2075a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines v2->y = t[1]; \ 2085a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return r; \ 2095a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} \ 2105a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float3 __attribute__((overloadable)) fnc(float3 v1, int3 *v2) { \ 2115a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float3 r; \ 2125a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines int t[3]; \ 2135a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.x = fnc(v1.x, &t[0]); \ 2145a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.y = fnc(v1.y, &t[1]); \ 2155a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.z = fnc(v1.z, &t[2]); \ 2165a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines v2->x = t[0]; \ 2175a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines v2->y = t[1]; \ 2185a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines v2->z = t[2]; \ 2195a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return r; \ 2205a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} \ 2215a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float4 __attribute__((overloadable)) fnc(float4 v1, int4 *v2) { \ 2225a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float4 r; \ 2235a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines int t[4]; \ 2245a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.x = fnc(v1.x, &t[0]); \ 2255a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.y = fnc(v1.y, &t[1]); \ 2265a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.z = fnc(v1.z, &t[2]); \ 2275a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.w = fnc(v1.w, &t[3]); \ 2285a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines v2->x = t[0]; \ 2295a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines v2->y = t[1]; \ 2305a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines v2->z = t[2]; \ 2315a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines v2->w = t[3]; \ 2325a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return r; \ 2335a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 2345a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 2355a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines#define FN_FUNC_FN_FN_FN(fnc) \ 2365a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float2 __attribute__((overloadable)) \ 2375a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines fnc(float2 v1, float2 v2, float2 v3) { \ 2385a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float2 r; \ 2395a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.x = fnc(v1.x, v2.x, v3.x); \ 2405a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.y = fnc(v1.y, v2.y, v3.y); \ 2415a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return r; \ 2425a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} \ 2435a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float3 __attribute__((overloadable)) \ 2445a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines fnc(float3 v1, float3 v2, float3 v3) { \ 2455a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float3 r; \ 2465a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.x = fnc(v1.x, v2.x, v3.x); \ 2475a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.y = fnc(v1.y, v2.y, v3.y); \ 2485a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.z = fnc(v1.z, v2.z, v3.z); \ 2495a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return r; \ 2505a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} \ 2515a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float4 __attribute__((overloadable)) \ 2525a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines fnc(float4 v1, float4 v2, float4 v3) { \ 2535a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float4 r; \ 2545a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.x = fnc(v1.x, v2.x, v3.x); \ 2555a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.y = fnc(v1.y, v2.y, v3.y); \ 2565a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.z = fnc(v1.z, v2.z, v3.z); \ 2575a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.w = fnc(v1.w, v2.w, v3.w); \ 2585a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return r; \ 2595a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 2605a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 2615a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines#define FN_FUNC_FN_FN_PIN(fnc) \ 2625a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float2 __attribute__((overloadable)) \ 2635a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines fnc(float2 v1, float2 v2, int2 *v3) { \ 2645a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float2 r; \ 2655a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines int t[2]; \ 2665a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.x = fnc(v1.x, v2.x, &t[0]); \ 2675a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.y = fnc(v1.y, v2.y, &t[1]); \ 2685a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines v3->x = t[0]; \ 2695a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines v3->y = t[1]; \ 2705a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return r; \ 2715a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} \ 2725a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float3 __attribute__((overloadable)) \ 2735a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines fnc(float3 v1, float3 v2, int3 *v3) { \ 2745a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float3 r; \ 2755a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines int t[3]; \ 2765a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.x = fnc(v1.x, v2.x, &t[0]); \ 2775a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.y = fnc(v1.y, v2.y, &t[1]); \ 2785a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.z = fnc(v1.z, v2.z, &t[2]); \ 2795a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines v3->x = t[0]; \ 2805a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines v3->y = t[1]; \ 2815a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines v3->z = t[2]; \ 2825a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return r; \ 2835a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} \ 2845a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float4 __attribute__((overloadable)) \ 2855a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines fnc(float4 v1, float4 v2, int4 *v3) { \ 2865a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float4 r; \ 2875a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines int t[4]; \ 2885a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.x = fnc(v1.x, v2.x, &t[0]); \ 2895a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.y = fnc(v1.y, v2.y, &t[1]); \ 2905a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.z = fnc(v1.z, v2.z, &t[2]); \ 2915a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.w = fnc(v1.w, v2.w, &t[3]); \ 2925a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines v3->x = t[0]; \ 2935a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines v3->y = t[1]; \ 2945a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines v3->z = t[2]; \ 2955a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines v3->w = t[3]; \ 2965a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return r; \ 2975a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 2985a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 2995a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesstatic const int iposinf = 0x7f800000; 3005a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesstatic const int ineginf = 0xff800000; 3015a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 3025a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesstatic const float posinf() { 3035a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float f = *((float*)&iposinf); 3045a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return f; 3055a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 3065a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 3075a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesstatic const float neginf() { 3085a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float f = *((float*)&ineginf); 3095a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return f; 3105a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 3115a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 3125a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesstatic bool isinf(float f) { 3135a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines int i = *((int*)(void*)&f); 3145a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return (i == iposinf) || (i == ineginf); 3155a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 3165a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 3175a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesstatic bool isnan(float f) { 3185a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines int i = *((int*)(void*)&f); 3195a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return (((i & 0x7f800000) == 0x7f800000) && (i & 0x007fffff)); 3205a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 3215a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 3225a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesstatic bool isposzero(float f) { 3235a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines int i = *((int*)(void*)&f); 3245a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return (i == 0x00000000); 3255a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 3265a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 3275a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesstatic bool isnegzero(float f) { 3285a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines int i = *((int*)(void*)&f); 3295a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return (i == 0x80000000); 3305a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 3315a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 3325a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesstatic bool iszero(float f) { 3335a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return isposzero(f) || isnegzero(f); 3345a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 3355a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 3365a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 3375a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) acos(float); 3385a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN(acos) 3395a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 3405a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) acosh(float); 3415a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN(acosh) 3425a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 3435a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 3445a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) acospi(float v) { 3455a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return acos(v) / M_PI; 3465a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 3475a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN(acospi) 3485a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 3495a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) asin(float); 3505a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN(asin) 3515a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 3525a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) asinh(float); 3535a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN(asinh) 3545a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 3555a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) asinpi(float v) { 3565a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return asin(v) / M_PI; 3575a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 3585a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN(asinpi) 3595a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 3605a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) atan(float); 3615a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN(atan) 3625a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 3635a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) atan2(float, float); 3645a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN_FN(atan2) 3655a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 3665a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) atanh(float); 3675a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN(atanh) 3685a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 3695a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) atanpi(float v) { 3705a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return atan(v) / M_PI; 3715a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 3725a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN(atanpi) 3735a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 3745a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 3755a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) atan2pi(float y, float x) { 3765a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return atan2(y, x) / M_PI; 3775a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 3785a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN_FN(atan2pi) 3795a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 3805a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) cbrt(float); 3815a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN(cbrt) 3825a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 3835a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) ceil(float); 3845a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN(ceil) 3855a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 3865a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) copysign(float, float); 3875a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN_FN(copysign) 3885a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 3895a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) cos(float); 3905a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN(cos) 3915a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 3925a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) cosh(float); 3935a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN(cosh) 3945a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 3955a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) cospi(float v) { 3965a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return cos(v * M_PI); 3975a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 3985a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN(cospi) 3995a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 4005a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) erfc(float); 4015a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN(erfc) 4025a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 4035a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) erf(float); 4045a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN(erf) 4055a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 4065a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) exp(float); 4075a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN(exp) 4085a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 4095a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) exp2(float); 4105a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN(exp2) 4115a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 4125a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) pow(float, float); 4135a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 4145a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) exp10(float v) { 4155a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return exp2(v * 3.321928095f); 4165a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 4175a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN(exp10) 4185a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 4195a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) expm1(float); 4205a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN(expm1) 4215a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 4225a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) fabs(float v) { 4235a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines int i = *((int*)(void*)&v) & 0x7fffffff; 4245a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return *((float*)(void*)&i); 4255a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 4265a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN(fabs) 4275a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 4285a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) fdim(float, float); 4295a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN_FN(fdim) 4305a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 4315a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) floor(float); 4325a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN(floor) 4335a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 4345a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) fma(float, float, float); 4355a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN_FN_FN(fma) 4365a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 4375a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) fmin(float, float); 4385a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 4395a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) fmod(float, float); 4405a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN_FN(fmod) 4415a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 4425a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) fract(float v, float *iptr) { 4435a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines int i = (int)floor(v); 4445a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines if (iptr) { 4455a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines iptr[0] = i; 4465a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines } 4475a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return fmin(v - i, 0x1.fffffep-1f); 4485a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 4495a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN_PFN(fract) 4505a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 4515a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) frexp(float, int *); 4525a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN_PIN(frexp) 4535a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 4545a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) hypot(float, float); 4555a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN_FN(hypot) 4565a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 4575a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern int __attribute__((overloadable)) ilogb(float); 4585a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesIN_FUNC_FN(ilogb) 4595a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 4605a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) ldexp(float, int); 4615a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN_IN(ldexp) 4625a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN_I(ldexp) 4635a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 4645a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) lgamma(float); 4655a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN(lgamma) 4665a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) lgamma(float, int*); 4675a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN_PIN(lgamma) 4685a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 4695a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) log(float); 4705a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN(log) 4715a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 4725a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) log10(float); 4735a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN(log10) 4745a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 4755a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 4765a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) log2(float v) { 4775a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return log10(v) * 3.321928095f; 4785a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 4795a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN(log2) 4805a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 4815a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) log1p(float); 4825a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN(log1p) 4835a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 4845a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) logb(float); 4855a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN(logb) 4865a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 4875a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) mad(float a, float b, float c) { 4885a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return a * b + c; 4895a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 4905a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float2 __attribute__((overloadable)) mad(float2 a, float2 b, float2 c) { 4915a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return a * b + c; 4925a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 4935a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float3 __attribute__((overloadable)) mad(float3 a, float3 b, float3 c) { 4945a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return a * b + c; 4955a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 4965a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float4 __attribute__((overloadable)) mad(float4 a, float4 b, float4 c) { 4975a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return a * b + c; 4985a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 4995a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 5005a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) modf(float, float *); 5015a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN_PFN(modf); 5025a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 5035a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) nan(uint v) { 5045a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float f[1]; 5055a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines uint32_t *ip = (uint32_t *)f; 5065a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines *ip = v | 0x7fc00000; 5075a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return f[0]; 5085a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 5095a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 5105a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) nextafter(float, float); 5115a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN_FN(nextafter) 5125a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 5135a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN_FN(pow) 5145a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 5155a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) pown(float v, int p) { 5160b0bcff691d047da1d658889866c6a0347850f1cJean-Luc Brouillet /* The mantissa of a float has fewer bits than an int (24 effective vs. 31). 5170b0bcff691d047da1d658889866c6a0347850f1cJean-Luc Brouillet * For very large ints, we'll lose whether the exponent is even or odd, making 518bcd5b9af756d10317faf54fa3742f89dfacef152Jean-Luc Brouillet * the selection of a correct sign incorrect. We correct this. Use copysign 519bcd5b9af756d10317faf54fa3742f89dfacef152Jean-Luc Brouillet * to handle the negative zero case. 5200b0bcff691d047da1d658889866c6a0347850f1cJean-Luc Brouillet */ 521bcd5b9af756d10317faf54fa3742f89dfacef152Jean-Luc Brouillet float sign = (p & 0x1) ? copysign(1.f, v) : 1.f; 5220b0bcff691d047da1d658889866c6a0347850f1cJean-Luc Brouillet float f = pow(v, (float)p); 5230b0bcff691d047da1d658889866c6a0347850f1cJean-Luc Brouillet return copysign(f, sign); 5240b0bcff691d047da1d658889866c6a0347850f1cJean-Luc Brouillet} 5250b0bcff691d047da1d658889866c6a0347850f1cJean-Luc BrouilletFN_FUNC_FN_IN(pown) 5265a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 5275a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) powr(float v, float p) { 5285a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return pow(v, p); 5295a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 5305a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float2 __attribute__((overloadable)) powr(float2 v, float2 p) { 5315a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return pow(v, p); 5325a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 5335a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float3 __attribute__((overloadable)) powr(float3 v, float3 p) { 5345a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return pow(v, p); 5355a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 5365a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float4 __attribute__((overloadable)) powr(float4 v, float4 p) { 5375a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return pow(v, p); 5385a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 5395a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 5405a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) remainder(float, float); 5415a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN_FN(remainder) 5425a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 5435a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) remquo(float, float, int *); 5445a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN_FN_PIN(remquo) 5455a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 5465a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) rint(float); 5475a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN(rint) 5485a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 5495a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) rootn(float v, int r) { 5505a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines if (r == 0) { 5513a3dfe7ecba55a3a832b44e4337276c09a6a25e9Dan Albert return posinf(); 5525a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines } 5535a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 5545a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines if (iszero(v)) { 5555a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines if (r < 0) { 5565a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines if (r & 1) { 5575a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return copysign(posinf(), v); 5585a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines } else { 5595a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return posinf(); 5605a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines } 5615a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines } else { 5625a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines if (r & 1) { 5635a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return copysign(0.f, v); 5645a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines } else { 5655a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return 0.f; 5665a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines } 5675a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines } 5685a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines } 5695a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 5705a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines if (!isinf(v) && !isnan(v) && (v < 0.f)) { 5715a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines if (r & 1) { 5725a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return (-1.f * pow(-1.f * v, 1.f / r)); 5735a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines } else { 5745a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return nan(0); 5755a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines } 5765a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines } 5775a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 5785a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return pow(v, 1.f / r); 5795a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 5805a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN_IN(rootn); 5815a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 5825a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) round(float); 5835a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN(round) 5845a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 5855a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 5865a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) sqrt(float); 5875a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) rsqrt(float v) { 5885a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return 1.f / sqrt(v); 5895a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 590146e138f5c6eb4980ee6d85d33b951b87b6e8efeStephen Hines 591dd635b0a5095b1b2dfae0458069d03c6a13c3473Yong Chen#if !defined(ARCH_X86_HAVE_SSSE3) || defined(RS_DEBUG_RUNTIME) 592a673fb0db28eac2300fcfa04549138c1c9202014Stephen Hines// These functions must be defined here if we are not using the SSE 593a673fb0db28eac2300fcfa04549138c1c9202014Stephen Hines// implementation, which includes when we are built as part of the 594a673fb0db28eac2300fcfa04549138c1c9202014Stephen Hines// debug runtime (libclcore_debug.bc). 595146e138f5c6eb4980ee6d85d33b951b87b6e8efeStephen HinesFN_FUNC_FN(sqrt) 596a140d9d93009aa5733f91bba86c9d5227279e457Jason Sams#else 597a140d9d93009aa5733f91bba86c9d5227279e457Jason Samsextern float2 __attribute__((overloadable)) sqrt(float2); 598a140d9d93009aa5733f91bba86c9d5227279e457Jason Samsextern float3 __attribute__((overloadable)) sqrt(float3); 599a140d9d93009aa5733f91bba86c9d5227279e457Jason Samsextern float4 __attribute__((overloadable)) sqrt(float4); 600dd635b0a5095b1b2dfae0458069d03c6a13c3473Yong Chen#endif // !defined(ARCH_X86_HAVE_SSSE3) || defined(RS_DEBUG_RUNTIME) 601146e138f5c6eb4980ee6d85d33b951b87b6e8efeStephen Hines 6025a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN(rsqrt) 6035a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 6045a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) sin(float); 6055a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN(sin) 6065a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 6075a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) sincos(float v, float *cosptr) { 6085a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines *cosptr = cos(v); 6095a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return sin(v); 6105a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 6115a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float2 __attribute__((overloadable)) sincos(float2 v, float2 *cosptr) { 6125a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines *cosptr = cos(v); 6135a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return sin(v); 6145a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 6155a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float3 __attribute__((overloadable)) sincos(float3 v, float3 *cosptr) { 6165a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines *cosptr = cos(v); 6175a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return sin(v); 6185a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 6195a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float4 __attribute__((overloadable)) sincos(float4 v, float4 *cosptr) { 6205a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines *cosptr = cos(v); 6215a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return sin(v); 6225a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 6235a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 6245a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) sinh(float); 6255a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN(sinh) 6265a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 6275a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) sinpi(float v) { 6285a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return sin(v * M_PI); 6295a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 6305a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN(sinpi) 6315a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 6325a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) tan(float); 6335a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN(tan) 6345a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 6355a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) tanh(float); 6365a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN(tanh) 6375a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 6385a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) tanpi(float v) { 6395a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return tan(v * M_PI); 6405a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 6415a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN(tanpi) 6425a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 6435a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 6445a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) tgamma(float); 6455a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN(tgamma) 6465a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 6475a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) trunc(float); 6485a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN(trunc) 6495a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 6505a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines// Int ops (partial), 6.11.3 6515a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 6525a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines#define XN_FUNC_YN(typeout, fnc, typein) \ 6535a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern typeout __attribute__((overloadable)) fnc(typein); \ 6545a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern typeout##2 __attribute__((overloadable)) fnc(typein##2 v) { \ 6555a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines typeout##2 r; \ 6565a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.x = fnc(v.x); \ 6575a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.y = fnc(v.y); \ 6585a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return r; \ 6595a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} \ 6605a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern typeout##3 __attribute__((overloadable)) fnc(typein##3 v) { \ 6615a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines typeout##3 r; \ 6625a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.x = fnc(v.x); \ 6635a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.y = fnc(v.y); \ 6645a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.z = fnc(v.z); \ 6655a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return r; \ 6665a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} \ 6675a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern typeout##4 __attribute__((overloadable)) fnc(typein##4 v) { \ 6685a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines typeout##4 r; \ 6695a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.x = fnc(v.x); \ 6705a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.y = fnc(v.y); \ 6715a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.z = fnc(v.z); \ 6725a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.w = fnc(v.w); \ 6735a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return r; \ 6745a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 6755a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 6765a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 6775a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines#define UIN_FUNC_IN(fnc) \ 6785a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesXN_FUNC_YN(uchar, fnc, char) \ 6795a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesXN_FUNC_YN(ushort, fnc, short) \ 6805a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesXN_FUNC_YN(uint, fnc, int) 6815a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 6825a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines#define IN_FUNC_IN(fnc) \ 6835a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesXN_FUNC_YN(uchar, fnc, uchar) \ 6845a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesXN_FUNC_YN(char, fnc, char) \ 6855a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesXN_FUNC_YN(ushort, fnc, ushort) \ 6865a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesXN_FUNC_YN(short, fnc, short) \ 6875a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesXN_FUNC_YN(uint, fnc, uint) \ 6885a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesXN_FUNC_YN(int, fnc, int) 6895a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 6905a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 6915a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines#define XN_FUNC_XN_XN_BODY(type, fnc, body) \ 6925a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern type __attribute__((overloadable)) \ 6935a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines fnc(type v1, type v2) { \ 6945a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return body; \ 6955a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} \ 6965a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern type##2 __attribute__((overloadable)) \ 6975a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines fnc(type##2 v1, type##2 v2) { \ 6985a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines type##2 r; \ 6995a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.x = fnc(v1.x, v2.x); \ 7005a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.y = fnc(v1.y, v2.y); \ 7015a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return r; \ 7025a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} \ 7035a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern type##3 __attribute__((overloadable)) \ 7045a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines fnc(type##3 v1, type##3 v2) { \ 7055a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines type##3 r; \ 7065a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.x = fnc(v1.x, v2.x); \ 7075a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.y = fnc(v1.y, v2.y); \ 7085a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.z = fnc(v1.z, v2.z); \ 7095a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return r; \ 7105a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} \ 7115a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern type##4 __attribute__((overloadable)) \ 7125a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines fnc(type##4 v1, type##4 v2) { \ 7135a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines type##4 r; \ 7145a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.x = fnc(v1.x, v2.x); \ 7155a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.y = fnc(v1.y, v2.y); \ 7165a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.z = fnc(v1.z, v2.z); \ 7175a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.w = fnc(v1.w, v2.w); \ 7185a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return r; \ 7195a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 7205a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 7215a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines#define IN_FUNC_IN_IN_BODY(fnc, body) \ 7225a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesXN_FUNC_XN_XN_BODY(uchar, fnc, body) \ 7235a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesXN_FUNC_XN_XN_BODY(char, fnc, body) \ 7245a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesXN_FUNC_XN_XN_BODY(ushort, fnc, body) \ 7255a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesXN_FUNC_XN_XN_BODY(short, fnc, body) \ 7265a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesXN_FUNC_XN_XN_BODY(uint, fnc, body) \ 7275a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesXN_FUNC_XN_XN_BODY(int, fnc, body) \ 7285a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesXN_FUNC_XN_XN_BODY(float, fnc, body) 7295a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 7305a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 7315a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines/** 7325a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines * abs 7335a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines */ 7345a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern uint32_t __attribute__((overloadable)) abs(int32_t v) { 7355a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines if (v < 0) 7365a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return -v; 7375a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return v; 7385a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 7395a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern uint16_t __attribute__((overloadable)) abs(int16_t v) { 7405a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines if (v < 0) 7415a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return -v; 7425a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return v; 7435a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 7445a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern uint8_t __attribute__((overloadable)) abs(int8_t v) { 7455a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines if (v < 0) 7465a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return -v; 7475a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return v; 7485a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 7495a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 7505a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines/** 7515a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines * clz 752c117d8dad895ab9bae4ba6077365f0dfd33ece47Stephen Hines * __builtin_clz only accepts a 32-bit unsigned int, so every input will be 753c117d8dad895ab9bae4ba6077365f0dfd33ece47Stephen Hines * expanded to 32 bits. For our smaller data types, we need to subtract off 754c117d8dad895ab9bae4ba6077365f0dfd33ece47Stephen Hines * these unused top bits (that will be always be composed of zeros). 7555a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines */ 7565a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern uint32_t __attribute__((overloadable)) clz(uint32_t v) { 7575a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return __builtin_clz(v); 7585a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 7595a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern uint16_t __attribute__((overloadable)) clz(uint16_t v) { 760c117d8dad895ab9bae4ba6077365f0dfd33ece47Stephen Hines return __builtin_clz(v) - 16; 7615a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 7625a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern uint8_t __attribute__((overloadable)) clz(uint8_t v) { 763c117d8dad895ab9bae4ba6077365f0dfd33ece47Stephen Hines return __builtin_clz(v) - 24; 7645a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 7655a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern int32_t __attribute__((overloadable)) clz(int32_t v) { 766c117d8dad895ab9bae4ba6077365f0dfd33ece47Stephen Hines return __builtin_clz(v); 7675a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 7685a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern int16_t __attribute__((overloadable)) clz(int16_t v) { 769c117d8dad895ab9bae4ba6077365f0dfd33ece47Stephen Hines return __builtin_clz(((uint32_t)v) & 0x0000ffff) - 16; 7705a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 7715a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern int8_t __attribute__((overloadable)) clz(int8_t v) { 772c117d8dad895ab9bae4ba6077365f0dfd33ece47Stephen Hines return __builtin_clz(((uint32_t)v) & 0x000000ff) - 24; 7735a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 7745a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 7755a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 7765a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesUIN_FUNC_IN(abs) 7775a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesIN_FUNC_IN(clz) 7785a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 7795a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 7805a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines// 6.11.4 7815a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 7825a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 7835a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) degrees(float radians) { 7845a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return radians * (180.f / M_PI); 7855a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 7865a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float2 __attribute__((overloadable)) degrees(float2 radians) { 7875a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return radians * (180.f / M_PI); 7885a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 7895a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float3 __attribute__((overloadable)) degrees(float3 radians) { 7905a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return radians * (180.f / M_PI); 7915a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 7925a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float4 __attribute__((overloadable)) degrees(float4 radians) { 7935a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return radians * (180.f / M_PI); 7945a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 7955a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 7965a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) mix(float start, float stop, float amount) { 7975a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return start + (stop - start) * amount; 7985a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 7995a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float2 __attribute__((overloadable)) mix(float2 start, float2 stop, float2 amount) { 8005a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return start + (stop - start) * amount; 8015a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 8025a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float3 __attribute__((overloadable)) mix(float3 start, float3 stop, float3 amount) { 8035a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return start + (stop - start) * amount; 8045a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 8055a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float4 __attribute__((overloadable)) mix(float4 start, float4 stop, float4 amount) { 8065a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return start + (stop - start) * amount; 8075a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 8085a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float2 __attribute__((overloadable)) mix(float2 start, float2 stop, float amount) { 8095a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return start + (stop - start) * amount; 8105a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 8115a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float3 __attribute__((overloadable)) mix(float3 start, float3 stop, float amount) { 8125a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return start + (stop - start) * amount; 8135a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 8145a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float4 __attribute__((overloadable)) mix(float4 start, float4 stop, float amount) { 8155a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return start + (stop - start) * amount; 8165a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 8175a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 8185a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) radians(float degrees) { 8195a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return degrees * (M_PI / 180.f); 8205a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 8215a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float2 __attribute__((overloadable)) radians(float2 degrees) { 8225a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return degrees * (M_PI / 180.f); 8235a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 8245a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float3 __attribute__((overloadable)) radians(float3 degrees) { 8255a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return degrees * (M_PI / 180.f); 8265a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 8275a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float4 __attribute__((overloadable)) radians(float4 degrees) { 8285a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return degrees * (M_PI / 180.f); 8295a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 8305a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 8315a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) step(float edge, float v) { 8325a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return (v < edge) ? 0.f : 1.f; 8335a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 8345a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float2 __attribute__((overloadable)) step(float2 edge, float2 v) { 8355a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float2 r; 8365a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.x = (v.x < edge.x) ? 0.f : 1.f; 8375a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.y = (v.y < edge.y) ? 0.f : 1.f; 8385a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return r; 8395a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 8405a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float3 __attribute__((overloadable)) step(float3 edge, float3 v) { 8415a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float3 r; 8425a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.x = (v.x < edge.x) ? 0.f : 1.f; 8435a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.y = (v.y < edge.y) ? 0.f : 1.f; 8445a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.z = (v.z < edge.z) ? 0.f : 1.f; 8455a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return r; 8465a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 8475a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float4 __attribute__((overloadable)) step(float4 edge, float4 v) { 8485a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float4 r; 8495a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.x = (v.x < edge.x) ? 0.f : 1.f; 8505a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.y = (v.y < edge.y) ? 0.f : 1.f; 8515a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.z = (v.z < edge.z) ? 0.f : 1.f; 8525a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.w = (v.w < edge.w) ? 0.f : 1.f; 8535a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return r; 8545a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 8555a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float2 __attribute__((overloadable)) step(float2 edge, float v) { 8565a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float2 r; 8575a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.x = (v < edge.x) ? 0.f : 1.f; 8585a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.y = (v < edge.y) ? 0.f : 1.f; 8595a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return r; 8605a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 8615a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float3 __attribute__((overloadable)) step(float3 edge, float v) { 8625a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float3 r; 8635a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.x = (v < edge.x) ? 0.f : 1.f; 8645a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.y = (v < edge.y) ? 0.f : 1.f; 8655a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.z = (v < edge.z) ? 0.f : 1.f; 8665a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return r; 8675a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 8685a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float4 __attribute__((overloadable)) step(float4 edge, float v) { 8695a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float4 r; 8705a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.x = (v < edge.x) ? 0.f : 1.f; 8715a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.y = (v < edge.y) ? 0.f : 1.f; 8725a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.z = (v < edge.z) ? 0.f : 1.f; 8735a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.w = (v < edge.w) ? 0.f : 1.f; 8745a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return r; 8755a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 8760ec1635641a2075c9d2349219632650401f88881Jean-Luc Brouilletextern float2 __attribute__((overloadable)) step(float edge, float2 v) { 8770ec1635641a2075c9d2349219632650401f88881Jean-Luc Brouillet float2 r; 8780ec1635641a2075c9d2349219632650401f88881Jean-Luc Brouillet r.x = (v.x < edge) ? 0.f : 1.f; 8790ec1635641a2075c9d2349219632650401f88881Jean-Luc Brouillet r.y = (v.y < edge) ? 0.f : 1.f; 8800ec1635641a2075c9d2349219632650401f88881Jean-Luc Brouillet return r; 8810ec1635641a2075c9d2349219632650401f88881Jean-Luc Brouillet} 8820ec1635641a2075c9d2349219632650401f88881Jean-Luc Brouilletextern float3 __attribute__((overloadable)) step(float edge, float3 v) { 8830ec1635641a2075c9d2349219632650401f88881Jean-Luc Brouillet float3 r; 8840ec1635641a2075c9d2349219632650401f88881Jean-Luc Brouillet r.x = (v.x < edge) ? 0.f : 1.f; 8850ec1635641a2075c9d2349219632650401f88881Jean-Luc Brouillet r.y = (v.y < edge) ? 0.f : 1.f; 8860ec1635641a2075c9d2349219632650401f88881Jean-Luc Brouillet r.z = (v.z < edge) ? 0.f : 1.f; 8870ec1635641a2075c9d2349219632650401f88881Jean-Luc Brouillet return r; 8880ec1635641a2075c9d2349219632650401f88881Jean-Luc Brouillet} 8890ec1635641a2075c9d2349219632650401f88881Jean-Luc Brouilletextern float4 __attribute__((overloadable)) step(float edge, float4 v) { 8900ec1635641a2075c9d2349219632650401f88881Jean-Luc Brouillet float4 r; 8910ec1635641a2075c9d2349219632650401f88881Jean-Luc Brouillet r.x = (v.x < edge) ? 0.f : 1.f; 8920ec1635641a2075c9d2349219632650401f88881Jean-Luc Brouillet r.y = (v.y < edge) ? 0.f : 1.f; 8930ec1635641a2075c9d2349219632650401f88881Jean-Luc Brouillet r.z = (v.z < edge) ? 0.f : 1.f; 8940ec1635641a2075c9d2349219632650401f88881Jean-Luc Brouillet r.w = (v.w < edge) ? 0.f : 1.f; 8950ec1635641a2075c9d2349219632650401f88881Jean-Luc Brouillet return r; 8960ec1635641a2075c9d2349219632650401f88881Jean-Luc Brouillet} 8975a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 8985a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) sign(float v) { 8995a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines if (v > 0) return 1.f; 9005a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines if (v < 0) return -1.f; 9015a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return v; 9025a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 9035a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN(sign) 9045a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 9055a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 9065a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines// 6.11.5 9075a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float3 __attribute__((overloadable)) cross(float3 lhs, float3 rhs) { 9085a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float3 r; 9095a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.x = lhs.y * rhs.z - lhs.z * rhs.y; 9105a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.y = lhs.z * rhs.x - lhs.x * rhs.z; 9115a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.z = lhs.x * rhs.y - lhs.y * rhs.x; 9125a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return r; 9135a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 9145a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 9155a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float4 __attribute__((overloadable)) cross(float4 lhs, float4 rhs) { 9165a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float4 r; 9175a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.x = lhs.y * rhs.z - lhs.z * rhs.y; 9185a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.y = lhs.z * rhs.x - lhs.x * rhs.z; 9195a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.z = lhs.x * rhs.y - lhs.y * rhs.x; 9205a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r.w = 0.f; 9215a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return r; 9225a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 9235a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 924dd635b0a5095b1b2dfae0458069d03c6a13c3473Yong Chen#if !defined(ARCH_X86_HAVE_SSSE3) || defined(RS_DEBUG_RUNTIME) 925a673fb0db28eac2300fcfa04549138c1c9202014Stephen Hines// These functions must be defined here if we are not using the SSE 926a673fb0db28eac2300fcfa04549138c1c9202014Stephen Hines// implementation, which includes when we are built as part of the 927a673fb0db28eac2300fcfa04549138c1c9202014Stephen Hines// debug runtime (libclcore_debug.bc). 928146e138f5c6eb4980ee6d85d33b951b87b6e8efeStephen Hines 929146e138f5c6eb4980ee6d85d33b951b87b6e8efeStephen Hinesextern float __attribute__((overloadable)) dot(float lhs, float rhs) { 930146e138f5c6eb4980ee6d85d33b951b87b6e8efeStephen Hines return lhs * rhs; 931146e138f5c6eb4980ee6d85d33b951b87b6e8efeStephen Hines} 932146e138f5c6eb4980ee6d85d33b951b87b6e8efeStephen Hinesextern float __attribute__((overloadable)) dot(float2 lhs, float2 rhs) { 933146e138f5c6eb4980ee6d85d33b951b87b6e8efeStephen Hines return lhs.x*rhs.x + lhs.y*rhs.y; 934146e138f5c6eb4980ee6d85d33b951b87b6e8efeStephen Hines} 935146e138f5c6eb4980ee6d85d33b951b87b6e8efeStephen Hinesextern float __attribute__((overloadable)) dot(float3 lhs, float3 rhs) { 936146e138f5c6eb4980ee6d85d33b951b87b6e8efeStephen Hines return lhs.x*rhs.x + lhs.y*rhs.y + lhs.z*rhs.z; 937146e138f5c6eb4980ee6d85d33b951b87b6e8efeStephen Hines} 938146e138f5c6eb4980ee6d85d33b951b87b6e8efeStephen Hinesextern float __attribute__((overloadable)) dot(float4 lhs, float4 rhs) { 939146e138f5c6eb4980ee6d85d33b951b87b6e8efeStephen Hines return lhs.x*rhs.x + lhs.y*rhs.y + lhs.z*rhs.z + lhs.w*rhs.w; 940146e138f5c6eb4980ee6d85d33b951b87b6e8efeStephen Hines} 941146e138f5c6eb4980ee6d85d33b951b87b6e8efeStephen Hines 942146e138f5c6eb4980ee6d85d33b951b87b6e8efeStephen Hinesextern float __attribute__((overloadable)) length(float v) { 943146e138f5c6eb4980ee6d85d33b951b87b6e8efeStephen Hines return fabs(v); 944146e138f5c6eb4980ee6d85d33b951b87b6e8efeStephen Hines} 945146e138f5c6eb4980ee6d85d33b951b87b6e8efeStephen Hinesextern float __attribute__((overloadable)) length(float2 v) { 946146e138f5c6eb4980ee6d85d33b951b87b6e8efeStephen Hines return sqrt(v.x*v.x + v.y*v.y); 947146e138f5c6eb4980ee6d85d33b951b87b6e8efeStephen Hines} 948146e138f5c6eb4980ee6d85d33b951b87b6e8efeStephen Hinesextern float __attribute__((overloadable)) length(float3 v) { 949146e138f5c6eb4980ee6d85d33b951b87b6e8efeStephen Hines return sqrt(v.x*v.x + v.y*v.y + v.z*v.z); 950146e138f5c6eb4980ee6d85d33b951b87b6e8efeStephen Hines} 951146e138f5c6eb4980ee6d85d33b951b87b6e8efeStephen Hinesextern float __attribute__((overloadable)) length(float4 v) { 952146e138f5c6eb4980ee6d85d33b951b87b6e8efeStephen Hines return sqrt(v.x*v.x + v.y*v.y + v.z*v.z + v.w*v.w); 953146e138f5c6eb4980ee6d85d33b951b87b6e8efeStephen Hines} 954146e138f5c6eb4980ee6d85d33b951b87b6e8efeStephen Hines 955146e138f5c6eb4980ee6d85d33b951b87b6e8efeStephen Hines#else 956146e138f5c6eb4980ee6d85d33b951b87b6e8efeStephen Hines 9575a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) length(float v); 9585a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) length(float2 v); 9595a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) length(float3 v); 9605a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) length(float4 v); 9615a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 962dd635b0a5095b1b2dfae0458069d03c6a13c3473Yong Chen#endif // !defined(ARCH_X86_HAVE_SSSE3) || defined(RS_DEBUG_RUNTIME) 963146e138f5c6eb4980ee6d85d33b951b87b6e8efeStephen Hines 9645a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) distance(float lhs, float rhs) { 9655a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return length(lhs - rhs); 9665a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 9675a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) distance(float2 lhs, float2 rhs) { 9685a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return length(lhs - rhs); 9695a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 9705a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) distance(float3 lhs, float3 rhs) { 9715a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return length(lhs - rhs); 9725a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 9735a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) distance(float4 lhs, float4 rhs) { 9745a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return length(lhs - rhs); 9755a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 9765a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 9773e0d1e79789df55021b459ae13590844b67aebd2Jean-Luc Brouillet/* For the normalization functions, vectors of length 0 should simply be 9783e0d1e79789df55021b459ae13590844b67aebd2Jean-Luc Brouillet * returned (i.e. all the components of that vector are 0). 9793e0d1e79789df55021b459ae13590844b67aebd2Jean-Luc Brouillet */ 9805a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) normalize(float v) { 9813e0d1e79789df55021b459ae13590844b67aebd2Jean-Luc Brouillet if (v == 0.0f) { 9823e0d1e79789df55021b459ae13590844b67aebd2Jean-Luc Brouillet return 0.0f; 9833e0d1e79789df55021b459ae13590844b67aebd2Jean-Luc Brouillet } else if (v < 0.0f) { 9843e0d1e79789df55021b459ae13590844b67aebd2Jean-Luc Brouillet return -1.0f; 9853e0d1e79789df55021b459ae13590844b67aebd2Jean-Luc Brouillet } else { 9863e0d1e79789df55021b459ae13590844b67aebd2Jean-Luc Brouillet return 1.0f; 9873e0d1e79789df55021b459ae13590844b67aebd2Jean-Luc Brouillet } 9885a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 9895a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float2 __attribute__((overloadable)) normalize(float2 v) { 9903e0d1e79789df55021b459ae13590844b67aebd2Jean-Luc Brouillet float l = length(v); 9913e0d1e79789df55021b459ae13590844b67aebd2Jean-Luc Brouillet return l == 0.0f ? v : v / l; 9925a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 9935a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float3 __attribute__((overloadable)) normalize(float3 v) { 9943e0d1e79789df55021b459ae13590844b67aebd2Jean-Luc Brouillet float l = length(v); 9953e0d1e79789df55021b459ae13590844b67aebd2Jean-Luc Brouillet return l == 0.0f ? v : v / l; 9965a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 9975a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float4 __attribute__((overloadable)) normalize(float4 v) { 9983e0d1e79789df55021b459ae13590844b67aebd2Jean-Luc Brouillet float l = length(v); 9993e0d1e79789df55021b459ae13590844b67aebd2Jean-Luc Brouillet return l == 0.0f ? v : v / l; 10005a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 10015a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 1002ba92a7085bbb8916334a6571ff33355873883173Jason Samsextern float __attribute__((overloadable)) half_sqrt(float v) { 1003ba92a7085bbb8916334a6571ff33355873883173Jason Sams return sqrt(v); 1004ba92a7085bbb8916334a6571ff33355873883173Jason Sams} 1005ba92a7085bbb8916334a6571ff33355873883173Jason SamsFN_FUNC_FN(half_sqrt) 10065a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 10075a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) fast_length(float v) { 1008582b3646d6634f74a13828cceb1414823c18e66fStephen Hines return fabs(v); 10095a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 10105a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) fast_length(float2 v) { 10115a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return half_sqrt(v.x*v.x + v.y*v.y); 10125a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 10135a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) fast_length(float3 v) { 10145a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return half_sqrt(v.x*v.x + v.y*v.y + v.z*v.z); 10155a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 10165a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) fast_length(float4 v) { 10175a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return half_sqrt(v.x*v.x + v.y*v.y + v.z*v.z + v.w*v.w); 10185a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 10195a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 10205a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) fast_distance(float lhs, float rhs) { 10215a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return fast_length(lhs - rhs); 10225a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 10235a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) fast_distance(float2 lhs, float2 rhs) { 10245a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return fast_length(lhs - rhs); 10255a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 10265a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) fast_distance(float3 lhs, float3 rhs) { 10275a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return fast_length(lhs - rhs); 10285a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 10295a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) fast_distance(float4 lhs, float4 rhs) { 10305a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return fast_length(lhs - rhs); 10315a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 10325a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 10335a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) half_rsqrt(float); 10345a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 10353e0d1e79789df55021b459ae13590844b67aebd2Jean-Luc Brouillet/* For the normalization functions, vectors of length 0 should simply be 10363e0d1e79789df55021b459ae13590844b67aebd2Jean-Luc Brouillet * returned (i.e. all the components of that vector are 0). 10373e0d1e79789df55021b459ae13590844b67aebd2Jean-Luc Brouillet */ 10385a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) fast_normalize(float v) { 10393e0d1e79789df55021b459ae13590844b67aebd2Jean-Luc Brouillet if (v == 0.0f) { 10403e0d1e79789df55021b459ae13590844b67aebd2Jean-Luc Brouillet return 0.0f; 10413e0d1e79789df55021b459ae13590844b67aebd2Jean-Luc Brouillet } else if (v < 0.0f) { 10423e0d1e79789df55021b459ae13590844b67aebd2Jean-Luc Brouillet return -1.0f; 10433e0d1e79789df55021b459ae13590844b67aebd2Jean-Luc Brouillet } else { 10443e0d1e79789df55021b459ae13590844b67aebd2Jean-Luc Brouillet return 1.0f; 10453e0d1e79789df55021b459ae13590844b67aebd2Jean-Luc Brouillet } 10465a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 10473e0d1e79789df55021b459ae13590844b67aebd2Jean-Luc Brouillet// If the length is 0, then rlength should be NaN. 10485a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float2 __attribute__((overloadable)) fast_normalize(float2 v) { 10493e0d1e79789df55021b459ae13590844b67aebd2Jean-Luc Brouillet float rlength = half_rsqrt(v.x*v.x + v.y*v.y); 10503e0d1e79789df55021b459ae13590844b67aebd2Jean-Luc Brouillet return (rlength == rlength) ? v * rlength : v; 10515a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 10525a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float3 __attribute__((overloadable)) fast_normalize(float3 v) { 10533e0d1e79789df55021b459ae13590844b67aebd2Jean-Luc Brouillet float rlength = half_rsqrt(v.x*v.x + v.y*v.y + v.z*v.z); 10543e0d1e79789df55021b459ae13590844b67aebd2Jean-Luc Brouillet return (rlength == rlength) ? v * rlength : v; 10555a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 10565a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float4 __attribute__((overloadable)) fast_normalize(float4 v) { 10573e0d1e79789df55021b459ae13590844b67aebd2Jean-Luc Brouillet float rlength = half_rsqrt(v.x*v.x + v.y*v.y + v.z*v.z + v.w*v.w); 10583e0d1e79789df55021b459ae13590844b67aebd2Jean-Luc Brouillet return (rlength == rlength) ? v * rlength : v; 10595a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 10605a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 1061ba92a7085bbb8916334a6571ff33355873883173Jason Samsextern float __attribute__((overloadable)) half_recip(float v) { 1062ba92a7085bbb8916334a6571ff33355873883173Jason Sams return 1.f / v; 1063ba92a7085bbb8916334a6571ff33355873883173Jason Sams} 10645a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 10655a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines/* 10665a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) approx_atan(float x) { 10675a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines if (x == 0.f) 10685a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return 0.f; 10695a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines if (x < 0.f) 10705a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return -1.f * approx_atan(-1.f * x); 10715a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines if (x > 1.f) 10725a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return M_PI_2 - approx_atan(approx_recip(x)); 10735a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return x * approx_recip(1.f + 0.28f * x*x); 10745a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 10755a47020542c52af3e879c1cd67674ca979ff0a18Stephen HinesFN_FUNC_FN(approx_atan) 10765a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines*/ 10775a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 10785a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinestypedef union 10795a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines{ 10805a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float fv; 10815a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines int32_t iv; 10825a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} ieee_float_shape_type; 10835a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 10845a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines/* Get a 32 bit int from a float. */ 10855a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 10865a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines#define GET_FLOAT_WORD(i,d) \ 10875a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesdo { \ 10885a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines ieee_float_shape_type gf_u; \ 10895a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines gf_u.fv = (d); \ 10905a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines (i) = gf_u.iv; \ 10915a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} while (0) 10925a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 10935a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines/* Set a float from a 32 bit int. */ 10945a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 10955a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines#define SET_FLOAT_WORD(d,i) \ 10965a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesdo { \ 10975a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines ieee_float_shape_type sf_u; \ 10985a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines sf_u.iv = (i); \ 10995a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines (d) = sf_u.fv; \ 11005a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} while (0) 11015a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 11025a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 11035a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 11045a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines// Valid -125 to 125 11055a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) native_exp2(float v) { 11065a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines int32_t iv = (int)v; 11075a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines int32_t x = iv + (iv >> 31); // ~floor(v) 11085a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float r = (v - x); 11095a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 11105a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float fo; 11115a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines SET_FLOAT_WORD(fo, (x + 127) << 23); 11125a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 11135a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r *= 0.694f; // ~ log(e) / log(2) 11145a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float r2 = r*r; 11155a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float adj = 1.f + r + (r2 * 0.5f) + (r2*r * 0.166666f) + (r2*r2 * 0.0416666f); 11165a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return fo * adj; 11175a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 11185a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 11195a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float2 __attribute__((overloadable)) native_exp2(float2 v) { 11205a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines int2 iv = convert_int2(v); 11215a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines int2 x = iv + (iv >> (int2)31);//floor(v); 11225a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float2 r = (v - convert_float2(x)); 11235a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 11245a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines x += 127; 11255a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 11265a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float2 fo = (float2)(x << (int2)23); 11275a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 11285a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r *= 0.694f; // ~ log(e) / log(2) 11295a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float2 r2 = r*r; 11305a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float2 adj = 1.f + r + (r2 * 0.5f) + (r2*r * 0.166666f) + (r2*r2 * 0.0416666f); 11315a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return fo * adj; 11325a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 11335a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 11345a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float4 __attribute__((overloadable)) native_exp2(float4 v) { 11355a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines int4 iv = convert_int4(v); 11365a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines int4 x = iv + (iv >> (int4)31);//floor(v); 11375a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float4 r = (v - convert_float4(x)); 11385a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 11395a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines x += 127; 11405a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 11415a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float4 fo = (float4)(x << (int4)23); 11425a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 11435a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines r *= 0.694f; // ~ log(e) / log(2) 11445a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float4 r2 = r*r; 11455a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float4 adj = 1.f + r + (r2 * 0.5f) + (r2*r * 0.166666f) + (r2*r2 * 0.0416666f); 11465a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return fo * adj; 11475a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 11485a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 11495a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float3 __attribute__((overloadable)) native_exp2(float3 v) { 11505a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float4 t = 1.f; 11515a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines t.xyz = v; 11525a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return native_exp2(t).xyz; 11535a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 11545a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 11555a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 11565a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) native_exp(float v) { 11575a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return native_exp2(v * 1.442695041f); 11585a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 11595a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float2 __attribute__((overloadable)) native_exp(float2 v) { 11605a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return native_exp2(v * 1.442695041f); 11615a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 11625a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float3 __attribute__((overloadable)) native_exp(float3 v) { 11635a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return native_exp2(v * 1.442695041f); 11645a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 11655a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float4 __attribute__((overloadable)) native_exp(float4 v) { 11665a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return native_exp2(v * 1.442695041f); 11675a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 11685a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 11695a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) native_exp10(float v) { 11705a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return native_exp2(v * 3.321928095f); 11715a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 11725a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float2 __attribute__((overloadable)) native_exp10(float2 v) { 11735a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return native_exp2(v * 3.321928095f); 11745a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 11755a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float3 __attribute__((overloadable)) native_exp10(float3 v) { 11765a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return native_exp2(v * 3.321928095f); 11775a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 11785a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float4 __attribute__((overloadable)) native_exp10(float4 v) { 11795a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return native_exp2(v * 3.321928095f); 11805a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 11815a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 11825a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) native_log2(float v) { 11835a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines int32_t ibits; 11845a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines GET_FLOAT_WORD(ibits, v); 11855a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 11865a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines int32_t e = (ibits >> 23) & 0xff; 11875a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 11885a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines ibits &= 0x7fffff; 11895a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines ibits |= 127 << 23; 11905a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 11915a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float ir; 11925a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines SET_FLOAT_WORD(ir, ibits); 11935a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines ir -= 1.5f; 11945a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float ir2 = ir*ir; 1195c944fc899e868612d25d5e70e3f038bbdb4a73b2Jason Sams float adj2 = (0.405465108f / 0.693147181f) + 1196c944fc899e868612d25d5e70e3f038bbdb4a73b2Jason Sams ((0.666666667f / 0.693147181f) * ir) - 1197c944fc899e868612d25d5e70e3f038bbdb4a73b2Jason Sams ((0.222222222f / 0.693147181f) * ir2) + 1198c944fc899e868612d25d5e70e3f038bbdb4a73b2Jason Sams ((0.098765432f / 0.693147181f) * ir*ir2) - 1199c944fc899e868612d25d5e70e3f038bbdb4a73b2Jason Sams ((0.049382716f / 0.693147181f) * ir2*ir2) + 1200c944fc899e868612d25d5e70e3f038bbdb4a73b2Jason Sams ((0.026337449f / 0.693147181f) * ir*ir2*ir2) - 1201c944fc899e868612d25d5e70e3f038bbdb4a73b2Jason Sams ((0.014631916f / 0.693147181f) * ir2*ir2*ir2); 12025a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return (float)(e - 127) + adj2; 12035a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 12045a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float2 __attribute__((overloadable)) native_log2(float2 v) { 12055a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float2 v2 = {native_log2(v.x), native_log2(v.y)}; 12065a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return v2; 12075a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 12085a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float3 __attribute__((overloadable)) native_log2(float3 v) { 12095a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float3 v2 = {native_log2(v.x), native_log2(v.y), native_log2(v.z)}; 12105a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return v2; 12115a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 12125a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float4 __attribute__((overloadable)) native_log2(float4 v) { 12135a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float4 v2 = {native_log2(v.x), native_log2(v.y), native_log2(v.z), native_log2(v.w)}; 12145a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return v2; 12155a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 12165a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 12175a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) native_log(float v) { 12185a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return native_log2(v) * (1.f / 1.442695041f); 12195a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 12205a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float2 __attribute__((overloadable)) native_log(float2 v) { 12215a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return native_log2(v) * (1.f / 1.442695041f); 12225a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 12235a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float3 __attribute__((overloadable)) native_log(float3 v) { 12245a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return native_log2(v) * (1.f / 1.442695041f); 12255a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 12265a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float4 __attribute__((overloadable)) native_log(float4 v) { 12275a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return native_log2(v) * (1.f / 1.442695041f); 12285a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 12295a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 12305a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) native_log10(float v) { 12315a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return native_log2(v) * (1.f / 3.321928095f); 12325a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 12335a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float2 __attribute__((overloadable)) native_log10(float2 v) { 12345a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return native_log2(v) * (1.f / 3.321928095f); 12355a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 12365a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float3 __attribute__((overloadable)) native_log10(float3 v) { 12375a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return native_log2(v) * (1.f / 3.321928095f); 12385a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 12395a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float4 __attribute__((overloadable)) native_log10(float4 v) { 12405a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return native_log2(v) * (1.f / 3.321928095f); 12415a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 12425a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 12435a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 12445a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float __attribute__((overloadable)) native_powr(float v, float y) { 12455a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float v2 = native_log2(v); 1246c944fc899e868612d25d5e70e3f038bbdb4a73b2Jason Sams v2 = fmax(v2 * y, -125.f); 1247c944fc899e868612d25d5e70e3f038bbdb4a73b2Jason Sams return native_exp2(v2); 12485a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 12495a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float2 __attribute__((overloadable)) native_powr(float2 v, float2 y) { 12505a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float2 v2 = native_log2(v); 1251c944fc899e868612d25d5e70e3f038bbdb4a73b2Jason Sams v2 = fmax(v2 * y, -125.f); 1252c944fc899e868612d25d5e70e3f038bbdb4a73b2Jason Sams return native_exp2(v2); 12535a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 12545a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float3 __attribute__((overloadable)) native_powr(float3 v, float3 y) { 12555a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float3 v2 = native_log2(v); 1256c944fc899e868612d25d5e70e3f038bbdb4a73b2Jason Sams v2 = fmax(v2 * y, -125.f); 1257c944fc899e868612d25d5e70e3f038bbdb4a73b2Jason Sams return native_exp2(v2); 12585a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 12595a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern float4 __attribute__((overloadable)) native_powr(float4 v, float4 y) { 12605a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines float4 v2 = native_log2(v); 1261c944fc899e868612d25d5e70e3f038bbdb4a73b2Jason Sams v2 = fmax(v2 * y, -125.f); 1262c944fc899e868612d25d5e70e3f038bbdb4a73b2Jason Sams return native_exp2(v2); 12635a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 12645a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 126553826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Samsextern double __attribute__((overloadable)) min(double v1, double v2) { 126653826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams return v1 < v2 ? v1 : v2; 126753826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams} 126853826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams 126953826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Samsextern double2 __attribute__((overloadable)) min(double2 v1, double2 v2) { 127053826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams double2 r; 127153826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.x = v1.x < v2.x ? v1.x : v2.x; 127253826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.y = v1.y < v2.y ? v1.y : v2.y; 127353826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams return r; 127453826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams} 127553826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams 127653826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Samsextern double3 __attribute__((overloadable)) min(double3 v1, double3 v2) { 127753826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams double3 r; 127853826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.x = v1.x < v2.x ? v1.x : v2.x; 127953826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.y = v1.y < v2.y ? v1.y : v2.y; 128053826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.z = v1.z < v2.z ? v1.z : v2.z; 128153826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams return r; 128253826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams} 128353826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams 128453826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Samsextern double4 __attribute__((overloadable)) min(double4 v1, double4 v2) { 128553826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams double4 r; 128653826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.x = v1.x < v2.x ? v1.x : v2.x; 128753826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.y = v1.y < v2.y ? v1.y : v2.y; 128853826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.z = v1.z < v2.z ? v1.z : v2.z; 128953826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.w = v1.w < v2.w ? v1.w : v2.w; 129053826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams return r; 129153826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams} 129253826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams 1293d8b8f8a16415496acc9844a89599ce7f377bd04dJason Samsextern long __attribute__((overloadable)) min(long v1, long v2) { 129453826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams return v1 < v2 ? v1 : v2; 129553826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams} 1296d8b8f8a16415496acc9844a89599ce7f377bd04dJason Samsextern long2 __attribute__((overloadable)) min(long2 v1, long2 v2) { 129753826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams long2 r; 129853826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.x = v1.x < v2.x ? v1.x : v2.x; 129953826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.y = v1.y < v2.y ? v1.y : v2.y; 130053826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams return r; 130153826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams} 1302d8b8f8a16415496acc9844a89599ce7f377bd04dJason Samsextern long3 __attribute__((overloadable)) min(long3 v1, long3 v2) { 130353826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams long3 r; 130453826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.x = v1.x < v2.x ? v1.x : v2.x; 130553826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.y = v1.y < v2.y ? v1.y : v2.y; 130653826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.z = v1.z < v2.z ? v1.z : v2.z; 130753826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams return r; 130853826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams} 1309d8b8f8a16415496acc9844a89599ce7f377bd04dJason Samsextern long4 __attribute__((overloadable)) min(long4 v1, long4 v2) { 131053826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams long4 r; 131153826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.x = v1.x < v2.x ? v1.x : v2.x; 131253826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.y = v1.y < v2.y ? v1.y : v2.y; 131353826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.z = v1.z < v2.z ? v1.z : v2.z; 131453826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.w = v1.w < v2.w ? v1.w : v2.w; 131553826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams return r; 131653826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams} 131753826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams 1318d8b8f8a16415496acc9844a89599ce7f377bd04dJason Samsextern ulong __attribute__((overloadable)) min(ulong v1, ulong v2) { 131953826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams return v1 < v2 ? v1 : v2; 132053826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams} 1321d8b8f8a16415496acc9844a89599ce7f377bd04dJason Samsextern ulong2 __attribute__((overloadable)) min(ulong2 v1, ulong2 v2) { 132253826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams ulong2 r; 132353826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.x = v1.x < v2.x ? v1.x : v2.x; 132453826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.y = v1.y < v2.y ? v1.y : v2.y; 132553826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams return r; 132653826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams} 1327d8b8f8a16415496acc9844a89599ce7f377bd04dJason Samsextern ulong3 __attribute__((overloadable)) min(ulong3 v1, ulong3 v2) { 132853826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams ulong3 r; 132953826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.x = v1.x < v2.x ? v1.x : v2.x; 133053826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.y = v1.y < v2.y ? v1.y : v2.y; 133153826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.z = v1.z < v2.z ? v1.z : v2.z; 133253826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams return r; 133353826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams} 1334d8b8f8a16415496acc9844a89599ce7f377bd04dJason Samsextern ulong4 __attribute__((overloadable)) min(ulong4 v1, ulong4 v2) { 133553826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams ulong4 r; 133653826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.x = v1.x < v2.x ? v1.x : v2.x; 133753826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.y = v1.y < v2.y ? v1.y : v2.y; 133853826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.z = v1.z < v2.z ? v1.z : v2.z; 133953826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.w = v1.w < v2.w ? v1.w : v2.w; 134053826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams return r; 134153826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams} 134253826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams 134353826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Samsextern double __attribute__((overloadable)) max(double v1, double v2) { 134453826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams return v1 > v2 ? v1 : v2; 134553826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams} 134653826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams 134753826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Samsextern double2 __attribute__((overloadable)) max(double2 v1, double2 v2) { 134853826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams double2 r; 134953826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.x = v1.x > v2.x ? v1.x : v2.x; 135053826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.y = v1.y > v2.y ? v1.y : v2.y; 135153826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams return r; 135253826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams} 135353826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams 135453826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Samsextern double3 __attribute__((overloadable)) max(double3 v1, double3 v2) { 135553826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams double3 r; 135653826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.x = v1.x > v2.x ? v1.x : v2.x; 135753826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.y = v1.y > v2.y ? v1.y : v2.y; 135853826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.z = v1.z > v2.z ? v1.z : v2.z; 135953826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams return r; 136053826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams} 136153826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams 136253826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Samsextern double4 __attribute__((overloadable)) max(double4 v1, double4 v2) { 136353826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams double4 r; 136453826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.x = v1.x > v2.x ? v1.x : v2.x; 136553826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.y = v1.y > v2.y ? v1.y : v2.y; 136653826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.z = v1.z > v2.z ? v1.z : v2.z; 136753826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.w = v1.w > v2.w ? v1.w : v2.w; 136853826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams return r; 136953826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams} 137053826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams 1371d8b8f8a16415496acc9844a89599ce7f377bd04dJason Samsextern long __attribute__((overloadable)) max(long v1, long v2) { 137253826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams return v1 > v2 ? v1 : v2; 137353826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams} 1374d8b8f8a16415496acc9844a89599ce7f377bd04dJason Samsextern long2 __attribute__((overloadable)) max(long2 v1, long2 v2) { 137553826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams long2 r; 137653826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.x = v1.x > v2.x ? v1.x : v2.x; 137753826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.y = v1.y > v2.y ? v1.y : v2.y; 137853826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams return r; 137953826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams} 1380d8b8f8a16415496acc9844a89599ce7f377bd04dJason Samsextern long3 __attribute__((overloadable)) max(long3 v1, long3 v2) { 138153826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams long3 r; 138253826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.x = v1.x > v2.x ? v1.x : v2.x; 138353826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.y = v1.y > v2.y ? v1.y : v2.y; 138453826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.z = v1.z > v2.z ? v1.z : v2.z; 138553826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams return r; 138653826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams} 1387d8b8f8a16415496acc9844a89599ce7f377bd04dJason Samsextern long4 __attribute__((overloadable)) max(long4 v1, long4 v2) { 138853826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams long4 r; 138953826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.x = v1.x > v2.x ? v1.x : v2.x; 139053826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.y = v1.y > v2.y ? v1.y : v2.y; 139153826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.z = v1.z > v2.z ? v1.z : v2.z; 139253826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.w = v1.w > v2.w ? v1.w : v2.w; 139353826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams return r; 139453826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams} 139553826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams 1396d8b8f8a16415496acc9844a89599ce7f377bd04dJason Samsextern ulong __attribute__((overloadable)) max(ulong v1, ulong v2) { 139753826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams return v1 > v2 ? v1 : v2; 139853826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams} 1399d8b8f8a16415496acc9844a89599ce7f377bd04dJason Samsextern ulong2 __attribute__((overloadable)) max(ulong2 v1, ulong2 v2) { 140053826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams ulong2 r; 140153826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.x = v1.x > v2.x ? v1.x : v2.x; 140253826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.y = v1.y > v2.y ? v1.y : v2.y; 140353826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams return r; 140453826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams} 1405d8b8f8a16415496acc9844a89599ce7f377bd04dJason Samsextern ulong3 __attribute__((overloadable)) max(ulong3 v1, ulong3 v2) { 140653826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams ulong3 r; 140753826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.x = v1.x > v2.x ? v1.x : v2.x; 140853826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.y = v1.y > v2.y ? v1.y : v2.y; 140953826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.z = v1.z > v2.z ? v1.z : v2.z; 141053826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams return r; 141153826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams} 1412d8b8f8a16415496acc9844a89599ce7f377bd04dJason Samsextern ulong4 __attribute__((overloadable)) max(ulong4 v1, ulong4 v2) { 141353826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams ulong4 r; 141453826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.x = v1.x > v2.x ? v1.x : v2.x; 141553826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.y = v1.y > v2.y ? v1.y : v2.y; 141653826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.z = v1.z > v2.z ? v1.z : v2.z; 141753826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams r.w = v1.w > v2.w ? v1.w : v2.w; 141853826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams return r; 141953826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams} 142053826db2ea7f26a241be881c2b454ab3e1e5dd50Jason Sams 1421a140d9d93009aa5733f91bba86c9d5227279e457Jason Sams#define THUNK_NATIVE_F(fn) \ 1422a140d9d93009aa5733f91bba86c9d5227279e457Jason Sams float __attribute__((overloadable)) native_##fn(float v) { return fn(v);} \ 1423a140d9d93009aa5733f91bba86c9d5227279e457Jason Sams float2 __attribute__((overloadable)) native_##fn(float2 v) { return fn(v);} \ 1424a140d9d93009aa5733f91bba86c9d5227279e457Jason Sams float3 __attribute__((overloadable)) native_##fn(float3 v) { return fn(v);} \ 1425a140d9d93009aa5733f91bba86c9d5227279e457Jason Sams float4 __attribute__((overloadable)) native_##fn(float4 v) { return fn(v);} 1426a140d9d93009aa5733f91bba86c9d5227279e457Jason Sams 1427a140d9d93009aa5733f91bba86c9d5227279e457Jason Sams#define THUNK_NATIVE_F_F(fn) \ 1428a140d9d93009aa5733f91bba86c9d5227279e457Jason Sams float __attribute__((overloadable)) native_##fn(float v1, float v2) { return fn(v1, v2);} \ 1429a140d9d93009aa5733f91bba86c9d5227279e457Jason Sams float2 __attribute__((overloadable)) native_##fn(float2 v1, float2 v2) { return fn(v1, v2);} \ 1430a140d9d93009aa5733f91bba86c9d5227279e457Jason Sams float3 __attribute__((overloadable)) native_##fn(float3 v1, float3 v2) { return fn(v1, v2);} \ 1431a140d9d93009aa5733f91bba86c9d5227279e457Jason Sams float4 __attribute__((overloadable)) native_##fn(float4 v1, float4 v2) { return fn(v1, v2);} 1432a140d9d93009aa5733f91bba86c9d5227279e457Jason Sams 1433a140d9d93009aa5733f91bba86c9d5227279e457Jason Sams#define THUNK_NATIVE_F_FP(fn) \ 1434a140d9d93009aa5733f91bba86c9d5227279e457Jason Sams float __attribute__((overloadable)) native_##fn(float v1, float *v2) { return fn(v1, v2);} \ 1435a140d9d93009aa5733f91bba86c9d5227279e457Jason Sams float2 __attribute__((overloadable)) native_##fn(float2 v1, float2 *v2) { return fn(v1, v2);} \ 1436a140d9d93009aa5733f91bba86c9d5227279e457Jason Sams float3 __attribute__((overloadable)) native_##fn(float3 v1, float3 *v2) { return fn(v1, v2);} \ 1437a140d9d93009aa5733f91bba86c9d5227279e457Jason Sams float4 __attribute__((overloadable)) native_##fn(float4 v1, float4 *v2) { return fn(v1, v2);} 1438a140d9d93009aa5733f91bba86c9d5227279e457Jason Sams 1439a140d9d93009aa5733f91bba86c9d5227279e457Jason Sams#define THUNK_NATIVE_F_I(fn) \ 1440a140d9d93009aa5733f91bba86c9d5227279e457Jason Sams float __attribute__((overloadable)) native_##fn(float v1, int v2) { return fn(v1, v2);} \ 1441a140d9d93009aa5733f91bba86c9d5227279e457Jason Sams float2 __attribute__((overloadable)) native_##fn(float2 v1, int2 v2) { return fn(v1, v2);} \ 1442a140d9d93009aa5733f91bba86c9d5227279e457Jason Sams float3 __attribute__((overloadable)) native_##fn(float3 v1, int3 v2) { return fn(v1, v2);} \ 1443a140d9d93009aa5733f91bba86c9d5227279e457Jason Sams float4 __attribute__((overloadable)) native_##fn(float4 v1, int4 v2) { return fn(v1, v2);} 1444a140d9d93009aa5733f91bba86c9d5227279e457Jason Sams 1445a140d9d93009aa5733f91bba86c9d5227279e457Jason SamsTHUNK_NATIVE_F(acos) 1446a140d9d93009aa5733f91bba86c9d5227279e457Jason SamsTHUNK_NATIVE_F(acosh) 1447a140d9d93009aa5733f91bba86c9d5227279e457Jason SamsTHUNK_NATIVE_F(acospi) 1448a140d9d93009aa5733f91bba86c9d5227279e457Jason SamsTHUNK_NATIVE_F(asin) 1449a140d9d93009aa5733f91bba86c9d5227279e457Jason SamsTHUNK_NATIVE_F(asinh) 1450a140d9d93009aa5733f91bba86c9d5227279e457Jason SamsTHUNK_NATIVE_F(asinpi) 1451a140d9d93009aa5733f91bba86c9d5227279e457Jason SamsTHUNK_NATIVE_F(atan) 1452a140d9d93009aa5733f91bba86c9d5227279e457Jason SamsTHUNK_NATIVE_F_F(atan2) 1453a140d9d93009aa5733f91bba86c9d5227279e457Jason SamsTHUNK_NATIVE_F(atanh) 1454a140d9d93009aa5733f91bba86c9d5227279e457Jason SamsTHUNK_NATIVE_F(atanpi) 1455a140d9d93009aa5733f91bba86c9d5227279e457Jason SamsTHUNK_NATIVE_F_F(atan2pi) 1456a140d9d93009aa5733f91bba86c9d5227279e457Jason SamsTHUNK_NATIVE_F(cbrt) 1457a140d9d93009aa5733f91bba86c9d5227279e457Jason SamsTHUNK_NATIVE_F(cos) 1458a140d9d93009aa5733f91bba86c9d5227279e457Jason SamsTHUNK_NATIVE_F(cosh) 1459a140d9d93009aa5733f91bba86c9d5227279e457Jason SamsTHUNK_NATIVE_F(cospi) 1460a140d9d93009aa5733f91bba86c9d5227279e457Jason SamsTHUNK_NATIVE_F(expm1) 1461a140d9d93009aa5733f91bba86c9d5227279e457Jason SamsTHUNK_NATIVE_F_F(hypot) 1462a140d9d93009aa5733f91bba86c9d5227279e457Jason SamsTHUNK_NATIVE_F(log1p) 1463a140d9d93009aa5733f91bba86c9d5227279e457Jason SamsTHUNK_NATIVE_F_I(rootn) 1464a140d9d93009aa5733f91bba86c9d5227279e457Jason SamsTHUNK_NATIVE_F(rsqrt) 1465a140d9d93009aa5733f91bba86c9d5227279e457Jason SamsTHUNK_NATIVE_F(sqrt) 1466a140d9d93009aa5733f91bba86c9d5227279e457Jason SamsTHUNK_NATIVE_F(sin) 1467a140d9d93009aa5733f91bba86c9d5227279e457Jason SamsTHUNK_NATIVE_F_FP(sincos) 1468a140d9d93009aa5733f91bba86c9d5227279e457Jason SamsTHUNK_NATIVE_F(sinh) 1469a140d9d93009aa5733f91bba86c9d5227279e457Jason SamsTHUNK_NATIVE_F(sinpi) 1470a140d9d93009aa5733f91bba86c9d5227279e457Jason SamsTHUNK_NATIVE_F(tan) 1471a140d9d93009aa5733f91bba86c9d5227279e457Jason SamsTHUNK_NATIVE_F(tanh) 1472a140d9d93009aa5733f91bba86c9d5227279e457Jason SamsTHUNK_NATIVE_F(tanpi) 1473a140d9d93009aa5733f91bba86c9d5227279e457Jason Sams 1474a140d9d93009aa5733f91bba86c9d5227279e457Jason Sams#undef THUNK_NATIVE_F 1475a140d9d93009aa5733f91bba86c9d5227279e457Jason Sams#undef THUNK_NATIVE_F_F 1476a140d9d93009aa5733f91bba86c9d5227279e457Jason Sams#undef THUNK_NATIVE_F_I 1477a140d9d93009aa5733f91bba86c9d5227279e457Jason Sams#undef THUNK_NATIVE_F_FP 1478a140d9d93009aa5733f91bba86c9d5227279e457Jason Sams 1479a140d9d93009aa5733f91bba86c9d5227279e457Jason Samsfloat __attribute__((overloadable)) native_normalize(float v) { return fast_normalize(v);} 1480a140d9d93009aa5733f91bba86c9d5227279e457Jason Samsfloat2 __attribute__((overloadable)) native_normalize(float2 v) { return fast_normalize(v);} 1481a140d9d93009aa5733f91bba86c9d5227279e457Jason Samsfloat3 __attribute__((overloadable)) native_normalize(float3 v) { return fast_normalize(v);} 1482a140d9d93009aa5733f91bba86c9d5227279e457Jason Samsfloat4 __attribute__((overloadable)) native_normalize(float4 v) { return fast_normalize(v);} 1483a140d9d93009aa5733f91bba86c9d5227279e457Jason Sams 1484a140d9d93009aa5733f91bba86c9d5227279e457Jason Samsfloat __attribute__((overloadable)) native_distance(float v1, float v2) { return fast_distance(v1, v2);} 1485a140d9d93009aa5733f91bba86c9d5227279e457Jason Samsfloat __attribute__((overloadable)) native_distance(float2 v1, float2 v2) { return fast_distance(v1, v2);} 1486a140d9d93009aa5733f91bba86c9d5227279e457Jason Samsfloat __attribute__((overloadable)) native_distance(float3 v1, float3 v2) { return fast_distance(v1, v2);} 1487a140d9d93009aa5733f91bba86c9d5227279e457Jason Samsfloat __attribute__((overloadable)) native_distance(float4 v1, float4 v2) { return fast_distance(v1, v2);} 1488a140d9d93009aa5733f91bba86c9d5227279e457Jason Sams 1489a140d9d93009aa5733f91bba86c9d5227279e457Jason Samsfloat __attribute__((overloadable)) native_length(float v) { return fast_length(v);} 1490a140d9d93009aa5733f91bba86c9d5227279e457Jason Samsfloat __attribute__((overloadable)) native_length(float2 v) { return fast_length(v);} 1491a140d9d93009aa5733f91bba86c9d5227279e457Jason Samsfloat __attribute__((overloadable)) native_length(float3 v) { return fast_length(v);} 1492a140d9d93009aa5733f91bba86c9d5227279e457Jason Samsfloat __attribute__((overloadable)) native_length(float4 v) { return fast_length(v);} 1493a140d9d93009aa5733f91bba86c9d5227279e457Jason Sams 1494a140d9d93009aa5733f91bba86c9d5227279e457Jason Samsfloat __attribute__((overloadable)) native_divide(float v1, float v2) { return v1 / v2;} 1495a140d9d93009aa5733f91bba86c9d5227279e457Jason Samsfloat2 __attribute__((overloadable)) native_divide(float2 v1, float2 v2) { return v1 / v2;} 1496a140d9d93009aa5733f91bba86c9d5227279e457Jason Samsfloat3 __attribute__((overloadable)) native_divide(float3 v1, float3 v2) { return v1 / v2;} 1497a140d9d93009aa5733f91bba86c9d5227279e457Jason Samsfloat4 __attribute__((overloadable)) native_divide(float4 v1, float4 v2) { return v1 / v2;} 1498a140d9d93009aa5733f91bba86c9d5227279e457Jason Sams 1499a140d9d93009aa5733f91bba86c9d5227279e457Jason Samsfloat __attribute__((overloadable)) native_recip(float v) { return 1.f / v;} 1500a140d9d93009aa5733f91bba86c9d5227279e457Jason Samsfloat2 __attribute__((overloadable)) native_recip(float2 v) { return ((float2)1.f) / v;} 1501a140d9d93009aa5733f91bba86c9d5227279e457Jason Samsfloat3 __attribute__((overloadable)) native_recip(float3 v) { return ((float3)1.f) / v;} 1502a140d9d93009aa5733f91bba86c9d5227279e457Jason Samsfloat4 __attribute__((overloadable)) native_recip(float4 v) { return ((float4)1.f) / v;} 1503a140d9d93009aa5733f91bba86c9d5227279e457Jason Sams 1504a140d9d93009aa5733f91bba86c9d5227279e457Jason Sams 1505a140d9d93009aa5733f91bba86c9d5227279e457Jason Sams 1506a140d9d93009aa5733f91bba86c9d5227279e457Jason Sams 15075a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 15085a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines#undef FN_FUNC_FN 15095a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines#undef IN_FUNC_FN 15105a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines#undef FN_FUNC_FN_FN 15115a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines#undef FN_FUNC_FN_F 15125a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines#undef FN_FUNC_FN_IN 15135a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines#undef FN_FUNC_FN_I 15145a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines#undef FN_FUNC_FN_PFN 15155a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines#undef FN_FUNC_FN_PIN 15165a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines#undef FN_FUNC_FN_FN_FN 15175a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines#undef FN_FUNC_FN_FN_PIN 15185a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines#undef XN_FUNC_YN 15195a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines#undef UIN_FUNC_IN 15205a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines#undef IN_FUNC_IN 15215a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines#undef XN_FUNC_XN_XN_BODY 15225a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines#undef IN_FUNC_IN_IN_BODY 152354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 152454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainartypedef union { 152554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar half hval; 152654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar short sval; 152754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} fp16_shape_type; 152854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 152954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar/* half h = unsigned short s; */ 153054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar#define SET_HALF_WORD(h, s) \ 153154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainardo { \ 153254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar fp16_shape_type fp16_u; \ 153354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar fp16_u.sval = (s); \ 153454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar (h) = fp16_u.hval; \ 153554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} while (0) 153654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 153754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarstatic const unsigned short kHalfPositiveInfinity = 0x7c00; 153854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 153954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar/* Define f16 functions of the form 154054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar * HN output = fn(HN input) 154154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar * where HN is scalar or vector half type 154254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar */ 154354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar#define HN_FUNC_HN(fn) \ 154454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half __attribute__((overloadable)) fn(half h) { \ 154554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return (half) fn((float) h); \ 154654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} \ 154754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half2 __attribute__((overloadable)) fn(half2 v) { \ 154854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return convert_half2(fn(convert_float2(v))); \ 154954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} \ 155054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half3 __attribute__((overloadable)) fn(half3 v) { \ 155154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return convert_half3(fn(convert_float3(v))); \ 155254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} \ 155354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half4 __attribute__((overloadable)) fn(half4 v) { \ 155454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return convert_half4(fn(convert_float4(v))); \ 155554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} 155654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 155754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar/* Define f16 functions of the form 155854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar * HN output = fn(HN input1, HN input2) 155954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar * where HN is scalar or vector half type 156054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar */ 156154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar#define HN_FUNC_HN_HN(fn) \ 156254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half __attribute__((overloadable)) fn(half h1, half h2) { \ 156354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return (half) fn((float) h1, (float) h2); \ 156454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} \ 156554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half2 __attribute__((overloadable)) fn(half2 v1, half2 v2) { \ 156654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return convert_half2(fn(convert_float2(v1), \ 156754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar convert_float2(v2))); \ 156854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} \ 156954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half3 __attribute__((overloadable)) fn(half3 v1, half3 v2) { \ 157054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return convert_half3(fn(convert_float3(v1), \ 157154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar convert_float3(v2))); \ 157254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} \ 157354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half4 __attribute__((overloadable)) fn(half4 v1, half4 v2) { \ 157454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return convert_half4(fn(convert_float4(v1), \ 157554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar convert_float4(v2))); \ 157654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} 157754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 157854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar/* Define f16 functions of the form 157954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar * HN output = fn(HN input1, half input2) 158054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar * where HN is scalar or vector half type 158154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar */ 158254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar#define HN_FUNC_HN_H(fn) \ 158354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half2 __attribute__((overloadable)) fn(half2 v1, half v2) { \ 158454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return convert_half2(fn(convert_float2(v1), (float) v2)); \ 158554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} \ 158654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half3 __attribute__((overloadable)) fn(half3 v1, half v2) { \ 158754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return convert_half3(fn(convert_float3(v1), (float) v2)); \ 158854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} \ 158954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half4 __attribute__((overloadable)) fn(half4 v1, half v2) { \ 159054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return convert_half4(fn(convert_float4(v1), (float) v2)); \ 159154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} 159254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 159354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar/* Define f16 functions of the form 159454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar * HN output = fn(HN input1, HN input2, HN input3) 159554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar * where HN is scalar or vector half type 159654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar */ 159754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar#define HN_FUNC_HN_HN_HN(fn) \ 159854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half __attribute__((overloadable)) fn(half h1, half h2, half h3) { \ 159954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return (half) fn((float) h1, (float) h2, (float) h3); \ 160054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} \ 160154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half2 __attribute__((overloadable)) fn(half2 v1, half2 v2, half2 v3) { \ 160254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return convert_half2(fn(convert_float2(v1), \ 160354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar convert_float2(v2), \ 160454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar convert_float2(v3))); \ 160554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} \ 160654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half3 __attribute__((overloadable)) fn(half3 v1, half3 v2, half3 v3) { \ 160754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return convert_half3(fn(convert_float3(v1), \ 160854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar convert_float3(v2), \ 160954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar convert_float3(v3))); \ 161054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} \ 161154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half4 __attribute__((overloadable)) fn(half4 v1, half4 v2, half4 v3) { \ 161254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return convert_half4(fn(convert_float4(v1), \ 161354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar convert_float4(v2), \ 161454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar convert_float4(v3))); \ 161554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} 161654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 161754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar/* Define f16 functions of the form 161854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar * HN output = fn(HN input1, IN input2) 161954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar * where HN is scalar or vector half type and IN the equivalent integer type 162054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar * of same vector length. 162154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar */ 162254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar#define HN_FUNC_HN_IN(fn) \ 162354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half __attribute__((overloadable)) fn(half h1, int v) { \ 162454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return (half) fn((float) h1, v); \ 162554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} \ 162654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half2 __attribute__((overloadable)) fn(half2 v1, int2 v2) { \ 162754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return convert_half2(fn(convert_float2(v1), v2)); \ 162854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} \ 162954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half3 __attribute__((overloadable)) fn(half3 v1, int3 v2) { \ 163054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return convert_half3(fn(convert_float3(v1), v2)); \ 163154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} \ 163254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half4 __attribute__((overloadable)) fn(half4 v1, int4 v2) { \ 163354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return convert_half4(fn(convert_float4(v1), v2)); \ 163454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} 163554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 163654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar/* Define f16 functions of the form 163754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar * half output = fn(HN input1) 163854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar * where HN is a scalar or vector half type. 163954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar */ 164054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar#define H_FUNC_HN(fn) \ 164154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half __attribute__((overloadable)) fn(half h) { \ 164254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return (half) fn((float) h); \ 164354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} \ 164454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half __attribute__((overloadable)) fn(half2 v) { \ 164554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return fn(convert_float2(v)); \ 164654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} \ 164754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half __attribute__((overloadable)) fn(half3 v) { \ 164854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return fn(convert_float3(v)); \ 164954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} \ 165054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half __attribute__((overloadable)) fn(half4 v) { \ 165154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return fn(convert_float4(v)); \ 165254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} 165354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 165454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar/* Define f16 functions of the form 165554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar * half output = fn(HN input1, HN input2) 165654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar * where HN is a scalar or vector half type. 165754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar */ 165854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar#define H_FUNC_HN_HN(fn) \ 165954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half __attribute__((overloadable)) fn(half h1, half h2) { \ 166054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return (half) fn((float) h1, (float) h2); \ 166154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} \ 166254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half __attribute__((overloadable)) fn(half2 v1, half2 v2) { \ 166354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return fn(convert_float2(v1), convert_float2(v2)); \ 166454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} \ 166554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half __attribute__((overloadable)) fn(half3 v1, half3 v2) { \ 166654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return fn(convert_float3(v1), convert_float3(v2)); \ 166754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} \ 166854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half __attribute__((overloadable)) fn(half4 v1, half4 v2) { \ 166954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return fn(convert_float4(v1), convert_float4(v2)); \ 167054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} 167154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 167254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar/* Define f16 functions of the form 167354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar * HN output = fn(HN input1, HN input2) 167454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar * where HN is a vector half type. The functions are defined to call the 167554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar * scalar function of the same name. 167654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar */ 167754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar#define SCALARIZE_HN_FUNC_HN_HN(fn) \ 167854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half2 __attribute__((overloadable)) fn(half2 v1, half2 v2) { \ 167954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar half2 ret; \ 168054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar ret.x = fn(v1.x, v2.x); \ 168154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar ret.y = fn(v1.y, v2.y); \ 168254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return ret; \ 168354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} \ 168454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half3 __attribute__((overloadable)) fn(half3 v1, half3 v2) { \ 168554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar half3 ret; \ 168654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar ret.x = fn(v1.x, v2.x); \ 168754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar ret.y = fn(v1.y, v2.y); \ 168854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar ret.z = fn(v1.z, v2.z); \ 168954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return ret; \ 169054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} \ 169154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half4 __attribute__((overloadable)) fn(half4 v1, half4 v2) { \ 169254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar half4 ret; \ 169354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar ret.x = fn(v1.x, v2.x); \ 169454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar ret.y = fn(v1.y, v2.y); \ 169554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar ret.z = fn(v1.z, v2.z); \ 169654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar ret.w = fn(v1.w, v2.w); \ 169754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return ret; \ 169854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} \ 169954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 170054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(acos); 170154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(acosh); 170254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(acospi); 170354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(asin); 170454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(asinh); 170554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(asinpi); 170654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(atan); 170754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(atanh); 170854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(atanpi); 170954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN_HN(atan2); 171054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN_HN(atan2pi); 171154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 171254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(cbrt); 171354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(ceil); 171454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 171554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar// TODO Add copysign 171654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 171754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(cos); 171854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(cosh); 171954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(cospi); 172054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 172154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half3 __attribute__((overloadable)) cross(half3 lhs, half3 rhs) { 172254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar half3 r; 172354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar r.x = lhs.y * rhs.z - lhs.z * rhs.y; 172454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar r.y = lhs.z * rhs.x - lhs.x * rhs.z; 172554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar r.z = lhs.x * rhs.y - lhs.y * rhs.x; 172654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return r; 172754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} 172854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 172954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half4 __attribute__((overloadable)) cross(half4 lhs, half4 rhs) { 173054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar half4 r; 173154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar r.x = lhs.y * rhs.z - lhs.z * rhs.y; 173254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar r.y = lhs.z * rhs.x - lhs.x * rhs.z; 173354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar r.z = lhs.x * rhs.y - lhs.y * rhs.x; 173454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar r.w = 0.f; 173554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return r; 173654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} 173754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 173854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(degrees); 173954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarH_FUNC_HN_HN(distance); 174054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarH_FUNC_HN_HN(dot); 174154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 174254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(erf); 174354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(erfc); 174454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(exp); 174554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(exp10); 174654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(exp2); 174754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(expm1); 174854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 174954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(fabs); 175054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN_HN(fdim); 175154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(floor); 175254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN_HN_HN(fma); 175354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN_HN(fmax); 175454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN_H(fmax); 175554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN_HN(fmin); 175654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN_H(fmin); 175754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN_HN(fmod); 175854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 175954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar// TODO Add (both variants) of fract 176054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar// TODO Add frexp 176154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 176254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN_HN(hypot); 176354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 176454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar// TODO Add ilogb 176554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 176654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN_IN(ldexp); 176754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half2 __attribute__((overloadable)) ldexp(half2 v, int exponent) { 176854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return convert_half2(ldexp(convert_float2(v), exponent)); 176954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} 177054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half3 __attribute__((overloadable)) ldexp(half3 v, int exponent) { 177154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return convert_half3(ldexp(convert_float3(v), exponent)); 177254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} 177354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half4 __attribute__((overloadable)) ldexp(half4 v, int exponent) { 177454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return convert_half4(ldexp(convert_float4(v), exponent)); 177554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} 177654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 177754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarH_FUNC_HN(length); 177854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(lgamma); 177954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 178054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half __attribute__((overloadable)) lgamma(half h, int *signp) { 178154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return (half) lgamma((float) h, signp); 178254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} 178354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half2 __attribute__((overloadable)) lgamma(half2 v, int2 *signp) { 178454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return convert_half2(lgamma(convert_float2(v), signp)); 178554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} 178654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half3 __attribute__((overloadable)) lgamma(half3 v, int3 *signp) { 178754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return convert_half3(lgamma(convert_float3(v), signp)); 178854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} 178954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half4 __attribute__((overloadable)) lgamma(half4 v, int4 *signp) { 179054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return convert_half4(lgamma(convert_float4(v), signp)); 179154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} 179254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 179354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(log); 179454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(log10); 179554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(log1p); 179654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(log2); 179754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(logb); 179854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 179954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN_HN_HN(mad); 180054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN_HN(max); 180154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN_H(max); // TODO can this be arch-specific similar to _Z3maxDv2_ff? 180254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN_HN(min); 180354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN_H(min); // TODO can this be arch-specific similar to _Z3minDv2_ff? 180454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 180554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half __attribute__((overloadable)) mix(half start, half stop, half amount) { 180654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return start + (stop - start) * amount; 180754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} 180854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half2 __attribute__((overloadable)) mix(half2 start, half2 stop, half2 amount) { 180954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return start + (stop - start) * amount; 181054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} 181154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half3 __attribute__((overloadable)) mix(half3 start, half3 stop, half3 amount) { 181254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return start + (stop - start) * amount; 181354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} 181454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half4 __attribute__((overloadable)) mix(half4 start, half4 stop, half4 amount) { 181554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return start + (stop - start) * amount; 181654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} 181754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half2 __attribute__((overloadable)) mix(half2 start, half2 stop, half amount) { 181854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return start + (stop - start) * amount; 181954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} 182054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half3 __attribute__((overloadable)) mix(half3 start, half3 stop, half amount) { 182154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return start + (stop - start) * amount; 182254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} 182354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half4 __attribute__((overloadable)) mix(half4 start, half4 stop, half amount) { 182454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return start + (stop - start) * amount; 182554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} 182654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 182754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar// TODO Define modf. Does it make sense to delegate to the float? 182854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 182954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarhalf __attribute__((overloadable)) nan_half() { 183054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar unsigned short nan_short = kHalfPositiveInfinity | 0x0200; 183154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar half nan; 183254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar SET_HALF_WORD(nan, nan_short); 183354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return nan; 183454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} 183554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 183654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar// TODO Add nextafter 183754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 183854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(normalize); 183954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 184054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN_HN(pow); 184154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN_IN(pown); 184254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN_HN(powr); 184354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(radians); 184454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN_HN(remainder); 184554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 184654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half __attribute__((overloadable)) remquo(half n, half d, int *quo) { 184754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return (float) remquo((float) n, (float) d, quo); 184854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} 184954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half2 __attribute__((overloadable)) remquo(half2 n, half2 d, int2 *quo) { 185054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return convert_half2(remquo(convert_float2(d), convert_float2(n), quo)); 185154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} 185254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half3 __attribute__((overloadable)) remquo(half3 n, half3 d, int3 *quo) { 185354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return convert_half3(remquo(convert_float3(d), convert_float3(n), quo)); 185454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} 185554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half4 __attribute__((overloadable)) remquo(half4 n, half4 d, int4 *quo) { 185654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return convert_half4(remquo(convert_float4(d), convert_float4(n), quo)); 185754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} 185854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 185954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(rint); 186054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN_IN(rootn); 186154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(round); 186254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(rsqrt); 186354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 186454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half __attribute__((overloadable)) sign(half h) { 186554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar if (h > 0) return (half) 1.f; 186654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar if (h < 0) return (half) -1.f; 186754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return h; 186854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} 186954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half2 __attribute__((overloadable)) sign(half2 v) { 187054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar half2 ret; 187154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar ret.x = sign(v.x); 187254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar ret.y = sign(v.y); 187354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return ret; 187454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} 187554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half3 __attribute__((overloadable)) sign(half3 v) { 187654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar half3 ret; 187754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar ret.x = sign(v.x); 187854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar ret.y = sign(v.y); 187954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar ret.z = sign(v.z); 188054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return ret; 188154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} 188254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half4 __attribute__((overloadable)) sign(half4 v) { 188354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar half4 ret; 188454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar ret.x = sign(v.x); 188554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar ret.y = sign(v.y); 188654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar ret.z = sign(v.z); 188754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar ret.w = sign(v.w); 188854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return ret; 188954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} 189054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 189154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(sin); 189254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 189354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half __attribute__((overloadable)) sincos(half v, half *cosptr) { 189454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar *cosptr = cos(v); 189554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return sin(v); 189654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} 189754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar// TODO verify if LLVM eliminates the duplicate convert_float2 189854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half2 __attribute__((overloadable)) sincos(half2 v, half2 *cosptr) { 189954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar *cosptr = cos(v); 190054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return sin(v); 190154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} 190254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half3 __attribute__((overloadable)) sincos(half3 v, half3 *cosptr) { 190354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar *cosptr = cos(v); 190454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return sin(v); 190554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} 190654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half4 __attribute__((overloadable)) sincos(half4 v, half4 *cosptr) { 190754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar *cosptr = cos(v); 190854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return sin(v); 190954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} 191054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 191154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(sinh); 191254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(sinpi); 191354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(sqrt); 191454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 191554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half __attribute__((overloadable)) step(half edge, half v) { 191654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return (v < edge) ? 0.f : 1.f; 191754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} 191854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half2 __attribute__((overloadable)) step(half2 edge, half2 v) { 191954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar half2 r; 192054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar r.x = (v.x < edge.x) ? 0.f : 1.f; 192154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar r.y = (v.y < edge.y) ? 0.f : 1.f; 192254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return r; 192354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} 192454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half3 __attribute__((overloadable)) step(half3 edge, half3 v) { 192554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar half3 r; 192654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar r.x = (v.x < edge.x) ? 0.f : 1.f; 192754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar r.y = (v.y < edge.y) ? 0.f : 1.f; 192854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar r.z = (v.z < edge.z) ? 0.f : 1.f; 192954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return r; 193054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} 193154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half4 __attribute__((overloadable)) step(half4 edge, half4 v) { 193254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar half4 r; 193354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar r.x = (v.x < edge.x) ? 0.f : 1.f; 193454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar r.y = (v.y < edge.y) ? 0.f : 1.f; 193554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar r.z = (v.z < edge.z) ? 0.f : 1.f; 193654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar r.w = (v.w < edge.w) ? 0.f : 1.f; 193754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return r; 193854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} 193954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half2 __attribute__((overloadable)) step(half2 edge, half v) { 194054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar half2 r; 194154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar r.x = (v < edge.x) ? 0.f : 1.f; 194254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar r.y = (v < edge.y) ? 0.f : 1.f; 194354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return r; 194454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} 194554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half3 __attribute__((overloadable)) step(half3 edge, half v) { 194654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar half3 r; 194754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar r.x = (v < edge.x) ? 0.f : 1.f; 194854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar r.y = (v < edge.y) ? 0.f : 1.f; 194954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar r.z = (v < edge.z) ? 0.f : 1.f; 195054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return r; 195154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} 195254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half4 __attribute__((overloadable)) step(half4 edge, half v) { 195354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar half4 r; 195454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar r.x = (v < edge.x) ? 0.f : 1.f; 195554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar r.y = (v < edge.y) ? 0.f : 1.f; 195654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar r.z = (v < edge.z) ? 0.f : 1.f; 195754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar r.w = (v < edge.w) ? 0.f : 1.f; 195854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return r; 195954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} 196054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half2 __attribute__((overloadable)) step(half edge, half2 v) { 196154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar half2 r; 196254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar r.x = (v.x < edge) ? 0.f : 1.f; 196354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar r.y = (v.y < edge) ? 0.f : 1.f; 196454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return r; 196554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} 196654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half3 __attribute__((overloadable)) step(half edge, half3 v) { 196754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar half3 r; 196854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar r.x = (v.x < edge) ? 0.f : 1.f; 196954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar r.y = (v.y < edge) ? 0.f : 1.f; 197054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar r.z = (v.z < edge) ? 0.f : 1.f; 197154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return r; 197254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} 197354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half4 __attribute__((overloadable)) step(half edge, half4 v) { 197454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar half4 r; 197554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar r.x = (v.x < edge) ? 0.f : 1.f; 197654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar r.y = (v.y < edge) ? 0.f : 1.f; 197754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar r.z = (v.z < edge) ? 0.f : 1.f; 197854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar r.w = (v.w < edge) ? 0.f : 1.f; 197954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return r; 198054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} 198154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 198254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(tan); 198354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(tanh); 198454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(tanpi); 198554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(tgamma); 198654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(trunc); // TODO: rethink: needs half-specific implementation? 198754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 198854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(native_acos); 198954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(native_acosh); 199054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(native_acospi); 199154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(native_asin); 199254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(native_asinh); 199354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(native_asinpi); 199454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(native_atan); 199554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(native_atanh); 199654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(native_atanpi); 199754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN_HN(native_atan2); 199854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN_HN(native_atan2pi); 199954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 200054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(native_cbrt); 200154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(native_cos); 200254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(native_cosh); 200354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(native_cospi); 200454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 200554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarH_FUNC_HN_HN(native_distance); 200654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN_HN(native_divide); 200754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 200854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(native_exp); 200954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(native_exp10); 201054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(native_exp2); 201154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(native_expm1); 201254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 201354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN_HN(native_hypot); 201454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarH_FUNC_HN(native_length); 201554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 201654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(native_log); 201754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(native_log10); 201854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(native_log1p); 201954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(native_log2); 202054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 202154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(native_normalize); 202254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 202354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN_HN(native_powr); // TODO are parameter limits different for half? 202454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 202554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(native_recip); 202654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN_IN(native_rootn); 202754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(native_rsqrt); 202854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 202954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(native_sin); 203054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 203154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half __attribute__((overloadable)) native_sincos(half v, half *cosptr) { 203254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return sincos(v, cosptr); 203354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} 203454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half2 __attribute__((overloadable)) native_sincos(half2 v, half2 *cosptr) { 203554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return sincos(v, cosptr); 203654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} 203754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half3 __attribute__((overloadable)) native_sincos(half3 v, half3 *cosptr) { 203854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return sincos(v, cosptr); 203954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} 204054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainarextern half4 __attribute__((overloadable)) native_sincos(half4 v, half4 *cosptr) { 204154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar return sincos(v, cosptr); 204254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar} 204354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 204454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(native_sinh); 204554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(native_sinpi); 204654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(native_sqrt); 204754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 204854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(native_tan); 204954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(native_tanh); 205054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga NainarHN_FUNC_HN(native_tanpi); 205154cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 205254cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar#undef HN_FUNC_HN 205354cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar#undef HN_FUNC_HN_HN 205454cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar#undef HN_FUNC_HN_H 205554cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar#undef HN_FUNC_HN_HN_HN 205654cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar#undef HN_FUNC_HN_IN 205754cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar#undef H_FUNC_HN 205854cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar#undef H_FUNC_HN_HN 205954cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar#undef SCALARIZE_HN_FUNC_HN_HN 206054cd5d1771ea5c95e181befc66ef8e2a2c1b78cdPirama Arumuga Nainar 2061