162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Copyright 2016, Cyril Bur, IBM Corp.
462306a36Sopenharmony_ci */
562306a36Sopenharmony_ci
662306a36Sopenharmony_ci#ifndef _SELFTESTS_POWERPC_FPU_ASM_H
762306a36Sopenharmony_ci#define _SELFTESTS_POWERPC_FPU_ASM_H
862306a36Sopenharmony_ci#include "basic_asm.h"
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci#define PUSH_FPU(stack_size) \
1162306a36Sopenharmony_ci	stfd	f31,(stack_size + STACK_FRAME_MIN_SIZE)(%r1); \
1262306a36Sopenharmony_ci	stfd	f30,(stack_size + STACK_FRAME_MIN_SIZE - 8)(%r1); \
1362306a36Sopenharmony_ci	stfd	f29,(stack_size + STACK_FRAME_MIN_SIZE - 16)(%r1); \
1462306a36Sopenharmony_ci	stfd	f28,(stack_size + STACK_FRAME_MIN_SIZE - 24)(%r1); \
1562306a36Sopenharmony_ci	stfd	f27,(stack_size + STACK_FRAME_MIN_SIZE - 32)(%r1); \
1662306a36Sopenharmony_ci	stfd	f26,(stack_size + STACK_FRAME_MIN_SIZE - 40)(%r1); \
1762306a36Sopenharmony_ci	stfd	f25,(stack_size + STACK_FRAME_MIN_SIZE - 48)(%r1); \
1862306a36Sopenharmony_ci	stfd	f24,(stack_size + STACK_FRAME_MIN_SIZE - 56)(%r1); \
1962306a36Sopenharmony_ci	stfd	f23,(stack_size + STACK_FRAME_MIN_SIZE - 64)(%r1); \
2062306a36Sopenharmony_ci	stfd	f22,(stack_size + STACK_FRAME_MIN_SIZE - 72)(%r1); \
2162306a36Sopenharmony_ci	stfd	f21,(stack_size + STACK_FRAME_MIN_SIZE - 80)(%r1); \
2262306a36Sopenharmony_ci	stfd	f20,(stack_size + STACK_FRAME_MIN_SIZE - 88)(%r1); \
2362306a36Sopenharmony_ci	stfd	f19,(stack_size + STACK_FRAME_MIN_SIZE - 96)(%r1); \
2462306a36Sopenharmony_ci	stfd	f18,(stack_size + STACK_FRAME_MIN_SIZE - 104)(%r1); \
2562306a36Sopenharmony_ci	stfd	f17,(stack_size + STACK_FRAME_MIN_SIZE - 112)(%r1); \
2662306a36Sopenharmony_ci	stfd	f16,(stack_size + STACK_FRAME_MIN_SIZE - 120)(%r1); \
2762306a36Sopenharmony_ci	stfd	f15,(stack_size + STACK_FRAME_MIN_SIZE - 128)(%r1); \
2862306a36Sopenharmony_ci	stfd	f14,(stack_size + STACK_FRAME_MIN_SIZE - 136)(%r1);
2962306a36Sopenharmony_ci
3062306a36Sopenharmony_ci#define POP_FPU(stack_size) \
3162306a36Sopenharmony_ci	lfd	f31,(stack_size + STACK_FRAME_MIN_SIZE)(%r1); \
3262306a36Sopenharmony_ci	lfd	f30,(stack_size + STACK_FRAME_MIN_SIZE - 8)(%r1); \
3362306a36Sopenharmony_ci	lfd	f29,(stack_size + STACK_FRAME_MIN_SIZE - 16)(%r1); \
3462306a36Sopenharmony_ci	lfd	f28,(stack_size + STACK_FRAME_MIN_SIZE - 24)(%r1); \
3562306a36Sopenharmony_ci	lfd	f27,(stack_size + STACK_FRAME_MIN_SIZE - 32)(%r1); \
3662306a36Sopenharmony_ci	lfd	f26,(stack_size + STACK_FRAME_MIN_SIZE - 40)(%r1); \
3762306a36Sopenharmony_ci	lfd	f25,(stack_size + STACK_FRAME_MIN_SIZE - 48)(%r1); \
3862306a36Sopenharmony_ci	lfd	f24,(stack_size + STACK_FRAME_MIN_SIZE - 56)(%r1); \
3962306a36Sopenharmony_ci	lfd	f23,(stack_size + STACK_FRAME_MIN_SIZE - 64)(%r1); \
4062306a36Sopenharmony_ci	lfd	f22,(stack_size + STACK_FRAME_MIN_SIZE - 72)(%r1); \
4162306a36Sopenharmony_ci	lfd	f21,(stack_size + STACK_FRAME_MIN_SIZE - 80)(%r1); \
4262306a36Sopenharmony_ci	lfd	f20,(stack_size + STACK_FRAME_MIN_SIZE - 88)(%r1); \
4362306a36Sopenharmony_ci	lfd	f19,(stack_size + STACK_FRAME_MIN_SIZE - 96)(%r1); \
4462306a36Sopenharmony_ci	lfd	f18,(stack_size + STACK_FRAME_MIN_SIZE - 104)(%r1); \
4562306a36Sopenharmony_ci	lfd	f17,(stack_size + STACK_FRAME_MIN_SIZE - 112)(%r1); \
4662306a36Sopenharmony_ci	lfd	f16,(stack_size + STACK_FRAME_MIN_SIZE - 120)(%r1); \
4762306a36Sopenharmony_ci	lfd	f15,(stack_size + STACK_FRAME_MIN_SIZE - 128)(%r1); \
4862306a36Sopenharmony_ci	lfd	f14,(stack_size + STACK_FRAME_MIN_SIZE - 136)(%r1);
4962306a36Sopenharmony_ci
5062306a36Sopenharmony_ci/*
5162306a36Sopenharmony_ci * Careful calling this, it will 'clobber' fpu (by design)
5262306a36Sopenharmony_ci * Don't call this from C
5362306a36Sopenharmony_ci */
5462306a36Sopenharmony_ciFUNC_START(load_fpu)
5562306a36Sopenharmony_ci	lfd	f14,0(r3)
5662306a36Sopenharmony_ci	lfd	f15,8(r3)
5762306a36Sopenharmony_ci	lfd	f16,16(r3)
5862306a36Sopenharmony_ci	lfd	f17,24(r3)
5962306a36Sopenharmony_ci	lfd	f18,32(r3)
6062306a36Sopenharmony_ci	lfd	f19,40(r3)
6162306a36Sopenharmony_ci	lfd	f20,48(r3)
6262306a36Sopenharmony_ci	lfd	f21,56(r3)
6362306a36Sopenharmony_ci	lfd	f22,64(r3)
6462306a36Sopenharmony_ci	lfd	f23,72(r3)
6562306a36Sopenharmony_ci	lfd	f24,80(r3)
6662306a36Sopenharmony_ci	lfd	f25,88(r3)
6762306a36Sopenharmony_ci	lfd	f26,96(r3)
6862306a36Sopenharmony_ci	lfd	f27,104(r3)
6962306a36Sopenharmony_ci	lfd	f28,112(r3)
7062306a36Sopenharmony_ci	lfd	f29,120(r3)
7162306a36Sopenharmony_ci	lfd	f30,128(r3)
7262306a36Sopenharmony_ci	lfd	f31,136(r3)
7362306a36Sopenharmony_ci	blr
7462306a36Sopenharmony_ciFUNC_END(load_fpu)
7562306a36Sopenharmony_ci
7662306a36Sopenharmony_ci#endif /* _SELFTESTS_POWERPC_FPU_ASM_H */
77