18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright 2016, Cyril Bur, IBM Corp.
48c2ecf20Sopenharmony_ci */
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci#ifndef _SELFTESTS_POWERPC_FPU_ASM_H
78c2ecf20Sopenharmony_ci#define _SELFTESTS_POWERPC_FPU_ASM_H
88c2ecf20Sopenharmony_ci#include "basic_asm.h"
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#define PUSH_FPU(stack_size) \
118c2ecf20Sopenharmony_ci	stfd	f31,(stack_size + STACK_FRAME_MIN_SIZE)(%r1); \
128c2ecf20Sopenharmony_ci	stfd	f30,(stack_size + STACK_FRAME_MIN_SIZE - 8)(%r1); \
138c2ecf20Sopenharmony_ci	stfd	f29,(stack_size + STACK_FRAME_MIN_SIZE - 16)(%r1); \
148c2ecf20Sopenharmony_ci	stfd	f28,(stack_size + STACK_FRAME_MIN_SIZE - 24)(%r1); \
158c2ecf20Sopenharmony_ci	stfd	f27,(stack_size + STACK_FRAME_MIN_SIZE - 32)(%r1); \
168c2ecf20Sopenharmony_ci	stfd	f26,(stack_size + STACK_FRAME_MIN_SIZE - 40)(%r1); \
178c2ecf20Sopenharmony_ci	stfd	f25,(stack_size + STACK_FRAME_MIN_SIZE - 48)(%r1); \
188c2ecf20Sopenharmony_ci	stfd	f24,(stack_size + STACK_FRAME_MIN_SIZE - 56)(%r1); \
198c2ecf20Sopenharmony_ci	stfd	f23,(stack_size + STACK_FRAME_MIN_SIZE - 64)(%r1); \
208c2ecf20Sopenharmony_ci	stfd	f22,(stack_size + STACK_FRAME_MIN_SIZE - 72)(%r1); \
218c2ecf20Sopenharmony_ci	stfd	f21,(stack_size + STACK_FRAME_MIN_SIZE - 80)(%r1); \
228c2ecf20Sopenharmony_ci	stfd	f20,(stack_size + STACK_FRAME_MIN_SIZE - 88)(%r1); \
238c2ecf20Sopenharmony_ci	stfd	f19,(stack_size + STACK_FRAME_MIN_SIZE - 96)(%r1); \
248c2ecf20Sopenharmony_ci	stfd	f18,(stack_size + STACK_FRAME_MIN_SIZE - 104)(%r1); \
258c2ecf20Sopenharmony_ci	stfd	f17,(stack_size + STACK_FRAME_MIN_SIZE - 112)(%r1); \
268c2ecf20Sopenharmony_ci	stfd	f16,(stack_size + STACK_FRAME_MIN_SIZE - 120)(%r1); \
278c2ecf20Sopenharmony_ci	stfd	f15,(stack_size + STACK_FRAME_MIN_SIZE - 128)(%r1); \
288c2ecf20Sopenharmony_ci	stfd	f14,(stack_size + STACK_FRAME_MIN_SIZE - 136)(%r1);
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci#define POP_FPU(stack_size) \
318c2ecf20Sopenharmony_ci	lfd	f31,(stack_size + STACK_FRAME_MIN_SIZE)(%r1); \
328c2ecf20Sopenharmony_ci	lfd	f30,(stack_size + STACK_FRAME_MIN_SIZE - 8)(%r1); \
338c2ecf20Sopenharmony_ci	lfd	f29,(stack_size + STACK_FRAME_MIN_SIZE - 16)(%r1); \
348c2ecf20Sopenharmony_ci	lfd	f28,(stack_size + STACK_FRAME_MIN_SIZE - 24)(%r1); \
358c2ecf20Sopenharmony_ci	lfd	f27,(stack_size + STACK_FRAME_MIN_SIZE - 32)(%r1); \
368c2ecf20Sopenharmony_ci	lfd	f26,(stack_size + STACK_FRAME_MIN_SIZE - 40)(%r1); \
378c2ecf20Sopenharmony_ci	lfd	f25,(stack_size + STACK_FRAME_MIN_SIZE - 48)(%r1); \
388c2ecf20Sopenharmony_ci	lfd	f24,(stack_size + STACK_FRAME_MIN_SIZE - 56)(%r1); \
398c2ecf20Sopenharmony_ci	lfd	f23,(stack_size + STACK_FRAME_MIN_SIZE - 64)(%r1); \
408c2ecf20Sopenharmony_ci	lfd	f22,(stack_size + STACK_FRAME_MIN_SIZE - 72)(%r1); \
418c2ecf20Sopenharmony_ci	lfd	f21,(stack_size + STACK_FRAME_MIN_SIZE - 80)(%r1); \
428c2ecf20Sopenharmony_ci	lfd	f20,(stack_size + STACK_FRAME_MIN_SIZE - 88)(%r1); \
438c2ecf20Sopenharmony_ci	lfd	f19,(stack_size + STACK_FRAME_MIN_SIZE - 96)(%r1); \
448c2ecf20Sopenharmony_ci	lfd	f18,(stack_size + STACK_FRAME_MIN_SIZE - 104)(%r1); \
458c2ecf20Sopenharmony_ci	lfd	f17,(stack_size + STACK_FRAME_MIN_SIZE - 112)(%r1); \
468c2ecf20Sopenharmony_ci	lfd	f16,(stack_size + STACK_FRAME_MIN_SIZE - 120)(%r1); \
478c2ecf20Sopenharmony_ci	lfd	f15,(stack_size + STACK_FRAME_MIN_SIZE - 128)(%r1); \
488c2ecf20Sopenharmony_ci	lfd	f14,(stack_size + STACK_FRAME_MIN_SIZE - 136)(%r1);
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci/*
518c2ecf20Sopenharmony_ci * Careful calling this, it will 'clobber' fpu (by design)
528c2ecf20Sopenharmony_ci * Don't call this from C
538c2ecf20Sopenharmony_ci */
548c2ecf20Sopenharmony_ciFUNC_START(load_fpu)
558c2ecf20Sopenharmony_ci	lfd	f14,0(r3)
568c2ecf20Sopenharmony_ci	lfd	f15,8(r3)
578c2ecf20Sopenharmony_ci	lfd	f16,16(r3)
588c2ecf20Sopenharmony_ci	lfd	f17,24(r3)
598c2ecf20Sopenharmony_ci	lfd	f18,32(r3)
608c2ecf20Sopenharmony_ci	lfd	f19,40(r3)
618c2ecf20Sopenharmony_ci	lfd	f20,48(r3)
628c2ecf20Sopenharmony_ci	lfd	f21,56(r3)
638c2ecf20Sopenharmony_ci	lfd	f22,64(r3)
648c2ecf20Sopenharmony_ci	lfd	f23,72(r3)
658c2ecf20Sopenharmony_ci	lfd	f24,80(r3)
668c2ecf20Sopenharmony_ci	lfd	f25,88(r3)
678c2ecf20Sopenharmony_ci	lfd	f26,96(r3)
688c2ecf20Sopenharmony_ci	lfd	f27,104(r3)
698c2ecf20Sopenharmony_ci	lfd	f28,112(r3)
708c2ecf20Sopenharmony_ci	lfd	f29,120(r3)
718c2ecf20Sopenharmony_ci	lfd	f30,128(r3)
728c2ecf20Sopenharmony_ci	lfd	f31,136(r3)
738c2ecf20Sopenharmony_ci	blr
748c2ecf20Sopenharmony_ciFUNC_END(load_fpu)
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ci#endif /* _SELFTESTS_POWERPC_FPU_ASM_H */
77