587float __attribute__ ((noinline)) riscv_emulate_fmins(
float rs1,
float rs2) {
589 float opa = subnormal_flush(rs1);
590 float opb = subnormal_flush(rs2);
593 uint32_t binary_value;
597 if ((fpclassify(opa) == FP_NAN) && (fpclassify(opb) == FP_NAN)) {
601 if (fpclassify(opa) == FP_NAN) {
605 if (fpclassify(opb) == FP_NAN) {
610 tmp_a.float_value = opa;
611 tmp_b.float_value = opb;
612 if (((tmp_a.binary_value == 0x80000000) && (tmp_b.binary_value == 0x00000000)) ||
613 ((tmp_a.binary_value == 0x00000000) && (tmp_b.binary_value == 0x80000000))) {
617 return fmin(opa, opb);
628float __attribute__ ((noinline)) riscv_emulate_fmaxs(
float rs1,
float rs2) {
630 float opa = subnormal_flush(rs1);
631 float opb = subnormal_flush(rs2);
634 uint32_t binary_value;
639 if ((fpclassify(opa) == FP_NAN) && (fpclassify(opb) == FP_NAN)) {
643 if (fpclassify(opa) == FP_NAN) {
647 if (fpclassify(opb) == FP_NAN) {
652 tmp_a.float_value = opa;
653 tmp_b.float_value = opb;
654 if (((tmp_a.binary_value == 0x80000000) && (tmp_b.binary_value == 0x00000000)) ||
655 ((tmp_a.binary_value == 0x00000000) && (tmp_b.binary_value == 0x80000000))) {
659 return fmax(opa, opb);
910uint32_t __attribute__ ((noinline)) riscv_emulate_fclasss(
float rs1) {
915 uint32_t binary_value;
920 const uint32_t CLASS_NEG_INF = 1 << 0;
921 const uint32_t CLASS_NEG_NORM = 1 << 1;
922 const uint32_t CLASS_NEG_DENORM = 1 << 2;
923 const uint32_t CLASS_NEG_ZERO = 1 << 3;
924 const uint32_t CLASS_POS_ZERO = 1 << 4;
925 const uint32_t CLASS_POS_DENORM = 1 << 5;
926 const uint32_t CLASS_POS_NORM = 1 << 6;
927 const uint32_t CLASS_POS_INF = 1 << 7;
928 const uint32_t CLASS_SNAN = 1 << 8;
929 const uint32_t CLASS_QNAN = 1 << 9;
931 int tmp = fpclassify(opa);
932 int sgn = (int)signbit(opa);
937 if (tmp == FP_INFINITE) {
938 if (sgn) { res |= CLASS_NEG_INF; }
939 else { res |= CLASS_POS_INF; }
943 if (tmp == FP_ZERO) {
944 if (sgn) { res |= CLASS_NEG_ZERO; }
945 else { res |= CLASS_POS_ZERO; }
949 if (tmp == FP_NORMAL) {
950 if (sgn) { res |= CLASS_NEG_NORM; }
951 else { res |= CLASS_POS_NORM; }
955 if (tmp == FP_SUBNORMAL) {
956 if (sgn) { res |= CLASS_NEG_DENORM; }
957 else { res |= CLASS_POS_DENORM; }
962 aux.float_value = opa;
963 if ((aux.binary_value >> 22) & 0b1) {
1055float __attribute__ ((noinline)) riscv_emulate_fnmsubs(
float rs1,
float rs2,
float rs3) {
1057 float opa = subnormal_flush(rs1);
1058 float opb = subnormal_flush(rs2);
1059 float opc = subnormal_flush(rs3);
1061 float res = -(opa * opb) + opc;
1062 return subnormal_flush(res);
1074float __attribute__ ((noinline)) riscv_emulate_fnmadds(
float rs1,
float rs2,
float rs3) {
1076 float opa = subnormal_flush(rs1);
1077 float opb = subnormal_flush(rs2);
1078 float opc = subnormal_flush(rs3);
1080 float res = -(opa * opb) - opc;
1081 return subnormal_flush(res);