Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 5e9f0ee

Browse files
Mike KleinSkia Commit-Bot
authored andcommitted
add and test stack load/store
Change-Id: Ie0d29e31bd8c156ecd46cd658b5a4c53d8d2e11d Reviewed-on: https://skia-review.googlesource.com/c/skia/+/282115 Reviewed-by: Herb Derby <[email protected]> Commit-Queue: Mike Klein <[email protected]>
1 parent 62a0fb2 commit 5e9f0ee

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

src/core/SkVM.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1934,6 +1934,18 @@ namespace skvm {
19341934
this->byte(mod_rm(Mod::Indirect, src&7, dst&7));
19351935
}
19361936

1937+
void Assembler::stack_load_store(int prefix, int map, int opcode, Ymm ymm, int off) {
1938+
VEX v = vex(0, ymm>>3, 0, rsp>>3/*i.e. 0*/,
1939+
map, 0, /*ymm?*/1, prefix);
1940+
this->bytes(v.bytes, v.len);
1941+
this->byte(opcode);
1942+
this->byte(mod_rm(mod(off), ymm&7, rsp/*use SIB*/));
1943+
this->byte(sib(ONE, rsp/*no index*/, rsp));
1944+
this->bytes(&off, imm_bytes(mod(off)));
1945+
}
1946+
void Assembler::vmovups(Ymm dst, int off) { this->stack_load_store(0, 0x0f, 0x10, dst,off); }
1947+
void Assembler::vmovups(int off, Ymm src) { this->stack_load_store(0, 0x0f, 0x11, src,off); }
1948+
19371949
void Assembler::vmovq(GP64 dst, Xmm src) {
19381950
int prefix = 0x66,
19391951
map = 0x0f,
@@ -1986,7 +1998,7 @@ namespace skvm {
19861998
map, 0, /*ymm?*/0, prefix);
19871999
this->bytes(v.bytes, v.len);
19882000
this->byte(opcode);
1989-
this->byte(mod_rm(Mod::Indirect, dst&7, rsp));
2001+
this->byte(mod_rm(Mod::Indirect, dst&7, rsp/*use SIB*/));
19902002
this->byte(sib(scale, index&7, base&7));
19912003
}
19922004

@@ -2082,7 +2094,7 @@ namespace skvm {
20822094
map, mask, /*ymm?*/1, prefix);
20832095
this->bytes(v.bytes, v.len);
20842096
this->byte(opcode);
2085-
this->byte(mod_rm(Mod::Indirect, dst&7, rsp));
2097+
this->byte(mod_rm(Mod::Indirect, dst&7, rsp/*use SIB*/));
20862098
this->byte(sib(scale, ix&7, base&7));
20872099
}
20882100

src/core/SkVM.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ namespace skvm {
144144
void vbroadcastss(Ymm dst, Xmm src);
145145
void vbroadcastss(Ymm dst, GP64 ptr, int off); // dst = *(ptr+off)
146146

147+
void vmovups (Ymm dst, int imm); // dst = *(sp + imm)
147148
void vmovups (Ymm dst, GP64 ptr); // dst = *ptr, 256-bit
148149
void vpmovzxwd(Ymm dst, GP64 ptr); // dst = *ptr, 128-bit, each uint16_t expanded to int
149150
void vpmovzxbd(Ymm dst, GP64 ptr); // dst = *ptr, 64-bit, each uint8_t expanded to int
@@ -152,6 +153,7 @@ namespace skvm {
152153
enum Scale { ONE, TWO, FOUR, EIGHT };
153154
void vmovd(Xmm dst, Scale, GP64 index, GP64 base); // dst = *(base + scale*index), 32-bit
154155

156+
void vmovups(int imm, Ymm src); // *(sp + imm) = src
155157
void vmovups(GP64 ptr, Ymm src); // *ptr = src, 256-bit
156158
void vmovups(GP64 ptr, Xmm src); // *ptr = src, 128-bit
157159
void vmovq (GP64 ptr, Xmm src); // *ptr = src, 64-bit
@@ -270,6 +272,8 @@ namespace skvm {
270272

271273
// *ptr = ymm or ymm = *ptr, depending on opcode.
272274
void load_store(int prefix, int map, int opcode, Ymm ymm, GP64 ptr);
275+
// *(sp+off) = ymm or ymm = *(sp+off), depending on opcode.
276+
void stack_load_store(int prefix, int map, int opcode, Ymm ymm, int off);
273277

274278
// Opcode for 3-arguments ops is split between hi and lo:
275279
// [11 bits hi] [5 bits m] [6 bits lo] [5 bits n] [5 bits d]

tests/SkVMTest.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1402,6 +1402,24 @@ DEF_TEST(SkVM_Assembler, r) {
14021402
0xc5, 0x79, 0xd6, 0b00'111'010,
14031403
});
14041404

1405+
test_asm(r, [&](A& a) {
1406+
a.vmovups(A::ymm5, 0);
1407+
a.vmovups(A::ymm5, 64);
1408+
a.vmovups(A::ymm5, 128);
1409+
1410+
a.vmovups( 0, A::ymm5);
1411+
a.vmovups( 64, A::ymm5);
1412+
a.vmovups(128, A::ymm5);
1413+
},{
1414+
0xc5,0xfc,0x10,0x2c,0x24,
1415+
0xc5,0xfc,0x10,0x6c,0x24,0x40,
1416+
0xc5,0xfc,0x10,0xac,0x24,0x80,0x00,0x00,0x00,
1417+
1418+
0xc5,0xfc,0x11,0x2c,0x24,
1419+
0xc5,0xfc,0x11,0x6c,0x24,0x40,
1420+
0xc5,0xfc,0x11,0xac,0x24,0x80,0x00,0x00,0x00,
1421+
});
1422+
14051423
test_asm(r, [&](A& a) {
14061424
a.movzbl(A::rax, A::rsi, 0); // Low registers for src and dst.
14071425
a.movzbl(A::rax, A::r8, 0); // High src register.

0 commit comments

Comments
 (0)