fix size property of rip addressing / support movsxd

This commit is contained in:
MITSUNARI Shigeo 2011-11-09 14:09:31 +09:00
parent 83b9047663
commit 08bb1a0433
5 changed files with 42 additions and 9 deletions

View file

@ -1,5 +1,5 @@
Xbyak 3.04 ; JIT assembler for x86(IA32), x64(AMD64, x86-64) by C++
Xbyak 3.05 ; JIT assembler for x86(IA32), x64(AMD64, x86-64) by C++
=============
Abstract
@ -202,6 +202,7 @@ http://www.opensource.org/licenses/bsd-license.php
History
-------------
* 2011/Nov/09 ver 3.05 fix bit property of rip addresing / support movsxd
* 2011/Aug/15 ver 3.04 fix dealing with imm8 such as add(dword [ebp-8], 0xda); (thanks to lolcat)
* 2011/Jun/16 ver 3.03 fix __GNUC_PREREQ macro for Mac gcc(thanks to t_teruya)
* 2011/Apr/28 ver 3.02 do not use xgetbv on Mac gcc
@ -251,5 +252,5 @@ Author
MITSUNARI Shigeo(herumi at nifty dot com)
---
$Revision: 1.14 $
$Date: 2011/08/15 01:29:40 $
$Revision: 1.15 $
$Date: 2011/11/09 02:50:21 $

View file

@ -1,5 +1,5 @@
C++用x86(IA-32), x64(AMD64, x86-64) JITアセンブラ Xbyak version 3.04
C++用x86(IA-32), x64(AMD64, x86-64) JITアセンブラ Xbyak version 3.05
-----------------------------------------------------------------------------
◎概要
@ -214,6 +214,7 @@ sample/{echo,hello}.bfは http://www.kmonos.net/alang/etc/brainfuck.php から
-----------------------------------------------------------------------------
◎履歴
2011/11/09 ver 3.05 rip相対の64bitサイズ以外の扱いのバグ修正 / movsxdサポート
2011/08/15 ver 3.04 add(dword [ebp-8], 0xda);などにおけるimm8の扱いのバグ修正(thanks to lolcat)
2011/06/16 ver 3.03 Macのgcc上での__GNUC_PREREQがミスってたのを修正(thanks to t_teruya)
2011/04/28 ver 3.02 Macのgcc上ではxgetbvをdisable

View file

@ -937,6 +937,9 @@ class Test {
put(p, REG32, REG16|REG8|MEM8|MEM16);
put(p, REG16, REG8|MEM8);
}
#ifdef XBYAK64
put("movsxd", REG64, REG32|MEM32);
#endif
put("cmpxchg8b", MEM);
#ifdef XBYAK64
put("cmpxchg16b", MEM);
@ -1782,6 +1785,22 @@ class Test {
}
}
}
void putRip()
{
const char tbl[][2][64] = {
{ "mov(byte [rip - 10], 3);dump();", "mov byte [rip - 10], 3" },
{ "mov(word [rip - 10], 3);dump();", "mov word [rip - 10], 3" },
{ "mov(dword[rip - 10], 3);dump();", "mov dword [rip - 10], 3" },
{ "mov(qword [rip - 10], 3);dump();", "mov qword [rip - 10], 3" },
{ "mov(ptr [rip - 10], al);dump();", "mov byte [rip - 10], al" },
{ "mov(ptr [rip - 10], ax);dump();", "mov word [rip - 10], ax" },
{ "mov(ptr [rip - 10], eax);dump();", "mov dword [rip - 10], eax" },
{ "mov(ptr [rip - 10], rax);dump();", "mov qword [rip - 10], rax" },
};
for (size_t i = 0; i < NUM_OF_ARRAY(tbl); i++) {
puts(tbl[i][isXbyak_ ? 0 : 1]);
}
}
public:
Test(bool isXbyak)
: isXbyak_(isXbyak)
@ -1878,6 +1897,9 @@ public:
separateFunc();
putSSE4_2();
putMov64();
#ifdef XBYAK64
putRip();
#endif
#endif
#endif
}

View file

@ -5,12 +5,15 @@
@file xbyak.h
@brief Xbyak ; JIT assembler for x86(IA32)/x64 by C++
@author herumi
@version $Revision: 1.252 $
@version $Revision: 1.256 $
@url http://homepage1.nifty.com/herumi/soft/xbyak.html
@date $Date: 2011/08/15 00:59:49 $
@date $Date: 2011/11/09 05:06:37 $
@note modified new BSD license
http://www.opensource.org/licenses/bsd-license.php
*/
#if not +0
#error "use -fno-operator-names"
#endif
#include <stdio.h> // for debug print
#include <assert.h>
@ -51,7 +54,7 @@ namespace Xbyak {
enum {
DEFAULT_MAX_CODE_SIZE = 4096,
VERSION = 0x3040, /* 0xABCD = A.BC(D) */
VERSION = 0x3050, /* 0xABCD = A.BC(D) */
};
#ifndef MIE_INTEGER_TYPE_DEFINED
@ -572,7 +575,7 @@ public:
}
Address operator[](const RegRip& addr) const
{
Address frame(64, true, addr.disp_, false);
Address frame(bit_, true, addr.disp_, false);
frame.db(B00000101);
frame.dd(addr.disp_);
return frame;
@ -1032,6 +1035,7 @@ private:
}
void opMovxx(const Reg& reg, const Operand& op, uint8 code)
{
if (op.isBit(32)) throw ERR_BAD_COMBINATION;
int w = op.isBit(16);
bool cond = reg.isREG() && (reg.getBit() > op.getBit());
opModRM(reg, op, cond && op.isREG(), cond && op.isMEM(), 0x0F, code | w);
@ -1340,6 +1344,11 @@ public:
if (!op.isREG(64) && !op.isMEM()) throw ERR_BAD_COMBINATION;
opGen(Reg64(xmm.getIdx()), op, 0x22, 0x66, 0, imm, B00111010); // force to 64bit
}
void movsxd(const Reg64& reg, const Operand& op)
{
if (!op.isBit(32)) throw ERR_BAD_COMBINATION;
opModRM(reg, op, op.isREG(), op.isMEM(), 0x63);
}
#endif
// MMX2 : pextrw : reg, mmx/xmm, imm
// SSE4 : pextrw, pextrb, pextrd, extractps : reg/mem, mmx/xmm, imm

View file

@ -1,4 +1,4 @@
const char *getVersionString() const { return "3.04"; }
const char *getVersionString() const { return "3.05"; }
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); }