change the behavior of push((byte|word), imm) to cast imm to int8_t/int16_t

This commit is contained in:
MITSUNARI Shigeo 2020-08-24 16:29:34 +09:00
parent d9696b54d1
commit be492be1a4
5 changed files with 36 additions and 6 deletions

View File

@ -1,6 +1,6 @@
[![Build Status](https://travis-ci.org/herumi/xbyak.png)](https://travis-ci.org/herumi/xbyak)
# Xbyak 5.941 ; JIT assembler for x86(IA32), x64(AMD64, x86-64) by C++
# Xbyak 5.95 ; JIT assembler for x86(IA32), x64(AMD64, x86-64) by C++
## Abstract
@ -16,6 +16,7 @@ Use `and_()`, `or_()`, ... instead of `and()`, `or()`.
If you want to use them, then specify `-fno-operator-names` option to gcc/clang.
### News
- (break backward compatibility) `push(byte, imm)` (resp. `push(word, imm)`) forces to cast `imm` to 8(resp. 16) bit.
- (Windows) `#include <winsock2.h>` has been removed from xbyak.h, so add it explicitly if you need it.
- support exception-less mode see. [Exception-less mode](#exception-less-mode)
- `XBYAK_USE_MMAP_ALLOCATOR` will be defined on Linux/macOS unless `XBYAK_DONT_USE_MMAP_ALLOCATOR` is defined.

View File

@ -1,5 +1,5 @@
C++用x86(IA-32), x64(AMD64, x86-64) JITアセンブラ Xbyak 5.941
C++用x86(IA-32), x64(AMD64, x86-64) JITアセンブラ Xbyak 5.95
-----------------------------------------------------------------------------
◎概要
@ -34,6 +34,7 @@ xbyak_bin2hex.h
Linuxではmake installで/usr/local/include/xbyakにコピーされます。
-----------------------------------------------------------------------------
◎下位互換性の破れ
* push byte, immまたはpush word, immが下位8bit, 16bitにキャストした値を使うように変更。
* (Windows) `<winsock2.h>`をincludeしなくなったので必要なら明示的にincludeしてください。
* XBYAK_USE_MMAP_ALLOCATORがデフォルトで有効になりました。従来の方式にする場合はXBYAK_DONT_USE_MMAP_ALLOCATORを定義してください。
* Xbyak::Errorの型をenumからclassに変更

View File

@ -1145,6 +1145,33 @@ class Test {
put("pop", REG32|MEM32);
#endif
}
void putPushPop8_16() const
{
const struct {
int b;
uint32_t v;
} tbl[] = {
{ 8, 0x7f },
{ 8, 0x80 },
{ 8, 0xff },
{ 8, 0x100 },
{ 8, 0x12345 },
{ 16, 0x7fff },
{ 16, 0x8000 },
{ 16, 0xffff },
{ 16, 0x10000 },
{ 16, 0x12345 },
};
for (size_t i = 0; i < NUM_OF_ARRAY(tbl); i++) {
const char *b = tbl[i].b == 8 ? "byte" : "word";
uint32_t v = tbl[i].v;
if (isXbyak_) {
printf("push(%s, 0x%x);dump();\n", b, v);
} else {
printf("push %s 0x%x\n", b, v);
}
}
}
void putTest() const
{
const char *p = "test";
@ -2496,6 +2523,7 @@ public:
separateFunc();
putSSE4_2();
putSeg(); // same behavior as yasm for mov rax, cx
putPushPop8_16();
#else
putSIMPLE();
putReg1();

View File

@ -126,7 +126,7 @@ namespace Xbyak {
enum {
DEFAULT_MAX_CODE_SIZE = 4096,
VERSION = 0x5941 /* 0xABCD = A.BC(D) */
VERSION = 0x5950 /* 0xABCD = A.BC(D) */
};
#ifndef MIE_INTEGER_TYPE_DEFINED
@ -2433,9 +2433,9 @@ public:
void pop(const Operand& op) { opPushPop(op, 0x8F, 0, 0x58); }
void push(const AddressFrame& af, uint32 imm)
{
if (af.bit_ == 8 && inner::IsInDisp8(imm)) {
if (af.bit_ == 8) {
db(0x6A); db(imm);
} else if (af.bit_ == 16 && isInDisp16(imm)) {
} else if (af.bit_ == 16) {
db(0x66); db(0x68); dw(imm);
} else {
db(0x68); dd(imm);

View File

@ -1,4 +1,4 @@
const char *getVersionString() const { return "5.941"; }
const char *getVersionString() const { return "5.95"; }
void adc(const Operand& op, uint32 imm) { opRM_I(op, imm, 0x10, 2); }
void adc(const Operand& op1, const Operand& op2) { opRM_RM(op1, op2, 0x10); }
void adcx(const Reg32e& reg, const Operand& op) { opGen(reg, op, 0xF6, 0x66, isREG32_REG32orMEM, NONE, 0x38); }