Skip to content
This repository has been archived by the owner on May 7, 2024. It is now read-only.

Commit

Permalink
Use __riscv_flush_icache to flush the I$ on Linux
Browse files Browse the repository at this point in the history
The fence.i instruction is not appropriate, because it only flushes
the current core's I$.  If the thread is migrated to a different core,
the instructions would be incoherent.

This depends on riscvarchive/riscv-glibc#22
  • Loading branch information
aswaterman authored and palmer-dabbelt committed Nov 8, 2017
1 parent 9a3711d commit d2cc398
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions gcc/config/riscv/linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -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} \
Expand Down
6 changes: 6 additions & 0 deletions gcc/config/riscv/riscv.md
Original file line number Diff line number Diff line change
Expand Up @@ -1456,7 +1456,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;
})

Expand Down

0 comments on commit d2cc398

Please sign in to comment.