#define MASK_SLTIU 0x707f
#define MATCH_FADD_S 0x53
#define MASK_FADD_S 0xfe00007f
+#define MATCH_FCLASS_D 0xea000053
+#define MASK_FCLASS_D 0xfff0707f
#define MATCH_FCVT_S_W 0x70000053
#define MASK_FCVT_S_W 0xfff0007f
#define MATCH_MUL 0x2000033
#define MASK_BLT 0x707f
#define MATCH_SCALL 0x73
#define MASK_SCALL 0xffffffff
+#define MATCH_FCLASS_S 0xe8000053
+#define MASK_FCLASS_S 0xfff0707f
#define MATCH_SC_W 0x1800202f
#define MASK_SC_W 0xf800707f
#define MATCH_REM 0x2006033
DECLARE_INSN(fadd_d, MATCH_FADD_D, MASK_FADD_D)
DECLARE_INSN(sltiu, MATCH_SLTIU, MASK_SLTIU)
DECLARE_INSN(fadd_s, MATCH_FADD_S, MASK_FADD_S)
+DECLARE_INSN(fclass_d, MATCH_FCLASS_D, MASK_FCLASS_D)
DECLARE_INSN(fcvt_s_w, MATCH_FCVT_S_W, MASK_FCVT_S_W)
DECLARE_INSN(mul, MATCH_MUL, MASK_MUL)
DECLARE_INSN(amominu_d, MATCH_AMOMINU_D, MASK_AMOMINU_D)
DECLARE_INSN(sub, MATCH_SUB, MASK_SUB)
DECLARE_INSN(blt, MATCH_BLT, MASK_BLT)
DECLARE_INSN(scall, MATCH_SCALL, MASK_SCALL)
+DECLARE_INSN(fclass_s, MATCH_FCLASS_S, MASK_FCLASS_S)
DECLARE_INSN(sc_w, MATCH_SC_W, MASK_SC_W)
DECLARE_INSN(rem, MATCH_REM, MASK_REM)
DECLARE_INSN(srliw, MATCH_SRLIW, MASK_SRLIW)
--- /dev/null
+require_fp;
+WRITE_RD(f64_classify(FRS1));
--- /dev/null
+require_fp;
+WRITE_RD(f32_classify(FRS1));
--- /dev/null
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "platform.h"
+#include "internals.h"
+#include "specialize.h"
+#include "softfloat.h"
+
+uint_fast16_t f32_classify( float32_t a )
+{
+ union ui32_f32 uA;
+ uint_fast32_t uiA;
+
+ uA.f = a;
+ uiA = uA.ui;
+
+ uint_fast16_t infOrNaN = expF32UI( uiA ) == 0xFF;
+ uint_fast16_t subnormalOrZero = expF32UI( uiA ) == 0;
+ bool sign = signF32UI( uiA );
+
+ return
+ ( sign && infOrNaN && fracF32UI( uiA ) == 0 ) << 0 |
+ ( sign && !infOrNaN && !subnormalOrZero ) << 1 |
+ ( sign && subnormalOrZero && fracF32UI( uiA ) ) << 2 |
+ ( sign && subnormalOrZero && fracF32UI( uiA ) == 0 ) << 3 |
+ ( !sign && infOrNaN && fracF32UI( uiA ) == 0 ) << 7 |
+ ( !sign && !infOrNaN && !subnormalOrZero ) << 6 |
+ ( !sign && subnormalOrZero && fracF32UI( uiA ) ) << 5 |
+ ( !sign && subnormalOrZero && fracF32UI( uiA ) == 0 ) << 4 |
+ ( isNaNF32UI( uiA ) && softfloat_isSigNaNF32UI( uiA )) << 8 |
+ ( isNaNF32UI( uiA ) && !softfloat_isSigNaNF32UI( uiA )) << 9;
+}
+
--- /dev/null
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "platform.h"
+#include "internals.h"
+#include "specialize.h"
+#include "softfloat.h"
+
+uint_fast16_t f64_classify( float64_t a )
+{
+ union ui64_f64 uA;
+ uint_fast64_t uiA;
+
+ uA.f = a;
+ uiA = uA.ui;
+
+ uint_fast16_t infOrNaN = expF64UI( uiA ) == 0x7FF;
+ uint_fast16_t subnormalOrZero = expF64UI( uiA ) == 0;
+ bool sign = signF64UI( uiA );
+
+ return
+ ( sign && infOrNaN && fracF64UI( uiA ) == 0 ) << 0 |
+ ( sign && !infOrNaN && !subnormalOrZero ) << 1 |
+ ( sign && subnormalOrZero && fracF64UI( uiA ) ) << 2 |
+ ( sign && subnormalOrZero && fracF64UI( uiA ) == 0 ) << 3 |
+ ( !sign && infOrNaN && fracF64UI( uiA ) == 0 ) << 7 |
+ ( !sign && !infOrNaN && !subnormalOrZero ) << 6 |
+ ( !sign && subnormalOrZero && fracF64UI( uiA ) ) << 5 |
+ ( !sign && subnormalOrZero && fracF64UI( uiA ) == 0 ) << 4 |
+ ( isNaNF64UI( uiA ) && softfloat_isSigNaNF64UI( uiA )) << 8 |
+ ( isNaNF64UI( uiA ) && !softfloat_isSigNaNF64UI( uiA )) << 9;
+}
+
bool f32_le_quiet( float32_t, float32_t );\r
bool f32_lt_quiet( float32_t, float32_t );\r
bool f32_isSignalingNaN( float32_t );\r
+uint_fast16_t f32_classify( float32_t );\r
\r
/*----------------------------------------------------------------------------\r
| 64-bit (double-precision) floating-point operations.\r
bool f64_le_quiet( float64_t, float64_t );\r
bool f64_lt_quiet( float64_t, float64_t );\r
bool f64_isSignalingNaN( float64_t );\r
+uint_fast16_t f64_classify( float64_t );\r
\r
/*----------------------------------------------------------------------------\r
| Extended double-precision rounding precision. Valid values are 32, 64, and\r
f32_to_ui32_r_minMag.c \
f32_to_ui64.c \
f32_to_ui64_r_minMag.c \
+ f32_classify.c \
f64_add.c \
f64_div.c \
f64_eq.c \
f64_to_ui32_r_minMag.c \
f64_to_ui64.c \
f64_to_ui64_r_minMag.c \
+ f64_classify.c \
i32_to_f32.c \
i32_to_f64.c \
i64_to_f32.c \
DEFINE_FXTYPE(fcvt_lu_s);
DEFINE_FXTYPE(fcvt_w_s);
DEFINE_FXTYPE(fcvt_wu_s);
+ DEFINE_FXTYPE(fclass_s);
DEFINE_FXTYPE(fmv_x_s);
DEFINE_FXTYPE(feq_s);
DEFINE_FXTYPE(flt_s);
DEFINE_FXTYPE(fcvt_lu_d);
DEFINE_FXTYPE(fcvt_w_d);
DEFINE_FXTYPE(fcvt_wu_d);
+ DEFINE_FXTYPE(fclass_d);
DEFINE_FXTYPE(fmv_x_d);
DEFINE_FXTYPE(feq_d);
DEFINE_FXTYPE(flt_d);