Skip to content

Commit 93bf5f5

Browse files
evgeniy-paltsevgalak
authored andcommitted
ARC: add TLS support for ARCv3
For ARCv3 the register is fixed to r30, so we don't need to configure it at compile-time. Signed-off-by: Eugeniy Paltsev <[email protected]> Signed-off-by: Evgeniy Paltsev <[email protected]>
1 parent 0a5137f commit 93bf5f5

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

arch/arc/CMakeLists.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@ zephyr_cc_option(-fno-delete-null-pointer-checks)
1212

1313
zephyr_cc_option_ifdef(CONFIG_ARC_USE_UNALIGNED_MEM_ACCESS -munaligned-access)
1414

15-
# Instruct compiler to use register R26 as thread pointer
16-
# for thread local storage.
17-
zephyr_cc_option_ifdef(CONFIG_THREAD_LOCAL_STORAGE -mtp-regno=26)
15+
if(CONFIG_ISA_ARCV2)
16+
# Instruct compiler to use register R26 as thread pointer
17+
# for thread local storage.
18+
# For ARCv3 the register is fixed to r30, so we don't need to specify it
19+
zephyr_cc_option_ifdef(CONFIG_THREAD_LOCAL_STORAGE -mtp-regno=26)
20+
endif()
1821

1922
add_subdirectory(core)

arch/arc/core/thread.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,13 @@ static inline void arch_setup_callee_saved_regs(struct k_thread *thread,
122122
ARG_UNUSED(regs);
123123

124124
#ifdef CONFIG_THREAD_LOCAL_STORAGE
125-
/* R26 is used for thread pointer */
125+
#ifdef CONFIG_ISA_ARCV2
126+
/* R26 is used for thread pointer for ARCv2 */
126127
regs->r26 = thread->tls;
128+
#else
129+
/* R30 is used for thread pointer for ARCv3 */
130+
regs->r30 = thread->tls;
131+
#endif /* CONFIG_ISA_ARCV2 */
127132
#endif
128133
}
129134

0 commit comments

Comments
 (0)