jalr, mul, rem
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Thu, 18 Oct 2018 22:38:06 +0000 (23:38 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Thu, 18 Oct 2018 22:38:06 +0000 (23:38 +0100)
riscv/insns/jalr.h
riscv/insns/mulh.h
riscv/insns/mulhsu.h
riscv/insns/mulhu.h
riscv/insns/rem.h
riscv/insns/remu.h
riscv/insns/remuw.h
riscv/insns/remw.h

index 386e8db1f569793e2ba3cba20da2020ca183cede..a4df628f5e06f66d37b58cfa3485fb5837db9949 100644 (file)
@@ -1,3 +1,3 @@
 reg_t tmp = npc;
-set_pc((RS1 + insn.i_imm()) & ~reg_t(1));
+set_pc(rv_and(rv_add(RS1, insn.i_imm()), ~reg_t(1)));
 WRITE_RD(tmp);
index 737b9cb657d89b7df58dde6e4b7441c919e336e5..d7a95e9ae98d513f7b70079a08be8b00ad6ab8a3 100644 (file)
@@ -2,4 +2,5 @@ require_extension('M');
 if (xlen == 64)
   WRITE_RD(mulh(RS1, RS2));
 else
-  WRITE_RD(sext32((rv_mul(sext32(RS1), sext32(RS2))) >> 32));
+  WRITE_RD(sext32(rv_sr(rv_mul(sext32(RS1), sext32(RS2)),
+                        sv_reg_t(32U))));
index 6890799e49af90465cd308dedd6993f1df613458..724e66170c62f92efc7ad0ebb2248736413f1841 100644 (file)
@@ -2,4 +2,5 @@ require_extension('M');
 if (xlen == 64)
   WRITE_RD(mulhsu(RS1, RS2));
 else
-  WRITE_RD(sext32((rv_mul(sext32(RS1), reg_t((uint32_t)RS2))) >> 32));
+  WRITE_RD(sext32(rv_sr((rv_mul(sext32(RS1), sv_reg_uint32(RS2))),
+                  sv_reg_t(32U))));
index a9527b27ba559d8d89ed4f25d9b1f6bb02046126..dee66b05e29e3955cf2af05353bc7b68fab668e2 100644 (file)
@@ -2,5 +2,6 @@ require_extension('M');
 if (xlen == 64)
   WRITE_RD(mulhu(RS1, RS2));
 else
-  WRITE_RD(sext32((rv_mul((uint64_t)(uint32_t)RS1,
-                          (uint64_t)(uint32_t)RS2)) >> 32));
+  WRITE_RD(sext32(rv_sr(rv_mul(sv_reg_uint32(RS1),
+                          sv_reg_uint32(RS2)),
+                        sv_reg_t(32U))));
index 5464915c3958ad63a6a29c4fd5094818d07da3e2..eae3d8013b9974d3fc5dd6394bfdbd52c81a52e8 100644 (file)
@@ -1,9 +1,9 @@
 require_extension('M');
-sreg_t lhs = sext_xlen(RS1);
-sreg_t rhs = sext_xlen(RS2);
-if(rhs == 0)
+sv_sreg_t lhs = sext_xlen(RS1);
+sv_sreg_t rhs = sext_xlen(RS2);
+if(rv_eq(rhs, sv_reg_t(0)))
   WRITE_RD(lhs);
-else if(lhs == INT64_MIN && rhs == -1)
+else if(rv_eq(lhs, sv_reg_t(INT64_MIN)) && rv_eq(rhs, sv_reg_t(-1L)))
   WRITE_RD(0);
 else
   WRITE_RD(sext_xlen(rv_rem(lhs, rhs)));
index 8c59de64284d27c1a588b328c79cb562a30e544d..cbd03fe7abd1d1edd4a835aa4026a75bb60d0125 100644 (file)
@@ -1,7 +1,7 @@
 require_extension('M');
-reg_t lhs = zext_xlen(RS1);
-reg_t rhs = zext_xlen(RS2);
-if(rhs == 0)
+sv_reg_t lhs = zext_xlen(RS1);
+sv_reg_t rhs = zext_xlen(RS2);
+if(rv_eq(rhs, sv_reg_t(0)))
   WRITE_RD(sext_xlen(RS1));
 else
   WRITE_RD(sext_xlen(rv_rem(lhs, rhs)));
index 7f30d0e7bb3404bd842f8f0d39f7310fe346ba46..d2a32642ef5c2280df349f72c593733082a4e84e 100644 (file)
@@ -1,8 +1,8 @@
 require_extension('M');
 require_rv64;
-reg_t lhs = zext32(RS1);
-reg_t rhs = zext32(RS2);
-if(rhs == 0)
+sv_reg_t lhs = zext32(RS1);
+sv_reg_t rhs = zext32(RS2);
+if(rv_eq(rhs, sv_reg_t(0)))
   WRITE_RD(sext32(lhs));
 else
   WRITE_RD(sext32(rv_rem(lhs, rhs)));
index cf4bd4f5c35a7922c7c04c8a460d1c95b4607587..fe326f0ed188ba3991ff91cbdfea52c4da5941c8 100644 (file)
@@ -1,8 +1,8 @@
 require_extension('M');
 require_rv64;
-sreg_t lhs = sext32(RS1);
-sreg_t rhs = sext32(RS2);
-if(rhs == 0)
+sv_sreg_t lhs = sext32(RS1);
+sv_sreg_t rhs = sext32(RS2);
+if(rv_eq(rhs, sv_reg_t(0)))
   WRITE_RD(lhs);
 else
   WRITE_RD(sext32(rv_rem(lhs, rhs)));