xref: /linux/tools/testing/selftests/powerpc/include/gpr_asm.h (revision 15ec3997aa3bffc461f7b47ca9365d4b0323c671)
1*15ec3997SSimon Guo /*
2*15ec3997SSimon Guo  * Copyright 2016, Cyril Bur, IBM Corp.
3*15ec3997SSimon Guo  *
4*15ec3997SSimon Guo  * This program is free software; you can redistribute it and/or
5*15ec3997SSimon Guo  * modify it under the terms of the GNU General Public License
6*15ec3997SSimon Guo  * as published by the Free Software Foundation; either version
7*15ec3997SSimon Guo  * 2 of the License, or (at your option) any later version.
8*15ec3997SSimon Guo  */
9*15ec3997SSimon Guo 
10*15ec3997SSimon Guo #ifndef _SELFTESTS_POWERPC_GPR_ASM_H
11*15ec3997SSimon Guo #define _SELFTESTS_POWERPC_GPR_ASM_H
12*15ec3997SSimon Guo 
13*15ec3997SSimon Guo #include "basic_asm.h"
14*15ec3997SSimon Guo 
15*15ec3997SSimon Guo #define __PUSH_NVREGS(top_pos); \
16*15ec3997SSimon Guo 	std r31,(top_pos)(%r1); \
17*15ec3997SSimon Guo 	std r30,(top_pos - 8)(%r1); \
18*15ec3997SSimon Guo 	std r29,(top_pos - 16)(%r1); \
19*15ec3997SSimon Guo 	std r28,(top_pos - 24)(%r1); \
20*15ec3997SSimon Guo 	std r27,(top_pos - 32)(%r1); \
21*15ec3997SSimon Guo 	std r26,(top_pos - 40)(%r1); \
22*15ec3997SSimon Guo 	std r25,(top_pos - 48)(%r1); \
23*15ec3997SSimon Guo 	std r24,(top_pos - 56)(%r1); \
24*15ec3997SSimon Guo 	std r23,(top_pos - 64)(%r1); \
25*15ec3997SSimon Guo 	std r22,(top_pos - 72)(%r1); \
26*15ec3997SSimon Guo 	std r21,(top_pos - 80)(%r1); \
27*15ec3997SSimon Guo 	std r20,(top_pos - 88)(%r1); \
28*15ec3997SSimon Guo 	std r19,(top_pos - 96)(%r1); \
29*15ec3997SSimon Guo 	std r18,(top_pos - 104)(%r1); \
30*15ec3997SSimon Guo 	std r17,(top_pos - 112)(%r1); \
31*15ec3997SSimon Guo 	std r16,(top_pos - 120)(%r1); \
32*15ec3997SSimon Guo 	std r15,(top_pos - 128)(%r1); \
33*15ec3997SSimon Guo 	std r14,(top_pos - 136)(%r1)
34*15ec3997SSimon Guo 
35*15ec3997SSimon Guo #define __POP_NVREGS(top_pos); \
36*15ec3997SSimon Guo 	ld r31,(top_pos)(%r1); \
37*15ec3997SSimon Guo 	ld r30,(top_pos - 8)(%r1); \
38*15ec3997SSimon Guo 	ld r29,(top_pos - 16)(%r1); \
39*15ec3997SSimon Guo 	ld r28,(top_pos - 24)(%r1); \
40*15ec3997SSimon Guo 	ld r27,(top_pos - 32)(%r1); \
41*15ec3997SSimon Guo 	ld r26,(top_pos - 40)(%r1); \
42*15ec3997SSimon Guo 	ld r25,(top_pos - 48)(%r1); \
43*15ec3997SSimon Guo 	ld r24,(top_pos - 56)(%r1); \
44*15ec3997SSimon Guo 	ld r23,(top_pos - 64)(%r1); \
45*15ec3997SSimon Guo 	ld r22,(top_pos - 72)(%r1); \
46*15ec3997SSimon Guo 	ld r21,(top_pos - 80)(%r1); \
47*15ec3997SSimon Guo 	ld r20,(top_pos - 88)(%r1); \
48*15ec3997SSimon Guo 	ld r19,(top_pos - 96)(%r1); \
49*15ec3997SSimon Guo 	ld r18,(top_pos - 104)(%r1); \
50*15ec3997SSimon Guo 	ld r17,(top_pos - 112)(%r1); \
51*15ec3997SSimon Guo 	ld r16,(top_pos - 120)(%r1); \
52*15ec3997SSimon Guo 	ld r15,(top_pos - 128)(%r1); \
53*15ec3997SSimon Guo 	ld r14,(top_pos - 136)(%r1)
54*15ec3997SSimon Guo 
55*15ec3997SSimon Guo #define PUSH_NVREGS(stack_size) \
56*15ec3997SSimon Guo 	__PUSH_NVREGS(stack_size + STACK_FRAME_MIN_SIZE)
57*15ec3997SSimon Guo 
58*15ec3997SSimon Guo /* 18 NV FPU REGS */
59*15ec3997SSimon Guo #define PUSH_NVREGS_BELOW_FPU(stack_size) \
60*15ec3997SSimon Guo 	__PUSH_NVREGS(stack_size + STACK_FRAME_MIN_SIZE - (18 * 8))
61*15ec3997SSimon Guo 
62*15ec3997SSimon Guo #define POP_NVREGS(stack_size) \
63*15ec3997SSimon Guo 	__POP_NVREGS(stack_size + STACK_FRAME_MIN_SIZE)
64*15ec3997SSimon Guo 
65*15ec3997SSimon Guo /* 18 NV FPU REGS */
66*15ec3997SSimon Guo #define POP_NVREGS_BELOW_FPU(stack_size) \
67*15ec3997SSimon Guo 	__POP_NVREGS(stack_size + STACK_FRAME_MIN_SIZE - (18 * 8))
68*15ec3997SSimon Guo 
69*15ec3997SSimon Guo /*
70*15ec3997SSimon Guo  * Careful calling this, it will 'clobber' NVGPRs (by design)
71*15ec3997SSimon Guo  * Don't call this from C
72*15ec3997SSimon Guo  */
73*15ec3997SSimon Guo FUNC_START(load_gpr)
74*15ec3997SSimon Guo 	ld	r14,0(r3)
75*15ec3997SSimon Guo 	ld	r15,8(r3)
76*15ec3997SSimon Guo 	ld	r16,16(r3)
77*15ec3997SSimon Guo 	ld	r17,24(r3)
78*15ec3997SSimon Guo 	ld	r18,32(r3)
79*15ec3997SSimon Guo 	ld	r19,40(r3)
80*15ec3997SSimon Guo 	ld	r20,48(r3)
81*15ec3997SSimon Guo 	ld	r21,56(r3)
82*15ec3997SSimon Guo 	ld	r22,64(r3)
83*15ec3997SSimon Guo 	ld	r23,72(r3)
84*15ec3997SSimon Guo 	ld	r24,80(r3)
85*15ec3997SSimon Guo 	ld	r25,88(r3)
86*15ec3997SSimon Guo 	ld	r26,96(r3)
87*15ec3997SSimon Guo 	ld	r27,104(r3)
88*15ec3997SSimon Guo 	ld	r28,112(r3)
89*15ec3997SSimon Guo 	ld	r29,120(r3)
90*15ec3997SSimon Guo 	ld	r30,128(r3)
91*15ec3997SSimon Guo 	ld	r31,136(r3)
92*15ec3997SSimon Guo 	blr
93*15ec3997SSimon Guo FUNC_END(load_gpr)
94*15ec3997SSimon Guo 
95*15ec3997SSimon Guo 
96*15ec3997SSimon Guo #endif /* _SELFTESTS_POWERPC_GPR_ASM_H */
97