Implement "half-baked" half-precision instruction subset for Hwacha
authorAlbert Ou <a_ou@eecs.berkeley.edu>
Tue, 5 Nov 2013 06:31:01 +0000 (22:31 -0800)
committerAlbert Ou <a_ou@eecs.berkeley.edu>
Tue, 5 Nov 2013 06:31:01 +0000 (22:31 -0800)
39 files changed:
hwacha/cvt16.cc [new file with mode: 0644]
hwacha/cvt16.h [new file with mode: 0644]
hwacha/decode_hwacha_ut_half.h [new file with mode: 0644]
hwacha/hwacha.mk.in
hwacha/insn_template_hwacha_ut_half.cc [new file with mode: 0644]
hwacha/insns_ut_half/ut_fadd_h.h [new file with mode: 0644]
hwacha/insns_ut_half/ut_fcvt_d_h.h [new file with mode: 0644]
hwacha/insns_ut_half/ut_fcvt_h_d.h [new file with mode: 0644]
hwacha/insns_ut_half/ut_fcvt_h_l.h [new file with mode: 0644]
hwacha/insns_ut_half/ut_fcvt_h_lu.h [new file with mode: 0644]
hwacha/insns_ut_half/ut_fcvt_h_s.h [new file with mode: 0644]
hwacha/insns_ut_half/ut_fcvt_h_w.h [new file with mode: 0644]
hwacha/insns_ut_half/ut_fcvt_h_wu.h [new file with mode: 0644]
hwacha/insns_ut_half/ut_fcvt_l_h.h [new file with mode: 0644]
hwacha/insns_ut_half/ut_fcvt_lu_h.h [new file with mode: 0644]
hwacha/insns_ut_half/ut_fcvt_s_h.h [new file with mode: 0644]
hwacha/insns_ut_half/ut_fcvt_w_h.h [new file with mode: 0644]
hwacha/insns_ut_half/ut_fcvt_wu_h.h [new file with mode: 0644]
hwacha/insns_ut_half/ut_fdiv_h.h [new file with mode: 0644]
hwacha/insns_ut_half/ut_feq_h.h [new file with mode: 0644]
hwacha/insns_ut_half/ut_fle_h.h [new file with mode: 0644]
hwacha/insns_ut_half/ut_flh.h [new file with mode: 0644]
hwacha/insns_ut_half/ut_flt_h.h [new file with mode: 0644]
hwacha/insns_ut_half/ut_fmadd_h.h [new file with mode: 0644]
hwacha/insns_ut_half/ut_fmax_h.h [new file with mode: 0644]
hwacha/insns_ut_half/ut_fmin_h.h [new file with mode: 0644]
hwacha/insns_ut_half/ut_fmsub_h.h [new file with mode: 0644]
hwacha/insns_ut_half/ut_fmul_h.h [new file with mode: 0644]
hwacha/insns_ut_half/ut_fmv_h_x.h [new file with mode: 0644]
hwacha/insns_ut_half/ut_fmv_x_h.h [new file with mode: 0644]
hwacha/insns_ut_half/ut_fnmadd_h.h [new file with mode: 0644]
hwacha/insns_ut_half/ut_fnmsub_h.h [new file with mode: 0644]
hwacha/insns_ut_half/ut_fsgnj_h.h [new file with mode: 0644]
hwacha/insns_ut_half/ut_fsgnjn_h.h [new file with mode: 0644]
hwacha/insns_ut_half/ut_fsgnjx_h.h [new file with mode: 0644]
hwacha/insns_ut_half/ut_fsh.h [new file with mode: 0644]
hwacha/insns_ut_half/ut_fsqrt_h.h [new file with mode: 0644]
hwacha/insns_ut_half/ut_fsub_h.h [new file with mode: 0644]
hwacha/opcodes_hwacha_ut_half.h [new file with mode: 0644]

