From fef96c125a3d415a58cbecd8169751cfe519e22f Mon Sep 17 00:00:00 2001 From: scribam Date: Sun, 22 Mar 2020 10:08:05 +0100 Subject: [PATCH] deps: Update xbyak to version 5.891 --- core/core.mk | 2 +- core/deps/xbyak/.travis.yml | 12 + core/deps/xbyak/CMakeLists.txt | 6 + core/deps/xbyak/COPYRIGHT | 94 +- core/deps/xbyak/Makefile | 24 + core/deps/xbyak/readme.md | 577 +++ core/deps/xbyak/readme.txt | 534 +++ core/deps/xbyak/sample/Makefile | 113 + core/deps/xbyak/sample/bf.cpp | 211 + core/deps/xbyak/sample/bf.vcxproj | 228 ++ core/deps/xbyak/sample/calc.cpp | 229 ++ core/deps/xbyak/sample/calc.vcxproj | 228 ++ core/deps/xbyak/sample/calc2.cpp | 302 ++ core/deps/xbyak/sample/echo.bf | 5 + core/deps/xbyak/sample/fizzbuzz.bf | 19 + core/deps/xbyak/sample/hello.bf | 3 + core/deps/xbyak/sample/jmp_table.cpp | 128 + core/deps/xbyak/sample/memfunc.cpp | 111 + core/deps/xbyak/sample/profiler.cpp | 90 + core/deps/xbyak/sample/protect-re.cpp | 70 + core/deps/xbyak/sample/quantize.cpp | 229 ++ core/deps/xbyak/sample/quantize.vcxproj | 228 ++ core/deps/xbyak/sample/stackframe.cpp | 29 + core/deps/xbyak/sample/static_buf.cpp | 45 + core/deps/xbyak/sample/test0.cpp | 190 + core/deps/xbyak/sample/test0.vcxproj | 228 ++ core/deps/xbyak/sample/test_util.cpp | 125 + core/deps/xbyak/sample/test_util.vcxproj | 228 ++ core/deps/xbyak/sample/toyvm.cpp | 380 ++ core/deps/xbyak/sample/toyvm.vcxproj | 228 ++ core/deps/xbyak/test/Makefile | 85 + core/deps/xbyak/test/Makefile.win | 14 + core/deps/xbyak/test/a.bat | 9 + core/deps/xbyak/test/address.cpp | 155 + core/deps/xbyak/test/bad_address.cpp | 28 + core/deps/xbyak/test/cvt_test.cpp | 151 + core/deps/xbyak/test/cybozu/inttype.hpp | 163 + core/deps/xbyak/test/cybozu/test.hpp | 373 ++ core/deps/xbyak/test/jmp.cpp | 1380 +++++++ core/deps/xbyak/test/jmp.sln | 20 + core/deps/xbyak/test/jmp.vcproj | 195 + core/deps/xbyak/test/lib.h | 63 + core/deps/xbyak/test/lib_min.cpp | 51 + core/deps/xbyak/test/lib_run.cpp | 9 + core/deps/xbyak/test/lib_test.cpp | 13 + core/deps/xbyak/test/make_512.cpp | 2200 +++++++++++ core/deps/xbyak/test/make_nm.cpp | 3439 +++++++++++++++++ core/deps/xbyak/test/misc.cpp | 724 ++++ core/deps/xbyak/test/mprotect_test.cpp | 37 + core/deps/xbyak/test/nm_frame.cpp | 39 + core/deps/xbyak/test/normalize_prefix.cpp | 45 + core/deps/xbyak/test/readme.txt | 6 + core/deps/xbyak/test/rip-label-imm.cpp | 88 + core/deps/xbyak/test/set_opt.bat | 2 + core/deps/xbyak/test/sf_test.cpp | 416 ++ core/deps/xbyak/test/state.pptx | Bin 0 -> 68370 bytes core/deps/xbyak/test/test_address.bat | 37 + core/deps/xbyak/test/test_address.sh | 41 + core/deps/xbyak/test/test_all.bat | 8 + core/deps/xbyak/test/test_avx.bat | 42 + core/deps/xbyak/test/test_avx.sh | 43 + core/deps/xbyak/test/test_avx512.bat | 31 + core/deps/xbyak/test/test_avx512.sh | 32 + core/deps/xbyak/test/test_avx_all.bat | 13 + core/deps/xbyak/test/test_jmp.bat | 4 + core/deps/xbyak/test/test_misc.bat | 4 + core/deps/xbyak/test/test_mmx.cpp | 78 + core/deps/xbyak/test/test_nm.bat | 42 + core/deps/xbyak/test/test_nm.sh | 49 + core/deps/xbyak/test/test_nm_all.bat | 11 + core/deps/xbyak/xbyak.sln | 90 + core/deps/xbyak/{ => xbyak}/xbyak.h | 328 +- core/deps/xbyak/{ => xbyak}/xbyak_bin2hex.h | 0 core/deps/xbyak/{ => xbyak}/xbyak_mnemonic.h | 192 +- core/deps/xbyak/{ => xbyak}/xbyak_util.h | 380 +- core/hw/aica/dsp_x64.cpp | 3 +- core/rec-x64/rec_x64.cpp | 4 +- core/rec-x64/x64_regalloc.h | 2 +- .../reicast-osx.xcodeproj/project.pbxproj | 8 +- 79 files changed, 15766 insertions(+), 277 deletions(-) create mode 100644 core/deps/xbyak/.travis.yml create mode 100644 core/deps/xbyak/CMakeLists.txt create mode 100644 core/deps/xbyak/Makefile create mode 100644 core/deps/xbyak/readme.md create mode 100644 core/deps/xbyak/readme.txt create mode 100644 core/deps/xbyak/sample/Makefile create mode 100644 core/deps/xbyak/sample/bf.cpp create mode 100644 core/deps/xbyak/sample/bf.vcxproj create mode 100644 core/deps/xbyak/sample/calc.cpp create mode 100644 core/deps/xbyak/sample/calc.vcxproj create mode 100644 core/deps/xbyak/sample/calc2.cpp create mode 100644 core/deps/xbyak/sample/echo.bf create mode 100644 core/deps/xbyak/sample/fizzbuzz.bf create mode 100644 core/deps/xbyak/sample/hello.bf create mode 100644 core/deps/xbyak/sample/jmp_table.cpp create mode 100644 core/deps/xbyak/sample/memfunc.cpp create mode 100644 core/deps/xbyak/sample/profiler.cpp create mode 100644 core/deps/xbyak/sample/protect-re.cpp create mode 100644 core/deps/xbyak/sample/quantize.cpp create mode 100644 core/deps/xbyak/sample/quantize.vcxproj create mode 100644 core/deps/xbyak/sample/stackframe.cpp create mode 100644 core/deps/xbyak/sample/static_buf.cpp create mode 100644 core/deps/xbyak/sample/test0.cpp create mode 100644 core/deps/xbyak/sample/test0.vcxproj create mode 100644 core/deps/xbyak/sample/test_util.cpp create mode 100644 core/deps/xbyak/sample/test_util.vcxproj create mode 100644 core/deps/xbyak/sample/toyvm.cpp create mode 100644 core/deps/xbyak/sample/toyvm.vcxproj create mode 100644 core/deps/xbyak/test/Makefile create mode 100644 core/deps/xbyak/test/Makefile.win create mode 100644 core/deps/xbyak/test/a.bat create mode 100644 core/deps/xbyak/test/address.cpp create mode 100644 core/deps/xbyak/test/bad_address.cpp create mode 100644 core/deps/xbyak/test/cvt_test.cpp create mode 100644 core/deps/xbyak/test/cybozu/inttype.hpp create mode 100644 core/deps/xbyak/test/cybozu/test.hpp create mode 100644 core/deps/xbyak/test/jmp.cpp create mode 100644 core/deps/xbyak/test/jmp.sln create mode 100644 core/deps/xbyak/test/jmp.vcproj create mode 100644 core/deps/xbyak/test/lib.h create mode 100644 core/deps/xbyak/test/lib_min.cpp create mode 100644 core/deps/xbyak/test/lib_run.cpp create mode 100644 core/deps/xbyak/test/lib_test.cpp create mode 100644 core/deps/xbyak/test/make_512.cpp create mode 100644 core/deps/xbyak/test/make_nm.cpp create mode 100644 core/deps/xbyak/test/misc.cpp create mode 100644 core/deps/xbyak/test/mprotect_test.cpp create mode 100644 core/deps/xbyak/test/nm_frame.cpp create mode 100644 core/deps/xbyak/test/normalize_prefix.cpp create mode 100644 core/deps/xbyak/test/readme.txt create mode 100644 core/deps/xbyak/test/rip-label-imm.cpp create mode 100644 core/deps/xbyak/test/set_opt.bat create mode 100644 core/deps/xbyak/test/sf_test.cpp create mode 100644 core/deps/xbyak/test/state.pptx create mode 100644 core/deps/xbyak/test/test_address.bat create mode 100644 core/deps/xbyak/test/test_address.sh create mode 100644 core/deps/xbyak/test/test_all.bat create mode 100644 core/deps/xbyak/test/test_avx.bat create mode 100644 core/deps/xbyak/test/test_avx.sh create mode 100644 core/deps/xbyak/test/test_avx512.bat create mode 100644 core/deps/xbyak/test/test_avx512.sh create mode 100644 core/deps/xbyak/test/test_avx_all.bat create mode 100644 core/deps/xbyak/test/test_jmp.bat create mode 100644 core/deps/xbyak/test/test_misc.bat create mode 100644 core/deps/xbyak/test/test_mmx.cpp create mode 100644 core/deps/xbyak/test/test_nm.bat create mode 100644 core/deps/xbyak/test/test_nm.sh create mode 100644 core/deps/xbyak/test/test_nm_all.bat create mode 100644 core/deps/xbyak/xbyak.sln rename core/deps/xbyak/{ => xbyak}/xbyak.h (90%) rename core/deps/xbyak/{ => xbyak}/xbyak_bin2hex.h (100%) rename core/deps/xbyak/{ => xbyak}/xbyak_mnemonic.h (95%) rename core/deps/xbyak/{ => xbyak}/xbyak_util.h (71%) diff --git a/core/core.mk b/core/core.mk index 71a82cfcd..8fd2caa09 100755 --- a/core/core.mk +++ b/core/core.mk @@ -139,7 +139,7 @@ endif RZDCY_CFLAGS += -I$(RZDCY_SRC_DIR) -I$(RZDCY_SRC_DIR)/rend/gles -I$(RZDCY_SRC_DIR)/deps \ -I$(RZDCY_SRC_DIR)/deps/vixl -I$(RZDCY_SRC_DIR)/khronos -I$(RZDCY_SRC_DIR)/deps/glslang \ - -I$(RZDCY_SRC_DIR)/deps/glm + -I$(RZDCY_SRC_DIR)/deps/glm -I$(RZDCY_SRC_DIR)/deps/xbyak ifdef USE_MODEM RZDCY_CFLAGS += -DENABLE_MODEM -I$(RZDCY_SRC_DIR)/deps/picotcp/include -I$(RZDCY_SRC_DIR)/deps/picotcp/modules diff --git a/core/deps/xbyak/.travis.yml b/core/deps/xbyak/.travis.yml new file mode 100644 index 000000000..4de8772d7 --- /dev/null +++ b/core/deps/xbyak/.travis.yml @@ -0,0 +1,12 @@ +sudo: true +dist: bionic +language: cpp +compiler: + - gcc + - clang +addons: + apt: + packages: + - nasm yasm g++-multilib tcsh +script: + - make test diff --git a/core/deps/xbyak/CMakeLists.txt b/core/deps/xbyak/CMakeLists.txt new file mode 100644 index 000000000..be131b144 --- /dev/null +++ b/core/deps/xbyak/CMakeLists.txt @@ -0,0 +1,6 @@ +cmake_minimum_required(VERSION 2.6) +project(xbyak) + +file(GLOB headers xbyak/*.h) +install(FILES ${headers} DESTINATION include/xbyak) + diff --git a/core/deps/xbyak/COPYRIGHT b/core/deps/xbyak/COPYRIGHT index 78d3140b8..66b6ea55d 100644 --- a/core/deps/xbyak/COPYRIGHT +++ b/core/deps/xbyak/COPYRIGHT @@ -1,47 +1,47 @@ - -Copyright (c) 2007 MITSUNARI Shigeo -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. -Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. -Neither the name of the copyright owner nor the names of its contributors may -be used to endorse or promote products derived from this software without -specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF -THE POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------------ -ソースコード形式かバイナリ形式か、変更するかしないかを問わず、以下の条件を満た -す場合に限り、再頒布および使用が許可されます。 - -ソースコードを再頒布する場合、上記の著作権表示、本条件一覧、および下記免責条項 -を含めること。 -バイナリ形式で再頒布する場合、頒布物に付属のドキュメント等の資料に、上記の著作 -権表示、本条件一覧、および下記免責条項を含めること。 -書面による特別の許可なしに、本ソフトウェアから派生した製品の宣伝または販売促進 -に、著作権者の名前またはコントリビューターの名前を使用してはならない。 -本ソフトウェアは、著作権者およびコントリビューターによって「現状のまま」提供さ -れており、明示黙示を問わず、商業的な使用可能性、および特定の目的に対する適合性 -に関する暗黙の保証も含め、またそれに限定されない、いかなる保証もありません。 -著作権者もコントリビューターも、事由のいかんを問わず、 損害発生の原因いかんを -問わず、かつ責任の根拠が契約であるか厳格責任であるか(過失その他の)不法行為で -あるかを問わず、仮にそのような損害が発生する可能性を知らされていたとしても、 -本ソフトウェアの使用によって発生した(代替品または代用サービスの調達、使用の -喪失、データの喪失、利益の喪失、業務の中断も含め、またそれに限定されない)直接 -損害、間接損害、偶発的な損害、特別損害、懲罰的損害、または結果損害について、 -一切責任を負わないものとします。 + +Copyright (c) 2007 MITSUNARI Shigeo +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. +Neither the name of the copyright owner nor the names of its contributors may +be used to endorse or promote products derived from this software without +specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. +----------------------------------------------------------------------------- +ソースコード形式かバイナリ形式か、変更するかしないかを問わず、以下の条件を満た +す場合に限り、再頒布および使用が許可されます。 + +ソースコードを再頒布する場合、上記の著作権表示、本条件一覧、および下記免責条項 +を含めること。 +バイナリ形式で再頒布する場合、頒布物に付属のドキュメント等の資料に、上記の著作 +権表示、本条件一覧、および下記免責条項を含めること。 +書面による特別の許可なしに、本ソフトウェアから派生した製品の宣伝または販売促進 +に、著作権者の名前またはコントリビューターの名前を使用してはならない。 +本ソフトウェアは、著作権者およびコントリビューターによって「現状のまま」提供さ +れており、明示黙示を問わず、商業的な使用可能性、および特定の目的に対する適合性 +に関する暗黙の保証も含め、またそれに限定されない、いかなる保証もありません。 +著作権者もコントリビューターも、事由のいかんを問わず、 損害発生の原因いかんを +問わず、かつ責任の根拠が契約であるか厳格責任であるか(過失その他の)不法行為で +あるかを問わず、仮にそのような損害が発生する可能性を知らされていたとしても、 +本ソフトウェアの使用によって発生した(代替品または代用サービスの調達、使用の +喪失、データの喪失、利益の喪失、業務の中断も含め、またそれに限定されない)直接 +損害、間接損害、偶発的な損害、特別損害、懲罰的損害、または結果損害について、 +一切責任を負わないものとします。 diff --git a/core/deps/xbyak/Makefile b/core/deps/xbyak/Makefile new file mode 100644 index 000000000..a7850a227 --- /dev/null +++ b/core/deps/xbyak/Makefile @@ -0,0 +1,24 @@ +PREFIX=/usr/local +INSTALL_DIR=$(PREFIX)/include/xbyak + +all: + $(MAKE) -C sample + +clean: + $(MAKE) -C sample clean + +install: + mkdir -p $(INSTALL_DIR) + cp -pR xbyak/*.h $(INSTALL_DIR) + +uninstall: + rm -i $(INSTALL_DIR)/*.h + rmdir $(INSTALL_DIR) + +update: + $(MAKE) -C gen + +test: + $(MAKE) -C test test + +.PHONY: test update diff --git a/core/deps/xbyak/readme.md b/core/deps/xbyak/readme.md new file mode 100644 index 000000000..5bffe3ae0 --- /dev/null +++ b/core/deps/xbyak/readme.md @@ -0,0 +1,577 @@ +[![Build Status](https://travis-ci.org/herumi/xbyak.png)](https://travis-ci.org/herumi/xbyak) + +# Xbyak 5.891 ; JIT assembler for x86(IA32), x64(AMD64, x86-64) by C++ + +## Abstract + +Xbyak is a C++ header library that enables dynamically to assemble x86(IA32), x64(AMD64, x86-64) mnemonic. + +## Feature +* header file only +* Intel/MASM like syntax +* fully support AVX-512 + +**Note**: +Use `and_()`, `or_()`, ... instead of `and()`, `or()`. +If you want to use them, then specify `-fno-operator-names` option to gcc/clang. + +### Supported OS + +* Windows Xp, Vista, Windows 7, Windows 10(32bit, 64bit) +* Linux(32bit, 64bit) +* Intel macOS + +### Supported Compilers + +Almost C++03 or later compilers for x86/x64 such as Visual Studio, g++, clang++, Intel C++ compiler and g++ on mingw/cygwin. + +## Install + +The following files are necessary. Please add the path to your compile directory. + +* xbyak.h +* xbyak_mnemonic.h +* xbyak_util.h + +Linux: +``` +make install +``` + +These files are copied into `/usr/local/include/xbyak`. + +## How to use it + +Inherit `Xbyak::CodeGenerator` class and make the class method. +``` +#include + +struct Code : Xbyak::CodeGenerator { + Code(int x) + { + mov(eax, x); + ret(); + } +}; +``` +Or you can pass the instance of CodeGenerator without inheriting. +``` +void genCode(Xbyak::CodeGenerator& code, int x) { + using namespace Xbyak::util; + code.mov(eax, x); + code.ret(); +} +``` + +Make an instance of the class and get the function +pointer by calling `getCode()` and call it. +``` +Code c(5); +int (*f)() = c.getCode(); +printf("ret=%d\n", f()); // ret = 5 +``` + +## Syntax +Similar to MASM/NASM syntax with parentheses. + +``` +NASM Xbyak +mov eax, ebx --> mov(eax, ebx); +inc ecx inc(ecx); +ret --> ret(); +``` + +## Addressing +Use `qword`, `dword`, `word` and `byte` if it is necessary to specify the size of memory, +otherwise use `ptr`. + +``` +(ptr|qword|dword|word|byte) [base + index * (1|2|4|8) + displacement] + [rip + 32bit disp] ; x64 only + +NASM Xbyak +mov eax, [ebx+ecx] --> mov(eax, ptr [ebx+ecx]); +mov al, [ebx+ecx] --> mov(al, ptr [ebx + ecx]); +test byte [esp], 4 --> test(byte [esp], 4); +inc qword [rax] --> inc(qword [rax]); +``` +**Note**: `qword`, ... are member variables, then don't use `dword` as unsigned int type. + +### How to use Selector (Segment Register) +``` +mov eax, [fs:eax] --> putSeg(fs); + mov(eax, ptr [eax]); +mov ax, cs --> mov(ax, cs); +``` +**Note**: Segment class is not derived from `Operand`. + +## AVX + +``` +vaddps(xmm1, xmm2, xmm3); // xmm1 <- xmm2 + xmm3 +vaddps(xmm2, xmm3, ptr [rax]); // use ptr to access memory +vgatherdpd(xmm1, ptr [ebp + 256 + xmm2*4], xmm3); +``` + +**Note**: +If `XBYAK_ENABLE_OMITTED_OPERAND` is defined, then you can use two operand version for backward compatibility. +But the newer version will not support it. +``` +vaddps(xmm2, xmm3); // xmm2 <- xmm2 + xmm3 +``` + +## AVX-512 + +``` +vaddpd zmm2, zmm5, zmm30 --> vaddpd(zmm2, zmm5, zmm30); +vaddpd xmm30, xmm20, [rax] --> vaddpd(xmm30, xmm20, ptr [rax]); +vaddps xmm30, xmm20, [rax] --> vaddps(xmm30, xmm20, ptr [rax]); +vaddpd zmm2{k5}, zmm4, zmm2 --> vaddpd(zmm2 | k5, zmm4, zmm2); +vaddpd zmm2{k5}{z}, zmm4, zmm2 --> vaddpd(zmm2 | k5 | T_z, zmm4, zmm2); +vaddpd zmm2{k5}{z}, zmm4, zmm2,{rd-sae} --> vaddpd(zmm2 | k5 | T_z, zmm4, zmm2 | T_rd_sae); + vaddpd(zmm2 | k5 | T_z | T_rd_sae, zmm4, zmm2); // the position of `|` is arbitrary. +vcmppd k4{k3}, zmm1, zmm2, {sae}, 5 --> vcmppd(k4 | k3, zmm1, zmm2 | T_sae, 5); + +vaddpd xmm1, xmm2, [rax+256] --> vaddpd(xmm1, xmm2, ptr [rax+256]); +vaddpd xmm1, xmm2, [rax+256]{1to2} --> vaddpd(xmm1, xmm2, ptr_b [rax+256]); +vaddpd ymm1, ymm2, [rax+256]{1to4} --> vaddpd(ymm1, ymm2, ptr_b [rax+256]); +vaddpd zmm1, zmm2, [rax+256]{1to8} --> vaddpd(zmm1, zmm2, ptr_b [rax+256]); +vaddps zmm1, zmm2, [rax+rcx*8+8]{1to16} --> vaddps(zmm1, zmm2, ptr_b [rax+rcx*8+8]); +vmovsd [rax]{k1}, xmm4 --> vmovsd(ptr [rax] | k1, xmm4); + +vcvtpd2dq xmm16, oword [eax+33] --> vcvtpd2dq(xmm16, xword [eax+33]); // use xword for m128 instead of oword + vcvtpd2dq(xmm16, ptr [eax+33]); // default xword +vcvtpd2dq xmm21, [eax+32]{1to2} --> vcvtpd2dq(xmm21, ptr_b [eax+32]); +vcvtpd2dq xmm0, yword [eax+33] --> vcvtpd2dq(xmm0, yword [eax+33]); // use yword for m256 +vcvtpd2dq xmm19, [eax+32]{1to4} --> vcvtpd2dq(xmm19, yword_b [eax+32]); // use yword_b to broadcast + +vfpclassps k5{k3}, zword [rax+64], 5 --> vfpclassps(k5|k3, zword [rax+64], 5); // specify m512 +vfpclasspd k5{k3}, [rax+64]{1to2}, 5 --> vfpclasspd(k5|k3, xword_b [rax+64], 5); // broadcast 64-bit to 128-bit +vfpclassps k5{k3}, [rax+64]{1to4}, 5 --> vfpclassps(k5|k3, yword_b [rax+64], 5); // broadcast 64-bit to 256-bit +``` +### Remark +* `k1`, ..., `k7` are opmask registers. +* use `| T_z`, `| T_sae`, `| T_rn_sae`, `| T_rd_sae`, `| T_ru_sae`, `| T_rz_sae` instead of `,{z}`, `,{sae}`, `,{rn-sae}`, `,{rd-sae}`, `,{ru-sae}`, `,{rz-sae}` respectively. +* `k4 | k3` is different from `k3 | k4`. +* use `ptr_b` for broadcast `{1toX}`. X is automatically determined. +* specify `xword`/`yword`/`zword(_b)` for m128/m256/m512 if necessary. + +## Label +Two kinds of Label are supported. (String literal and Label class). + +### String literal +``` +L("L1"); + jmp("L1"); + + jmp("L2"); + ... + a few mnemonics (8-bit displacement jmp) + ... +L("L2"); + + jmp("L3", T_NEAR); + ... + a lot of mnemonics (32-bit displacement jmp) + ... +L("L3"); +``` + +* Call `hasUndefinedLabel()` to verify your code has no undefined label. +* you can use a label for immediate value of mov like as `mov(eax, "L2")`. + +### Support `@@`, `@f`, `@b` like MASM + +``` +L("@@"); // + jmp("@b"); // jmp to + jmp("@f"); // jmp to +L("@@"); // + jmp("@b"); // jmp to + mov(eax, "@b"); + jmp(eax); // jmp to +``` + +### Local label + +Label symbols beginning with a period between `inLocalLabel()` and `outLocalLabel()` +are treated as a local label. +`inLocalLabel()` and `outLocalLabel()` can be nested. + +``` +void func1() +{ + inLocalLabel(); + L(".lp"); // ; local label + ... + jmp(".lp"); // jmp to + L("aaa"); // global label + outLocalLabel(); + + inLocalLabel(); + L(".lp"); // ; local label + func1(); + jmp(".lp"); // jmp to + inLocalLabel(); + jmp("aaa"); // jmp to +} +``` + +### short and long jump +Xbyak deals with jump mnemonics of an undefined label as short jump if no type is specified. +So if the size between jmp and label is larger than 127 byte, then xbyak will cause an error. + +``` +jmp("short-jmp"); // short jmp +// small code +L("short-jmp"); + +jmp("long-jmp"); +// long code +L("long-jmp"); // throw exception +``` +Then specify T_NEAR for jmp. +``` +jmp("long-jmp", T_NEAR); // long jmp +// long code +L("long-jmp"); +``` +Or call `setDefaultJmpNEAR(true);` once, then the default type is set to T_NEAR. +``` +jmp("long-jmp"); // long jmp +// long code +L("long-jmp"); +``` + +### Label class + +`L()` and `jxx()` support Label class. + +``` + Xbyak::Label label1, label2; +L(label1); + ... + jmp(label1); + ... + jmp(label2); + ... +L(label2); +``` + +Use `putL` for jmp table +``` + Label labelTbl, L0, L1, L2; + mov(rax, labelTbl); + // rdx is an index of jump table + jmp(ptr [rax + rdx * sizeof(void*)]); +L(labelTbl); + putL(L0); + putL(L1); + putL(L2); +L(L0); + .... +L(L1); + .... +``` + +`assignL(dstLabel, srcLabel)` binds dstLabel with srcLabel. + +``` + Label label2; + Label label1 = L(); // make label1 ; same to Label label1; L(label1); + ... + jmp(label2); // label2 is not determined here + ... + assignL(label2, label1); // label2 <- label1 +``` +The `jmp` in the above code jumps to label1 assigned by `assignL`. + +**Note**: +* srcLabel must be used in `L()`. +* dstLabel must not be used in `L()`. + +`Label::getAddress()` returns the address specified by the label instance and 0 if not specified. +``` +// not AutoGrow mode +Label label; +assert(label.getAddress() == 0); +L(label); +assert(label.getAddress() == getCurr()); +``` + +### Rip ; relative addressing +``` +Label label; +mov(eax, ptr [rip + label]); // eax = 4 +... + +L(label); +dd(4); +``` +``` +int x; +... + mov(eax, ptr[rip + &x]); // throw exception if the difference between &x and current position is larger than 2GiB +``` + +## Code size +The default max code size is 4096 bytes. +Specify the size in constructor of `CodeGenerator()` if necessary. + +``` +class Quantize : public Xbyak::CodeGenerator { +public: + Quantize() + : CodeGenerator(8192) + { + } + ... +}; +``` + +## User allocated memory + +You can make jit code on prepaired memory. + +Call `setProtectModeRE` yourself to change memory mode if using the prepaired memory. + +``` +uint8_t alignas(4096) buf[8192]; // C++11 or later + +struct Code : Xbyak::CodeGenerator { + Code() : Xbyak::CodeGenerator(sizeof(buf), buf) + { + mov(rax, 123); + ret(); + } +}; + +int main() +{ + Code c; + c.setProtectModeRE(); // set memory to Read/Exec + printf("%d\n", c.getCode()()); +} +``` + +**Note**: See [sample/test0.cpp](sample/test0.cpp). + +### AutoGrow + +The memory region for jit is automatically extended if necessary when `AutoGrow` is specified in a constructor of `CodeGenerator`. + +Call `ready()` or `readyRE()` before calling `getCode()` to fix jump address. +``` +struct Code : Xbyak::CodeGenerator { + Code() + : Xbyak::CodeGenerator(, Xbyak::AutoGrow) + { + ... + } +}; +Code c; +// generate code for jit +c.ready(); // mode = Read/Write/Exec +``` + +**Note**: +* Don't use the address returned by `getCurr()` before calling `ready()` because it may be invalid address. + +### Read/Exec mode +Xbyak set Read/Write/Exec mode to memory to run jit code. +If you want to use Read/Exec mode for security, then specify `DontSetProtectRWE` for `CodeGenerator` and +call `setProtectModeRE()` after generating jit code. + +``` +struct Code : Xbyak::CodeGenerator { + Code() + : Xbyak::CodeGenerator(4096, Xbyak::DontSetProtectRWE) + { + mov(eax, 123); + ret(); + } +}; + +Code c; +c.setProtectModeRE(); +... + +``` +Call `readyRE()` instead of `ready()` when using `AutoGrow` mode. +See [protect-re.cpp](sample/protect-re.cpp). + +## Macro + +* **XBYAK32** is defined on 32bit. +* **XBYAK64** is defined on 64bit. +* **XBYAK64_WIN** is defined on 64bit Windows(VC) +* **XBYAK64_GCC** is defined on 64bit gcc, cygwin +* define **XBYAK_USE_OP_NAMES** on gcc with `-fno-operator-names` if you want to use `and()`, .... +* define **XBYAK_ENABLE_OMITTED_OPERAND** if you use omitted destination such as `vaddps(xmm2, xmm3);`(deprecated in the future) +* define **XBYAK_UNDEF_JNL** if Bessel function jnl is defined as macro + +## Sample + +* [test0.cpp](sample/test0.cpp) ; tiny sample (x86, x64) +* [quantize.cpp](sample/quantize.cpp) ; JIT optimized quantization by fast division (x86 only) +* [calc.cpp](sample/calc.cpp) ; assemble and estimate a given polynomial (x86, x64) +* [bf.cpp](sample/bf.cpp) ; JIT brainfuck (x86, x64) + +## License + +modified new BSD License +http://opensource.org/licenses/BSD-3-Clause + +## History +* 2020/Feb/26 ver 5.891 fix typo of type +* 2020/Jan/03 ver 5.89 fix error of vfpclasspd +* 2019/Dec/20 ver 5.88 fix compile error on Windows +* 2019/Dec/19 ver 5.87 add setDefaultJmpNEAR(), which deals with `jmp` of an undefined label as T_NEAR if no type is specified. +* 2019/Dec/13 ver 5.86 [changed] revert to the behavior before v5.84 if -fno-operator-names is defined (and() is available) +* 2019/Dec/07 ver 5.85 append MAP_JIT flag to mmap for macOS mojave or later +* 2019/Nov/29 ver 5.84 [changed] XBYAK_NO_OP_NAMES is defined unless XBYAK_USE_OP_NAMES is defined +* 2019/Oct/12 ver 5.83 exit(1) was removed +* 2019/Sep/23 ver 5.82 support monitorx, mwaitx, clzero (thanks to @MagurosanTeam) +* 2019/Sep/14 ver 5.81 support some generic mnemonics. +* 2019/Aug/01 ver 5.802 fix detection of AVX512_BF16 (thanks to vpirogov) +* 2019/May/27 support vp2intersectd, vp2intersectq (not tested) +* 2019/May/26 ver 5.80 support vcvtne2ps2bf16, vcvtneps2bf16, vdpbf16ps +* 2019/Apr/27 ver 5.79 vcmppd/vcmpps supports ptr_b(thanks to jkopinsky) +* 2019/Apr/15 ver 5.78 rewrite Reg::changeBit() (thanks to MerryMage) +* 2019/Mar/06 ver 5.77 fix number of cores that share LLC cache by densamoilov +* 2019/Jan/17 ver 5.76 add Cpu::getNumCores() by shelleygoel +* 2018/Oct/31 ver 5.751 recover Xbyak::CastTo for compatibility +* 2018/Oct/29 ver 5.75 unlink LabelManager from Label when msg is destroyed +* 2018/Oct/21 ver 5.74 support RegRip +/- int. Xbyak::CastTo is removed +* 2018/Oct/15 util::AddressFrame uses push/pop instead of mov +* 2018/Sep/19 ver 5.73 fix evex encoding of vpslld, vpslldq, vpsllw, etc for (reg, mem, imm8) +* 2018/Sep/19 ver 5.72 fix the encoding of vinsertps for disp8N(Thanks to petercaday) +* 2018/Sep/04 ver 5.71 L() returns a new label instance +* 2018/Aug/27 ver 5.70 support setProtectMode() and DontUseProtect for read/exec setting +* 2018/Aug/24 ver 5.68 fix wrong VSIB encoding with vector index >= 16(thanks to petercaday) +* 2018/Aug/14 ver 5.67 remove mutable in Address ; fix setCacheHierarchy for cloud vm +* 2018/Jul/26 ver 5.661 support mingw64 +* 2018/Jul/24 ver 5.66 add CodeArray::PROTECT_RE to mode of protect() +* 2018/Jun/26 ver 5.65 fix push(qword [mem]) +* 2018/Mar/07 ver 5.64 fix zero division in Cpu() on some cpu +* 2018/Feb/14 ver 5.63 fix Cpu::setCacheHierarchy() and fix EvexModifierZero for clang<3.9(thanks to mgouicem) +* 2018/Feb/13 ver 5.62 Cpu::setCacheHierarchy() by mgouicem and rsdubtso +* 2018/Feb/07 ver 5.61 vmov* supports mem{k}{z}(I forgot it) +* 2018/Jan/24 ver 5.601 add xword, yword, etc. into Xbyak::util namespace +* 2018/Jan/05 ver 5.60 support AVX-512 for Ice lake(319433-030.pdf) +* 2017/Aug/22 ver 5.53 fix mpx encoding, add bnd() prefix +* 2017/Aug/18 ver 5.52 fix align (thanks to MerryMage) +* 2017/Aug/17 ver 5.51 add multi-byte nop and align() uses it(thanks to inolen) +* 2017/Aug/08 ver 5.50 add mpx(thanks to magurosan) +* 2017/Aug/08 ver 5.45 add sha(thanks to magurosan) +* 2017/Aug/08 ver 5.44 add prefetchw(thanks to rsdubtso) +* 2017/Jul/12 ver 5.432 reduce warnings of PVS studio +* 2017/Jul/09 ver 5.431 fix hasRex() (no affect) (thanks to drillsar) +* 2017/May/14 ver 5.43 fix CodeGenerator::resetSize() (thanks to gibbed) +* 2017/May/13 ver 5.42 add movs{b,w,d,q} +* 2017/Jan/26 ver 5.41 add prefetchwt1 and support for scale == 0(thanks to rsdubtso) +* 2016/Dec/14 ver 5.40 add Label::getAddress() method to get the pointer specified by the label +* 2016/Dec/09 ver 5.34 fix handling of negative offsets when encoding disp8N(thanks to rsdubtso) +* 2016/Dec/08 ver 5.33 fix encoding of vpbroadcast{b,w,d,q}, vpinsr{b,w}, vpextr{b,w} for disp8N +* 2016/Dec/01 ver 5.32 rename __xgetbv() to _xgetbv() to support clang for Visual Studio(thanks to freiro) +* 2016/Nov/27 ver 5.31 rename AVX512_4VNNI to AVX512_4VNNIW +* 2016/Nov/27 ver 5.30 add AVX512_4VNNI, AVX512_4FMAPS instructions(thanks to rsdubtso) +* 2016/Nov/26 ver 5.20 add detection of AVX512_4VNNI and AVX512_4FMAPS(thanks to rsdubtso) +* 2016/Nov/20 ver 5.11 lost vptest for ymm(thanks to gregory38) +* 2016/Nov/20 ver 5.10 add addressing [rip+&var] +* 2016/Sep/29 ver 5.03 fix detection ERR_INVALID_OPMASK_WITH_MEMORY(thanks to PVS-Studio) +* 2016/Aug/15 ver 5.02 xbyak does not include xbyak_bin2hex.h +* 2016/Aug/15 ver 5.011 fix detection of version of gcc 5.4 +* 2016/Aug/03 ver 5.01 disable omitted operand +* 2016/Jun/24 ver 5.00 support avx-512 instruction set +* 2016/Jun/13 avx-512 add mask instructions +* 2016/May/05 ver 4.91 add detection of AVX-512 to Xbyak::util::Cpu +* 2016/Mar/14 ver 4.901 comment to ready() function(thanks to skmp) +* 2016/Feb/04 ver 4.90 add jcc(const void *addr); +* 2016/Jan/30 ver 4.89 vpblendvb supports ymm reg(thanks to John Funnell) +* 2016/Jan/24 ver 4.88 lea, cmov supports 16-bit register(thanks to whyisthisfieldhere) +* 2015/Oct/05 ver 4.87 support segment selectors +* 2015/Aug/18 ver 4.86 fix [rip + label] addressing with immediate value(thanks to whyisthisfieldhere) +* 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 +* 2015/Apr/25 ver 4.81 fix the condition to throw exception for setSize(thanks to whyisthisfieldhere) +* 2015/Apr/22 ver 4.80 rip supports label(thanks to whyisthisfieldhere) +* 2015/Jar/28 ver 4.71 support adcx, adox, cmpxchg, rdseed, stac +* 2014/Oct/14 ver 4.70 support MmapAllocator +* 2014/Jun/13 ver 4.62 disable warning of VC2014 +* 2014/May/30 ver 4.61 support bt, bts, btr, btc +* 2014/May/28 ver 4.60 support vcvtph2ps, vcvtps2ph +* 2014/Apr/11 ver 4.52 add detection of rdrand +* 2014/Mar/25 ver 4.51 remove state information of unreferenced labels +* 2014/Mar/16 ver 4.50 support new Label +* 2014/Mar/05 ver 4.40 fix wrong detection of BMI/enhanced rep on VirtualBox +* 2013/Dec/03 ver 4.30 support Reg::cvt8(), cvt16(), cvt32(), cvt64() +* 2013/Oct/16 ver 4.21 label support std::string +* 2013/Jul/30 ver 4.20 [break backward compatibility] split Reg32e class into RegExp(base+index*scale+disp) and Reg32e(means Reg32 or Reg64) +* 2013/Jul/04 ver 4.10 [break backward compatibility] change the type of Xbyak::Error from enum to a class +* 2013/Jun/21 ver 4.02 add putL(LABEL) function to put the address of the label +* 2013/Jun/21 ver 4.01 vpsllw, vpslld, vpsllq, vpsraw, vpsrad, vpsrlw, vpsrld, vpsrlq support (ymm, ymm, xmm). support vpbroadcastb, vpbroadcastw, vpbroadcastd, vpbroadcastq(thanks to Gabest). +* 2013/May/30 ver 4.00 support AVX2, VEX-encoded GPR-instructions +* 2013/Mar/27 ver 3.80 support mov(reg, "label"); +* 2013/Mar/13 ver 3.76 add cqo(), jcxz(), jecxz(), jrcxz() +* 2013/Jan/15 ver 3.75 add setSize() to modify generated code +* 2013/Jan/12 ver 3.74 add CodeGenerator::reset() ; add Allocator::useProtect() +* 2013/Jan/06 ver 3.73 use unordered_map if possible +* 2012/Dec/04 ver 3.72 eax, ebx, ... are member variables of CodeGenerator(revert), Xbyak::util::eax, ... are static const. +* 2012/Nov/17 ver 3.71 and_(), or_(), xor_(), not_() are available if XBYAK_NO_OP_NAMES is not defined. +* 2012/Nov/17 change eax, ebx, ptr and so on in CodeGenerator as static member and alias of them are defined in Xbyak::util. +* 2012/Nov/09 ver 3.70 XBYAK_NO_OP_NAMES macro is added to use and_() instead of and() (thanks to Mattias) +* 2012/Nov/01 ver 3.62 add fwait/fnwait/finit/fninit +* 2012/Nov/01 ver 3.61 add fldcw/fstcw +* 2012/May/03 ver 3.60 change interface of Allocator +* 2012/Mar/23 ver 3.51 fix userPtr mode +* 2012/Mar/19 ver 3.50 support AutoGrow mode +* 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 +* 2011/May/24 ver 3.01 fix typo of OSXSAVE +* 2011/May/23 ver 3.00 add vcmpeqps and so on +* 2011/Feb/16 ver 2.994 beta add vmovq for 32-bit mode(I forgot it) +* 2011/Feb/16 ver 2.993 beta remove cvtReg to avoid thread unsafe +* 2011/Feb/10 ver 2.992 beta support one argument syntax for fadd like nasm +* 2011/Feb/07 ver 2.991 beta fix pextrw reg, xmm, imm(Thanks to Gabest) +* 2011/Feb/04 ver 2.99 beta support AVX +* 2010/Dec/08 ver 2.31 fix ptr [rip + 32bit offset], support rdtscp +* 2010/Oct/19 ver 2.30 support pclmulqdq, aesdec, aesdeclast, aesenc, aesenclast, aesimc, aeskeygenassist +* 2010/Jun/07 ver 2.29 fix call( + jmp("@b"); // jmp to + jmp("@f"); // jmp to + L("@@"); // + jmp("@b"); // jmp to + mov(eax, "@b"); + jmp(eax); // jmp to + +2. ラベルの局所化 + +ピリオドで始まるラベルをinLocalLabel(), outLocalLabel()で挟むことで局所化できます。 +inLocalLabel(), outLocalLabel()は入れ子にすることができます。 + +void func1() +{ + inLocalLabel(); + L(".lp"); // ; ローカルラベル + ... + jmp(".lp"); // jmpt to + L("aaa"); // グローバルラベル + outLocalLabel(); +} + +void func2() +{ + inLocalLabel(); + L(".lp"); // ; ローカルラベル + func1(); + jmp(".lp"); // jmp to + outLocalLabel(); +} + +上記サンプルではinLocalLabel(), outLocalLabel()が無いと、 +".lp"ラベルの二重定義エラーになります。 + +3. 新しいLabelクラスによるジャンプ命令 + +ジャンプ先を文字列による指定だけでなくラベルクラスを使えるようになりました。 + + Label label1, label2; + L(label1); + ... + jmp(label1); + ... + jmp(label2); + ... + L(label2); + +更にラベルの割り当てを行うassignL(dstLabel, srcLabel)という命令も追加されました。 + + Label label2; + Label label1 = L(); // Label label1; L(label1);と同じ意味 + ... + jmp(label2); + ... + assignL(label2, label1); + +上記jmp命令はlabel1にジャンプします。 + +制限 +* srcLabelはL()により飛び先が確定していないといけません。 +* dstLabelはL()により飛び先が確定していてはいけません。 + +ラベルは`getAddress()`によりそのアドレスを取得できます。 +未定義のときは0が返ります。 +``` +// not AutoGrow mode +Label label; +assert(label.getAddress(), 0); +L(label); +assert(label.getAddress(), getCurr()); +``` + +・Xbyak::CodeGenerator()コンストラクタインタフェース + +@param maxSize [in] コード生成最大サイズ(デフォルト4096byte) +@param userPtr [in] ユーザ指定メモリ + +CodeGenerator(size_t maxSize = DEFAULT_MAX_CODE_SIZE, void *userPtr = 0); + +デフォルトコードサイズは4096(=DEFAULT_MAX_CODE_SIZE)バイトです。 +それより大きなコードを生成する場合はCodeGenerator()のコンストラクタに指定してください。 + +class Quantize : public Xbyak::CodeGenerator { +public: + Quantize() + : CodeGenerator(8192) + { + } + ... +}; + +またユーザ指定メモリをコード生成最大サイズと共に指定すると、CodeGeneratorは +指定されたメモリ上にバイト列を生成します。 + +補助関数として指定されたアドレスの実行属性を変更するCodeArray::protect()と +与えられたポインタからアライメントされたポインタを取得するCodeArray::getAlignedAddress() +も用意しました。詳細はsample/test0.cppのuse memory allocated by userを参考に +してください。 + +/** + change exec permission of memory + @param addr [in] buffer address + @param size [in] buffer size + @param canExec [in] true(enable to exec), false(disable to exec) + @return true(success), false(failure) +*/ +bool CodeArray::protect(const void *addr, size_t size, bool canExec); + +/** + get aligned memory pointer +*/ +uint8 *CodeArray::getAlignedAddress(uint8 *addr, size_t alignedSize = ALIGN_SIZE); + +・read/execモード +デフォルトのCodeGeneratorはコンストラクト時にJIT用の領域をread/write/execモードに設定して利用します。 +コード生成時はread/writeでコード実行時にはread/execにしたい場合、次のようにしてください。 + +struct Code : Xbyak::CodeGenerator { + Code() + : Xbyak::CodeGenerator(4096, Xbyak::DontUseProtect) // JIT領域をread/writeのままコード生成 + { + mov(eax, 123); + ret(); + } +}; + +Code c; +c.setProtectModeRE(); // read/execモードに変更 +// JIT領域を実行 + +AutoGrowの場合はreadyの代わりにreadyRE()を読んでください。 + +struct Code : Xbyak::CodeGenerator { + Code() + : Xbyak::CodeGenerator(4096, Xbyak::AutoGrow) // JIT領域をread/writeのままコード生成 + { + mov(eax, 123); + ret(); + } +}; + +Code c; +c.readyRE(); // read/exeモードに変更 +// JIT領域を実行 + +setProtectModeRW()を呼ぶと領域が元のread/execモードに戻ります。 + + +その他詳細は各種サンプルを参照してください。 +----------------------------------------------------------------------------- +◎マクロ + +32bit環境上でコンパイルするとXBYAK32が、64bit環境上でコンパイルするとXBYAK64が +定義されます。さらに64bit環境上ではWindows(VC)ならXBYAK64_WIN、cygwin, gcc上では +XBYAK64_GCCが定義されます。 + +----------------------------------------------------------------------------- +◎使用例 + +test0.cpp ; 簡単な例(x86, x64) +quantize.cpp ; 割り算のJITアセンブルによる量子化の高速化(x86) +calc.cpp ; 与えられた多項式をアセンブルして実行(x86, x64) + boost(http://www.boost.org/)が必要 +bf.cpp ; JIT Brainfuck(x86, x64) + +----------------------------------------------------------------------------- +◎ライセンス + +修正された新しいBSDライセンスに従います。 +http://opensource.org/licenses/BSD-3-Clause + +sample/{echo,hello}.bfは http://www.kmonos.net/alang/etc/brainfuck.php から +いただきました。 + +----------------------------------------------------------------------------- +◎履歴 + +2020/02/26 ver 5.891 zm0のtype修正 +2020/01/03 ver 5.89 vfpclasspdの処理エラー修正 +2019/12/20 ver 5.88 Windowsでのコンパイルエラー修正 +2019/12/19 ver 5.87 未定義ラベルへのjmp命令のデフォルト挙動をT_NEARにするsetDefaultJmpNEAR()を追加 +2019/12/13 ver 5.86 [変更] -fno-operator-namesが指定されたときは5.84以前の挙動に戻す +2019/12/07 ver 5.85 mmapにMAP_JITフラグを追加(macOS mojave以上) +2019/11/29 ver 5.84 [変更] XBYAK_USE_OP_NAMESが定義されていない限りXBYAK_NO_OP_NAMESが定義されるように変更 +2019/10/12 ver 5.83 exit(1)の除去 +2019/09/23 ver 5.82 monitorx, mwaitx, clzero対応 (thanks to MagurosanTeam) +2019/09/14 ver 5.81 いくつかの一般命令をサポート +2019/08/01 ver 5.802 AVX512_BF16判定修正 (thanks to vpirogov) +2019/05/27 support vp2intersectd, vp2intersectq (not tested) +2019/05/26 ver 5.80 support vcvtne2ps2bf16, vcvtneps2bf16, vdpbf16ps +2019/04/27 ver 5.79 vcmppd/vcmppsのptr_b対応忘れ(thanks to jkopinsky) +2019/04/15 ver 5.78 Reg::changeBit()のリファクタリング(thanks to MerryMage) +2019/03/06 ver 5.77 LLCキャッシュを共有数CPU数の修整(by densamoilov) +2019/01/17 ver 5.76 Cpu::getNumCores()追加(by shelleygoel) +2018/10/31 ver 5.751 互換性のためにXbyak::CastToの復元 +2018/10/29 ver 5.75 LabelManagerのデストラクタでLabelから参照を切り離す +2018/10/21 ver 5.74 RegRip +/intの形をサポート Xbyak::CastToを削除 +2018/10/15 util::StackFrameでmovの代わりにpush/popを使う +2018/09/19 ver 5.73 vpslld, vpslldq, vpsllwなどの(reg, mem, imm8)に対するevexエンコーディング修整 +2018/09/19 ver 5.72 fix the encoding of vinsertps for disp8N(Thanks to petercaday) +2018/08/27 ver 5.71 新しいlabelインスタンスを返すL()を追加 +2018/08/27 ver 5.70 read/exec設定のためのsetProtectMode()とDontUseProtectの追加 +2018/08/24 ver 5.68 indexが16以上のVSIBエンコーディングのバグ修正(thanks to petercaday) +2018/08/14 ver 5.67 Addressクラス内のmutableを削除 ; fix setCacheHierarchy for cloud vm +2018/07/26 ver 5.661 mingw64対応 +2018/07/24 ver 5.66 protect()のmodeにCodeArray::PROTECT_REを追加 +2018/06/26 ver 5.65 fix push(qword [mem]) +2018/03/07 ver 5.64 Cpu()の中でzero divisionが出ることがあるのを修正 +2018/02/14 ver 5.63 Cpu::setCacheHierarchy()の修正とclang<3.9のためのEvexModifierZero修正(thanks to mgouicem) +2018/02/13 ver 5.62 Cpu::setCacheHierarchy() by mgouicem and rsdubtso +2018/02/07 ver 5.61 vmov*がmem{k}{z}形式対応(忘れてた) +2018/01/24 ver 5.601 xword, ywordなどをXbyak::util名前空間に追加 +2018/01/05 ver 5.60 Ice lake系命令対応(319433-030.pdf) +2017/08/22 ver 5.53 mpxエンコーディングバグ修正, bnd()プレフィクス追加 +2017/08/18 ver 5.52 align修正(thanks to MerryMage) +2017/08/17 ver 5.51 multi-byte nop追加 align()はそれを使用する(thanks to inolen) +2017/08/08 ver 5.50 mpx追加(thanks to magurosan) +2017/08/08 ver 5.45 sha追加(thanks to magurosan) +2017/08/08 ver 5.44 prefetchw追加(thanks to rsdubtso) +2017/07/12 ver 5.432 PVS-studioの警告を減らす +2017/07/09 ver 5.431 hasRex()修正 (影響なし) (thanks to drillsar) +2017/05/14 ver 5.43 CodeGenerator::resetSize()修正(thanks to gibbed) +2017/05/13 ver 5.42 movs{b,w,d,q}追加 +2017/01/26 ver 5.41 prefetcwt1追加とscale == 0対応(thanks to rsdubtso) +2016/12/14 ver 5.40 Labelが示すアドレスを取得するLabel::getAddress()追加 +2016/12/07 ver 5.34 disp8N時の負のオフセット処理の修正(thanks to rsdubtso) +2016/12/06 ver 5.33 disp8N時のvpbroadcast{b,w,d,q}, vpinsr{b,w}, vpextr{b,w}のバグ修正 +2016/12/01 ver 5.32 clang for Visual Studioサポートのために__xgetbv()を_xgetbv()に変更(thanks to freiro) +2016/11/27 ver 5.31 AVX512_4VNNIをAVX512_4VNNIWに変更 +2016/11/27 ver 5.30 AVX512_4VNNI, AVX512_4FMAPS命令の追加(thanks to rsdubtso) +2016/11/26 ver 5.20 AVX512_4VNNIとAVX512_4FMAPSの判定追加(thanks to rsdubtso) +2016/11/20 ver 5.11 何故か消えていたvptest for ymm追加(thanks to gregory38) +2016/11/20 ver 5.10 [rip+&var]の形のアドレッシング追加 +2016/09/29 ver 5.03 ERR_INVALID_OPMASK_WITH_MEMORYの判定ミス修正(thanks to PVS-Studio) +2016/08/15 ver 5.02 xbyak_bin2hex.hをincludeしない +2016/08/15 ver 5.011 gcc 5.4のバージョン取得ミスの修正 +2016/08/03 ver 5.01 AVXの省略表記非サポート +2016/07/24 ver 5.00 avx-512フルサポート +2016/06/13 avx-512 opmask命令サポート +2016/05/05 ver 4.91 AVX-512命令の検出サポート +2016/03/14 ver 4.901 ready()関数にコメント加筆(thanks to skmp) +2016/02/04 ver 4.90 条件分岐命令にjcc(const void *addr);のタイプを追加 +2016/01/30 ver 4.89 vpblendvbがymmレジスタをサポートしていなかった(thanks to John Funnell) +2016/01/24 ver 4.88 lea, cmovの16bitレジスタ対応(thanks to whyisthisfieldhere) +2015/08/16 ver 4.87 セグメントセレクタに対応 +2015/08/16 ver 4.86 [rip + label]アドレッシングで即値を使うと壊れる(thanks to whyisthisfieldhere) +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が使えるかどうかの判定追加 +2015/04/25 ver 4.81 setSizeが例外を投げる条件を修正(thanks to whyisthisfieldhere) +2015/04/22 ver 4.80 rip相対でLabelのサポート(thanks to whyisthisfieldhere) +2015/01/28 ver 4.71 adcx, adox, cmpxchg, rdseed, stacのサポート +2014/10/14 ver 4.70 MmapAllocatorのサポート +2014/06/13 ver 4.62 VC2014で警告抑制 +2014/05/30 ver 4.61 bt, bts, btr, btcのサポート +2014/05/28 ver 4.60 vcvtph2ps, vcvtps2phのサポート +2014/04/11 ver 4.52 rdrandの判定追加 +2014/03/25 ver 4.51 参照されなくなったラベルの状態を削除する +2014/03/16 ver 4.50 新しいラベルクラスのサポート +2014/03/05 ver 4.40 VirtualBox上でBMI/enhanced repのサポート判定を間違うことがあるのを修正 +2013/12/03 ver 4.30 Reg::cvt8(), cvt16(), cvt32()のサポート +2013/10/16 ver 4.21 ラベルでstd::stringを受け付ける。 +2013/07/30 ver 4.20 [break backward compatibility] 従来のReg32eクラスをアドレッシング用のRegExpとReg32, Reg64を表すReg32eに分離 +2013/07/04 ver 4.10 [break backward compatibility] Xbyak::Errorの型をenumからclassに変更 +2013/06/21 ver 4.02 LABELの指すアドレスを書き込むputL(LABEL)関数の追加。 +2013/06/21 ver 4.01 vpsllw, vpslld, vpsllq, vpsraw, vpsrad, vpsrlw, vpsrld, vpsrlq support (ymm, ymm, xmm) + support vpbroadcastb, vpbroadcastw, vpbroadcastd, vpbroadcastq(thanks to Gabest) +2013/05/30 ver 4.00 AVX2, VEX-encoded GPR-instructionをサポート +2013/03/27 ver 3.80 mov(reg, "label");をサポート +2013/03/13 ver 3.76 cqo, jcxz, jecxz, jrcxz追加 +2013/01/15 ver 3.75 生成されたコードを修正するためにsetSize()を追加 +2013/01/12 ver 3.74 CodeGenerator::reset()とAllocator::useProtect()を追加 +2013/01/06 ver 3.73 可能ならunordered_mapを使う +2012/12/04 ver 3.72 eaxなどをCodeGeneratorのメンバ変数に戻す. Xbyak::util::eaxはstatic const変数 +2012/11/17 ver 3.71 and_(), or_(), xor_(), not_()をXBYAK_NO_OP_NAMESが定義されていないときでも使えるようにした +2012/11/17 CodeGeneratorのeax, ecx, ptrなどのメンバ変数をstaticにし、const参照をXbyak::utilにも定義 +2012/11/09 ver 3.70 and()をand_()にするためのマクロXBYAK_NO_OP_NAMESを追加(thanks to Mattias) +2012/11/01 ver 3.62 add fwait/fnwait/finit/fninit +2012/11/01 ver 3.61 add fldcw/fstcw +2012/05/03 ver 3.60 Allocatorクラスのインタフェースを変更 +2012/03/23 ver 3.51 userPtrモードがバグったのを修正 +2012/03/19 ver 3.50 AutoGrowモードサポート +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 +2011/03/24 ver 3.01 fix typo of OSXSAVE +2011/03/23 ver 3.00 vcmpeqpsなどを追加 +2011/02/16 ver 2.994 beta add vmovq for 32-bit mode(I forgot it) +2011/02/16 ver 2.993 beta remove cvtReg to avoid thread unsafe +2011/02/10 ver 2.992 beta support one argument syntax for fadd like nasm +2011/02/07 ver 2.991 beta fix pextrw reg, xmm, imm(Thanks to Gabest) +2011/02/04 ver 2.99 beta support AVX +2010/12/08 ver 2.31 fix ptr [rip + 32bit offset], support rtdscp +2010/10/19 ver 2.30 support pclmulqdq, aesdec, aesdeclast, aesenc, aesenclast, aesimc, aeskeygenassist +2010/07/07 ver 2.29 fix call(