Explorar o código

Replace mul instruction with a loop for rv32i

Vadim Kaushan %!s(int64=5) %!d(string=hai) anos
pai
achega
579f68ddf7
Modificáronse 1 ficheiros con 11 adicións e 0 borrados
  1. 11 0
      riscv-rt/asm.S

+ 11 - 0
riscv-rt/asm.S

@@ -84,7 +84,18 @@ _abs_start:
     la sp, _stack_start
     lui t0, %hi(_hart_stack_size)
     add t0, t0, %lo(_hart_stack_size)
+#ifdef __riscv_mul
     mul t0, a2, t0
+#else
+    beqz a2, 2f  // Jump if single-hart
+    mv t1, a2
+    mv t2, t0
+1:
+    add t0, t0, t2
+    addi t1, t1, -1
+    bnez t1, 1b
+2:
+#endif
     sub sp, sp, t0
 
     // Set frame pointer