RISC-V: Fix for icache flush issue on multicore processors.

Message ID 20180102210552.781-1-jimw@sifive.com
State New
Headers show
Series
  • RISC-V: Fix for icache flush issue on multicore processors.
Related show

Commit Message

Jim Wilson Jan. 2, 2018, 9:05 p.m.
The gcc-7-branch version of the patch, tested same as the mainline patch.
Committed.

	gcc/
	* config/riscv/linux.h (ICACHE_FLUSH_FUNC): New.
	* config/riscv/riscv.md (clear_cache): Use it.
---
 gcc/config/riscv/linux.h  | 2 ++
 gcc/config/riscv/riscv.md | 6 ++++++
 2 files changed, 8 insertions(+)

-- 
2.14.1

Patch

diff --git a/gcc/config/riscv/linux.h b/gcc/config/riscv/linux.h
index 6c7e3c4e819..4b2f7b6e1fd 100644
--- a/gcc/config/riscv/linux.h
+++ b/gcc/config/riscv/linux.h
@@ -45,6 +45,8 @@  along with GCC; see the file COPYING3.  If not see
 #define LIB_SPEC GNU_USER_TARGET_LIB_SPEC " -latomic "
 #endif
 
+#define ICACHE_FLUSH_FUNC "__riscv_flush_icache"
+
 #define LINK_SPEC "\
 -melf" XLEN_SPEC "lriscv \
 %{shared} \
diff --git a/gcc/config/riscv/riscv.md b/gcc/config/riscv/riscv.md
index c478e03fbbe..5f216d3255b 100644
--- a/gcc/config/riscv/riscv.md
+++ b/gcc/config/riscv/riscv.md
@@ -1429,7 +1429,13 @@ 
    (match_operand 1 "pmode_register_operand")]
   ""
 {
+#ifdef ICACHE_FLUSH_FUNC
+  emit_library_call (gen_rtx_SYMBOL_REF (Pmode, ICACHE_FLUSH_FUNC),
+		     LCT_NORMAL, VOIDmode, 3, operands[0], Pmode,
+		     operands[1], Pmode, const0_rtx, Pmode);
+#else
   emit_insn (gen_fence_i ());
+#endif
   DONE;
 })