RISC-V: Fix interrupt support for -g.
authorJim Wilson <jimw@sifive.com>
Tue, 3 Jul 2018 00:19:59 +0000 (00:19 +0000)
committerJim Wilson <wilson@gcc.gnu.org>
Tue, 3 Jul 2018 00:19:59 +0000 (17:19 -0700)
gcc/
* config/riscv/riscv.c (riscv_expand_epilogue): Use emit_jump_insn
instead of emit_insn for interrupt returns.
* config/riscv/riscv.md (riscv_met): Add (return) to rtl.
(riscv_sret, riscv_uret): Likewise.

gcc/testsuite/
* gcc.target/riscv/interrupt-debug.c: New.

From-SVN: r262327

gcc/ChangeLog
gcc/config/riscv/riscv.c
gcc/config/riscv/riscv.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/riscv/interrupt-debug.c [new file with mode: 0644]

index e0b5c65062aa29edb619723f2e97477e48709dbf..a8c2629cdac622a01d613697112d6a0b94e71cc5 100644 (file)
@@ -1,3 +1,10 @@
+2018-07-02  Jim Wilson  <jimw@sifive.com>
+
+       * config/riscv/riscv.c (riscv_expand_epilogue): Use emit_jump_insn
+       instead of emit_insn for interrupt returns.
+       * config/riscv/riscv.md (riscv_met): Add (return) to rtl.
+       (riscv_sret, riscv_uret): Likewise.
+
 2018-07-02  David Malcolm  <dmalcolm@redhat.com>
 
        * pretty-print.c (selftest::test_pp_format): Move save and restore
index 2709ebdd7975292b388e36360a185baa98ced002..d87836f53f859e58db0bb8ecfd06df70fd9b5ad3 100644 (file)
@@ -3985,11 +3985,11 @@ riscv_expand_epilogue (int style)
       enum riscv_privilege_levels mode = cfun->machine->interrupt_mode;
 
       if (mode == MACHINE_MODE)
-       emit_insn (gen_riscv_mret ());
+       emit_jump_insn (gen_riscv_mret ());
       else if (mode == SUPERVISOR_MODE)
-       emit_insn (gen_riscv_sret ());
+       emit_jump_insn (gen_riscv_sret ());
       else
-       emit_insn (gen_riscv_uret ());
+       emit_jump_insn (gen_riscv_uret ());
     }
   else if (style != SIBCALL_RETURN)
     emit_jump_insn (gen_simple_return_internal (ra));
index 7b411f0538e2891ed1607e238c45a270bf88a7cb..613af9d79e47070c6e6ac4e161983b744df680c1 100644 (file)
   "fsflags\t%0")
 
 (define_insn "riscv_mret"
-  [(unspec_volatile [(const_int 0)] UNSPECV_MRET)]
+  [(return)
+   (unspec_volatile [(const_int 0)] UNSPECV_MRET)]
   ""
   "mret")
 
 (define_insn "riscv_sret"
-  [(unspec_volatile [(const_int 0)] UNSPECV_SRET)]
+  [(return)
+   (unspec_volatile [(const_int 0)] UNSPECV_SRET)]
   ""
   "sret")
 
 (define_insn "riscv_uret"
-  [(unspec_volatile [(const_int 0)] UNSPECV_URET)]
+  [(return)
+   (unspec_volatile [(const_int 0)] UNSPECV_URET)]
   ""
   "uret")
 
index f2485db4f0fce57a415c07f28ce217b899f86586..fb4422ff6e797be2250a994aeb0a955e3ab02381 100644 (file)
@@ -1,3 +1,7 @@
+2018-07-02  Jim Wilson  <jimw@sifive.com>
+
+       * gcc.target/riscv/interrupt-debug.c: New.
+
 2018-07-02  Paolo Carlini  <paolo.carlini@oracle.com>
 
        * g++.dg/diagnostic/thread-thread_local.C: New.
diff --git a/gcc/testsuite/gcc.target/riscv/interrupt-debug.c b/gcc/testsuite/gcc.target/riscv/interrupt-debug.c
new file mode 100644 (file)
index 0000000..a1b6dac
--- /dev/null
@@ -0,0 +1,15 @@
+/* Verify that we can compile with debug info.  */
+/* { dg-do compile } */
+/* { dg-options "-Og -g" } */
+extern int var1;
+extern int var2;
+extern void sub2 (void);
+
+void __attribute__ ((interrupt))
+sub (void)
+{
+  if (var1)
+    var2 = 0;
+  else
+    sub2 ();
+}