Skip to content

Commit be3458a

Browse files
Added push(...) and pop(...) for SIMD registers
1 parent 167f937 commit be3458a

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/cpu/x64/jit_generator.hpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ class jit_generator : public Xbyak::CodeGenerator, public c_compatible {
147147

148148
private:
149149
const size_t xmm_len = 16;
150+
const size_t ymm_len = 32;
151+
const size_t zmm_len = 64;
150152
#ifdef _WIN32
151153
const size_t xmm_to_preserve_start = 6;
152154
const size_t xmm_to_preserve = 10;
@@ -182,6 +184,35 @@ class jit_generator : public Xbyak::CodeGenerator, public c_compatible {
182184

183185
inline size_t get_size_of_abi_save_regs() { return size_of_abi_save_regs; }
184186

187+
using Xbyak::CodeGenerator::push;
188+
using Xbyak::CodeGenerator::pop;
189+
190+
inline void push(const Xbyak::Xmm &xmm) {
191+
if (xmm.isXMM()) {
192+
sub(rsp, xmm_len);
193+
uni_vmovdqu(ptr[rsp], xmm);
194+
} else if (xmm.isYMM()) {
195+
sub(rsp, ymm_len);
196+
uni_vmovdqu(ptr[rsp], Xbyak::Ymm{xmm.getIdx()});
197+
} else if (xmm.isZMM()) {
198+
sub(rsp, zmm_len);
199+
uni_vmovdqu(ptr[rsp], Xbyak::Zmm{xmm.getIdx()});
200+
}
201+
}
202+
203+
inline void pop(const Xbyak::Xmm &xmm) {
204+
if (xmm.isXMM()) {
205+
uni_vmovdqu(xmm, ptr[rsp]);
206+
add(rsp, xmm_len);
207+
} else if (xmm.isYMM()) {
208+
uni_vmovdqu(Xbyak::Ymm{xmm.getIdx()}, ptr[rsp]);
209+
add(rsp, ymm_len);
210+
} else if (xmm.isZMM()) {
211+
uni_vmovdqu(Xbyak::Zmm{xmm.getIdx()}, ptr[rsp]);
212+
add(rsp, zmm_len);
213+
}
214+
}
215+
185216
void preamble() {
186217
if (xmm_to_preserve) {
187218
sub(rsp, xmm_to_preserve * xmm_len);

0 commit comments

Comments
 (0)