add int3, vptest, jc
Will use these to implement assert_true on x86.
Change-Id: I9d2595a35518b6971dd8e418b583febd3960c7f6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/253896
Commit-Queue: Mike Klein <mtklein@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Auto-Submit: Mike Klein <mtklein@google.com>
Reviewed-by: Mike Reed <reed@google.com>
diff --git a/src/core/SkVM.cpp b/src/core/SkVM.cpp
index 5330297..1674cd2 100644
--- a/src/core/SkVM.cpp
+++ b/src/core/SkVM.cpp
@@ -722,6 +722,10 @@
}
}
+ void Assembler::int3() {
+ this->byte(0xcc);
+ }
+
void Assembler::vzeroupper() {
this->byte(0xc5);
this->byte(0xf8);
@@ -870,6 +874,8 @@
void Assembler::vpaddd (Ymm dst, Ymm x, Label* l) { this->op(0x66, 0x0f,0xfe, dst,x,l); }
void Assembler::vpsubd (Ymm dst, Ymm x, Label* l) { this->op(0x66, 0x0f,0xfa, dst,x,l); }
+ void Assembler::vptest(Ymm dst, Label* l) { this->op(0x66, 0x380f, 0x17, dst, (Ymm)0, l); }
+
void Assembler::vbroadcastss(Ymm dst, Label* l) { this->op(0x66,0x380f,0x18, dst, (Ymm)0, l); }
void Assembler::vbroadcastss(Ymm dst, Xmm src) { this->op(0x66,0x380f,0x18, dst, (Ymm)src); }
void Assembler::vbroadcastss(Ymm dst, GP64 ptr, int off) {
@@ -897,6 +903,7 @@
void Assembler::je (Label* l) { this->jump(0x84, l); }
void Assembler::jne(Label* l) { this->jump(0x85, l); }
void Assembler::jl (Label* l) { this->jump(0x8c, l); }
+ void Assembler::jc (Label* l) { this->jump(0x82, l); }
void Assembler::jmp(Label* l) {
// Like above in jump(), we could use 8-bit displacement here, but always use 32-bit.
diff --git a/src/core/SkVM.h b/src/core/SkVM.h
index 05ba8a1..4954920 100644
--- a/src/core/SkVM.h
+++ b/src/core/SkVM.h
@@ -58,6 +58,7 @@
void align(int mod);
+ void int3();
void vzeroupper();
void ret();
@@ -104,8 +105,11 @@
void je (Label*);
void jne(Label*);
void jl (Label*);
+ void jc (Label*);
void cmp(GP64, int imm);
+ void vptest(Ymm dst, Label*);
+
void vbroadcastss(Ymm dst, Label*);
void vbroadcastss(Ymm dst, Xmm src);
void vbroadcastss(Ymm dst, GP64 ptr, int off); // dst = *(ptr+off)
diff --git a/tests/SkVMTest.cpp b/tests/SkVMTest.cpp
index c20ead9..618eb1b 100644
--- a/tests/SkVMTest.cpp
+++ b/tests/SkVMTest.cpp
@@ -763,9 +763,11 @@
using A = skvm::Assembler;
// Our exit strategy from AVX code.
test_asm(r, [&](A& a) {
+ a.int3();
a.vzeroupper();
a.ret();
},{
+ 0xcc,
0xc5, 0xf8, 0x77,
0xc3,
});
@@ -882,6 +884,8 @@
a.vpshufb(A::ymm4, A::ymm3, &l);
a.vpaddd (A::ymm4, A::ymm3, &l);
a.vpsubd (A::ymm4, A::ymm3, &l);
+
+ a.vptest(A::ymm4, &l);
},{
0x01, 0x02, 0x03, 0x4,
@@ -895,6 +899,8 @@
0xc5, 0xe5, 0xfe, 0b00'100'101, 0xc7,0xff,0xff,0xff, // 0xffffffc7 == -57
0xc5, 0xe5, 0xfa, 0b00'100'101, 0xbf,0xff,0xff,0xff, // 0xffffffbf == -65
+
+ 0xc4, 0xe2, 0x7d, 0x17, 0b00'100'101, 0xb6,0xff,0xff,0xff, // 0xffffffb6 == -72
});
test_asm(r, [&](A& a) {
@@ -923,6 +929,7 @@
a.je (&l);
a.jmp(&l);
a.jl (&l);
+ a.jc (&l);
a.cmp(A::rdx, 0);
a.cmp(A::rax, 12);
@@ -933,6 +940,7 @@
0x0f,0x84, 0xee,0xff,0xff,0xff, // near je -18 bytes
0xe9, 0xe9,0xff,0xff,0xff, // near jmp -23 bytes
0x0f,0x8c, 0xe3,0xff,0xff,0xff, // near jl -29 bytes
+ 0x0f,0x82, 0xdd,0xff,0xff,0xff, // near jc -35 bytes
0x48,0x83,0xfa,0x00,
0x48,0x83,0xf8,0x0c,