aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/include/asm/processor.h
diff options
context:
space:
mode:
authorPaul Burton <paul.burton@imgtec.com>2014-02-13 06:26:41 -0500
committerRalf Baechle <ralf@linux-mips.org>2014-03-26 18:09:09 -0400
commitbbd426f542cb61f2322e15dab4507f2661090c06 (patch)
tree66cc94a921b0342a4a412646d549562a578fc257 /arch/mips/include/asm/processor.h
parent490b004febb3fe9aca7330a729b29fe935be3b31 (diff)
MIPS: Simplify FP context access
This patch replaces the fpureg_t typedef with a "union fpureg" enabling easier access to 32 & 64 bit values. This allows the access macros used in cp1emu.c to be simplified somewhat. It will also make it easier to expand the width of the FP registers as will be done in a future patch in order to support the 128 bit registers introduced with MSA. No behavioural change is intended by this patch. Signed-off-by: Paul Burton <paul.burton@imgtec.com> Reviewed-by: Qais Yousef <qais.yousef@imgtec.com> Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/6532/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/include/asm/processor.h')
-rw-r--r--arch/mips/include/asm/processor.h31
1 files changed, 28 insertions, 3 deletions
diff --git a/arch/mips/include/asm/processor.h b/arch/mips/include/asm/processor.h
index 3605b844ad87..49a61bedf40e 100644
--- a/arch/mips/include/asm/processor.h
+++ b/arch/mips/include/asm/processor.h
@@ -96,8 +96,33 @@ extern unsigned int vced_count, vcei_count;
96 96
97 97
98#define NUM_FPU_REGS 32 98#define NUM_FPU_REGS 32
99#define FPU_REG_WIDTH 64
99 100
100typedef __u64 fpureg_t; 101union fpureg {
102 __u32 val32[FPU_REG_WIDTH / 32];
103 __u64 val64[FPU_REG_WIDTH / 64];
104};
105
106#ifdef CONFIG_CPU_LITTLE_ENDIAN
107# define FPR_IDX(width, idx) (idx)
108#else
109# define FPR_IDX(width, idx) ((FPU_REG_WIDTH / (width)) - 1 - (idx))
110#endif
111
112#define BUILD_FPR_ACCESS(width) \
113static inline u##width get_fpr##width(union fpureg *fpr, unsigned idx) \
114{ \
115 return fpr->val##width[FPR_IDX(width, idx)]; \
116} \
117 \
118static inline void set_fpr##width(union fpureg *fpr, unsigned idx, \
119 u##width val) \
120{ \
121 fpr->val##width[FPR_IDX(width, idx)] = val; \
122}
123
124BUILD_FPR_ACCESS(32)
125BUILD_FPR_ACCESS(64)
101 126
102/* 127/*
103 * It would be nice to add some more fields for emulator statistics, but there 128 * It would be nice to add some more fields for emulator statistics, but there
@@ -107,7 +132,7 @@ typedef __u64 fpureg_t;
107 */ 132 */
108 133
109struct mips_fpu_struct { 134struct mips_fpu_struct {
110 fpureg_t fpr[NUM_FPU_REGS]; 135 union fpureg fpr[NUM_FPU_REGS];
111 unsigned int fcr31; 136 unsigned int fcr31;
112}; 137};
113 138
@@ -284,7 +309,7 @@ struct thread_struct {
284 * Saved FPU/FPU emulator stuff \ 309 * Saved FPU/FPU emulator stuff \
285 */ \ 310 */ \
286 .fpu = { \ 311 .fpu = { \
287 .fpr = {0,}, \ 312 .fpr = {{{0,},},}, \
288 .fcr31 = 0, \ 313 .fcr31 = 0, \
289 }, \ 314 }, \
290 /* \ 315 /* \