MIPS: MSA: Update helpers to use new asm macros
Update MSA control register access helpers to use the new helpers for parsing register names and creating custom assembly macro instructions. This allows the move via $at to be dropped (saving a total of about 20 bytes of kernel code). Note, this does not alter the equivalent code in .S files, which still uses the $at trick. Signed-off-by: James Hogan <jhogan@kernel.org> Cc: Ralf Baechle <ralf@linux-mips.org> Cc: Paul Burton <paul.burton@mips.com> Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/17776/
This commit is contained in:
Родитель
abbd52fd6b
Коммит
93738d4893
|
@ -160,7 +160,23 @@ static inline void init_msa_upper(void)
|
|||
_init_msa_upper();
|
||||
}
|
||||
|
||||
#ifdef TOOLCHAIN_SUPPORTS_MSA
|
||||
#ifndef TOOLCHAIN_SUPPORTS_MSA
|
||||
/*
|
||||
* Define assembler macros using .word for the c[ft]cmsa instructions in order
|
||||
* to allow compilation with toolchains that do not support MSA. Once all
|
||||
* toolchains in use support MSA these can be removed.
|
||||
*/
|
||||
_ASM_MACRO_2R(cfcmsa, rd, cs,
|
||||
_ASM_INSN_IF_MIPS(0x787e0019 | __cs << 11 | __rd << 6)
|
||||
_ASM_INSN32_IF_MM(0x587e0016 | __cs << 11 | __rd << 6));
|
||||
_ASM_MACRO_2R(ctcmsa, cd, rs,
|
||||
_ASM_INSN_IF_MIPS(0x783e0019 | __rs << 11 | __cd << 6)
|
||||
_ASM_INSN32_IF_MM(0x583e0016 | __rs << 11 | __cd << 6));
|
||||
#define _ASM_SET_MSA ""
|
||||
#else /* TOOLCHAIN_SUPPORTS_MSA */
|
||||
#define _ASM_SET_MSA ".set\tfp=64\n\t" \
|
||||
".set\tmsa\n\t"
|
||||
#endif
|
||||
|
||||
#define __BUILD_MSA_CTL_REG(name, cs) \
|
||||
static inline unsigned int read_msa_##name(void) \
|
||||
|
@ -168,8 +184,7 @@ static inline unsigned int read_msa_##name(void) \
|
|||
unsigned int reg; \
|
||||
__asm__ __volatile__( \
|
||||
" .set push\n" \
|
||||
" .set fp=64\n" \
|
||||
" .set msa\n" \
|
||||
_ASM_SET_MSA \
|
||||
" cfcmsa %0, $" #cs "\n" \
|
||||
" .set pop\n" \
|
||||
: "=r"(reg)); \
|
||||
|
@ -180,52 +195,12 @@ static inline void write_msa_##name(unsigned int val) \
|
|||
{ \
|
||||
__asm__ __volatile__( \
|
||||
" .set push\n" \
|
||||
" .set fp=64\n" \
|
||||
" .set msa\n" \
|
||||
_ASM_SET_MSA \
|
||||
" ctcmsa $" #cs ", %0\n" \
|
||||
" .set pop\n" \
|
||||
: : "r"(val)); \
|
||||
}
|
||||
|
||||
#else /* !TOOLCHAIN_SUPPORTS_MSA */
|
||||
|
||||
/*
|
||||
* Define functions using .word for the c[ft]cmsa instructions in order to
|
||||
* allow compilation with toolchains that do not support MSA. Once all
|
||||
* toolchains in use support MSA these can be removed.
|
||||
*/
|
||||
|
||||
#define __BUILD_MSA_CTL_REG(name, cs) \
|
||||
static inline unsigned int read_msa_##name(void) \
|
||||
{ \
|
||||
unsigned int reg; \
|
||||
__asm__ __volatile__( \
|
||||
" .set push\n" \
|
||||
" .set noat\n" \
|
||||
" # cfcmsa $1, $%1\n" \
|
||||
_ASM_INSN_IF_MIPS(0x787e0059 | %1 << 11) \
|
||||
_ASM_INSN32_IF_MM(0x587e0056 | %1 << 11) \
|
||||
" move %0, $1\n" \
|
||||
" .set pop\n" \
|
||||
: "=r"(reg) : "i"(cs)); \
|
||||
return reg; \
|
||||
} \
|
||||
\
|
||||
static inline void write_msa_##name(unsigned int val) \
|
||||
{ \
|
||||
__asm__ __volatile__( \
|
||||
" .set push\n" \
|
||||
" .set noat\n" \
|
||||
" move $1, %0\n" \
|
||||
" # ctcmsa $%1, $1\n" \
|
||||
_ASM_INSN_IF_MIPS(0x783e0819 | %1 << 6) \
|
||||
_ASM_INSN32_IF_MM(0x583e0816 | %1 << 6) \
|
||||
" .set pop\n" \
|
||||
: : "r"(val), "i"(cs)); \
|
||||
}
|
||||
|
||||
#endif /* !TOOLCHAIN_SUPPORTS_MSA */
|
||||
|
||||
__BUILD_MSA_CTL_REG(ir, 0)
|
||||
__BUILD_MSA_CTL_REG(csr, 1)
|
||||
__BUILD_MSA_CTL_REG(access, 2)
|
||||
|
|
Загрузка…
Ссылка в новой задаче