diff --git a/hwacha/cvt16.cc b/hwacha/cvt16.cc
new file mode 100644 (file)
index 0000000..0176822
--- /dev/null
@@ -0,0 +1,128 @@
+#include "cvt16.h"
+
+#define H_BIAS    (UINT16_C(0xf))
+#define H_F_MASK  (UINT16_C(0x03FF))
+#define H_E_MASK  (UINT16_C(0x7C00))
+#define H_E_SHIFT (10)
+#define H_S_MASK  (UINT16_C(0x8000))
+
+#define H_QNAN    (H_F_MASK)
+
+#define S_BIAS    (UINT32_C(0x7F))
+#define S_F_MASK  (UINT32_C(0x007fffff))
+#define S_E_MASK  (UINT32_C(0x7f800000))
+#define S_E_SHIFT (23)
+#define S_S_MASK  (UINT32_C(0x80000000))
+
+#define S_QNAN    (S_F_MASK)
+
+#define PAD  (S_E_SHIFT - H_E_SHIFT)
+
+uint_fast32_t cvt_hs(uint_fast16_t x)
+{
+#define MSB (UINT32_C(0x00800000))
+       uint_fast32_t frac, exp, sign;
+       frac = (x & H_F_MASK) << PAD;
+       exp  = (x & H_E_MASK);
+       sign = (x & H_S_MASK);
+
+       switch (exp) {
+       case 0:
+               if (frac) { /* Denormal */
+                       exp = S_BIAS - 14;
+                       /* Adjust fraction for implicit leading 1-bit */
+                       for (; !(frac & MSB); frac <<= 1, exp--);
+                       frac &= ~(MSB);
+                       exp <<= S_E_SHIFT;
+               }
+               break;
+
+       case H_E_MASK: /* Infinity and NaN */
+               exp = S_E_MASK;
+               if (frac) { /* Set padding bits for NaN */
+                       frac |= (1 << PAD) - 1;
+               }
+               break;
+       default:
+               exp += (S_BIAS - H_BIAS) << H_E_SHIFT; /* Re-bias */
+               exp <<= PAD;
+       }
+       return (sign << 16) | exp | frac;
+#undef MSB
+}
+
+enum riscv_rm {
+       RNE = 0, /* Round to nearest; ties to even */
+       RTZ = 1, /* Round towards zero (truncate) */
+       RDN = 2, /* Round towards negative infinity (down) */
+       RUP = 3, /* Round towards positive infinity (up) */
+       RMM = 4, /* Round to nearest; ties to max magnitude */
+};
+
+/*
+ * LSB           : frac[13]
+ * Guard bit  (G): frac[12]
+ * Round bit  (R): frac[11]
+ * Sticky bit (S): OR of frac[10..0]
+ *
+ * RTZ:
+ *   truncate
+ * RUP:
+ *   000 : exact
+ *  else : round up
+ * RDN:
+ *   000 : exact
+ *  else : round down
+ * RNE:
+ *   0xx : round down 
+ *   100 : tie; round up if LSB is 1
+ *   101 : round up
+ *   110 : round up
+ *   111 : round up
+ */
+uint_fast16_t cvt_sh(uint_fast32_t x, int rm)
+{
+#define MSB UINT16_C(0x0400)
+       uint_fast32_t frac, exp, sign;
+       int e;
+       sign = (x & S_S_MASK) >> 16;
+       exp = (x & S_E_MASK);
+       if (exp && exp != S_E_MASK) {
+               int inc;
+               inc = 0;
+               switch (rm) {
+               case RNE:
+                       /* Round up if G is set and either R, S,
+                          or the bit before G is non-zero */
+                       inc = (x & 0x1000) && (x & 0x2fff);
+                       break;
+               case RUP:
+                       inc = ((x & 0x1fff) != 0) && (!sign);
+                       break;
+               case RDN:
+                       inc = ((x & 0x1fff) != 0) && sign;
+                       break;
+               }
+               x += inc << PAD;
+               exp = (x & S_E_MASK);
+       }
+       frac = (x & S_F_MASK) >> PAD;
+
+       e = (exp >> S_E_SHIFT) - S_BIAS;
+       if (e < -24) { /* Round to zero */
+               return sign;
+       } else if (e < -14) { /* Denormal */
+               frac = (frac | MSB) >> (-e - 14);
+               return sign | frac;
+       } else if (e < 16) {
+               exp = (e + H_BIAS) << H_E_SHIFT;
+       } else if (e < 127) { /* Round to infinity */
+               exp = H_E_MASK;
+               frac = 0;
+       } else {
+               /* Infinity and NaN */
+       }
+       return sign | exp | frac;
+#undef MSB
+}
+
diff --git a/hwacha/cvt16.h b/hwacha/cvt16.h
new file mode 100644 (file)
index 0000000..1132f3f
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef _CVT16_H
+#define _CVT16_H
+
+#include <cstdint>
+
+extern uint_fast32_t cvt_hs(uint_fast16_t);
+extern uint_fast16_t cvt_sh(uint_fast32_t, int);
+
+#endif
diff --git a/hwacha/decode_hwacha_ut_half.h b/hwacha/decode_hwacha_ut_half.h
new file mode 100644 (file)
index 0000000..b4bff21
--- /dev/null
@@ -0,0 +1,15 @@
+#ifndef _DECODE_HWACHA_UT_HALF_H
+#define _DECODE_HWACHA_UT_HALF_H
+
+#include "decode_hwacha_ut.h"
+#include "cvt16.h"
+
+#define HFRS1 cvt_hs(FRS1)
+#define HFRS2 cvt_hs(FRS2)
+#define HFRS3 cvt_hs(FRS3)
+
+#define WRITE_HFRD(value) write_frd(h, insn, UTIDX, cvt_sh(value, RM))
+
+#define sext16(x) ((sreg_t)(int16_t)(x))
+
+#endif
index bf16b6fba823d4c7bdc2cf82533023dec121379f..487259dd171c061a4fdb37ad071176f4d0b20624 100644 (file)
@@ -1,4 +1,4 @@
-get_insn_list = $(shell cat $(1) | sed 's/DECLARE_INSN(\(.*\),.*,.*)/\1/')
+get_insn_list = $(shell sed 's/DECLARE_INSN(\(.*\),.*,.*)/\1/' $(1))
 get_opcode = $(shell grep \\\<$(2)\\\> $(1) | sed 's/DECLARE_INSN(.*,\(.*\),.*)/\1/')
 
 hwacha_subproject_deps = \
