make registers a little less verbose to work with

Change-Id: I92c6027e16af19112a5497854f1085715cc38e3d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/221652
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Herb Derby <herb@google.com>
This commit is contained in:
Mike Klein 2019-06-18 15:04:16 -05:00 committed by Skia Commit-Bot
parent 61703a643d
commit 948045d1a5
3 changed files with 14 additions and 13 deletions

View File

@ -509,9 +509,9 @@ namespace skvm {
int opcode_ext = 5; // subtract
this->byte(REX{1,dst >= GP64::r8,0,0}.bits);
this->byte(REX{1,dst >= r8,0,0}.bits);
this->byte(opcode);
this->byte(ModRM{ModRM::Direct/*don't understand yet*/, opcode_ext, (int)dst}.bits);
this->byte(ModRM{ModRM::Direct/*don't understand yet*/, opcode_ext, dst}.bits);
this->byte(&imm, imm_bytes);
}
@ -537,7 +537,7 @@ namespace skvm {
#else
// These registers are used to pass the first 6 arguments,
// so if we stick to these we need not push, pop, spill, or move anything around.
Assembler::GP64 N = Assembler::GP64::rdi;
Assembler::GP64 N = Assembler::rdi;
Xbyak::Reg arg[] = { X.rsi, X.rdx, X.rcx, X.r8, X.r9 };

View File

@ -26,15 +26,15 @@ namespace skvm {
size_t size() const;
// Order matters... GP64, XMM, YMM values match 4-bit register encoding for each.
enum class GP64 {
enum GP64 {
rax, rcx, rdx, rbx, rsp, rbp, rsi, rdi,
r8 , r9, r10, r11, r12, r13, r14, r15,
};
enum class XMM {
enum XMM {
xmm0, xmm1, xmm2 , xmm3 , xmm4 , xmm5 , xmm6 , xmm7 ,
xmm8, xmm9, xmm10, xmm11, xmm12, xmm13, xmm14, xmm15,
};
enum class YMM {
enum YMM {
ymm0, ymm1, ymm2 , ymm3 , ymm4 , ymm5 , ymm6 , ymm7 ,
ymm8, ymm9, ymm10, ymm11, ymm12, ymm13, ymm14, ymm15,
};

View File

@ -198,8 +198,9 @@ static void test_asm(skiatest::Reporter* r, Fn&& fn, std::initializer_list<uint8
}
DEF_TEST(SkVM_Assembler, r) {
using skvm::Assembler;
// Our exit strategy from AVX code.
test_asm(r, [&](skvm::Assembler& a) {
test_asm(r, [&](Assembler& a) {
a.vzeroupper();
a.ret();
},{
@ -208,7 +209,7 @@ DEF_TEST(SkVM_Assembler, r) {
});
// Align should pad with nop().
test_asm(r, [&](skvm::Assembler& a) {
test_asm(r, [&](Assembler& a) {
a.ret();
a.align(4);
},{
@ -216,11 +217,11 @@ DEF_TEST(SkVM_Assembler, r) {
0x90, 0x90, 0x90,
});
test_asm(r, [&](skvm::Assembler& a) {
a.sub(skvm::Assembler::GP64::rax, 32); // Always good to test rax.
a.sub(skvm::Assembler::GP64::rdi, 8); // Last 0x48 REX
a.sub(skvm::Assembler::GP64::r8 , 4); // First 0x4c REX
a.sub(skvm::Assembler::GP64::r8 , 1000000); // Requires 4 byte immediate.
test_asm(r, [&](Assembler& a) {
a.sub(Assembler::rax, 32); // Always good to test rax.
a.sub(Assembler::rdi, 8); // Last 0x48 REX
a.sub(Assembler::r8 , 4); // First 0x4c REX
a.sub(Assembler::r8 , 1000000); // Requires 4 byte immediate.
},{
0x48, 0x83, 0b11'101'000, 0x20,
0x48, 0x83, 0b11'101'111, 0x08,