Skip to content

Commit

Permalink
fix wrong addressing for xmm2
Browse files Browse the repository at this point in the history
  • Loading branch information
herumi committed Apr 23, 2015
1 parent 2158b53 commit c81d6d8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
8 changes: 5 additions & 3 deletions test/jmp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -951,9 +951,11 @@ CYBOZU_TEST_AUTO(rip)
db(a[1], 4);
L("@@");
mov(eax, ptr [rip + label1]); // a[0]
add(eax, ptr [rip + label1+4]); // a[1]
add(eax, ptr [rip + label2-8+2+6]); // b[0]
add(eax, ptr [rip + 16+label2-12]); // b[1]
mov(ecx, ptr [rip + label1+4]); // a[1]
mov(edx, ptr [rip + label2-8+2+6]); // b[0]
add(ecx, ptr [rip + 16+label2-12]); // b[1]
add(eax, ecx);
add(eax, edx);
ret();
L(label2);
db(b[0], 4);
Expand Down
9 changes: 9 additions & 0 deletions test/make_nm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,15 @@ class Test {
#ifdef XBYAK64
put("jmp", "ptr[(void*)0x12345678]", "[0x12345678]");
put("call", "ptr[(void*)0x12345678]", "[0x12345678]");
if (isXbyak_) {
puts("{ Label label0;");
puts("L(label0);");
puts("pshufb (xmm14, ptr [rip+label0]); dump();");
puts("}");
} else {
puts("label0:");
puts("pshufb xmm14, [rel label0]");
}
#ifdef USE_YASM
put("jmp", "ptr[rip + 0x12345678]", "[rip+0x12345678]");
put("call", "ptr[rip + 0x12345678]", "[rip+0x12345678]");
Expand Down
25 changes: 7 additions & 18 deletions xbyak/xbyak.h
Original file line number Diff line number Diff line change
Expand Up @@ -842,19 +842,6 @@ class Address : public Operand {
, isYMM_(isYMM)
{
}
Address(uint32 sizeBit, const Label *label, uint64 disp)
: Operand(0, MEM, sizeBit)
, size_(0)
, rex_(0)
, disp_(disp)
, label_(label)
, isOnlyDisp_(false)
, is64bitDisp_(false)
, is32bit_(false)
, isVsib_(false)
, isYMM_(false)
{
}
void db(int code)
{
if (size_ >= sizeof(top_)) throw Error(ERR_CODE_IS_TOO_BIG);
Expand All @@ -876,6 +863,7 @@ class Address : public Operand {
uint8 getRex() const { verify(); return rex_; }
bool is64bitDisp() const { verify(); return is64bitDisp_; } // for moffset
void setRex(uint8 rex) { rex_ = rex; }
void setLabel(const Label* label) { label_ = label; }
const Label* getLabel() const { return label_; }
};

Expand Down Expand Up @@ -947,10 +935,13 @@ class AddressFrame {
}
Address operator[](const RegRip& addr) const
{
if (addr.label_) return Address(bit_, addr.label_, addr.disp_);
Address frame(bit_, true, addr.disp_, false);
frame.db(0x05);
frame.dd(inner::VerifyInInt32(addr.disp_));
if (addr.label_) {
frame.setLabel(addr.label_);
} else {
frame.dd(inner::VerifyInInt32(addr.disp_));
}
return frame;
}
#endif
Expand Down Expand Up @@ -1368,11 +1359,9 @@ class CodeGenerator : public CodeArray {
}
void opAddr(const Address &addr)
{
db(addr.getCode(), static_cast<int>(addr.getSize()));
if (addr.getLabel()) { // [rip + Label]
db(0x05);
putL_inner(*addr.getLabel(), true, addr.getDisp());
} else {
db(addr.getCode(), static_cast<int>(addr.getSize()));
}
}
/* preCode is for SSSE3/SSE4 */
Expand Down

0 comments on commit c81d6d8

Please sign in to comment.