Skip to content
This repository was archived by the owner on May 7, 2024. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d2cc398

Browse files
aswatermanpalmer-dabbelt
authored andcommittedNov 8, 2017
Use __riscv_flush_icache to flush the I$ on Linux
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
1 parent 9a3711d commit d2cc398

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed
 

‎gcc/config/riscv/linux.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ along with GCC; see the file COPYING3. If not see
4545
#define LIB_SPEC GNU_USER_TARGET_LIB_SPEC " -latomic "
4646
#endif
4747

48+
#define ICACHE_FLUSH_FUNC "__riscv_flush_icache"
49+
4850
#define LINK_SPEC "\
4951
-melf" XLEN_SPEC "lriscv \
5052
%{shared} \

‎gcc/config/riscv/riscv.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,7 +1456,13 @@
14561456
(match_operand 1 "pmode_register_operand")]
14571457
""
14581458
{
1459+
#ifdef ICACHE_FLUSH_FUNC
1460+
emit_library_call (gen_rtx_SYMBOL_REF (Pmode, ICACHE_FLUSH_FUNC),
1461+
LCT_NORMAL, VOIDmode, 3, operands[0], Pmode,
1462+
operands[1], Pmode, const0_rtx, Pmode);
1463+
#else
14591464
emit_insn (gen_fence_i ());
1465+
#endif
14601466
DONE;
14611467
})
14621468

0 commit comments

Comments
 (0)
This repository has been archived.