Skip to content

Commit

Permalink
test adc2(r, op, mem) and adc2(r, mem, op)
Browse files Browse the repository at this point in the history
  • Loading branch information
herumi committed Oct 26, 2023
1 parent 6f593a1 commit 4c62d1f
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
26 changes: 25 additions & 1 deletion test/apx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ CYBOZU_TEST_AUTO(rm)
CYBOZU_TEST_EQUAL_ARRAY(c.getCode(), tbl, n);
}

CYBOZU_TEST_AUTO(rrr)
CYBOZU_TEST_AUTO(r3)
{
struct Code : Xbyak::CodeGenerator {
Code()
Expand All @@ -279,3 +279,27 @@ CYBOZU_TEST_AUTO(rrr)
CYBOZU_TEST_EQUAL_ARRAY(c.getCode(), tbl, n);
}

CYBOZU_TEST_AUTO(rm3)
{
struct Code : Xbyak::CodeGenerator {
Code()
{
adc2(rax, r18, ptr [rbx+rcx*4+0x123]);
adc2(rax, ptr [rbx+rcx*4+0x123], r20);
adc2(rax, ptr [r30], r29);
adc2(r11, r13, ptr [r10]);
adc2(r11, r13, ptr [r10*4]);
adc2(r11, ptr [r10*8], r9);
}
} c;
const uint8_t tbl[] = {
0x62, 0xe4, 0xfc, 0x18, 0x13, 0x94, 0x8b, 0x23, 0x01, 0x00, 0x00, 0x62, 0xe4, 0xfc, 0x18, 0x11,
0xa4, 0x8b, 0x23, 0x01, 0x00, 0x00, 0x62, 0x4c, 0xfc, 0x18, 0x11, 0x2e, 0x62, 0x54, 0xa4, 0x18,
0x13, 0x2a, 0x62, 0x34, 0xa4, 0x18, 0x13, 0x2c, 0x95, 0x00, 0x00, 0x00, 0x00, 0x62, 0x34, 0xa4,
0x18, 0x11, 0x0c, 0xd5, 0x00, 0x00, 0x00, 0x00,
};
const size_t n = sizeof(tbl);
CYBOZU_TEST_EQUAL(c.getSize(), n);
CYBOZU_TEST_EQUAL_ARRAY(c.getCode(), tbl, n);
}

11 changes: 9 additions & 2 deletions xbyak/xbyak.h
Original file line number Diff line number Diff line change
Expand Up @@ -1698,7 +1698,6 @@ class CodeGenerator : public CodeArray {
db(0xD5);
db((rexRXB(4, bit3, r, b, x) << 4) | rex4bit);
}
// optimize = false is a special case for bnd*
void rex(const Operand& op1, const Operand& op2 = Operand())
{
uint8_t rex = 0;
Expand Down Expand Up @@ -2815,9 +2814,17 @@ class CodeGenerator : public CodeArray {
{
int code0 = 0x10;
const Operand *p1 = &op1, *p2 = &op2;
if (p1->isMEM()) std::swap(p1, p2);
if (p1->isMEM()) { std::swap(p1, p2); } else { if (p2->isMEM()) code0 |= 2; }
if (p1->isMEM()) XBYAK_THROW(ERR_BAD_COMBINATION)
if (p2->isMEM()) {
const Reg& r = *static_cast<const Reg*>(p1);
const Address& addr = p2->getAddress();
const RegExp e = addr.getRegExp();
const Reg& base = e.getBase();
const Reg& idx = e.getIndex();
evexLeg(r, base, idx, d);
db(code0 | (r.isBit(8) ? 0 : 1));
opAddr(addr, r.getIdx());
} else {
evexLeg(static_cast<const Reg&>(op2), static_cast<const Reg&>(op1), Reg(), d);
db(code0 | (d.isBit(8) ? 0 : 1));
Expand Down

0 comments on commit 4c62d1f

Please sign in to comment.