18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright 2015, Cyril Bur, IBM Corp.
48c2ecf20Sopenharmony_ci */
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci#include "basic_asm.h"
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci/* POS MUST BE 16 ALIGNED! */
98c2ecf20Sopenharmony_ci#define PUSH_VMX(pos,reg) \
108c2ecf20Sopenharmony_ci	li	reg,pos; \
118c2ecf20Sopenharmony_ci	stvx	v20,reg,%r1; \
128c2ecf20Sopenharmony_ci	addi	reg,reg,16; \
138c2ecf20Sopenharmony_ci	stvx	v21,reg,%r1; \
148c2ecf20Sopenharmony_ci	addi	reg,reg,16; \
158c2ecf20Sopenharmony_ci	stvx	v22,reg,%r1; \
168c2ecf20Sopenharmony_ci	addi	reg,reg,16; \
178c2ecf20Sopenharmony_ci	stvx	v23,reg,%r1; \
188c2ecf20Sopenharmony_ci	addi	reg,reg,16; \
198c2ecf20Sopenharmony_ci	stvx	v24,reg,%r1; \
208c2ecf20Sopenharmony_ci	addi	reg,reg,16; \
218c2ecf20Sopenharmony_ci	stvx	v25,reg,%r1; \
228c2ecf20Sopenharmony_ci	addi	reg,reg,16; \
238c2ecf20Sopenharmony_ci	stvx	v26,reg,%r1; \
248c2ecf20Sopenharmony_ci	addi	reg,reg,16; \
258c2ecf20Sopenharmony_ci	stvx	v27,reg,%r1; \
268c2ecf20Sopenharmony_ci	addi	reg,reg,16; \
278c2ecf20Sopenharmony_ci	stvx	v28,reg,%r1; \
288c2ecf20Sopenharmony_ci	addi	reg,reg,16; \
298c2ecf20Sopenharmony_ci	stvx	v29,reg,%r1; \
308c2ecf20Sopenharmony_ci	addi	reg,reg,16; \
318c2ecf20Sopenharmony_ci	stvx	v30,reg,%r1; \
328c2ecf20Sopenharmony_ci	addi	reg,reg,16; \
338c2ecf20Sopenharmony_ci	stvx	v31,reg,%r1;
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci/* POS MUST BE 16 ALIGNED! */
368c2ecf20Sopenharmony_ci#define POP_VMX(pos,reg) \
378c2ecf20Sopenharmony_ci	li	reg,pos; \
388c2ecf20Sopenharmony_ci	lvx	v20,reg,%r1; \
398c2ecf20Sopenharmony_ci	addi	reg,reg,16; \
408c2ecf20Sopenharmony_ci	lvx	v21,reg,%r1; \
418c2ecf20Sopenharmony_ci	addi	reg,reg,16; \
428c2ecf20Sopenharmony_ci	lvx	v22,reg,%r1; \
438c2ecf20Sopenharmony_ci	addi	reg,reg,16; \
448c2ecf20Sopenharmony_ci	lvx	v23,reg,%r1; \
458c2ecf20Sopenharmony_ci	addi	reg,reg,16; \
468c2ecf20Sopenharmony_ci	lvx	v24,reg,%r1; \
478c2ecf20Sopenharmony_ci	addi	reg,reg,16; \
488c2ecf20Sopenharmony_ci	lvx	v25,reg,%r1; \
498c2ecf20Sopenharmony_ci	addi	reg,reg,16; \
508c2ecf20Sopenharmony_ci	lvx	v26,reg,%r1; \
518c2ecf20Sopenharmony_ci	addi	reg,reg,16; \
528c2ecf20Sopenharmony_ci	lvx	v27,reg,%r1; \
538c2ecf20Sopenharmony_ci	addi	reg,reg,16; \
548c2ecf20Sopenharmony_ci	lvx	v28,reg,%r1; \
558c2ecf20Sopenharmony_ci	addi	reg,reg,16; \
568c2ecf20Sopenharmony_ci	lvx	v29,reg,%r1; \
578c2ecf20Sopenharmony_ci	addi	reg,reg,16; \
588c2ecf20Sopenharmony_ci	lvx	v30,reg,%r1; \
598c2ecf20Sopenharmony_ci	addi	reg,reg,16; \
608c2ecf20Sopenharmony_ci	lvx	v31,reg,%r1;
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ci/*
638c2ecf20Sopenharmony_ci * Careful this will 'clobber' vmx (by design)
648c2ecf20Sopenharmony_ci * Don't call this from C
658c2ecf20Sopenharmony_ci */
668c2ecf20Sopenharmony_ciFUNC_START(load_vmx)
678c2ecf20Sopenharmony_ci	li	r5,0
688c2ecf20Sopenharmony_ci	lvx	v20,r5,r3
698c2ecf20Sopenharmony_ci	addi	r5,r5,16
708c2ecf20Sopenharmony_ci	lvx	v21,r5,r3
718c2ecf20Sopenharmony_ci	addi	r5,r5,16
728c2ecf20Sopenharmony_ci	lvx	v22,r5,r3
738c2ecf20Sopenharmony_ci	addi	r5,r5,16
748c2ecf20Sopenharmony_ci	lvx	v23,r5,r3
758c2ecf20Sopenharmony_ci	addi	r5,r5,16
768c2ecf20Sopenharmony_ci	lvx	v24,r5,r3
778c2ecf20Sopenharmony_ci	addi	r5,r5,16
788c2ecf20Sopenharmony_ci	lvx	v25,r5,r3
798c2ecf20Sopenharmony_ci	addi	r5,r5,16
808c2ecf20Sopenharmony_ci	lvx	v26,r5,r3
818c2ecf20Sopenharmony_ci	addi	r5,r5,16
828c2ecf20Sopenharmony_ci	lvx	v27,r5,r3
838c2ecf20Sopenharmony_ci	addi	r5,r5,16
848c2ecf20Sopenharmony_ci	lvx	v28,r5,r3
858c2ecf20Sopenharmony_ci	addi	r5,r5,16
868c2ecf20Sopenharmony_ci	lvx	v29,r5,r3
878c2ecf20Sopenharmony_ci	addi	r5,r5,16
888c2ecf20Sopenharmony_ci	lvx	v30,r5,r3
898c2ecf20Sopenharmony_ci	addi	r5,r5,16
908c2ecf20Sopenharmony_ci	lvx	v31,r5,r3
918c2ecf20Sopenharmony_ci	blr
928c2ecf20Sopenharmony_ciFUNC_END(load_vmx)
93