diff --git a/arch/arc/CMakeLists.txt b/arch/arc/CMakeLists.txt index 8135d072f10..66f4848e23d 100644 --- a/arch/arc/CMakeLists.txt +++ b/arch/arc/CMakeLists.txt @@ -12,8 +12,11 @@ zephyr_cc_option(-fno-delete-null-pointer-checks) zephyr_cc_option_ifdef(CONFIG_ARC_USE_UNALIGNED_MEM_ACCESS -munaligned-access) -# Instruct compiler to use register R26 as thread pointer -# for thread local storage. -zephyr_cc_option_ifdef(CONFIG_THREAD_LOCAL_STORAGE -mtp-regno=26) +if(CONFIG_ISA_ARCV2) + # Instruct compiler to use register R26 as thread pointer + # for thread local storage. + # For ARCv3 the register is fixed to r30, so we don't need to specify it + zephyr_cc_option_ifdef(CONFIG_THREAD_LOCAL_STORAGE -mtp-regno=26) +endif() add_subdirectory(core) diff --git a/arch/arc/core/thread.c b/arch/arc/core/thread.c index f0a0fd7ac26..be3b4052111 100644 --- a/arch/arc/core/thread.c +++ b/arch/arc/core/thread.c @@ -122,8 +122,13 @@ static inline void arch_setup_callee_saved_regs(struct k_thread *thread, ARG_UNUSED(regs); #ifdef CONFIG_THREAD_LOCAL_STORAGE - /* R26 is used for thread pointer */ +#ifdef CONFIG_ISA_ARCV2 + /* R26 is used for thread pointer for ARCv2 */ regs->r26 = thread->tls; +#else + /* R30 is used for thread pointer for ARCv3 */ + regs->r30 = thread->tls; +#endif /* CONFIG_ISA_ARCV2 */ #endif }