Skip to content

Commit

Permalink
fix Address::operator==()
Browse files Browse the repository at this point in the history
  • Loading branch information
herumi committed Aug 10, 2015
1 parent 1e208fd commit 93aae57
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 5 deletions.
3 changes: 2 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

Xbyak 4.84 ; JIT assembler for x86(IA32), x64(AMD64, x86-64) by C++
Xbyak 4.85 ; JIT assembler for x86(IA32), x64(AMD64, x86-64) by C++
=============

Abstract
Expand Down Expand Up @@ -277,6 +277,7 @@ The header files under xbyak/ are independent of cybozulib.

History
-------------
* 2015/Aug/10 ver 4.85 Address::operator==() is not correct(thanks to inolen)
* 2015/Jun/22 ver 4.84 call() support variadic template if available(thanks to randomstuff)
* 2015/Jun/16 ver 4.83 support movbe(thanks to benvanik)
* 2015/May/24 ver 4.82 support detection of F16C
Expand Down
3 changes: 2 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

C++用x86(IA-32), x64(AMD64, x86-64) JITアセンブラ Xbyak 4.84
C++用x86(IA-32), x64(AMD64, x86-64) JITアセンブラ Xbyak 4.85

-----------------------------------------------------------------------------
◎概要
Expand Down Expand Up @@ -296,6 +296,7 @@ cybozulibは単体テストでのみ利用されていて、xbyak/ディレク
-----------------------------------------------------------------------------
◎履歴

2015/08/10 ver 4.85 Address::operator==()が間違っている(thanks to inolen)
2015/07/22 ver 4.84 call()がvariadic template対応
2015/05/24 ver 4.83 mobveサポート(thanks to benvanik)
2015/05/24 ver 4.82 F16Cが使えるかどうかの判定追加
Expand Down
11 changes: 11 additions & 0 deletions test/misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,14 @@ CYBOZU_TEST_AUTO(setSize)
}
} code;
}

CYBOZU_TEST_AUTO(compOperand)
{
using namespace Xbyak::util;
CYBOZU_TEST_ASSERT(eax == eax);
CYBOZU_TEST_ASSERT(ecx != xmm0);
CYBOZU_TEST_ASSERT(ptr[eax] == ptr[eax]);
CYBOZU_TEST_ASSERT(dword[eax] != ptr[eax]);
CYBOZU_TEST_ASSERT(ptr[eax] != ptr[eax+3]);
CYBOZU_TEST_ASSERT(ptr[eax] != ptr[eax+3]);
}
17 changes: 15 additions & 2 deletions xbyak/xbyak.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ namespace Xbyak {

enum {
DEFAULT_MAX_CODE_SIZE = 4096,
VERSION = 0x4840 /* 0xABCD = A.BC(D) */
VERSION = 0x4850 /* 0xABCD = A.BC(D) */
};

#ifndef MIE_INTEGER_TYPE_DEFINED
Expand Down Expand Up @@ -411,7 +411,8 @@ class Operand {
}
throw Error(ERR_INTERNAL);
}
bool operator==(const Operand& rhs) const { return idx_ == rhs.idx_ && kind_ == rhs.kind_ && bit_ == rhs.bit_; }
bool isSameNotInherited(const Operand& rhs) const { return idx_ == rhs.idx_ && kind_ == rhs.kind_ && bit_ == rhs.bit_; }
bool operator==(const Operand& rhs) const;
bool operator!=(const Operand& rhs) const { return !operator==(rhs); }
};

Expand Down Expand Up @@ -870,8 +871,20 @@ class Address : public Operand {
void setRex(uint8 rex) { rex_ = rex; }
void setLabel(const Label* label) { label_ = label; }
const Label* getLabel() const { return label_; }
bool operator==(const Address& rhs) const
{
return getBit() == rhs.getBit() && size_ == rhs.size_ && rex_ == rhs.rex_ && disp_ == rhs.disp_ && label_ == rhs.label_ && isOnlyDisp_ == rhs.isOnlyDisp_
&& is64bitDisp_ == rhs.is64bitDisp_ && is32bit_ == rhs.is32bit_ && isVsib_ == rhs.isVsib_ && isYMM_ == rhs.isYMM_;
}
bool operator!=(const Address& rhs) const { return !operator==(rhs); }
};

inline bool Operand::operator==(const Operand& rhs) const
{
if (isMEM() && rhs.isMEM()) return static_cast<const Address&>(*this) == static_cast<const Address&>(rhs);
return isSameNotInherited(rhs);
}

class AddressFrame {
private:
void operator=(const AddressFrame&);
Expand Down
2 changes: 1 addition & 1 deletion xbyak/xbyak_mnemonic.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const char *getVersionString() const { return "4.84"; }
const char *getVersionString() const { return "4.85"; }
void packssdw(const Mmx& mmx, const Operand& op) { opMMX(mmx, op, 0x6B); }
void packsswb(const Mmx& mmx, const Operand& op) { opMMX(mmx, op, 0x63); }
void packuswb(const Mmx& mmx, const Operand& op) { opMMX(mmx, op, 0x67); }
Expand Down

0 comments on commit 93aae57

Please sign in to comment.