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_GPR_ASM_H
78c2ecf20Sopenharmony_ci#define _SELFTESTS_POWERPC_GPR_ASM_H
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#include "basic_asm.h"
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#define __PUSH_NVREGS(top_pos); \
128c2ecf20Sopenharmony_ci	std r31,(top_pos)(%r1); \
138c2ecf20Sopenharmony_ci	std r30,(top_pos - 8)(%r1); \
148c2ecf20Sopenharmony_ci	std r29,(top_pos - 16)(%r1); \
158c2ecf20Sopenharmony_ci	std r28,(top_pos - 24)(%r1); \
168c2ecf20Sopenharmony_ci	std r27,(top_pos - 32)(%r1); \
178c2ecf20Sopenharmony_ci	std r26,(top_pos - 40)(%r1); \
188c2ecf20Sopenharmony_ci	std r25,(top_pos - 48)(%r1); \
198c2ecf20Sopenharmony_ci	std r24,(top_pos - 56)(%r1); \
208c2ecf20Sopenharmony_ci	std r23,(top_pos - 64)(%r1); \
218c2ecf20Sopenharmony_ci	std r22,(top_pos - 72)(%r1); \
228c2ecf20Sopenharmony_ci	std r21,(top_pos - 80)(%r1); \
238c2ecf20Sopenharmony_ci	std r20,(top_pos - 88)(%r1); \
248c2ecf20Sopenharmony_ci	std r19,(top_pos - 96)(%r1); \
258c2ecf20Sopenharmony_ci	std r18,(top_pos - 104)(%r1); \
268c2ecf20Sopenharmony_ci	std r17,(top_pos - 112)(%r1); \
278c2ecf20Sopenharmony_ci	std r16,(top_pos - 120)(%r1); \
288c2ecf20Sopenharmony_ci	std r15,(top_pos - 128)(%r1); \
298c2ecf20Sopenharmony_ci	std r14,(top_pos - 136)(%r1)
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ci#define __POP_NVREGS(top_pos); \
328c2ecf20Sopenharmony_ci	ld r31,(top_pos)(%r1); \
338c2ecf20Sopenharmony_ci	ld r30,(top_pos - 8)(%r1); \
348c2ecf20Sopenharmony_ci	ld r29,(top_pos - 16)(%r1); \
358c2ecf20Sopenharmony_ci	ld r28,(top_pos - 24)(%r1); \
368c2ecf20Sopenharmony_ci	ld r27,(top_pos - 32)(%r1); \
378c2ecf20Sopenharmony_ci	ld r26,(top_pos - 40)(%r1); \
388c2ecf20Sopenharmony_ci	ld r25,(top_pos - 48)(%r1); \
398c2ecf20Sopenharmony_ci	ld r24,(top_pos - 56)(%r1); \
408c2ecf20Sopenharmony_ci	ld r23,(top_pos - 64)(%r1); \
418c2ecf20Sopenharmony_ci	ld r22,(top_pos - 72)(%r1); \
428c2ecf20Sopenharmony_ci	ld r21,(top_pos - 80)(%r1); \
438c2ecf20Sopenharmony_ci	ld r20,(top_pos - 88)(%r1); \
448c2ecf20Sopenharmony_ci	ld r19,(top_pos - 96)(%r1); \
458c2ecf20Sopenharmony_ci	ld r18,(top_pos - 104)(%r1); \
468c2ecf20Sopenharmony_ci	ld r17,(top_pos - 112)(%r1); \
478c2ecf20Sopenharmony_ci	ld r16,(top_pos - 120)(%r1); \
488c2ecf20Sopenharmony_ci	ld r15,(top_pos - 128)(%r1); \
498c2ecf20Sopenharmony_ci	ld r14,(top_pos - 136)(%r1)
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci#define PUSH_NVREGS(stack_size) \
528c2ecf20Sopenharmony_ci	__PUSH_NVREGS(stack_size + STACK_FRAME_MIN_SIZE)
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci/* 18 NV FPU REGS */
558c2ecf20Sopenharmony_ci#define PUSH_NVREGS_BELOW_FPU(stack_size) \
568c2ecf20Sopenharmony_ci	__PUSH_NVREGS(stack_size + STACK_FRAME_MIN_SIZE - (18 * 8))
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ci#define POP_NVREGS(stack_size) \
598c2ecf20Sopenharmony_ci	__POP_NVREGS(stack_size + STACK_FRAME_MIN_SIZE)
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci/* 18 NV FPU REGS */
628c2ecf20Sopenharmony_ci#define POP_NVREGS_BELOW_FPU(stack_size) \
638c2ecf20Sopenharmony_ci	__POP_NVREGS(stack_size + STACK_FRAME_MIN_SIZE - (18 * 8))
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci/*
668c2ecf20Sopenharmony_ci * Careful calling this, it will 'clobber' NVGPRs (by design)
678c2ecf20Sopenharmony_ci * Don't call this from C
688c2ecf20Sopenharmony_ci */
698c2ecf20Sopenharmony_ciFUNC_START(load_gpr)
708c2ecf20Sopenharmony_ci	ld	r14,0(r3)
718c2ecf20Sopenharmony_ci	ld	r15,8(r3)
728c2ecf20Sopenharmony_ci	ld	r16,16(r3)
738c2ecf20Sopenharmony_ci	ld	r17,24(r3)
748c2ecf20Sopenharmony_ci	ld	r18,32(r3)
758c2ecf20Sopenharmony_ci	ld	r19,40(r3)
768c2ecf20Sopenharmony_ci	ld	r20,48(r3)
778c2ecf20Sopenharmony_ci	ld	r21,56(r3)
788c2ecf20Sopenharmony_ci	ld	r22,64(r3)
798c2ecf20Sopenharmony_ci	ld	r23,72(r3)
808c2ecf20Sopenharmony_ci	ld	r24,80(r3)
818c2ecf20Sopenharmony_ci	ld	r25,88(r3)
828c2ecf20Sopenharmony_ci	ld	r26,96(r3)
838c2ecf20Sopenharmony_ci	ld	r27,104(r3)
848c2ecf20Sopenharmony_ci	ld	r28,112(r3)
858c2ecf20Sopenharmony_ci	ld	r29,120(r3)
868c2ecf20Sopenharmony_ci	ld	r30,128(r3)
878c2ecf20Sopenharmony_ci	ld	r31,136(r3)
888c2ecf20Sopenharmony_ci	blr
898c2ecf20Sopenharmony_ciFUNC_END(load_gpr)
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_ci#endif /* _SELFTESTS_POWERPC_GPR_ASM_H */
93