add rv_div (signed and unsigned) to replace operator /
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sun, 14 Oct 2018 04:35:03 +0000 (05:35 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sun, 14 Oct 2018 04:35:03 +0000 (05:35 +0100)
riscv/insns/div.h
riscv/insns/divu.h
riscv/insns/divuw.h
riscv/insns/divw.h
riscv/sv_insn_redirect.cc
riscv/sv_insn_redirect.h

index 9cbe8d6b321648b144834ef2514948c1b8f19bff..b4dd9f21124e2e49bae18405e9a2931facbbf9d8 100644 (file)
@@ -6,4 +6,4 @@ if(rhs == 0)
 else if(lhs == INT64_MIN && rhs == -1)
   WRITE_RD(lhs);
 else
-  WRITE_RD(sext_xlen(lhs / rhs));
+  WRITE_RD(sext_xlen(rv_div(lhs, rhs)));
index 31d758560b8e5b9074c74292b871f32bd5207d06..30225fbc68697511ddf6826937ec2aa1c6035e9c 100644 (file)
@@ -4,4 +4,4 @@ reg_t rhs = zext_xlen(RS2);
 if(rhs == 0)
   WRITE_RD(UINT64_MAX);
 else
-  WRITE_RD(sext_xlen(lhs / rhs));
+  WRITE_RD(sext_xlen(rv_div(lhs, rhs)));
index e127619aa990ad3394c16810268be611543ef221..2fba815962a320749fe7fccf821bb360204132c7 100644 (file)
@@ -5,4 +5,4 @@ reg_t rhs = zext32(RS2);
 if(rhs == 0)
   WRITE_RD(UINT64_MAX);
 else
-  WRITE_RD(sext32(lhs / rhs));
+  WRITE_RD(sext32(rv_div(lhs, rhs)));
index 11be17e4c33d450244c42d98c99d2c31c8a35bd9..f8b47852ba48c459a5f02b9d7a8f61cc06db4f82 100644 (file)
@@ -5,4 +5,4 @@ sreg_t rhs = sext32(RS2);
 if(rhs == 0)
   WRITE_RD(UINT64_MAX);
 else
-  WRITE_RD(sext32(lhs / rhs));
+  WRITE_RD(sext32(rv_div(lhs, rhs)));
index f883a7b7c2bd7726ec8b628dd4e9c51be1a44ff1..603defe81506ba1736c523453fa042645a190112 100644 (file)
@@ -227,3 +227,13 @@ reg_t sv_proc_t::rv_sub(reg_t lhs, reg_t rhs)
     return lhs - rhs;
 }
 
+sreg_t sv_proc_t::rv_div(sreg_t lhs, sreg_t rhs)
+{
+    return lhs / rhs;
+}
+
+reg_t sv_proc_t::rv_div(reg_t lhs, reg_t rhs)
+{
+    return lhs / rhs;
+}
+
index 05faf61dc8c226de7792484e6d77dcf595f9e49c..6a029bb9ead8261a2cbd67e8bf8231a746d84ebb 100644 (file)
@@ -96,6 +96,8 @@ public:
 
     reg_t rv_add(reg_t lhs, reg_t rhs);
     reg_t rv_sub(reg_t lhs, reg_t rhs);
+    reg_t rv_div(reg_t lhs, reg_t rhs);
+    sreg_t rv_div(sreg_t lhs, sreg_t rhs);
 
 #include "sv_insn_decl.h"
 };