Fix FPU initialization code
authorAndrew Waterman <andrew@sifive.com>
Sat, 25 Mar 2017 23:07:25 +0000 (16:07 -0700)
committerAndrew Waterman <andrew@sifive.com>
Sat, 25 Mar 2017 23:07:25 +0000 (16:07 -0700)
benchmarks/common/crt.S

index be03ebbdb3e6b9a54ea835225d8e89963b3bb1d7..3d4d6cff0bfdc97bb42a82d880859f71039f5665 100644 (file)
@@ -15,9 +15,6 @@
   .section ".text.init"
   .globl _start
 _start:
   .section ".text.init"
   .globl _start
 _start:
-  la t0, trap_entry
-  csrw mtvec, t0
-
   li  x1, 0
   li  x2, 0
   li  x3, 0
   li  x1, 0
   li  x2, 0
   li  x3, 0
@@ -62,14 +59,16 @@ _start:
 #else
   bltz t0, 1f
 #endif
 #else
   bltz t0, 1f
 #endif
+2:
   li a0, 1
   sw a0, tohost, t0
   li a0, 1
   sw a0, tohost, t0
+  j 2b
 1:
 
 #ifdef __riscv_flen
   # initialize FPU if we have one
 1:
 
 #ifdef __riscv_flen
   # initialize FPU if we have one
-  andi t0, t0, 1 << ('f' - 'a')
-  beqz t0, 1f
+  la t0, 1f
+  csrw mtvec, t0
 
   fssr    x0
   fmv.s.x f0, x0
 
   fssr    x0
   fmv.s.x f0, x0
@@ -104,9 +103,12 @@ _start:
   fmv.s.x f29,x0
   fmv.s.x f30,x0
   fmv.s.x f31,x0
   fmv.s.x f29,x0
   fmv.s.x f30,x0
   fmv.s.x f31,x0
+1:
 #endif
 
 #endif
 
-1:
+  # initialize trap vector
+  la t0, trap_entry
+  csrw mtvec, t0
 
   # initialize global pointer
   la gp, _gp
 
   # initialize global pointer
   la gp, _gp