xref: /linux/tools/testing/selftests/powerpc/math/fpu_asm.S (revision 01127f1ead4cef75e2b9b309e0ea95418ccd53bd)
1*01127f1eSCyril Bur/*
2*01127f1eSCyril Bur * Copyright 2015, Cyril Bur, IBM Corp.
3*01127f1eSCyril Bur *
4*01127f1eSCyril Bur * This program is free software; you can redistribute it and/or
5*01127f1eSCyril Bur * modify it under the terms of the GNU General Public License
6*01127f1eSCyril Bur * as published by the Free Software Foundation; either version
7*01127f1eSCyril Bur * 2 of the License, or (at your option) any later version.
8*01127f1eSCyril Bur */
9*01127f1eSCyril Bur
10*01127f1eSCyril Bur#include "../basic_asm.h"
11*01127f1eSCyril Bur
12*01127f1eSCyril Bur#define PUSH_FPU(pos) \
13*01127f1eSCyril Bur	stfd	f14,pos(sp); \
14*01127f1eSCyril Bur	stfd	f15,pos+8(sp); \
15*01127f1eSCyril Bur	stfd	f16,pos+16(sp); \
16*01127f1eSCyril Bur	stfd	f17,pos+24(sp); \
17*01127f1eSCyril Bur	stfd	f18,pos+32(sp); \
18*01127f1eSCyril Bur	stfd	f19,pos+40(sp); \
19*01127f1eSCyril Bur	stfd	f20,pos+48(sp); \
20*01127f1eSCyril Bur	stfd	f21,pos+56(sp); \
21*01127f1eSCyril Bur	stfd	f22,pos+64(sp); \
22*01127f1eSCyril Bur	stfd	f23,pos+72(sp); \
23*01127f1eSCyril Bur	stfd	f24,pos+80(sp); \
24*01127f1eSCyril Bur	stfd	f25,pos+88(sp); \
25*01127f1eSCyril Bur	stfd	f26,pos+96(sp); \
26*01127f1eSCyril Bur	stfd	f27,pos+104(sp); \
27*01127f1eSCyril Bur	stfd	f28,pos+112(sp); \
28*01127f1eSCyril Bur	stfd	f29,pos+120(sp); \
29*01127f1eSCyril Bur	stfd	f30,pos+128(sp); \
30*01127f1eSCyril Bur	stfd	f31,pos+136(sp);
31*01127f1eSCyril Bur
32*01127f1eSCyril Bur#define POP_FPU(pos) \
33*01127f1eSCyril Bur	lfd	f14,pos(sp); \
34*01127f1eSCyril Bur	lfd	f15,pos+8(sp); \
35*01127f1eSCyril Bur	lfd	f16,pos+16(sp); \
36*01127f1eSCyril Bur	lfd	f17,pos+24(sp); \
37*01127f1eSCyril Bur	lfd	f18,pos+32(sp); \
38*01127f1eSCyril Bur	lfd	f19,pos+40(sp); \
39*01127f1eSCyril Bur	lfd	f20,pos+48(sp); \
40*01127f1eSCyril Bur	lfd	f21,pos+56(sp); \
41*01127f1eSCyril Bur	lfd	f22,pos+64(sp); \
42*01127f1eSCyril Bur	lfd	f23,pos+72(sp); \
43*01127f1eSCyril Bur	lfd	f24,pos+80(sp); \
44*01127f1eSCyril Bur	lfd	f25,pos+88(sp); \
45*01127f1eSCyril Bur	lfd	f26,pos+96(sp); \
46*01127f1eSCyril Bur	lfd	f27,pos+104(sp); \
47*01127f1eSCyril Bur	lfd	f28,pos+112(sp); \
48*01127f1eSCyril Bur	lfd	f29,pos+120(sp); \
49*01127f1eSCyril Bur	lfd	f30,pos+128(sp); \
50*01127f1eSCyril Bur	lfd	f31,pos+136(sp);
51*01127f1eSCyril Bur
52*01127f1eSCyril Bur# Careful calling this, it will 'clobber' fpu (by design)
53*01127f1eSCyril Bur# Don't call this from C
54*01127f1eSCyril BurFUNC_START(load_fpu)
55*01127f1eSCyril Bur	lfd	f14,0(r3)
56*01127f1eSCyril Bur	lfd	f15,8(r3)
57*01127f1eSCyril Bur	lfd	f16,16(r3)
58*01127f1eSCyril Bur	lfd	f17,24(r3)
59*01127f1eSCyril Bur	lfd	f18,32(r3)
60*01127f1eSCyril Bur	lfd	f19,40(r3)
61*01127f1eSCyril Bur	lfd	f20,48(r3)
62*01127f1eSCyril Bur	lfd	f21,56(r3)
63*01127f1eSCyril Bur	lfd	f22,64(r3)
64*01127f1eSCyril Bur	lfd	f23,72(r3)
65*01127f1eSCyril Bur	lfd	f24,80(r3)
66*01127f1eSCyril Bur	lfd	f25,88(r3)
67*01127f1eSCyril Bur	lfd	f26,96(r3)
68*01127f1eSCyril Bur	lfd	f27,104(r3)
69*01127f1eSCyril Bur	lfd	f28,112(r3)
70*01127f1eSCyril Bur	lfd	f29,120(r3)
71*01127f1eSCyril Bur	lfd	f30,128(r3)
72*01127f1eSCyril Bur	lfd	f31,136(r3)
73*01127f1eSCyril Bur	blr
74*01127f1eSCyril BurFUNC_END(load_fpu)
75*01127f1eSCyril Bur
76*01127f1eSCyril BurFUNC_START(check_fpu)
77*01127f1eSCyril Bur	mr r4,r3
78*01127f1eSCyril Bur	li	r3,1 # assume a bad result
79*01127f1eSCyril Bur	lfd	f0,0(r4)
80*01127f1eSCyril Bur	fcmpu	cr1,f0,f14
81*01127f1eSCyril Bur	bne	cr1,1f
82*01127f1eSCyril Bur	lfd	f0,8(r4)
83*01127f1eSCyril Bur	fcmpu	cr1,f0,f15
84*01127f1eSCyril Bur	bne	cr1,1f
85*01127f1eSCyril Bur	lfd	f0,16(r4)
86*01127f1eSCyril Bur	fcmpu	cr1,f0,f16
87*01127f1eSCyril Bur	bne	cr1,1f
88*01127f1eSCyril Bur	lfd	f0,24(r4)
89*01127f1eSCyril Bur	fcmpu	cr1,f0,f17
90*01127f1eSCyril Bur	bne	cr1,1f
91*01127f1eSCyril Bur	lfd	f0,32(r4)
92*01127f1eSCyril Bur	fcmpu	cr1,f0,f18
93*01127f1eSCyril Bur	bne	cr1,1f
94*01127f1eSCyril Bur	lfd	f0,40(r4)
95*01127f1eSCyril Bur	fcmpu	cr1,f0,f19
96*01127f1eSCyril Bur	bne	cr1,1f
97*01127f1eSCyril Bur	lfd	f0,48(r4)
98*01127f1eSCyril Bur	fcmpu	cr1,f0,f20
99*01127f1eSCyril Bur	bne	cr1,1f
100*01127f1eSCyril Bur	lfd	f0,56(r4)
101*01127f1eSCyril Bur	fcmpu	cr1,f0,f21
102*01127f1eSCyril Bur	bne	cr1,1f
103*01127f1eSCyril Bur	lfd	f0,64(r4)
104*01127f1eSCyril Bur	fcmpu	cr1,f0,f22
105*01127f1eSCyril Bur	bne	cr1,1f
106*01127f1eSCyril Bur	lfd	f0,72(r4)
107*01127f1eSCyril Bur	fcmpu	cr1,f0,f23
108*01127f1eSCyril Bur	bne	cr1,1f
109*01127f1eSCyril Bur	lfd	f0,80(r4)
110*01127f1eSCyril Bur	fcmpu	cr1,f0,f24
111*01127f1eSCyril Bur	bne	cr1,1f
112*01127f1eSCyril Bur	lfd	f0,88(r4)
113*01127f1eSCyril Bur	fcmpu	cr1,f0,f25
114*01127f1eSCyril Bur	bne	cr1,1f
115*01127f1eSCyril Bur	lfd	f0,96(r4)
116*01127f1eSCyril Bur	fcmpu	cr1,f0,f26
117*01127f1eSCyril Bur	bne	cr1,1f
118*01127f1eSCyril Bur	lfd	f0,104(r4)
119*01127f1eSCyril Bur	fcmpu	cr1,f0,f27
120*01127f1eSCyril Bur	bne	cr1,1f
121*01127f1eSCyril Bur	lfd	f0,112(r4)
122*01127f1eSCyril Bur	fcmpu	cr1,f0,f28
123*01127f1eSCyril Bur	bne	cr1,1f
124*01127f1eSCyril Bur	lfd	f0,120(r4)
125*01127f1eSCyril Bur	fcmpu	cr1,f0,f29
126*01127f1eSCyril Bur	bne	cr1,1f
127*01127f1eSCyril Bur	lfd	f0,128(r4)
128*01127f1eSCyril Bur	fcmpu	cr1,f0,f30
129*01127f1eSCyril Bur	bne	cr1,1f
130*01127f1eSCyril Bur	lfd	f0,136(r4)
131*01127f1eSCyril Bur	fcmpu	cr1,f0,f31
132*01127f1eSCyril Bur	bne	cr1,1f
133*01127f1eSCyril Bur	li	r3,0 # Success!!!
134*01127f1eSCyril Bur1:	blr
135*01127f1eSCyril Bur
136*01127f1eSCyril BurFUNC_START(test_fpu)
137*01127f1eSCyril Bur	# r3 holds pointer to where to put the result of fork
138*01127f1eSCyril Bur	# r4 holds pointer to the pid
139*01127f1eSCyril Bur	# f14-f31 are non volatiles
140*01127f1eSCyril Bur	PUSH_BASIC_STACK(256)
141*01127f1eSCyril Bur	std	r3,STACK_FRAME_PARAM(0)(sp) # Address of darray
142*01127f1eSCyril Bur	std r4,STACK_FRAME_PARAM(1)(sp) # Address of pid
143*01127f1eSCyril Bur	PUSH_FPU(STACK_FRAME_LOCAL(2,0))
144*01127f1eSCyril Bur
145*01127f1eSCyril Bur	bl load_fpu
146*01127f1eSCyril Bur	nop
147*01127f1eSCyril Bur	li	r0,__NR_fork
148*01127f1eSCyril Bur	sc
149*01127f1eSCyril Bur
150*01127f1eSCyril Bur	# pass the result of the fork to the caller
151*01127f1eSCyril Bur	ld	r9,STACK_FRAME_PARAM(1)(sp)
152*01127f1eSCyril Bur	std	r3,0(r9)
153*01127f1eSCyril Bur
154*01127f1eSCyril Bur	ld r3,STACK_FRAME_PARAM(0)(sp)
155*01127f1eSCyril Bur	bl check_fpu
156*01127f1eSCyril Bur	nop
157*01127f1eSCyril Bur
158*01127f1eSCyril Bur	POP_FPU(STACK_FRAME_LOCAL(2,0))
159*01127f1eSCyril Bur	POP_BASIC_STACK(256)
160*01127f1eSCyril Bur	blr
161*01127f1eSCyril BurFUNC_END(test_fpu)
162