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

Commit f3881b2

Browse files
Mike KleinSkia Commit-Bot
authored andcommitted
vmovq
Change-Id: Id83573bb7e66c0a6316917ae17abe7f56a172941 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/222629 Reviewed-by: Herb Derby <[email protected]> Commit-Queue: Mike Klein <[email protected]>
1 parent ae51aa3 commit f3881b2

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

src/core/SkVM.cpp

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,6 @@ namespace skvm {
681681
void Assembler::load_store(int prefix, int map, int opcode, Ymm ymm, GP64 ptr) {
682682
VEX v = vex(0, ymm>>3, 0, ptr>>3,
683683
map, 0, /*ymm?*/1, prefix);
684-
685684
this->byte(v.bytes, v.len);
686685
this->byte(opcode);
687686
this->byte(mod_rm(Mod::Indirect, ymm&7, ptr&7));
@@ -690,6 +689,17 @@ namespace skvm {
690689
void Assembler::vmovups (Ymm dst, GP64 src) { this->load_store(0 , 0x0f,0x10, dst,src); }
691690
void Assembler::vpmovzxbd(Ymm dst, GP64 src) { this->load_store(0x66,0x380f,0x31, dst,src); }
692691
void Assembler::vmovups (GP64 dst, Ymm src) { this->load_store(0 , 0x0f,0x11, src,dst); }
692+
void Assembler::vmovq (GP64 dst, Xmm src) {
693+
int prefix = 0x66,
694+
map = 0x0f,
695+
opcode = 0xd6;
696+
VEX v = vex(0, src>>3, 0, dst>>3,
697+
map, 0, /*ymm?*/0, prefix);
698+
this->byte(v.bytes, v.len);
699+
this->byte(opcode);
700+
this->byte(mod_rm(Mod::Indirect, src&7, dst&7));
701+
}
702+
693703

694704
static bool can_jit(int regs, int nargs) {
695705
return true
@@ -829,11 +839,10 @@ namespace skvm {
829839
// One stop shop! Pack 8x I32 -> U8 and store to ptr.
830840
X.vpmovusdb(X.ptr[xarg(y.imm)], r(x));
831841
} else {
832-
a.vpackusdw(ar(tmp), ar(x), ar(x)); // pack 32-bit -> 16-bit
833-
a.vpermq (ar(tmp), ar(tmp), 0xd8); // u64 tmp[0,1,2,3] = tmp[0,2,1,3]
834-
a.vpackuswb(ar(tmp), ar(tmp), ar(tmp)); // pack 16-bit -> 8-bit
835-
X.vmovq(X.ptr[xarg(y.imm)], // store low 8 bytes
836-
Xbyak::Xmm{tmp}); // (arg must be an xmm)
842+
a.vpackusdw(ar(tmp), ar(x), ar(x)); // pack 32-bit -> 16-bit
843+
a.vpermq (ar(tmp), ar(tmp), 0xd8); // u64 tmp[0,1,2,3] = tmp[0,2,1,3]
844+
a.vpackuswb(ar(tmp), ar(tmp), ar(tmp)); // pack 16-bit -> 8-bit
845+
a.vmovq (arg[y.imm], (A::Xmm)tmp); // store low 8 bytes
837846
}
838847
break;
839848

src/core/SkVM.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ namespace skvm {
8181

8282
void vmovups (Ymm dst, GP64 src);
8383
void vpmovzxbd(Ymm dst, GP64 src);
84-
void vmovups (GP64 dst, Ymm src);
84+
85+
void vmovups(GP64 dst, Ymm src);
86+
void vmovq (GP64 dst, Xmm src);
8587

8688
//private:
8789
std::unique_ptr<Xbyak::CodeGenerator> X;

tests/SkVMTest.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,12 +353,16 @@ DEF_TEST(SkVM_Assembler, r) {
353353
a.vmovups(A::rsi, A::ymm5);
354354

355355
a.vpmovzxbd(A::ymm4, A::rsi);
356+
357+
a.vmovq(A::rdx, A::xmm15);
356358
},{
357359
/* VEX */ /*Op*/ /* ModRM */
358360
0xc5, 0xfc, 0x10, 0b00'101'110,
359361
0xc5, 0xfc, 0x11, 0b00'101'110,
360362

361363
0xc4,0xe2,0x7d, 0x31, 0b00'100'110,
364+
365+
0xc5, 0x79, 0xd6, 0b00'111'010,
362366
});
363367
}
364368

0 commit comments

Comments
 (0)