This commit is contained in:
MITSUNARI Shigeo 2022-01-28 10:57:21 +09:00
parent 4d9906a94d
commit 82e0deb8ab
9 changed files with 31 additions and 7 deletions

View File

@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 2.6...3.0.2)
project(xbyak LANGUAGES CXX VERSION 6.01)
project(xbyak LANGUAGES CXX VERSION 6.02)
file(GLOB headers xbyak/*.h)

View File

@ -5,7 +5,7 @@
project(
'xbyak',
'cpp',
version: '6.01',
version: '6.02',
license: 'BSD-3-Clause',
default_options: 'b_ndebug=if-release'
)

View File

@ -1,6 +1,6 @@
[![Build Status](https://github.com/herumi/xbyak/actions/workflows/main.yml/badge.svg)](https://github.com/herumi/xbyak/actions/workflows/main.yml)
# Xbyak 6.01 ; JIT assembler for x86(IA32), x64(AMD64, x86-64) by C++
#lXbyak 6.02 ; JIT assembler for x86(IA32), x64(AMD64, x86-64) by C++
## Abstract
@ -19,6 +19,8 @@ Use `and_()`, `or_()`, ... instead of `and()`, `or()`.
If you want to use them, then specify `-fno-operator-names` option to gcc/clang.
### News
- strictly check address offset disp32 in a signed 32-bit integer. e.g., `ptr[(void*)0xffffffff]` causes an error.
- define `XBYAK_OLD_DISP_CHECK` if you need an old check, but the option will be remoevd.
- add `jmp(mem, T_FAR)`, `call(mem, T_FAR)` `retf()` for far absolute indirect jump.
- vnni instructions such as vpdpbusd supports vex encoding.
- (break backward compatibility) `push(byte, imm)` (resp. `push(word, imm)`) forces to cast `imm` to 8(resp. 16) bit.
@ -452,6 +454,7 @@ The status will not be changed automatically, then you should reset it by `Xbyak
* define **XBYAK_UNDEF_JNL** if Bessel function jnl is defined as macro.
* define **XBYAK_NO_EXCEPTION** for a compiler option `-fno-exceptions`.
* define **XBYAK_USE_MEMFD** on Linux then /proc/self/maps shows the area used by xbyak.
* define **XBYAK_OLD_DISP_CHECK** if the old disp check is necessary (deprecated in the future).
## Sample

View File

@ -1,5 +1,5 @@
C++用x86(IA-32), x64(AMD64, x86-64) JITアセンブラ Xbyak 6.01
C++用x86(IA-32), x64(AMD64, x86-64) JITアセンブラ Xbyak 6.02
-----------------------------------------------------------------------------
◎概要

View File

@ -93,7 +93,7 @@ void genAddress(bool isJIT, const char regTbl[][5], size_t regTblNum)
}
if (isFirst) {
if (isJIT) printf("(void*)");
printf("0x%08X", disp);
printf("%d", disp);
} else {
if (disp >= 0) {
putchar('+');

View File

@ -1269,6 +1269,10 @@ class Test {
put("mov", REG64, "0x12345678", "0x12345678");
put("mov", REG64, "0xffffffff12345678LL", "0xffffffff12345678");
put("mov", REG32e|REG16|REG8|RAX|EAX|AX|AL, IMM);
put("mov", EAX, "ptr[(void*)-1]", "[-1]");
put("mov", EAX, "ptr[(void*)0x7fffffff]", "[0x7fffffff]");
put("mov", EAX, "ptr[(void*)0xffffffffffffffff]", "[0xffffffffffffffff]");
}
void putEtc() const
{

View File

@ -79,6 +79,17 @@ CYBOZU_TEST_AUTO(mov_const)
CYBOZU_TEST_NO_EXCEPTION(mov(af[eax], v));
}
}
#ifdef XBYAK64
CYBOZU_TEST_NO_EXCEPTION(mov(rax, ptr[(void*)0x7fffffff]));
CYBOZU_TEST_EXCEPTION(mov(rax, ptr[(void*)0x17fffffff]), Xbyak::Error);
#ifdef XBYAK_OLD_DISP_CHECK
CYBOZU_TEST_NO_EXCEPTION(mov(rax, ptr[(void*)0x80000000]));
CYBOZU_TEST_NO_EXCEPTION(mov(rax, ptr[(void*)0xffffffff]));
#else
CYBOZU_TEST_EXCEPTION(mov(rax, ptr[(void*)0x80000000]), Xbyak::Error);
CYBOZU_TEST_EXCEPTION(mov(rax, ptr[(void*)0xffffffff]), Xbyak::Error);
#endif
#endif
}
} code;
}

View File

@ -142,7 +142,7 @@ namespace Xbyak {
enum {
DEFAULT_MAX_CODE_SIZE = 4096,
VERSION = 0x6010 /* 0xABCD = A.BC(D) */
VERSION = 0x6020 /* 0xABCD = A.BC(D) */
};
#ifndef MIE_INTEGER_TYPE_DEFINED
@ -1786,9 +1786,15 @@ private:
{
uint64_t disp64 = e.getDisp();
#ifdef XBYAK64
#ifdef XBYAK_OLD_DISP_CHECK
// treat 0xffffffff as 0xffffffffffffffff
uint64_t high = disp64 >> 32;
if (high != 0 && high != 0xFFFFFFFF) XBYAK_THROW(ERR_OFFSET_IS_TOO_BIG)
#else
// displacement should be a signed 32-bit value, so also check sign bit
uint64_t high = disp64 >> 31;
if (high != 0 && high != 0x1FFFFFFFF) XBYAK_THROW(ERR_OFFSET_IS_TOO_BIG)
#endif
#endif
uint32_t disp = static_cast<uint32_t>(disp64);
const Reg& base = e.getBase();

View File

@ -1,4 +1,4 @@
const char *getVersionString() const { return "6.01"; }
const char *getVersionString() const { return "6.02"; }
void adc(const Operand& op, uint32_t 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); }