提交 06a2c55f 编写于 作者: H Hongchen Zhang

LoongArch: change global registers to local registers

LoongArch inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I5OHOB

--------------------------------

From gcc commit 3f13154553f8
("df-scan: remove ad-hoc handling of global regs in asms"),
global registers will no longer be forced to add to the def-use
chain for the following inline asm :
  __asm("" : "=r"(a) : "0"(c)); /* the case for RELOC_HIDE */
  __asm("" : "=r"(b));

So we change to use $r21 $tp $sp as local registers,this way
they can be forced to add to the def-use chain.
Signed-off-by: NHongchen Zhang <zhanghongchen@loongson.cn>
Signed-off-by: NXing Li <lixing@loongson.cn>
Change-Id: I8ab88684ba8093f5ab84dec837d10594128ee16b
上级 19c02837
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
static inline bool on_thread_stack(void) static inline bool on_thread_stack(void)
{ {
return !(((unsigned long)(current->stack) ^ current_stack_pointer) & ~(THREAD_SIZE - 1)); return !(((unsigned long)(current->stack) ^ current_stack_pointer()) & ~(THREAD_SIZE - 1));
} }
#endif #endif
...@@ -18,14 +18,19 @@ ...@@ -18,14 +18,19 @@
#endif #endif
/* Use r21 for fast access */ /* Use r21 for fast access */
register unsigned long __my_cpu_offset __asm__("$r21"); static inline unsigned long __kern_my_cpu_offset(void)
{
register unsigned long off __asm__("$r21");
return off;
}
#define __my_cpu_offset __kern_my_cpu_offset()
static inline void set_my_cpu_offset(unsigned long off) static inline void set_my_cpu_offset(unsigned long off)
{ {
__my_cpu_offset = off; asm volatile("move $r21, %0"::"r"(off));
csr_write64(off, PERCPU_BASE_KS); csr_write64(off, PERCPU_BASE_KS);
} }
#define __my_cpu_offset __my_cpu_offset
#define PERCPU_OP(op, asm_op, c_op) \ #define PERCPU_OP(op, asm_op, c_op) \
static inline unsigned long __percpu_##op(void *ptr, \ static inline unsigned long __percpu_##op(void *ptr, \
......
...@@ -44,14 +44,19 @@ struct thread_info { ...@@ -44,14 +44,19 @@ struct thread_info {
} }
/* How to get the thread information struct from C. */ /* How to get the thread information struct from C. */
register struct thread_info *__current_thread_info __asm__("$tp");
static inline struct thread_info *current_thread_info(void) static inline struct thread_info *current_thread_info(void)
{ {
register struct thread_info *__current_thread_info __asm__("$tp");
return __current_thread_info; return __current_thread_info;
} }
register unsigned long current_stack_pointer __asm__("$sp"); static inline unsigned long current_stack_pointer(void)
{
register unsigned long __current_stack_pointer __asm__("$sp");
return __current_stack_pointer;
}
#endif /* !__ASSEMBLY__ */ #endif /* !__ASSEMBLY__ */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册