@@ -9,17 +9,19 @@ hwacha_install_prog_srcs = \
 
 hwacha_hdrs = \
        hwacha.h \
-       hwacha_xcpt.h \
        decode_hwacha.h \
        decode_hwacha_ut.h \
+       decode_hwacha_ut_half.h \
        opcodes_hwacha.h \
        opcodes_hwacha_ut.h \
+       opcodes_hwacha_ut_half.h \
 
 hwacha_srcs = \
        hwacha.cc \
        hwacha_disasm.cc \
        $(hwacha_gen_srcs) \
        $(hwacha_ut_gen_srcs) \
+       $(hwacha_ut_half_gen_srcs) \
 
 hwacha_test_srcs =
 
@@ -35,3 +37,8 @@ hwacha_ut_gen_srcs = \
 $(hwacha_ut_gen_srcs): %.cc: insns_ut/%.h insn_template_hwacha_ut.cc
        sed 's/NAME/$(subst .cc,,$@)/' $(src_dir)/hwacha/insn_template_hwacha_ut.cc | sed 's/OPCODE/$(call get_opcode,$(src_dir)/hwacha/opcodes_hwacha_ut.h,$(subst .cc,,$@))/' > $@
 
+hwacha_ut_half_gen_srcs = \
+       $(addsuffix .cc, $(call get_insn_list,$(src_dir)/hwacha/opcodes_hwacha_ut_half.h))
+
+$(hwacha_ut_half_gen_srcs): %.cc: insns_ut_half/%.h insn_template_hwacha_ut_half.cc
+       sed 's/NAME/$(subst .cc,,$@)/' $(src_dir)/hwacha/insn_template_hwacha_ut_half.cc | sed 's/OPCODE/$(call get_opcode,$(src_dir)/hwacha/opcodes_hwacha_ut_half.h,$(subst .cc,,$@))/' > $@
diff --git a/hwacha/insn_template_hwacha_ut_half.cc b/hwacha/insn_template_hwacha_ut_half.cc
new file mode 100644 (file)
index 0000000..12a0fb2
--- /dev/null
@@ -0,0 +1,25 @@
+// See LICENSE for license details.
+
+#include "config.h"
+#include "processor.h"
+#include "mmu.h"
+#include "softfloat.h"
+#include "platform.h" // softfloat isNaNF32UI, etc.
+#include "internals.h" // ditto
+#include "hwacha.h"
+#include "decode_hwacha_ut_half.h"
+#include "cvt16.h"
+#include <assert.h>
+
+reg_t hwacha_NAME(processor_t* p, insn_t insn, reg_t pc)
+{
+  int xprlen = 64;
+  reg_t npc = sext_xprlen(pc + insn_length(OPCODE));
+  hwacha_t* h = static_cast<hwacha_t*>(p->get_extension());
+  do {
+    #include "insns_ut_half/NAME.h"
+    WRITE_UTIDX(UTIDX+1);
+  } while (UTIDX < VL);
+  WRITE_UTIDX(0);
+  return npc;
+}
diff --git a/hwacha/insns_ut_half/ut_fadd_h.h b/hwacha/insns_ut_half/ut_fadd_h.h
new file mode 100644 (file)
index 0000000..8192562
--- /dev/null
@@ -0,0 +1,4 @@
+require_fp;
+softfloat_roundingMode = RM;
+WRITE_HFRD(f32_mulAdd(HFRS1, 0x3f800000, HFRS2));
+set_fp_exceptions;
diff --git a/hwacha/insns_ut_half/ut_fcvt_d_h.h b/hwacha/insns_ut_half/ut_fcvt_d_h.h
new file mode 100644 (file)
index 0000000..9251ae9
--- /dev/null
@@ -0,0 +1,4 @@
+require_fp;
+softfloat_roundingMode = RM;
+WRITE_FRD(f32_to_f64(HFRS1));
+set_fp_exceptions;
diff --git a/hwacha/insns_ut_half/ut_fcvt_h_d.h b/hwacha/insns_ut_half/ut_fcvt_h_d.h
new file mode 100644 (file)
index 0000000..89dc473
--- /dev/null
@@ -0,0 +1,4 @@
+require_fp;
+softfloat_roundingMode = RM;
+WRITE_HFRD(f64_to_f32(FRS1));
+set_fp_exceptions;
diff --git a/hwacha/insns_ut_half/ut_fcvt_h_l.h b/hwacha/insns_ut_half/ut_fcvt_h_l.h
new file mode 100644 (file)
index 0000000..fe75c27
--- /dev/null
@@ -0,0 +1,5 @@
+require_xpr64;
+require_fp;
+softfloat_roundingMode = RM;
+WRITE_HFRD(i64_to_f32(RS1));
+set_fp_exceptions;
diff --git a/hwacha/insns_ut_half/ut_fcvt_h_lu.h b/hwacha/insns_ut_half/ut_fcvt_h_lu.h
new file mode 100644 (file)
index 0000000..38fc8a7
--- /dev/null
@@ -0,0 +1,5 @@
+require_xpr64;
+require_fp;
+softfloat_roundingMode = RM;
+WRITE_HFRD(ui64_to_f32(RS1));
+set_fp_exceptions;
diff --git a/hwacha/insns_ut_half/ut_fcvt_h_s.h b/hwacha/insns_ut_half/ut_fcvt_h_s.h
new file mode 100644 (file)
index 0000000..ee49e1b
--- /dev/null
@@ -0,0 +1,3 @@
+require_fp;
+WRITE_FRD(cvt_sh(FRS1, RM));
+set_fp_exceptions;
diff --git a/hwacha/insns_ut_half/ut_fcvt_h_w.h b/hwacha/insns_ut_half/ut_fcvt_h_w.h
new file mode 100644 (file)
index 0000000..383a3c0
--- /dev/null
@@ -0,0 +1,4 @@
+require_fp;
+softfloat_roundingMode = RM;
+WRITE_HFRD(i32_to_f32((int32_t)RS1));
+set_fp_exceptions;
diff --git a/hwacha/insns_ut_half/ut_fcvt_h_wu.h b/hwacha/insns_ut_half/ut_fcvt_h_wu.h
new file mode 100644 (file)
index 0000000..228b25a
--- /dev/null
@@ -0,0 +1,4 @@
+require_fp;
+softfloat_roundingMode = RM;
+WRITE_HFRD(ui32_to_f32((uint32_t)RS1));
+set_fp_exceptions;
diff --git a/hwacha/insns_ut_half/ut_fcvt_l_h.h b/hwacha/insns_ut_half/ut_fcvt_l_h.h
new file mode 100644 (file)
index 0000000..1551ce2
--- /dev/null
@@ -0,0 +1,5 @@
+require_xpr64;
+require_fp;
+softfloat_roundingMode = RM;
+WRITE_RD(f32_to_i64(HFRS1, RM, true));
+set_fp_exceptions;
diff --git a/hwacha/insns_ut_half/ut_fcvt_lu_h.h b/hwacha/insns_ut_half/ut_fcvt_lu_h.h
new file mode 100644 (file)
index 0000000..b2fc5fd
--- /dev/null
@@ -0,0 +1,5 @@
+require_xpr64;
+require_fp;
+softfloat_roundingMode = RM;
+WRITE_RD(f32_to_ui64(HFRS1, RM, true));
+set_fp_exceptions;
diff --git a/hwacha/insns_ut_half/ut_fcvt_s_h.h b/hwacha/insns_ut_half/ut_fcvt_s_h.h
new file mode 100644 (file)
index 0000000..f779da8
--- /dev/null
@@ -0,0 +1,3 @@
+require_fp;
+WRITE_FRD(HFRS1);
+set_fp_exceptions;
diff --git a/hwacha/insns_ut_half/ut_fcvt_w_h.h b/hwacha/insns_ut_half/ut_fcvt_w_h.h
new file mode 100644 (file)
index 0000000..5a2f084
--- /dev/null
@@ -0,0 +1,4 @@
+require_fp;
+softfloat_roundingMode = RM;
+WRITE_RD(sext32(f32_to_i32(HFRS1, RM, true)));
+set_fp_exceptions;
diff --git a/hwacha/insns_ut_half/ut_fcvt_wu_h.h b/hwacha/insns_ut_half/ut_fcvt_wu_h.h
new file mode 100644 (file)
index 0000000..537f50a
--- /dev/null
@@ -0,0 +1,4 @@
+require_fp;
+softfloat_roundingMode = RM;
+WRITE_RD(sext32(f32_to_ui32(HFRS1, RM, true)));
+set_fp_exceptions;
diff --git a/hwacha/insns_ut_half/ut_fdiv_h.h b/hwacha/insns_ut_half/ut_fdiv_h.h
new file mode 100644 (file)
index 0000000..924b0c7
--- /dev/null
@@ -0,0 +1,4 @@
+require_fp;
+softfloat_roundingMode = RM;
+WRITE_HFRD(f32_div(HFRS1, HFRS2));
+set_fp_exceptions;
diff --git a/hwacha/insns_ut_half/ut_feq_h.h b/hwacha/insns_ut_half/ut_feq_h.h
new file mode 100644 (file)
index 0000000..a6b4707
--- /dev/null
@@ -0,0 +1,3 @@
+require_fp;
+WRITE_RD(f32_eq(HFRS1, HFRS2));
+set_fp_exceptions;
diff --git a/hwacha/insns_ut_half/ut_fle_h.h b/hwacha/insns_ut_half/ut_fle_h.h
new file mode 100644 (file)
index 0000000..2c17204
--- /dev/null
@@ -0,0 +1,3 @@
+require_fp;
+WRITE_RD(f32_le(HFRS1, HFRS2));
+set_fp_exceptions;
diff --git a/hwacha/insns_ut_half/ut_flh.h b/hwacha/insns_ut_half/ut_flh.h
new file mode 100644 (file)
index 0000000..90872ed
--- /dev/null
@@ -0,0 +1,2 @@
+require_fp;
+WRITE_FRD(MMU.load_int16(RS1 + insn.i_imm()));
diff --git a/hwacha/insns_ut_half/ut_flt_h.h b/hwacha/insns_ut_half/ut_flt_h.h
new file mode 100644 (file)
index 0000000..39a0393
--- /dev/null
@@ -0,0 +1,3 @@
+require_fp;
+WRITE_RD(f32_lt(HFRS1, HFRS2));
+set_fp_exceptions;
diff --git a/hwacha/insns_ut_half/ut_fmadd_h.h b/hwacha/insns_ut_half/ut_fmadd_h.h
new file mode 100644 (file)
index 0000000..cfbd82e
--- /dev/null
@@ -0,0 +1,4 @@
+require_fp;
+softfloat_roundingMode = RM;
+WRITE_HFRD(f32_mulAdd(HFRS1, HFRS2, HFRS3));
+set_fp_exceptions;
diff --git a/hwacha/insns_ut_half/ut_fmax_h.h b/hwacha/insns_ut_half/ut_fmax_h.h
new file mode 100644 (file)
index 0000000..32d3aa6
--- /dev/null
@@ -0,0 +1,4 @@
+require_fp;
+WRITE_HFRD(isNaNF32UI(HFRS2) || f32_le_quiet(HFRS2,HFRS1) /* && FRS1 not NaN */
+      ? HFRS1 : HFRS2);
+set_fp_exceptions;
diff --git a/hwacha/insns_ut_half/ut_fmin_h.h b/hwacha/insns_ut_half/ut_fmin_h.h
new file mode 100644 (file)
index 0000000..a6a7cc3
--- /dev/null
@@ -0,0 +1,4 @@
+require_fp;
+WRITE_HFRD(isNaNF32UI(HFRS2) || f32_lt_quiet(HFRS1,HFRS2) /* && FRS1 not NaN */
+      ? HFRS1 : HFRS2);
+set_fp_exceptions;
diff --git a/hwacha/insns_ut_half/ut_fmsub_h.h b/hwacha/insns_ut_half/ut_fmsub_h.h
new file mode 100644 (file)
index 0000000..323a8d0
--- /dev/null
@@ -0,0 +1,4 @@
+require_fp;
+softfloat_roundingMode = RM;
+WRITE_HFRD(f32_mulAdd(HFRS1, HFRS2, HFRS3 ^ (uint32_t)INT32_MIN));
+set_fp_exceptions;
diff --git a/hwacha/insns_ut_half/ut_fmul_h.h b/hwacha/insns_ut_half/ut_fmul_h.h
new file mode 100644 (file)
index 0000000..669dd0e
--- /dev/null
@@ -0,0 +1,4 @@
+require_fp;
+softfloat_roundingMode = RM;
+WRITE_HFRD(f32_mulAdd(HFRS1, HFRS2, (HFRS1 ^ HFRS2) & (uint32_t)INT32_MIN));
+set_fp_exceptions;
diff --git a/hwacha/insns_ut_half/ut_fmv_h_x.h b/hwacha/insns_ut_half/ut_fmv_h_x.h
new file mode 100644 (file)
index 0000000..f3eac82
--- /dev/null
@@ -0,0 +1,2 @@
+require_fp;
+WRITE_FRD(RS1);
diff --git a/hwacha/insns_ut_half/ut_fmv_x_h.h b/hwacha/insns_ut_half/ut_fmv_x_h.h
new file mode 100644 (file)
index 0000000..d0a84bc
--- /dev/null
@@ -0,0 +1,2 @@
+require_fp;
+WRITE_RD(sext16(FRS1));
diff --git a/hwacha/insns_ut_half/ut_fnmadd_h.h b/hwacha/insns_ut_half/ut_fnmadd_h.h
new file mode 100644 (file)
index 0000000..f17cd8e
--- /dev/null
@@ -0,0 +1,4 @@
+require_fp;
+softfloat_roundingMode = RM;
+WRITE_HFRD(f32_mulAdd(HFRS1 ^ (uint32_t)INT32_MIN, HFRS2, HFRS3 ^ (uint32_t)INT32_MIN));
+set_fp_exceptions;
diff --git a/hwacha/insns_ut_half/ut_fnmsub_h.h b/hwacha/insns_ut_half/ut_fnmsub_h.h
new file mode 100644 (file)
index 0000000..9a3161a
--- /dev/null
@@ -0,0 +1,4 @@
+require_fp;
+softfloat_roundingMode = RM;
+WRITE_HFRD(f32_mulAdd(HFRS1 ^ (uint32_t)INT32_MIN, HFRS2, HFRS3));
+set_fp_exceptions;
diff --git a/hwacha/insns_ut_half/ut_fsgnj_h.h b/hwacha/insns_ut_half/ut_fsgnj_h.h
new file mode 100644 (file)
index 0000000..152d02b
--- /dev/null
@@ -0,0 +1,2 @@
+require_fp;
+WRITE_FRD((FRS1 &~ (uint16_t)INT16_MIN) | (FRS2 & (uint16_t)INT16_MIN));
diff --git a/hwacha/insns_ut_half/ut_fsgnjn_h.h b/hwacha/insns_ut_half/ut_fsgnjn_h.h
new file mode 100644 (file)
index 0000000..b098150
--- /dev/null
@@ -0,0 +1,2 @@
+require_fp;
+WRITE_FRD((FRS1 &~ (uint32_t)INT32_MIN) | ((~FRS2) & (uint32_t)INT32_MIN));
diff --git a/hwacha/insns_ut_half/ut_fsgnjx_h.h b/hwacha/insns_ut_half/ut_fsgnjx_h.h
new file mode 100644 (file)
index 0000000..2b6d7ac
--- /dev/null
@@ -0,0 +1,2 @@
+require_fp;
+WRITE_FRD(FRS1 ^ (FRS2 & (uint16_t)INT16_MIN));
diff --git a/hwacha/insns_ut_half/ut_fsh.h b/hwacha/insns_ut_half/ut_fsh.h
new file mode 100644 (file)
index 0000000..945d3e3
--- /dev/null
@@ -0,0 +1,2 @@
+require_fp;
+MMU.store_uint16(RS1 + insn.s_imm(), FRS2);
diff --git a/hwacha/insns_ut_half/ut_fsqrt_h.h b/hwacha/insns_ut_half/ut_fsqrt_h.h
new file mode 100644 (file)
index 0000000..f8b83fb
--- /dev/null
@@ -0,0 +1,4 @@
+require_fp;
+softfloat_roundingMode = RM;
+WRITE_HFRD(f32_sqrt(HFRS1));
+set_fp_exceptions;
diff --git a/hwacha/insns_ut_half/ut_fsub_h.h b/hwacha/insns_ut_half/ut_fsub_h.h
new file mode 100644 (file)
index 0000000..39cebbe
--- /dev/null
@@ -0,0 +1,4 @@
+require_fp;
+softfloat_roundingMode = RM;
+WRITE_HFRD(f32_mulAdd(HFRS1, 0x3f800000, HFRS2 ^ (uint32_t)INT32_MIN));
+set_fp_exceptions;
diff --git a/hwacha/opcodes_hwacha_ut_half.h b/hwacha/opcodes_hwacha_ut_half.h
new file mode 100644 (file)
index 0000000..b869a07
--- /dev/null
@@ -0,0 +1,33 @@
+DECLARE_INSN(ut_fcvt_h_lu, 0x6c000053, 0xfff0007f)
+DECLARE_INSN(ut_fmin_h, 0xc4000053, 0xfe00707f)
+DECLARE_INSN(ut_fcvt_wu_h, 0x5c000053, 0xfff0007f)
+DECLARE_INSN(ut_fdiv_h, 0x1c000053, 0xfe00007f)
+DECLARE_INSN(ut_fcvt_h_wu, 0x7c000053, 0xfff0007f)
+DECLARE_INSN(ut_fsgnj_h, 0x2c000053, 0xfe00707f)
+DECLARE_INSN(ut_fnmsub_h, 0x400004b, 0x600007f)
+DECLARE_INSN(ut_fle_h, 0xbc000053, 0xfe00707f)
+DECLARE_INSN(ut_fcvt_l_h, 0x44000053, 0xfff0007f)
+DECLARE_INSN(ut_fnmadd_h, 0x400004f, 0x600007f)
+DECLARE_INSN(ut_fcvt_h_s, 0x90000053, 0xfff0007f)
+DECLARE_INSN(ut_fcvt_h_w, 0x74000053, 0xfff0007f)
+DECLARE_INSN(ut_fcvt_d_h, 0x8c000053, 0xfff0007f)
+DECLARE_INSN(ut_fmax_h, 0xcc000053, 0xfe00707f)
+DECLARE_INSN(ut_fcvt_lu_h, 0x4c000053, 0xfff0007f)
+DECLARE_INSN(ut_fcvt_h_l, 0x64000053, 0xfff0007f)
+DECLARE_INSN(ut_fmv_x_h, 0xe4000053, 0xfff0707f)
+DECLARE_INSN(ut_fcvt_h_d, 0x92000053, 0xfff0007f)
+DECLARE_INSN(ut_flt_h, 0xb4000053, 0xfe00707f)
+DECLARE_INSN(ut_fadd_h, 0x4000053, 0xfe00007f)
+DECLARE_INSN(ut_fcvt_s_h, 0x84000053, 0xfff0007f)
+DECLARE_INSN(ut_fcvt_w_h, 0x54000053, 0xfff0007f)
+DECLARE_INSN(ut_fmul_h, 0x14000053, 0xfe00007f)
+DECLARE_INSN(ut_fmadd_h, 0x4000043, 0x600007f)
+DECLARE_INSN(ut_fsqrt_h, 0x24000053, 0xfff0007f)
+DECLARE_INSN(ut_fsgnjn_h, 0x34000053, 0xfe00707f)
+DECLARE_INSN(ut_fsub_h, 0xc000053, 0xfe00007f)
+DECLARE_INSN(ut_fsh, 0x1027, 0x707f)
+DECLARE_INSN(ut_fsgnjx_h, 0x3c000053, 0xfe00707f)
+DECLARE_INSN(ut_flh, 0x1007, 0x707f)
+DECLARE_INSN(ut_fmsub_h, 0x4000047, 0x600007f)
+DECLARE_INSN(ut_feq_h, 0xac000053, 0xfe00707f)
+DECLARE_INSN(ut_fmv_h_x, 0xf4000053, 0xfff0707f)