551float __attribute__ ((noinline)) riscv_emulate_fmins(
float rs1,
float rs2) {
553 float opa = subnormal_flush(rs1);
554 float opb = subnormal_flush(rs2);
557 uint32_t binary_value;
561 if ((fpclassify(opa) == FP_NAN) && (fpclassify(opb) == FP_NAN)) {
565 if (fpclassify(opa) == FP_NAN) {
569 if (fpclassify(opb) == FP_NAN) {
574 tmp_a.float_value = opa;
575 tmp_b.float_value = opb;
576 if (((tmp_a.binary_value == 0x80000000) && (tmp_b.binary_value == 0x00000000)) ||
577 ((tmp_a.binary_value == 0x00000000) && (tmp_b.binary_value == 0x80000000))) {
581 return fmin(opa, opb);
592float __attribute__ ((noinline)) riscv_emulate_fmaxs(
float rs1,
float rs2) {
594 float opa = subnormal_flush(rs1);
595 float opb = subnormal_flush(rs2);
598 uint32_t binary_value;
603 if ((fpclassify(opa) == FP_NAN) && (fpclassify(opb) == FP_NAN)) {
607 if (fpclassify(opa) == FP_NAN) {
611 if (fpclassify(opb) == FP_NAN) {
616 tmp_a.float_value = opa;
617 tmp_b.float_value = opb;
618 if (((tmp_a.binary_value == 0x80000000) && (tmp_b.binary_value == 0x00000000)) ||
619 ((tmp_a.binary_value == 0x00000000) && (tmp_b.binary_value == 0x80000000))) {
623 return fmax(opa, opb);
874uint32_t __attribute__ ((noinline)) riscv_emulate_fclasss(
float rs1) {
879 uint32_t binary_value;
884 const uint32_t CLASS_NEG_INF = 1 << 0;
885 const uint32_t CLASS_NEG_NORM = 1 << 1;
886 const uint32_t CLASS_NEG_DENORM = 1 << 2;
887 const uint32_t CLASS_NEG_ZERO = 1 << 3;
888 const uint32_t CLASS_POS_ZERO = 1 << 4;
889 const uint32_t CLASS_POS_DENORM = 1 << 5;
890 const uint32_t CLASS_POS_NORM = 1 << 6;
891 const uint32_t CLASS_POS_INF = 1 << 7;
892 const uint32_t CLASS_SNAN = 1 << 8;
893 const uint32_t CLASS_QNAN = 1 << 9;
895 int tmp = fpclassify(opa);
896 int sgn = (int)signbit(opa);
901 if (tmp == FP_INFINITE) {
902 if (sgn) { res |= CLASS_NEG_INF; }
903 else { res |= CLASS_POS_INF; }
907 if (tmp == FP_ZERO) {
908 if (sgn) { res |= CLASS_NEG_ZERO; }
909 else { res |= CLASS_POS_ZERO; }
913 if (tmp == FP_NORMAL) {
914 if (sgn) { res |= CLASS_NEG_NORM; }
915 else { res |= CLASS_POS_NORM; }
919 if (tmp == FP_SUBNORMAL) {
920 if (sgn) { res |= CLASS_NEG_DENORM; }
921 else { res |= CLASS_POS_DENORM; }
926 aux.float_value = opa;
927 if ((aux.binary_value >> 22) & 0b1) {
1019float __attribute__ ((noinline)) riscv_emulate_fnmsubs(
float rs1,
float rs2,
float rs3) {
1021 float opa = subnormal_flush(rs1);
1022 float opb = subnormal_flush(rs2);
1023 float opc = subnormal_flush(rs3);
1025 float res = -(opa * opb) + opc;
1026 return subnormal_flush(res);
1038float __attribute__ ((noinline)) riscv_emulate_fnmadds(
float rs1,
float rs2,
float rs3) {
1040 float opa = subnormal_flush(rs1);
1041 float opb = subnormal_flush(rs2);
1042 float opc = subnormal_flush(rs3);
1044 float res = -(opa * opb) - opc;
1045 return subnormal_flush(res);