return __roundAndPackInt64(aSign, aFracHi, aFracLo, zFrac2);
}
-uint64_t
-__fp32_to_uint64(float f)
-{
- uint a = floatBitsToUint(f);
- uint aFrac = a & 0x007FFFFFu;
- int aExp = int((a>>23) & 0xFFu);
- uint aSign = a & 0x80000000u;
- uint zFrac0 = 0u;
- uint zFrac1 = 0u;
- uint zFrac2 = 0u;
- uint64_t default_nan = 0xFFFFFFFFFFFFFFFFUL;
- int shiftCount = 0xBE - aExp;
-
- if (shiftCount <0) {
- if (aExp == 0xFF)
- return default_nan;
- }
-
- aFrac = mix(aFrac, aFrac | 0x00800000u, aExp != 0);
- __shortShift64Left(aFrac, 0, 40, zFrac0, zFrac1);
-
- if (shiftCount != 0) {
- __shift64ExtraRightJamming(zFrac0, zFrac1, zFrac2, shiftCount,
- zFrac0, zFrac1, zFrac2);
- }
-
- return __roundAndPackUInt64(aSign, zFrac0, zFrac1, zFrac2);
-}
-
-int64_t
-__fp32_to_int64(float f)
-{
- uint a = floatBitsToUint(f);
- uint aFrac = a & 0x007FFFFFu;
- int aExp = int((a>>23) & 0xFFu);
- uint aSign = a & 0x80000000u;
- uint zFrac0 = 0u;
- uint zFrac1 = 0u;
- uint zFrac2 = 0u;
- int64_t default_NegNaN = -0x7FFFFFFFFFFFFFFEL;
- int64_t default_PosNaN = 0xFFFFFFFFFFFFFFFFL;
- int shiftCount = 0xBE - aExp;
-
- if (shiftCount <0) {
- if (aExp == 0xFF && aFrac != 0u)
- return default_NegNaN;
- return mix(default_NegNaN, default_PosNaN, aSign == 0u);
- }
-
- aFrac = mix(aFrac, aFrac | 0x00800000u, aExp != 0);
- __shortShift64Left(aFrac, 0, 40, zFrac0, zFrac1);
-
- if (shiftCount != 0) {
- __shift64ExtraRightJamming(zFrac0, zFrac1, zFrac2, shiftCount,
- zFrac0, zFrac1, zFrac2);
- }
-
- return __roundAndPackInt64(aSign, zFrac0, zFrac1, zFrac2);
-}
-
uint64_t
__int64_to_fp64(int64_t a)
{
return __roundAndPackFloat32(aSign, aExp - 0x381, zFrac);
}
-float
-__uint64_to_fp32(uint64_t __a)
-{
- uvec2 aFrac = unpackUint2x32(__a);
- int shiftCount = mix(__countLeadingZeros32(aFrac.y) - 33,
- __countLeadingZeros32(aFrac.x) - 1,
- aFrac.y == 0u);
-
- if (0 <= shiftCount)
- __shortShift64Left(aFrac.y, aFrac.x, shiftCount, aFrac.y, aFrac.x);
- else
- __shift64RightJamming(aFrac.y, aFrac.x, -shiftCount, aFrac.y, aFrac.x);
-
- return __roundAndPackFloat32(0u, 0x9C - shiftCount, aFrac.x);
-}
-
-float
-__int64_to_fp32(int64_t __a)
-{
- uint aSign = uint(unpackInt2x32(__a).y) & 0x80000000u;
- uint64_t absA = mix(uint64_t(__a), uint64_t(-__a), __a < 0);
- uvec2 aFrac = unpackUint2x32(absA);
- int shiftCount = mix(__countLeadingZeros32(aFrac.y) - 33,
- __countLeadingZeros32(aFrac.x) - 1,
- aFrac.y == 0u);
-
- if (0 <= shiftCount)
- __shortShift64Left(aFrac.y, aFrac.x, shiftCount, aFrac.y, aFrac.x);
- else
- __shift64RightJamming(aFrac.y, aFrac.x, -shiftCount, aFrac.y, aFrac.x);
-
- return __roundAndPackFloat32(aSign, 0x9C - shiftCount, aFrac.x);
-}
-
/* Returns the result of converting the single-precision floating-point value
* `a' to the double-precision floating-point format.
*/
switch (instr->op) {
case nir_op_f2i64:
- if (instr->src[0].src.ssa->bit_size == 64)
- name = "__fp64_to_int64";
- else
- name = "__fp32_to_int64";
+ if (instr->src[0].src.ssa->bit_size != 64)
+ return false;
+ name = "__fp64_to_int64";
return_type = glsl_int64_t_type();
break;
case nir_op_f2u64:
- if (instr->src[0].src.ssa->bit_size == 64)
- name = "__fp64_to_uint64";
- else
- name = "__fp32_to_uint64";
+ if (instr->src[0].src.ssa->bit_size != 64)
+ return false;
+ name = "__fp64_to_uint64";
break;
case nir_op_f2f64:
name = "__fp32_to_fp64";
case nir_op_b2f64:
name = "__bool_to_fp64";
break;
- case nir_op_i2f32:
- if (instr->src[0].src.ssa->bit_size != 64)
- return false;
- name = "__int64_to_fp32";
- return_type = glsl_float_type();
- break;
- case nir_op_u2f32:
- if (instr->src[0].src.ssa->bit_size != 64)
- return false;
- name = "__uint64_to_fp32";
- return_type = glsl_float_type();
- break;
case nir_op_i2f64:
if (instr->src[0].src.ssa->bit_size == 64)
name = "__int64_to_fp64";