Merge commit '0a097849af1bcd979ff4b430a03971f16822cbcb' as 'external/xbyak'
This commit is contained in:
32
external/xbyak/.github/CONTRIBUTING.md
vendored
Normal file
32
external/xbyak/.github/CONTRIBUTING.md
vendored
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
# Contributing to Xbyak
|
||||||
|
|
||||||
|
Thank you for considering contributing to the Xbyak project. This document provides guidelines on how to contribute.
|
||||||
|
|
||||||
|
## Bug Reports and Feedback
|
||||||
|
|
||||||
|
If you find a bug, have a feature request, or have questions, please open an issue. Include the following information:
|
||||||
|
|
||||||
|
- Detailed description of the problem
|
||||||
|
- Steps to reproduce
|
||||||
|
- Expected behavior
|
||||||
|
- Actual behavior
|
||||||
|
- Environment details (OS, compiler version, etc.)
|
||||||
|
|
||||||
|
## Creating Pull Requests
|
||||||
|
|
||||||
|
If you want to add features or make fixes, follow these steps to create a pull request:
|
||||||
|
|
||||||
|
1. Fork the repository
|
||||||
|
2. Create a new branch: `git checkout -b my-feature-branch`
|
||||||
|
3. Make your changes
|
||||||
|
4. Run tests and ensure all tests pass
|
||||||
|
5. Commit your changes: `git commit -am 'Add new feature'`
|
||||||
|
6. Push the branch: `git push origin my-feature-branch`
|
||||||
|
7. Create a pull request
|
||||||
|
|
||||||
|
When creating a pull request, clearly describe the changes and include any related issue numbers.
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
Xbyak is released under the BSD-3-Clause License. Any code contributions will be licensed under the same license.
|
||||||
|
|
||||||
1
external/xbyak/.github/FUNDING.yml
vendored
Normal file
1
external/xbyak/.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
github: herumi
|
||||||
32
external/xbyak/.github/workflows/main.yml
vendored
Normal file
32
external/xbyak/.github/workflows/main.yml
vendored
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
name: test
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- '*'
|
||||||
|
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: sh
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: debian:testing
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- run: apt -y update
|
||||||
|
- run: apt -y install g++-multilib libboost-dev make nasm yasm wget python3 #xz-utils
|
||||||
|
- run: make test
|
||||||
|
- run: make -C sample CXXFLAGS="-DXBYAK_NO_EXCEPTION"
|
||||||
|
- run: |
|
||||||
|
cd test
|
||||||
|
#wget https://downloadmirror.intel.com/831748/sde-external-9.44.0-2024-08-22-lin.tar.xz
|
||||||
|
#tar xvf sde-external-9.44.0-2024-08-22-lin.tar.xz
|
||||||
|
wget https://github.com/herumi/xed-bin/raw/refs/heads/main/xed.tgz
|
||||||
|
tar xvf xed.tgz
|
||||||
|
./xed -version
|
||||||
|
env XED=./xed make xed_test
|
||||||
2
external/xbyak/.gitignore
vendored
Normal file
2
external/xbyak/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
/build* # cmake
|
||||||
|
*CVS
|
||||||
8
external/xbyak/Android.bp
vendored
Normal file
8
external/xbyak/Android.bp
vendored
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
//#################################################
|
||||||
|
cc_library_headers {
|
||||||
|
name: "xbyak_headers",
|
||||||
|
vendor: true,
|
||||||
|
export_include_dirs: [
|
||||||
|
"xbyak"
|
||||||
|
],
|
||||||
|
}
|
||||||
51
external/xbyak/CMakeLists.txt
vendored
Normal file
51
external/xbyak/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.10)
|
||||||
|
|
||||||
|
project(xbyak LANGUAGES CXX VERSION 7.30)
|
||||||
|
|
||||||
|
file(GLOB headers xbyak/*.h)
|
||||||
|
|
||||||
|
include(GNUInstallDirs)
|
||||||
|
add_library(${PROJECT_NAME} INTERFACE)
|
||||||
|
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
|
||||||
|
|
||||||
|
target_include_directories(
|
||||||
|
${PROJECT_NAME} INTERFACE
|
||||||
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
|
||||||
|
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
|
||||||
|
)
|
||||||
|
|
||||||
|
install(
|
||||||
|
TARGETS ${PROJECT_NAME}
|
||||||
|
EXPORT ${PROJECT_NAME}-targets
|
||||||
|
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}
|
||||||
|
)
|
||||||
|
|
||||||
|
include(CMakePackageConfigHelpers)
|
||||||
|
configure_package_config_file(
|
||||||
|
cmake/config.cmake.in
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
|
||||||
|
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
|
||||||
|
)
|
||||||
|
write_basic_package_version_file(
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake"
|
||||||
|
COMPATIBILITY SameMajorVersion
|
||||||
|
)
|
||||||
|
|
||||||
|
install(
|
||||||
|
FILES
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake"
|
||||||
|
DESTINATION
|
||||||
|
${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
|
||||||
|
)
|
||||||
|
|
||||||
|
install(
|
||||||
|
EXPORT ${PROJECT_NAME}-targets
|
||||||
|
NAMESPACE ${PROJECT_NAME}::
|
||||||
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
|
||||||
|
)
|
||||||
|
|
||||||
|
install(
|
||||||
|
FILES ${headers}
|
||||||
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/xbyak
|
||||||
|
)
|
||||||
27
external/xbyak/COPYRIGHT
vendored
Normal file
27
external/xbyak/COPYRIGHT
vendored
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
|
||||||
|
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.
|
||||||
24
external/xbyak/Makefile
vendored
Normal file
24
external/xbyak/Makefile
vendored
Normal file
@@ -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
|
||||||
3
external/xbyak/cmake/config.cmake.in
vendored
Normal file
3
external/xbyak/cmake/config.cmake.in
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
@PACKAGE_INIT@
|
||||||
|
|
||||||
|
include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake")
|
||||||
8
external/xbyak/cmake/meson-config.cmake.in
vendored
Normal file
8
external/xbyak/cmake/meson-config.cmake.in
vendored
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
@PACKAGE_INIT@
|
||||||
|
|
||||||
|
if(NOT TARGET @TARGET_NAME@)
|
||||||
|
add_library(@TARGET_NAME@ INTERFACE IMPORTED)
|
||||||
|
set_target_properties(@TARGET_NAME@ PROPERTIES
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES "@ABSOLUTE_INCLUDE_DIR@"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
232
external/xbyak/doc/changelog.md
vendored
Normal file
232
external/xbyak/doc/changelog.md
vendored
Normal file
@@ -0,0 +1,232 @@
|
|||||||
|
# History
|
||||||
|
|
||||||
|
* 2025/Sep/02 ver 7.30 add tcvtrowd2ps
|
||||||
|
* 2025/Aug/22 ver 7.29.2 add override specifiers to virtual methods
|
||||||
|
* 2025/Aug/16 ver 7.29.1 support ptr[integer value]
|
||||||
|
* 2025/Aug/15 ver 7.29 support addressing with label
|
||||||
|
* 2025/Jul/19 ver 7.28 support movrs, vmovrs{b,w,d,q}
|
||||||
|
* 2025/Jul/02 ver 7.27 disable embedded rounding and sae for YMM according to AVX10.2 rev 4.0
|
||||||
|
* 2025/Jun/06 ver 7.26 support AMX-{MOVRS,AVX512,FP8,TF32,TRANSPOSE} for Diamond Rapids
|
||||||
|
* 2025/Jun/02 ver 7.25 rename BF16 operations according to new AVX10.2 specification
|
||||||
|
* 2025/Mar/12 ver 7.24.2 fix. vcvtneps2bf16 should support AVX-NE-CONVERT (revert 749aa31)
|
||||||
|
* 2025/Feb/26 ver 7.24.1 fix 3-op shift APX instructions with NDD format.
|
||||||
|
* 2025/Feb/17 ver 7.24 feat: add error check for invalid REX prefix with AH/BH/CH/DH registers. enhance size mismatch detection for mem-reg operations like 'add eax, byte[rax]'
|
||||||
|
* 2025/Feb/07 ver 7.23.1 revert the behavior of StackFrame::close().
|
||||||
|
* 2025/Feb/03 ver 7.23 stricter checking of register size, improve handling of 16-bit immediates, change spec of StackFrame::close(), fix push/pop to support APX.
|
||||||
|
* 2024/Nov/11 ver 7.22 add Reg::cvt{128,256,512}(). tested by xed 2024.11.04
|
||||||
|
* 2024/Oct/31 ver 7.21 Enhance XMM register validation in SSE instructions
|
||||||
|
* 2024/Oct/17 ver 7.20.1 Updated to comply with AVX10.2 specification rev 2.0
|
||||||
|
* 2024/Oct/15 ver 7.20 Fixed the specification of setDefaultEncoding, setDefaultEncodingAVX10.
|
||||||
|
* 2024/Oct/15 ver 7.11 Added full support for AVX10.2
|
||||||
|
* 2024/Oct/13 ver 7.10 support AVX10 integer and fp16 vnni, media new instructions. setDefaultEncoding is extended.
|
||||||
|
* 2024/Oct/10 ver 7.09.1 fix the names of vpcompressb and vpcompressw
|
||||||
|
* 2024/Oct/08 ver 7.09 support YMM embedded rounding of AVX10.2 and fix some mnemonics with {sae}/{er}.
|
||||||
|
* 2024/Oct/07 ver 7.08 support rdfsbase etc.
|
||||||
|
* 2024/Aug/29 ver 7.07.1 adapt to NASM 2.16.03 output of xchg (The functionality stays the same.)
|
||||||
|
* 2024/Jun/11 ver 7.07 support xresldtrk/xsusldtrk
|
||||||
|
* 2024/Mar/07 ver 7.06 Xbyak::util::Cpu supports AMD processor
|
||||||
|
* 2024/Feb/11 ver 7.05.1 fix extractBit() in util::Cpu and align() for autoGrow mode
|
||||||
|
* 2024/Jan/03 ver 7.05 support RAO-INT for APX
|
||||||
|
* 2023/Dec/28 ver 7.04 rex2 supports two-byte opecode
|
||||||
|
* 2023/Dec/26 ver 7.03 set the default value of dfv to 0
|
||||||
|
* 2023/Dec/20 ver 7.02 SHA* support APX
|
||||||
|
* 2023/Dec/19 ver 7.01 support AESKLE, WIDE_KL, KEYLOCKER, KEYLOCKER_WIDE, detection of APX10/APX
|
||||||
|
* 2023/Dec/01 ver 7.00 support APX
|
||||||
|
* 2023/Aug/07 ver 6.73 add sha512/sm3/sm4/avx-vnni-int16
|
||||||
|
* 2023/Aug/02 ver 6.72 add xbegin/xabort/xend
|
||||||
|
* 2023/Jul/27 ver 6.71 Allocator supports huge page
|
||||||
|
* 2023/Jul/05 ver 6.70 add alias of vclmulqdq, correct alias of pclmulqdq
|
||||||
|
* 2023/Jun/27 ver 6.69.2 add constexpr to `TypeT operator|` (thanks to Wunkolo)
|
||||||
|
* 2023/Mar/23 ver 6.69.1 add detection of xsave (thanks to Wunkolo)
|
||||||
|
* 2023/Feb/20 ver 6.69 util::Cpu supports AMD CPUs. support UINTR
|
||||||
|
* 2022/Dec/07 ver 6.68 support prefetchit{0,1}
|
||||||
|
* 2022/Nov/30 ver 6.67 support CMPccXADD
|
||||||
|
* 2022/Nov/25 ver 6.66 support RAO-INT
|
||||||
|
* 2022/Nov/22 ver 6.65 consider x32
|
||||||
|
* 2022/Nov/04 ver 6.64 some vmov* support addressing with mask
|
||||||
|
* 2022/Oct/06 ver 6.63 vpmadd52{h,l}uq support AVX-IFMA
|
||||||
|
* 2022/Oct/05 ver 6.63 support amx_fp16/avx_vnni_int8/avx_ne_convert and add setDefaultEncoding()
|
||||||
|
* 2022/Aug/15 ver 6.62 add serialize instruction
|
||||||
|
* 2022/Aug/02 ver 6.61.1 noexcept is supported by Visual Studio 2015 or later
|
||||||
|
* 2022/Jul/29 ver 6.61 fix exception of movzx eax, ah in 64-bit mode
|
||||||
|
* 2022/Jun/16 ver 6.60.2 fix detection of GFNI, VAES, and VPCLMULQDQ
|
||||||
|
* 2022/Jun/15 ver 6.60.1 fix link error of Xbyak::util::Cpu on Visual Studio with /O0 option
|
||||||
|
* 2022/Jun/06 ver 6.60 change the version format to avoid it going backward
|
||||||
|
* 2022/Jun/01 ver 6.06 refactor Cpu::Type class and improve MmapAllocator when XBYAK_USE_MEMFD is defined.
|
||||||
|
* 2022/Mar/20 ver 6.052 add Cpu::operator==()
|
||||||
|
* 2022/Mar/13 ver 6.051 fix compile error when XBYAK_NO_EXCEPTION is defined
|
||||||
|
* 2022/Mar/12 ver 6.05 add movdiri, movdir64b, clwb, cldemote
|
||||||
|
* 2022/Apr/22 ver 6.041 consider Android and mingw
|
||||||
|
* 2022/Apr/05 ver 6.04 add tpause, umonitor, umwait
|
||||||
|
* 2022/Mar/08 ver 6.03 MmapAllocator supports memfd with user-defined strings.
|
||||||
|
* 2022/Jan/28 ver 6.02 strict check the range of 32-bit dispacement
|
||||||
|
* 2021/Dec/14 ver 6.01 support T_FAR jump/call and retf
|
||||||
|
* 2021/Sep/14 ver 6.00 fully support AVX512-FP16
|
||||||
|
* 2021/Sep/09 ver 5.997 fix vrndscale* to support {sae}
|
||||||
|
* 2021/Sep/03 ver 5.996 fix v{add,sub,mul,div,max,min}{sd,ss} to support T_rd_sae.
|
||||||
|
* 2021/Aug/15 ver 5.995 add a label to /proc/self/maps if XBYAK_USE_MEMFD is defined on Linux
|
||||||
|
* 2021/Jun/17 ver 5.994 add alias of vcmpXX{ps,pd,ss,sd} with mask register
|
||||||
|
* 2021/Jun/06 ver 5.993 strict check of gather/scatter register combination
|
||||||
|
* 2021/May/09 ver 5.992 support endbr32 and endbr64
|
||||||
|
* 2020/Nov/16 ver 5.991 disable constexpr for gcc-5 with -std=c++-14
|
||||||
|
* 2020/Oct/19 ver 5.99 support VNNI instructions(Thanks to akharito)
|
||||||
|
* 2020/Oct/17 ver 5.98 support the form of [scale * reg]
|
||||||
|
* 2020/Sep/08 ver 5.97 replace uint32 with uint32_t etc.
|
||||||
|
* 2020/Aug/28 ver 5.95 some constructors of register classes support constexpr if C++14 or later
|
||||||
|
* 2020/Aug/04 ver 5.941 `CodeGenerator::reset()` calls `ClearError()`.
|
||||||
|
* 2020/Jul/28 ver 5.94 remove #include <winsock2.h> (only windows)
|
||||||
|
* 2020/Jul/21 ver 5.93 support exception-less mode
|
||||||
|
* 2020/Jun/30 ver 5.92 support Intel AMX instruction set (Thanks to nshustrov)
|
||||||
|
* 2020/Jun/22 ver 5.913 fix mov(r64, imm64) on 32-bit env with XBYAK64
|
||||||
|
* 2020/Jun/19 ver 5.912 define MAP_JIT on macOS regardless of Xcode version (Thanks to rsdubtso)
|
||||||
|
* 2020/May/10 ver 5.911 XBYAK_USE_MMAP_ALLOCATOR is defined unless XBYAK_DONT_USE_MMAP_ALLOCATOR is defined.
|
||||||
|
* 2020/Apr/20 ver 5.91 accept mask register k0 (it means no mask)
|
||||||
|
* 2020/Apr/09 ver 5.90 kmov{b,d,w,q} throws exception for an unsupported register
|
||||||
|
* 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(<label>)
|
||||||
|
* 2010/Jun/17 ver 2.28 move some member functions to public
|
||||||
|
* 2010/Jun/01 ver 2.27 support encoding of mov(reg64, imm) like yasm(not nasm)
|
||||||
|
* 2010/May/24 ver 2.26 fix sub(rsp, 1000)
|
||||||
|
* 2010/Apr/26 ver 2.25 add jc/jnc(I forgot to implement them...)
|
||||||
|
* 2010/Apr/16 ver 2.24 change the prototype of rewrite() method
|
||||||
|
* 2010/Apr/15 ver 2.23 fix align() and xbyak_util.h for Mac
|
||||||
|
* 2010/Feb/16 ver 2.22 fix inLocalLabel()/outLocalLabel()
|
||||||
|
* 2009/Dec/09 ver 2.21 support cygwin(gcc 4.3.2)
|
||||||
|
* 2009/Nov/28 support a part of FPU
|
||||||
|
* 2009/Jun/25 fix mov(qword[rax], imm); (thanks to Martin)
|
||||||
|
* 2009/Mar/10 fix redundant REX.W prefix on jmp/call reg64
|
||||||
|
* 2009/Feb/24 add movq reg64, mmx/xmm; movq mmx/xmm, reg64
|
||||||
|
* 2009/Feb/13 movd(xmm7, dword[eax]) drops 0x66 prefix (thanks to Gabest)
|
||||||
|
* 2008/Dec/30 fix call in short relative address(thanks to kato san)
|
||||||
|
* 2008/Sep/18 support @@, @f, @b and localization of label(thanks to nobu-q san)
|
||||||
|
* 2008/Sep/18 support (ptr[rip + 32bit offset]) (thanks to Dango-Chu san)
|
||||||
|
* 2008/Jun/03 fix align(). mov(ptr[eax],1) throws ERR_MEM_SIZE_IS_NOT_SPECIFIED.
|
||||||
|
* 2008/Jun/02 support memory interface allocated by user
|
||||||
|
* 2008/May/26 fix protect() to avoid invalid setting(thanks to shinichiro_h san)
|
||||||
|
* 2008/Apr/30 add cmpxchg16b, cdqe
|
||||||
|
* 2008/Apr/29 support x64
|
||||||
|
* 2008/Apr/14 code refactoring
|
||||||
|
* 2008/Mar/12 add bsr/bsf
|
||||||
|
* 2008/Feb/14 fix output of sub eax, 1234 (thanks to Robert)
|
||||||
|
* 2007/Nov/5 support lock, xadd, xchg
|
||||||
|
* 2007/Nov/2 support SSSE3/SSE4 (thanks to Dango-Chu san)
|
||||||
|
* 2007/Feb/4 fix the bug that exception doesn't occur under the condition which the offset of jmp mnemonic without T_NEAR is over 127.
|
||||||
|
* 2007/Jan/21 fix the bug to create address like [disp] select smaller representation for mov (eax|ax|al, [disp])
|
||||||
|
* 2007/Jan/4 first version
|
||||||
26
external/xbyak/doc/install.md
vendored
Normal file
26
external/xbyak/doc/install.md
vendored
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
# 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`.
|
||||||
|
|
||||||
|
# Building xbyak - Using vcpkg
|
||||||
|
|
||||||
|
You can download and install xbyak using the [vcpkg](https://github.com/Microsoft/vcpkg) dependency manager:
|
||||||
|
|
||||||
|
git clone https://github.com/Microsoft/vcpkg.git
|
||||||
|
cd vcpkg
|
||||||
|
./bootstrap-vcpkg.sh
|
||||||
|
./vcpkg integrate install
|
||||||
|
./vcpkg install xbyak
|
||||||
|
|
||||||
|
The xbyak port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository.
|
||||||
503
external/xbyak/doc/usage.md
vendored
Normal file
503
external/xbyak/doc/usage.md
vendored
Normal file
@@ -0,0 +1,503 @@
|
|||||||
|
# Usage
|
||||||
|
|
||||||
|
Inherit the `Xbyak::CodeGenerator` class and define a class method.
|
||||||
|
```cpp
|
||||||
|
#include <xbyak/xbyak.h>
|
||||||
|
|
||||||
|
struct Code : Xbyak::CodeGenerator {
|
||||||
|
Code(int x)
|
||||||
|
{
|
||||||
|
mov(eax, x);
|
||||||
|
ret();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
```
|
||||||
|
Alternatively, you can pass an instance of `CodeGenerator` without inheriting.
|
||||||
|
```cpp
|
||||||
|
void genCode(Xbyak::CodeGenerator& code, int x) {
|
||||||
|
using namespace Xbyak::util;
|
||||||
|
code.mov(eax, x);
|
||||||
|
code.ret();
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Create an instance of the class, obtain the function pointer by calling `getCode()`, and invoke it.
|
||||||
|
```cpp
|
||||||
|
Code c(5);
|
||||||
|
int (*f)() = c.getCode<int (*)()>();
|
||||||
|
printf("ret=%d\n", f()); // ret = 5
|
||||||
|
```
|
||||||
|
|
||||||
|
**Note**: For security considerations and memory protection modes, see the [Read/Exec mode](#readexec-mode) section.
|
||||||
|
|
||||||
|
## Syntax
|
||||||
|
The syntax is similar to MASM/NASM, but uses parentheses for function-like expressions.
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
NASM Xbyak
|
||||||
|
mov eax, ebx --> mov(eax, ebx);
|
||||||
|
inc ecx inc(ecx);
|
||||||
|
ret --> ret();
|
||||||
|
```
|
||||||
|
|
||||||
|
## Addressing
|
||||||
|
Use `qword`, `dword`, `word`, or `byte` to specify the memory size explicitly. If the size is not specified, `ptr` is used by default.
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
(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)
|
||||||
|
```cpp
|
||||||
|
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
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
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, you can use the two-operand version for backward compatibility.
|
||||||
|
But the newer version will not support it.
|
||||||
|
```cpp
|
||||||
|
vaddps(xmm2, xmm3); // xmm2 <- xmm2 + xmm3
|
||||||
|
```
|
||||||
|
|
||||||
|
## AVX-512
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
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.
|
||||||
|
- `k0` is dealt as no mask.
|
||||||
|
- e.g. `vmovaps(zmm0|k0, ptr[rax]);` and `vmovaps(zmm0|T_z, ptr[rax]);` are same to `vmovaps(zmm0, ptr[rax]);`.
|
||||||
|
* 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.
|
||||||
|
|
||||||
|
## Selecting AVX512-VNNI, AVX-VNNI, AVX-VNNI-INT8, AVX10.2.
|
||||||
|
Some mnemonics have some types of encodings: VEX, EVEX, AVX10.2.
|
||||||
|
The functions for these mnemonics include an optional parameter as the last argument to specify the encoding.
|
||||||
|
The default behavior depends on the order in which the instruction was introduced (whether VEX, EVEX or AVX10.2 came first),
|
||||||
|
and can be specified using setDefaultEncoding.
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
vpdpbusd(xm0, xm1, xm2); // default encoding: EVEX (AVX512-VNNI)
|
||||||
|
vpdpbusd(xm0, xm1, xm2, EvexEncoding); // same as the above
|
||||||
|
vpdpbusd(xm0, xm1, xm2, VexEncoding); // VEX (AVX-VNNI)
|
||||||
|
setDefaultEncoding(VexEncoding); // change default encoding
|
||||||
|
vpdpbusd(xm0, xm1, xm2); // VEX
|
||||||
|
|
||||||
|
vmpsadbw(xm1, xm3, xm15, 3); // default encoding: AVX
|
||||||
|
vmpsadbw(xm1, xm3, xm15, 3, PreAVX10v2Encoding); // same as the above
|
||||||
|
vmpsadbw(xm1, xm3, xm15, 3, AVX10v2Encoding); // AVX10.2
|
||||||
|
setDefaultEncodingAVX10(AVX10v2Encoding); // change default encoding
|
||||||
|
vmpsadbw(xm1, xm3, xm15, 3); // AVX10.2
|
||||||
|
```
|
||||||
|
|
||||||
|
- `setDefaultEncoding(PreferredEncoding enc = EvexEncoding)`
|
||||||
|
- Configure encoding for AVX512-VNNI or AVX-VNNI instructions.
|
||||||
|
- `setDefaultEncodingAVX10(PreferredEncoding enc = PreAVXv2Encoding)`
|
||||||
|
- Configure encoding for pre-AVX10.2 and AVX10.2 instructions.
|
||||||
|
|
||||||
|
`setDefaultEncoding`|EvexEncoding (default)|VexEncoding
|
||||||
|
-|-|-
|
||||||
|
feature|AVX512-VNNI|AVX-VNNI
|
||||||
|
|
||||||
|
- Target functions: vpdpbusd, vpdpbusds, vpdpwssd, vpdpwssds
|
||||||
|
|
||||||
|
`setDefaultEncodingAVX10`|PreAVX10v2Encoding (default)|AVX10v2Encoding
|
||||||
|
-|-|-
|
||||||
|
feature|AVX-VNNI-INT8, AVX512-FP16|AVX10.2
|
||||||
|
|
||||||
|
- Target functions: vmpsadbw, vpdpbssd, vpdpbssds, vpdpbsud, vpdpbsuds, vpdpbuud, vpdpbuuds, vpdpwsud vpdpwsuds vpdpwusd vpdpwusds vpdpwuud, vpdpwuuds and vmovd, vmovw with MEM-to-MEM.
|
||||||
|
|
||||||
|
### Remark
|
||||||
|
|
||||||
|
1. `vmovd` and `vmovw` instructions with REG-to-XMM or XMM-to-REG operands are always encoded using AVX10.1.
|
||||||
|
When used with XMM-to-XMM operands, these instructions are always encoded using AVX10.2.
|
||||||
|
|
||||||
|
2. `vmovd` and `vmovw` instructions with XMM-to-MEM or MEM-to-XMM operands support multiple encoding formats, including AVX, AVX512F, AVX512-FP16, and AVX10.2.
|
||||||
|
|
||||||
|
Initially, I tried implementing `setDefaultEncodingAVX10` using `EvexEncoding` (resp. `VexEncoding`) instead of `AVX10v2Encoding` (resp. `EvexEncoding`).
|
||||||
|
However, I abandoned this approach after discovering the complexity of the encoding requirements of `vmovd` and `vmovw`.
|
||||||
|
|
||||||
|
## APX
|
||||||
|
[Advanced Performance Extensions (APX) Architecture Specification](https://www.intel.com/content/www/us/en/content-details/786223/intel-advanced-performance-extensions-intel-apx-architecture-specification.html)
|
||||||
|
- Support 64-bit 16 additional GPRs (general-purpose registers) r16, ..., r31
|
||||||
|
- 32-bit regs are r16d, ..., r31d
|
||||||
|
- 16-bit regs are r16w, ..., r31w
|
||||||
|
- 8-bit regs are r16b, ..., r31b
|
||||||
|
- `add(r20, r21);`
|
||||||
|
- `lea(r30, ptr[r29+r31]);`
|
||||||
|
- Support three-operand instruction
|
||||||
|
- `add(r20, r21, r23);`
|
||||||
|
- `add(r20, ptr[rax + rcx * 8 + 0x1234], r23);`
|
||||||
|
- Support T_nf for NF=1 (status flags update suppression)
|
||||||
|
- `add(r20|T_nf, r21, r23);` // Set EVEX.NF=1
|
||||||
|
- Support T_zu for NF=ZU (zero upper) for imul and setcc
|
||||||
|
- `imul(ax|T_zu, cx, 0x1234);` // Set ND=ZU
|
||||||
|
- `imul(ax|T_zu|T_nf, cx, 0x1234);` // Set ND=ZU and EVEX.NF=1
|
||||||
|
- `setb(r31b|T_zu);` // same as set(r31b); movzx(r31, r31b);
|
||||||
|
- See [sample/zero_upper.cpp](../sample/zero_upper.cpp)
|
||||||
|
|
||||||
|
### ccmpSCC and ctestSCC
|
||||||
|
|
||||||
|
- ccmpSCC(op1, op2, dfv = 0); // eflags = eflags == SCC ? cmp(op1, op2) : dfv
|
||||||
|
- ctestSCC(op1, op2, dfv = 0); // eflags = eflags == SCC ? test(op1, op2) : dfv
|
||||||
|
- SCC means source condition code such as z, a, gt.
|
||||||
|
- See [sample/ccmp.cpp](../sample/ccmp.cpp)
|
||||||
|
- Specify the union of T_of(=8), T_sf(=4), T_zf(=2), or T_cf(=1) for dfv.
|
||||||
|
|
||||||
|
|
||||||
|
## Label
|
||||||
|
Two types of labels are supported: string literals and the `Label` class.
|
||||||
|
|
||||||
|
### String literal
|
||||||
|
```cpp
|
||||||
|
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
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
L("@@"); // <A>
|
||||||
|
jmp("@b"); // jmp to <A>
|
||||||
|
jmp("@f"); // jmp to <B>
|
||||||
|
L("@@"); // <B>
|
||||||
|
jmp("@b"); // jmp to <B>
|
||||||
|
mov(eax, "@b");
|
||||||
|
jmp(eax); // jmp to <B>
|
||||||
|
```
|
||||||
|
|
||||||
|
### Local label
|
||||||
|
|
||||||
|
Label symbols beginning with a period between `inLocalLabel()` and `outLocalLabel()`
|
||||||
|
are treated as a local label.
|
||||||
|
`inLocalLabel()` and `outLocalLabel()` can be nested.
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
void func1()
|
||||||
|
{
|
||||||
|
inLocalLabel();
|
||||||
|
L(".lp"); // <A> ; local label
|
||||||
|
...
|
||||||
|
jmp(".lp"); // jmp to <A>
|
||||||
|
L("aaa"); // global label <C>
|
||||||
|
outLocalLabel();
|
||||||
|
|
||||||
|
inLocalLabel();
|
||||||
|
L(".lp"); // <B> ; local label
|
||||||
|
func1();
|
||||||
|
jmp(".lp"); // jmp to <B>
|
||||||
|
inLocalLabel();
|
||||||
|
jmp("aaa"); // jmp to <C>
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### 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.
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
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.
|
||||||
|
```cpp
|
||||||
|
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.
|
||||||
|
```cpp
|
||||||
|
jmp("long-jmp"); // long jmp
|
||||||
|
// long code
|
||||||
|
L("long-jmp");
|
||||||
|
```
|
||||||
|
|
||||||
|
### Label class
|
||||||
|
|
||||||
|
`L()` and `jxx()` support Label class.
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
Xbyak::Label label1, label2;
|
||||||
|
L(label1);
|
||||||
|
...
|
||||||
|
jmp(label1);
|
||||||
|
...
|
||||||
|
jmp(label2);
|
||||||
|
...
|
||||||
|
L(label2);
|
||||||
|
```
|
||||||
|
|
||||||
|
Use `putL` for jmp table
|
||||||
|
```cpp
|
||||||
|
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.
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
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.
|
||||||
|
```cpp
|
||||||
|
// not AutoGrow mode
|
||||||
|
Label label;
|
||||||
|
assert(label.getAddress() == 0);
|
||||||
|
L(label);
|
||||||
|
assert(label.getAddress() == getCurr());
|
||||||
|
```
|
||||||
|
|
||||||
|
### Rip ; relative addressing
|
||||||
|
```cpp
|
||||||
|
Label label;
|
||||||
|
mov(eax, ptr [rip + label]); // eax = 4
|
||||||
|
...
|
||||||
|
|
||||||
|
L(label);
|
||||||
|
dd(4);
|
||||||
|
```
|
||||||
|
```cpp
|
||||||
|
int x;
|
||||||
|
...
|
||||||
|
mov(eax, ptr[rip + &x]); // throw exception if the difference between &x and current position is larger than 2GiB
|
||||||
|
```
|
||||||
|
|
||||||
|
### Addressing with Label
|
||||||
|
The Label class can be used for addressing displacement.
|
||||||
|
However, in 64-bit mode, `dataL.getAddress()` must be 2GiB or less.
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
Label dataL;
|
||||||
|
|
||||||
|
mov(eax, ptr[dataL+ecx*4]);
|
||||||
|
...
|
||||||
|
L(dataL);
|
||||||
|
for (int i = 0; i < 10; i++) {
|
||||||
|
dd(i);
|
||||||
|
}
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
||||||
|
Only the form `mov((al|ax|eax|rax), ptr[label])` can be used even if the label exceeds 2GiB.
|
||||||
|
|
||||||
|
## Far jump
|
||||||
|
|
||||||
|
Use `word|dword|qword` instead of `ptr` to specify the address size.
|
||||||
|
|
||||||
|
### 32 bit mode
|
||||||
|
```cpp
|
||||||
|
jmp(word[eax], T_FAR); // jmp m16:16(FF /5)
|
||||||
|
jmp(dword[eax], T_FAR); // jmp m16:32(FF /5)
|
||||||
|
```
|
||||||
|
|
||||||
|
### 64 bit mode
|
||||||
|
```cpp
|
||||||
|
jmp(word[rax], T_FAR); // jmp m16:16(FF /5)
|
||||||
|
jmp(dword[rax], T_FAR); // jmp m16:32(FF /5)
|
||||||
|
jmp(qword[rax], T_FAR); // jmp m16:64(REX.W FF /5)
|
||||||
|
```
|
||||||
|
The same applies to `call`.
|
||||||
|
|
||||||
|
## Code size
|
||||||
|
The default max code size is 4096 bytes.
|
||||||
|
Specify the size in the constructor of `CodeGenerator()` if needed.
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
class Quantize : public Xbyak::CodeGenerator {
|
||||||
|
public:
|
||||||
|
Quantize()
|
||||||
|
: CodeGenerator(8192)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
...
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
## User allocated memory
|
||||||
|
|
||||||
|
You can make jit code on prepared memory.
|
||||||
|
|
||||||
|
Call `setProtectModeRE` yourself to change memory mode if using the prepared memory.
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
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<int(*)()>()());
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**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.
|
||||||
|
```cpp
|
||||||
|
struct Code : Xbyak::CodeGenerator {
|
||||||
|
Code()
|
||||||
|
: Xbyak::CodeGenerator(<default memory size>, 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.
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
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).
|
||||||
|
|
||||||
|
## Exception-less mode
|
||||||
|
If `XBYAK_NO_EXCEPTION` is defined, then gcc/clang can compile xbyak with `-fno-exceptions`.
|
||||||
|
In stead of throwing an exception, `Xbyak::GetError()` returns non-zero value (e.g. `ERR_BAD_ADDRESSING`) if there is something wrong.
|
||||||
|
The status will not be changed automatically, then you should reset it by `Xbyak::ClearError()`.
|
||||||
|
`CodeGenerator::reset()` calls `ClearError()`.
|
||||||
|
|
||||||
|
## 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.
|
||||||
|
* 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
|
||||||
|
|
||||||
|
* [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)
|
||||||
44
external/xbyak/gen/Makefile
vendored
Normal file
44
external/xbyak/gen/Makefile
vendored
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
TARGET=../xbyak/xbyak_mnemonic.h
|
||||||
|
BIN=sortline gen_code gen_avx512
|
||||||
|
CFLAGS=-I../ -I ./ -Wall -Wextra -Wno-missing-field-initializers $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS)
|
||||||
|
all: $(TARGET) ../CMakeLists.txt ../meson.build ../readme.md ../readme.txt
|
||||||
|
|
||||||
|
avx_type_def.h: ../xbyak/xbyak.h
|
||||||
|
sed -n '/@@@begin of avx_type_def.h/,/@@@end of avx_type_def.h/p' $< > $@
|
||||||
|
|
||||||
|
avx_type.hpp: avx_type_def.h
|
||||||
|
sortline: sortline.cpp
|
||||||
|
$(CXX) $(CFLAGS) $< -o $@
|
||||||
|
gen_code: gen_code.cpp avx_type.hpp
|
||||||
|
$(CXX) $(CFLAGS) $< -o $@
|
||||||
|
gen_avx512: gen_avx512.cpp avx_type.hpp
|
||||||
|
$(CXX) $(CFLAGS) $< -o $@
|
||||||
|
|
||||||
|
$(TARGET): $(BIN)
|
||||||
|
./gen_code | ./sortline > $@
|
||||||
|
echo "#ifdef XBYAK_ENABLE_OMITTED_OPERAND" >> $@
|
||||||
|
./gen_code omit | ./sortline >> $@
|
||||||
|
echo "#endif" >>$@
|
||||||
|
./gen_code fixed >> $@
|
||||||
|
echo "#ifndef XBYAK_DISABLE_AVX512" >> $@
|
||||||
|
./gen_avx512 | ./sortline >> $@
|
||||||
|
echo "#ifdef XBYAK64" >> $@
|
||||||
|
./gen_avx512 64 | ./sortline >> $@
|
||||||
|
echo "#endif" >> $@
|
||||||
|
echo "#endif" >> $@
|
||||||
|
|
||||||
|
VER=$(shell head -n 1 ../xbyak/xbyak_mnemonic.h|grep -o "[0-9.]*")
|
||||||
|
../CMakeLists.txt: $(TARGET)
|
||||||
|
sed -i -e 's/CXX VERSION [0-9.]*/CXX VERSION $(VER)/' $@
|
||||||
|
|
||||||
|
../meson.build: $(TARGET)
|
||||||
|
sed -i -e "s/version: '[0-9.]*',/version: '$(VER)',/" $@
|
||||||
|
|
||||||
|
../readme.md: $(TARGET)
|
||||||
|
sed -l 2 -i -e "s/# Xbyak [0-9.]*/# Xbyak $(VER)/" $@
|
||||||
|
|
||||||
|
../readme.txt: $(TARGET)
|
||||||
|
sed -l 2 -i -e "s/Xbyak [0-9.]*/Xbyak $(VER)/" $@
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) $(BIN) $(TARGET) avx_type_def.h
|
||||||
60
external/xbyak/gen/avx_type.hpp
vendored
Normal file
60
external/xbyak/gen/avx_type.hpp
vendored
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
#include <assert.h>
|
||||||
|
#include "avx_type_def.h"
|
||||||
|
|
||||||
|
const int NONE = 256; // same as Xbyak::CodeGenerator::NONE
|
||||||
|
|
||||||
|
std::string type2String(uint64_t type)
|
||||||
|
{
|
||||||
|
if (type == 0) return "T_NONE";
|
||||||
|
std::string str;
|
||||||
|
int low = type & T_NX_MASK;
|
||||||
|
if (0 < low && low < 7) {
|
||||||
|
const char *tbl[8] = {
|
||||||
|
"T_N1", "T_N2", "T_N4", "T_N8", "T_N16", "T_N32"
|
||||||
|
};
|
||||||
|
assert(low < int(sizeof(tbl) / sizeof(tbl[0])));
|
||||||
|
str = tbl[low - 1];
|
||||||
|
}
|
||||||
|
if (type & T_N_VL) str += "|T_N_VL";
|
||||||
|
if (type & T_APX) str += "|T_APX";
|
||||||
|
if ((type & T_NX_MASK) == T_DUP) str += "|T_DUP";
|
||||||
|
if (type & T_66) str += "|T_66";
|
||||||
|
if (type & T_F3) str += "|T_F3";
|
||||||
|
if (type & T_F2) str += "|T_F2";
|
||||||
|
if (type & T_MAP5) str += "|T_MAP5";
|
||||||
|
if (type & T_0F) str += "|T_0F";
|
||||||
|
if (type & T_MAP6) str += "|T_MAP6";
|
||||||
|
if (type & T_0F38) str += "|T_0F38";
|
||||||
|
if (type & T_0F3A) str += "|T_0F3A";
|
||||||
|
if (type & T_L1) str += "|T_L1";
|
||||||
|
if (type & T_W0) str += "|T_W0";
|
||||||
|
if (type & T_W1) str += "|T_W1";
|
||||||
|
if (type & T_EW1) str += "|T_EW1";
|
||||||
|
if (type & T_YMM) str += "|T_YMM";
|
||||||
|
if (type & T_EVEX) str += "|T_EVEX";
|
||||||
|
if (type & T_ER_X) str += "|T_ER_X";
|
||||||
|
if (type & T_ER_Y) str += "|T_ER_Y";
|
||||||
|
if (type & T_ER_Z) str += "|T_ER_Z";
|
||||||
|
if (type & T_ER_R) str += "|T_ER_R";
|
||||||
|
if (type & T_SAE_X) str += "|T_SAE_X";
|
||||||
|
if (type & T_SAE_Y) str += "|T_SAE_Y";
|
||||||
|
if (type & T_SAE_Z) str += "|T_SAE_Z";
|
||||||
|
if (type & T_MUST_EVEX) str += "|T_MUST_EVEX";
|
||||||
|
|
||||||
|
switch (type & T_B16) { // T_B16 = T_B32 | T_B64
|
||||||
|
case T_B16: str += "|T_B16"; break;
|
||||||
|
case T_B32: str += "|T_B32"; break;
|
||||||
|
case T_B64: str += "|T_B64"; break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
if (type & T_M_K) str += "|T_M_K";
|
||||||
|
if (type & T_VSIB) str += "|T_VSIB";
|
||||||
|
if (type & T_MEM_EVEX) str += "|T_MEM_EVEX";
|
||||||
|
if (type & T_NF) str += "|T_NF";
|
||||||
|
if (type & T_CODE1_IF1) str += "|T_CODE1_IF1";
|
||||||
|
if (type & T_ND1) str += "|T_ND1";
|
||||||
|
if (type & T_ZU) str += "|T_ZU";
|
||||||
|
|
||||||
|
if (str[0] == '|') str = str.substr(1);
|
||||||
|
return str;
|
||||||
|
}
|
||||||
52
external/xbyak/gen/avx_type_def.h
vendored
Normal file
52
external/xbyak/gen/avx_type_def.h
vendored
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
// @@@begin of avx_type_def.h
|
||||||
|
static const uint64_t T_NONE = 0ull;
|
||||||
|
// low 3 bit
|
||||||
|
static const uint64_t T_N1 = 1ull;
|
||||||
|
static const uint64_t T_N2 = 2ull;
|
||||||
|
static const uint64_t T_N4 = 3ull;
|
||||||
|
static const uint64_t T_N8 = 4ull;
|
||||||
|
static const uint64_t T_N16 = 5ull;
|
||||||
|
static const uint64_t T_N32 = 6ull;
|
||||||
|
static const uint64_t T_NX_MASK = 7ull;
|
||||||
|
static const uint64_t T_DUP = T_NX_MASK;//1 << 4, // N = (8, 32, 64)
|
||||||
|
static const uint64_t T_N_VL = 1ull << 3; // N * (1, 2, 4) for VL
|
||||||
|
static const uint64_t T_APX = 1ull << 4;
|
||||||
|
static const uint64_t T_66 = 1ull << 5; // pp = 1
|
||||||
|
static const uint64_t T_F3 = 1ull << 6; // pp = 2
|
||||||
|
static const uint64_t T_ER_R = 1ull << 7; // reg{er}
|
||||||
|
static const uint64_t T_0F = 1ull << 8;
|
||||||
|
static const uint64_t T_0F38 = 1ull << 9;
|
||||||
|
static const uint64_t T_0F3A = 1ull << 10;
|
||||||
|
static const uint64_t T_MAP5 = 1ull << 11;
|
||||||
|
static const uint64_t T_L1 = 1ull << 12;
|
||||||
|
static const uint64_t T_W0 = 1ull << 13; // T_EW0 = T_W0
|
||||||
|
static const uint64_t T_W1 = 1ull << 14; // for VEX
|
||||||
|
static const uint64_t T_EW1 = 1ull << 16; // for EVEX
|
||||||
|
static const uint64_t T_YMM = 1ull << 17; // support YMM, ZMM
|
||||||
|
static const uint64_t T_EVEX = 1ull << 18;
|
||||||
|
static const uint64_t T_ER_X = 1ull << 19; // xmm{er}
|
||||||
|
static const uint64_t T_ER_Y = 1ull << 20; // ymm{er}
|
||||||
|
static const uint64_t T_ER_Z = 1ull << 21; // zmm{er}
|
||||||
|
static const uint64_t T_SAE_X = 1ull << 22; // xmm{sae}
|
||||||
|
static const uint64_t T_SAE_Y = 1ull << 23; // ymm{sae}
|
||||||
|
static const uint64_t T_SAE_Z = 1ull << 24; // zmm{sae}
|
||||||
|
static const uint64_t T_MUST_EVEX = 1ull << 25; // contains T_EVEX
|
||||||
|
static const uint64_t T_B32 = 1ull << 26; // m32bcst
|
||||||
|
static const uint64_t T_B64 = 1ull << 27; // m64bcst
|
||||||
|
static const uint64_t T_B16 = T_B32 | T_B64; // m16bcst (Be careful)
|
||||||
|
static const uint64_t T_M_K = 1ull << 28; // mem{k}
|
||||||
|
static const uint64_t T_VSIB = 1ull << 29;
|
||||||
|
static const uint64_t T_MEM_EVEX = 1ull << 30; // use evex if mem
|
||||||
|
static const uint64_t T_MAP6 = 1ull << 31;
|
||||||
|
static const uint64_t T_NF = 1ull << 32; // T_nf
|
||||||
|
static const uint64_t T_CODE1_IF1 = 1ull << 33; // code|=1 if !r.isBit(8)
|
||||||
|
|
||||||
|
static const uint64_t T_ND1 = 1ull << 35; // ND=1
|
||||||
|
static const uint64_t T_ZU = 1ull << 36; // ND=ZU
|
||||||
|
static const uint64_t T_F2 = 1ull << 37; // pp = 3
|
||||||
|
static const uint64_t T_SENTRY = (1ull << 38)-1; // attribute(>=T_SENTRY) is for error check
|
||||||
|
static const uint64_t T_ALLOW_DIFF_SIZE = 1ull << 38; // allow difference reg size
|
||||||
|
static const uint64_t T_ALLOW_ABCDH = 1ull << 39; // allow [abcd]h reg
|
||||||
|
// T_66 = 1, T_F3 = 2, T_F2 = 3
|
||||||
|
static inline uint32_t getPP(uint64_t type) { return (type & T_66) ? 1 : (type & T_F3) ? 2 : (type & T_F2) ? 3 : 0; }
|
||||||
|
// @@@end of avx_type_def.h
|
||||||
17
external/xbyak/gen/b2hex.cpp
vendored
Normal file
17
external/xbyak/gen/b2hex.cpp
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
puts("enum {");
|
||||||
|
for (int i = 0; i < 256; i++) {
|
||||||
|
printf(" B");
|
||||||
|
for (int j = 0; j < 8; j++) {
|
||||||
|
putchar(i & (1 << (7 - j)) ? '1' : '0');
|
||||||
|
}
|
||||||
|
printf("= %d", i);
|
||||||
|
if (i < 255) putchar(',');
|
||||||
|
putchar('\n');
|
||||||
|
}
|
||||||
|
puts("};");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
1205
external/xbyak/gen/gen_avx512.cpp
vendored
Normal file
1205
external/xbyak/gen/gen_avx512.cpp
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2208
external/xbyak/gen/gen_code.cpp
vendored
Normal file
2208
external/xbyak/gen/gen_code.cpp
vendored
Normal file
File diff suppressed because it is too large
Load Diff
23
external/xbyak/gen/sortline.cpp
vendored
Normal file
23
external/xbyak/gen/sortline.cpp
vendored
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
#include <string>
|
||||||
|
#include <set>
|
||||||
|
|
||||||
|
typedef std::set<std::string> StrSet;
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
StrSet ss;
|
||||||
|
std::string line;
|
||||||
|
while (std::getline(std::cin, line)) {
|
||||||
|
if (!line.empty() && line[line.size() - 1] == '\n') {
|
||||||
|
line.resize(line.size() - 1);
|
||||||
|
}
|
||||||
|
if (!line.empty()) {
|
||||||
|
ss.insert(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (StrSet::const_iterator i = ss.begin(), ie = ss.end(); i != ie; ++i) {
|
||||||
|
std::cout << *i << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
17
external/xbyak/gen/update.bat
vendored
Normal file
17
external/xbyak/gen/update.bat
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
@echo off
|
||||||
|
set OPT=/EHsc -I../ /W4 -D_CRT_SECURE_NO_WARNINGS
|
||||||
|
set TARGET=..\\xbyak\\xbyak_mnemonic.h
|
||||||
|
set SORT=sortline
|
||||||
|
cl gen_code.cpp %OPT%
|
||||||
|
gen_code | %SORT% > %TARGET%
|
||||||
|
echo #ifdef XBYAK_ENABLE_OMITTED_OPERAND>> %TARGET%
|
||||||
|
gen_code omit | %SORT% >> %TARGET%
|
||||||
|
echo #endif>>%TARGET%
|
||||||
|
gen_code fixed >> %TARGET%
|
||||||
|
cl gen_avx512.cpp %OPT%
|
||||||
|
echo #ifndef XBYAK_DISABLE_AVX512>> %TARGET%
|
||||||
|
gen_avx512 | %SORT% >> %TARGET%
|
||||||
|
echo #ifdef XBYAK64>> %TARGET%
|
||||||
|
gen_avx512 64 | %SORT% >> %TARGET%
|
||||||
|
echo #endif>> %TARGET%
|
||||||
|
echo #endif>> %TARGET%
|
||||||
45
external/xbyak/meson.build
vendored
Normal file
45
external/xbyak/meson.build
vendored
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
# SPDX-FileCopyrightText: 2021 Andrea Pappacoda
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
|
project(
|
||||||
|
'xbyak',
|
||||||
|
'cpp',
|
||||||
|
version: '7.30',
|
||||||
|
license: 'BSD-3-Clause',
|
||||||
|
default_options: 'b_ndebug=if-release'
|
||||||
|
)
|
||||||
|
|
||||||
|
install_subdir('xbyak', install_dir: get_option('includedir'))
|
||||||
|
|
||||||
|
xbyak_dep = declare_dependency(include_directories: include_directories('.'))
|
||||||
|
|
||||||
|
if meson.version().version_compare('>=0.54.0')
|
||||||
|
meson.override_dependency(meson.project_name(), xbyak_dep)
|
||||||
|
endif
|
||||||
|
|
||||||
|
import('pkgconfig').generate(
|
||||||
|
name: meson.project_name(),
|
||||||
|
description: 'JIT assembler for x86(IA32), x64(AMD64, x86-64)',
|
||||||
|
version: meson.project_version(),
|
||||||
|
url: 'https://github.com/herumi/xbyak'
|
||||||
|
)
|
||||||
|
|
||||||
|
if meson.version().version_compare('>=0.50.0')
|
||||||
|
cmake = import('cmake')
|
||||||
|
|
||||||
|
cmake.write_basic_package_version_file(
|
||||||
|
name: meson.project_name(),
|
||||||
|
version: meson.project_version()
|
||||||
|
)
|
||||||
|
|
||||||
|
cmake_conf = configuration_data()
|
||||||
|
cmake_conf.set('TARGET_NAME', meson.project_name() + '::' + meson.project_name())
|
||||||
|
cmake_conf.set('ABSOLUTE_INCLUDE_DIR', get_option('prefix')/get_option('includedir'))
|
||||||
|
|
||||||
|
cmake.configure_package_config_file(
|
||||||
|
name: meson.project_name(),
|
||||||
|
input: 'cmake'/'meson-config.cmake.in',
|
||||||
|
configuration: cmake_conf
|
||||||
|
)
|
||||||
|
endif
|
||||||
93
external/xbyak/readme.md
vendored
Normal file
93
external/xbyak/readme.md
vendored
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
|
||||||
|
# Xbyak 7.30 [![Badge Build]][Build Status]
|
||||||
|
|
||||||
|
*A JIT assembler for x86/x64 architectures supporting advanced instruction sets up to AVX10.2*
|
||||||
|
|
||||||
|
## Menu
|
||||||
|
|
||||||
|
- [Install]
|
||||||
|
- [Usage]
|
||||||
|
- [Changelog]
|
||||||
|
|
||||||
|
## Abstract
|
||||||
|
|
||||||
|
Xbyak is a C++ header-only library that enables dynamic assembly of x86/x64 instructions using mnemonics.
|
||||||
|
|
||||||
|
The pronunciation of Xbyak is `/kʌɪbjæk/` (kai-byak).
|
||||||
|
|
||||||
|
The name is derived from the Japanese word [開闢](https://translate.google.com/?hl=ja&sl=ja&tl=en&text=%E9%96%8B%E9%97%A2&op=translate) (kaibyaku), which means "the beginning of the world" or "creation".
|
||||||
|
|
||||||
|
## Features
|
||||||
|
- Header-only library
|
||||||
|
- Intel/MASM-like syntax
|
||||||
|
- Full support for AVX-512, APX, and AVX10.2
|
||||||
|
|
||||||
|
**Note**:
|
||||||
|
Use `and_()`, `or_()`, ... instead of `and()`, `or()`.
|
||||||
|
If you want to use them, then specify `-fno-operator-names` option to gcc/clang.
|
||||||
|
|
||||||
|
### Derived Projects
|
||||||
|
- [Xbyak_aarch64](https://github.com/fujitsu/xbyak_aarch64/) : for AArch64
|
||||||
|
- [Xbyak_riscv](https://github.com/herumi/xbyak_riscv) : for RISC-V
|
||||||
|
|
||||||
|
### News
|
||||||
|
|
||||||
|
- Support AVX10.2
|
||||||
|
- Support xresldtrk/xsusldtrk
|
||||||
|
- Support RAO-INT for APX
|
||||||
|
- Support AVX10 detection, AESKLE, WIDE_KL, KEYLOCKER, KEYLOCKER_WIDE
|
||||||
|
- Support APX except for a few instructions
|
||||||
|
- Add amx_fp16/avx_vnni_int8/avx_ne_convert/avx-ifma
|
||||||
|
- Add movdiri, movdir64b, clwb, cldemote
|
||||||
|
- WAITPKG instructions (tpause, umonitor, umwait) are supported.
|
||||||
|
- MmapAllocator supports memfd with user-defined strings. see sample/memfd.cpp
|
||||||
|
- 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.
|
||||||
|
- (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.
|
||||||
|
|
||||||
|
### Supported OS
|
||||||
|
|
||||||
|
- Windows (Xp, Vista, 7, 10, 11) (32 / 64 bit)
|
||||||
|
- Linux (32 / 64 bit)
|
||||||
|
- macOS (Intel CPU)
|
||||||
|
|
||||||
|
### 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.
|
||||||
|
|
||||||
|
|
||||||
|
### References
|
||||||
|
- [Intel 64 and IA-32 Architectures Software Developer Manuals](https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html)
|
||||||
|
- [Intel Advanced Performance Extensions (Intel APX) Architecture Specification](https://www.intel.com/content/www/us/en/content-details/836198/intel-advanced-performance-extensions-intel-apx-architecture-specification.html)
|
||||||
|
- [Intel Advanced Vector Extensions 10.2 (Intel AVX10.2) Architecture Specification](https://www.intel.com/content/www/us/en/content-details/855340/intel-advanced-vector-extensions-10-2-intel-avx10-2-architecture-specification.html)
|
||||||
|
- [Intel Architecture Instruction Set Extensions Programming Reference](https://www.intel.com/content/www/us/en/content-details/851355/intel-architecture-instruction-set-extensions-programming-reference.html)
|
||||||
|
- [Intel Software Development Emulator](https://www.intel.com/content/www/us/en/download/684897/intel-software-development-emulator.html)
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
[BSD-3-Clause License](http://opensource.org/licenses/BSD-3-Clause)
|
||||||
|
|
||||||
|
## Author
|
||||||
|
|
||||||
|
#### 光成滋生 Mitsunari Shigeo
|
||||||
|
[GitHub](https://github.com/herumi) | [Website (Japanese)](http://herumi.in.coocan.jp/) | [herumi@nifty.com](mailto:herumi@nifty.com)
|
||||||
|
|
||||||
|
## Sponsors welcome
|
||||||
|
[GitHub Sponsor](https://github.com/sponsors/herumi)
|
||||||
|
|
||||||
|
<!----------------------------------------------------------------------------->
|
||||||
|
|
||||||
|
[Badge Build]: https://github.com/herumi/xbyak/actions/workflows/main.yml/badge.svg
|
||||||
|
[Build Status]: https://github.com/herumi/xbyak/actions/workflows/main.yml
|
||||||
|
|
||||||
|
[License]: COPYRIGHT
|
||||||
|
|
||||||
|
[Changelog]: doc/changelog.md
|
||||||
|
[Install]: doc/install.md
|
||||||
|
[Usage]: doc/usage.md
|
||||||
|
|
||||||
648
external/xbyak/readme.txt
vendored
Normal file
648
external/xbyak/readme.txt
vendored
Normal file
@@ -0,0 +1,648 @@
|
|||||||
|
|
||||||
|
C++用x86(IA-32), x64(AMD64, x86-64) JITアセンブラ Xbyak 7.30
|
||||||
|
|
||||||
|
-----------------------------------------------------------------------------
|
||||||
|
◎概要
|
||||||
|
|
||||||
|
これはx86, x64(AMD64, x86-64)のマシン語命令を生成するC++のクラスライブラリです。
|
||||||
|
プログラム実行時に動的にアセンブルすることが可能です。
|
||||||
|
|
||||||
|
-----------------------------------------------------------------------------
|
||||||
|
◎特徴
|
||||||
|
|
||||||
|
・ヘッダファイルオンリー
|
||||||
|
xbyak.hをインクルードするだけですぐ利用することができます。
|
||||||
|
C++の枠組み内で閉じているため、外部アセンブラは不要です。
|
||||||
|
32bit/64bit両対応です。
|
||||||
|
対応ニーモニック:特権命令除くx86, MMX/MMX2/SSE/SSE2/SSE3/SSSE3/SSE4/FPU(一部)/AVX/AVX2/FMA/AVX-512/APX/AVX10.2
|
||||||
|
|
||||||
|
・Windows Xp(32bit, 64bit), Windows 7/Linux(32bit, 64bit)/Intel Mac対応
|
||||||
|
Windows Xp, Windows 7上ではVC2008, VC2010, VC2012
|
||||||
|
Linux (kernel 3.8)上ではgcc 4.7.3, clang 3.3
|
||||||
|
Intel Mac
|
||||||
|
などで動作確認をしています。
|
||||||
|
|
||||||
|
※ and, orなどの代わりにand_, or_を使用してください。
|
||||||
|
and, orなどを使いたい場合は-fno-operator-namesをgcc/clangに指定してください。
|
||||||
|
|
||||||
|
-----------------------------------------------------------------------------
|
||||||
|
◎準備
|
||||||
|
xbyak.h
|
||||||
|
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に変更
|
||||||
|
** 従来のenumの値をとるにはintにキャストしてください。
|
||||||
|
* (古い)Reg32eクラスを(新しい)Reg32eとRegExpに分ける。
|
||||||
|
** (新しい)Reg32eはReg32かReg64
|
||||||
|
** (新しい)RegExpは'Reg32e + (Reg32e|Xmm|Ymm) * scale + disp'の型
|
||||||
|
|
||||||
|
-----------------------------------------------------------------------------
|
||||||
|
◎新機能
|
||||||
|
|
||||||
|
APX/AVX10.2対応
|
||||||
|
|
||||||
|
例外なしモード追加
|
||||||
|
XBYAK_NO_EXCEPTIONを定義してコンパイルするとgcc/clangで-fno-exceptionsオプションでコンパイルできます。
|
||||||
|
エラーは例外の代わりに`Xbyak::GetError()`で通達されます。
|
||||||
|
この値が0でなければ何か問題が発生しています。
|
||||||
|
この値は自動的に変更されないので`Xbyak::ClearError()`でリセットしてください。
|
||||||
|
`CodeGenerator::reset()`は`ClearError()`を呼びます。
|
||||||
|
|
||||||
|
MmapAllocator追加
|
||||||
|
これはUnix系OSでのみの仕様です。XBYAK_USE_MMAP_ALLOCATORを使うと利用できます。
|
||||||
|
デフォルトのAllocatorはメモリ確保時にposix_memalignを使います。
|
||||||
|
この領域に対するmprotectはmap countを減らします。
|
||||||
|
map countの最大値は/proc/sys/vm/max_map_countに書かれています。
|
||||||
|
デフォルトでは3万個ほどのXbyak::CodeGeneratorインスタンスを生成するとエラーになります。
|
||||||
|
test/mprotect_test.cppで確認できます。
|
||||||
|
これを避けるためにはmmapを使うMmapAllocatorを使ってください。
|
||||||
|
|
||||||
|
|
||||||
|
AutoGrowモード追加
|
||||||
|
これはメモリ伸長を動的に行うモードです。
|
||||||
|
今まではXbyak::CodeGenerator()に渡したメモリサイズを超えると例外が発生して
|
||||||
|
いましたが、このモードでは内部でメモリを再確保して伸長します。
|
||||||
|
ただし、getCode()を呼び出す前にジャンプ命令のアドレス解決をするためにready()
|
||||||
|
関数を呼ぶ必要があります。
|
||||||
|
|
||||||
|
次のように使います。
|
||||||
|
|
||||||
|
struct Code : Xbyak::CodeGenerator {
|
||||||
|
Code()
|
||||||
|
: Xbyak::CodeGenerator(<default memory size>, Xbyak::AutoGrow)
|
||||||
|
{
|
||||||
|
...
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Code c;
|
||||||
|
c.ready(); // この呼び出しを忘れてはいけない
|
||||||
|
|
||||||
|
注意1. ready()を呼んで確定するまではgetCurr()で得たポインタは無効化されている
|
||||||
|
可能性があります。getSize()でoffsetを保持しておきready()のあとにgetCode()を
|
||||||
|
呼び出してからgetCode() + offsetで新しいポインタを取得してください。
|
||||||
|
|
||||||
|
注意2. AutoGrowモードでは64bitモードの相対アドレッシング[rip]は非サポートです。
|
||||||
|
|
||||||
|
-----------------------------------------------------------------------------
|
||||||
|
◎文法
|
||||||
|
|
||||||
|
Xbyak::CodeGeneratorクラスを継承し、そのクラスメソッド内でx86, x64アセンブラを
|
||||||
|
記述します。そのメソッドを呼び出した後、getCode()メソッドを呼び出し、その戻
|
||||||
|
り値を自分が使いたい関数ポインタに変換して利用します。アセンブルエラーは例外
|
||||||
|
により通知されます(cf. main.cpp)。
|
||||||
|
|
||||||
|
・基本的にnasmの命令で括弧をつければよいです。
|
||||||
|
|
||||||
|
mov eax, ebx --> mov(eax, ebx);
|
||||||
|
inc ecx inc(ecx);
|
||||||
|
ret --> ret();
|
||||||
|
|
||||||
|
・アドレッシング
|
||||||
|
|
||||||
|
(ptr|dword|word|byte) [base + index * (1|2|4|8) + displacement]
|
||||||
|
[rip + 32bit disp] ; x64 only
|
||||||
|
という形で指定します。サイズを指定する必要がない限りptrを使えばよいです。
|
||||||
|
|
||||||
|
セレクター(セグメントレジスタ)をサポートしました。
|
||||||
|
(注意)セグメントレジスタはOperandを継承していません。
|
||||||
|
|
||||||
|
mov eax, [fs:eax] --> putSeg(fs); mov(eax, ptr [eax]);
|
||||||
|
mov ax, cs --> mov(ax, cs);
|
||||||
|
|
||||||
|
mov eax, [ebx+ecx] --> mov (eax, ptr[ebx+ecx]);
|
||||||
|
test byte [esp], 4 --> test (byte [esp], 4);
|
||||||
|
|
||||||
|
(注意) dword, word, byteはメンバ変数です。従ってたとえばunsigned intの
|
||||||
|
つもりでdwordをtypedefしないでください。
|
||||||
|
|
||||||
|
・AVX
|
||||||
|
|
||||||
|
FMAについては簡略表記を導入するか検討中です(アイデア募集中)。
|
||||||
|
|
||||||
|
vaddps(xmm1, xmm2, xmm3); // xmm1 <- xmm2 + xmm3
|
||||||
|
vaddps(xmm2, xmm3, ptr [rax]); // メモリアクセスはptrで
|
||||||
|
|
||||||
|
vfmadd231pd(xmm1, xmm2, xmm3); // xmm1 <- (xmm2 * xmm3) + xmm1
|
||||||
|
|
||||||
|
*注意*
|
||||||
|
デスティネーションの省略形はサポートされなくなりました。
|
||||||
|
|
||||||
|
vaddps(xmm2, xmm3); // xmm2 <- xmm2 + xmm3
|
||||||
|
|
||||||
|
XBYAK_ENABLE_OMITTED_OPERANDを定義すると使えますが、将来はそれも非サポートになるでしょう。
|
||||||
|
|
||||||
|
・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]{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, xword_b [rax+64], 5); // broadcast 64-bit to 256-bit
|
||||||
|
|
||||||
|
vpdpbusd(xm0, xm1, xm2); // default encoding is EVEX
|
||||||
|
vpdpbusd(xm0, xm1, xm2, EvexEncoding); // same as the above
|
||||||
|
vpdpbusd(xm0, xm1, xm2, VexEncoding); // VEX encoding
|
||||||
|
setDefaultEncoding(VexEncoding); // default encoding is VEX
|
||||||
|
vpdpbusd(xm0, xm1, xm2); // VEX encoding
|
||||||
|
注意
|
||||||
|
* k1, ..., k7 は新しいopmaskレジスタです。
|
||||||
|
* z, sae, rn-sae, rd-sae, ru-sae, rz-saeの代わりにT_z, T_sae, T_rn_sae, T_rd_sae, T_ru_sae, T_rz_saeを使ってください。
|
||||||
|
* `k4 | k3`と`k3 | k4`は意味が異なります。
|
||||||
|
* {1toX}の代わりにptr_bを使ってください。Xは自動的に決まります。
|
||||||
|
* 一部の命令はメモリサイズを指定するためにxword/yword/zword(_b)を使ってください。
|
||||||
|
* setDefaultEncoding()でencoding省略時のEVEX/VEXを設定できます。
|
||||||
|
|
||||||
|
・ラベル
|
||||||
|
|
||||||
|
L(文字列);
|
||||||
|
で定義します。ジャンプするときはその文字列を指定します。後方参照も可能ですが、
|
||||||
|
相対アドレスが8ビットに収まらない場合はT_NEARをつけないと実行時に例外が発生
|
||||||
|
します。
|
||||||
|
mov(eax, "L2");の様にラベルが表すアドレスをmovの即値として使えます。
|
||||||
|
|
||||||
|
・hasUndefinedLabel()を呼び出して真ならジャンプ先が存在しないことを示します。
|
||||||
|
コードを見直してください。
|
||||||
|
|
||||||
|
L("L1");
|
||||||
|
jmp ("L1");
|
||||||
|
|
||||||
|
jmp ("L2");
|
||||||
|
...
|
||||||
|
少しの命令の場合。
|
||||||
|
...
|
||||||
|
L("L2");
|
||||||
|
|
||||||
|
jmp ("L3", T_NEAR);
|
||||||
|
...
|
||||||
|
沢山の命令がある場合
|
||||||
|
...
|
||||||
|
L("L3");
|
||||||
|
|
||||||
|
<応用編>
|
||||||
|
|
||||||
|
1. MASMライクな@@, @f, @bをサポート
|
||||||
|
|
||||||
|
L("@@"); // <A>
|
||||||
|
jmp("@b"); // jmp to <A>
|
||||||
|
jmp("@f"); // jmp to <B>
|
||||||
|
L("@@"); // <B>
|
||||||
|
jmp("@b"); // jmp to <B>
|
||||||
|
mov(eax, "@b");
|
||||||
|
jmp(eax); // jmp to <B>
|
||||||
|
|
||||||
|
2. ラベルの局所化
|
||||||
|
|
||||||
|
ピリオドで始まるラベルをinLocalLabel(), outLocalLabel()で挟むことで局所化できます。
|
||||||
|
inLocalLabel(), outLocalLabel()は入れ子にすることができます。
|
||||||
|
|
||||||
|
void func1()
|
||||||
|
{
|
||||||
|
inLocalLabel();
|
||||||
|
L(".lp"); // <A> ; ローカルラベル
|
||||||
|
...
|
||||||
|
jmp(".lp"); // jmpt to <A>
|
||||||
|
L("aaa"); // グローバルラベル
|
||||||
|
outLocalLabel();
|
||||||
|
}
|
||||||
|
|
||||||
|
void func2()
|
||||||
|
{
|
||||||
|
inLocalLabel();
|
||||||
|
L(".lp"); // <B> ; ローカルラベル
|
||||||
|
func1();
|
||||||
|
jmp(".lp"); // jmp to <B>
|
||||||
|
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());
|
||||||
|
```
|
||||||
|
|
||||||
|
4. farジャンプ
|
||||||
|
|
||||||
|
`jmp(mem, T_FAR)`, `call(mem, T_FAR)`, `retf()`をサポートします。
|
||||||
|
サイズを明示するために`ptr`の代わりに`word|dword|qword`を利用してください。
|
||||||
|
|
||||||
|
32bit
|
||||||
|
```
|
||||||
|
jmp(word[eax], T_FAR); // jmp m16:16(FF /5)
|
||||||
|
jmp(dword[eax], T_FAR); // jmp m16:32(FF /5)
|
||||||
|
```
|
||||||
|
|
||||||
|
64bit
|
||||||
|
```
|
||||||
|
jmp(word[rax], T_FAR); // jmp m16:16(FF /5)
|
||||||
|
jmp(dword[rax], T_FAR); // jmp m16:32(FF /5)
|
||||||
|
jmp(qword[rax], T_FAR); // jmp m16:64(REX.W FF /5)
|
||||||
|
```
|
||||||
|
|
||||||
|
・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 から
|
||||||
|
いただきました。
|
||||||
|
|
||||||
|
-----------------------------------------------------------------------------
|
||||||
|
◎履歴
|
||||||
|
|
||||||
|
2025/09/02 ver 7.30 tcvtrowd2ps追加
|
||||||
|
2025/08/22 ver 7.29.2 override属性追加
|
||||||
|
2025/08/16 ver 7.29.1 ptr[整数] 形式のサポート
|
||||||
|
2025/08/15 ver 7.29 アドレッシングでラベルサポート
|
||||||
|
2025/07/19 ver 7.28 movrs, vmovrs{b,w,d,q}をサポート
|
||||||
|
2025/07/02 ver 7.27 新しいAVX10.2仕様書にしたがってYMMレジスタの埋め込み丸めとsaeの削除
|
||||||
|
2025/06/10 ver 7.26 Diamond Rapids用AMX対応
|
||||||
|
2025/06/02 ver 7.25 新しいAVX10.2仕様書にしたがってBF16命令をリネーム
|
||||||
|
2025/03/12 ver 7.24.2 vcvtneps2bf16はAVX-NE-CONVERTをサポートすべき(revert 749aa31)
|
||||||
|
2025/02/26 ver 7.24.1 NDD形式の3-opシフト命令のバグ修正
|
||||||
|
2025/02/17 ver 7.24 ahなどとREXプレフィクスの共用やadd eax, byte[rax]のようなサイズ不整合をエラーとする
|
||||||
|
2025/02/07 ver 7.23.1 StackFrame::close()の挙動を元に戻す
|
||||||
|
2025/02/07 ver 7.23 レジスタサイズのチェック厳密化・16ビット側値の範囲改善・StackFrame::close()の仕様変更。push/pop with APX修正。
|
||||||
|
2024/11/11 ver 7.22 Reg::cvt{128,256,512}(). xed 2024.11.04でテスト
|
||||||
|
2024/10/31 ver 7.21 SSE命令のXMMレジスタのチェックを厳密化
|
||||||
|
2024/10/17 ver 7.20.1 AVX10.2 rev 2.0仕様書の変更に追従
|
||||||
|
2024/10/15 ver 7.20 setDefaultEncoding/setDefaultEncodingAVX10の仕様確定
|
||||||
|
2024/10/15 ver 7.11 AVX10.2完全サポート
|
||||||
|
2024/10/13 ver 7.10 AVX10 integer and fp16 vnni, mediaの新命令対応. setDefaultEncodingの拡張.
|
||||||
|
2024/10/10 ver 7.09.1 vpcompressbとvpcompresswの名前修正
|
||||||
|
2024/10/08 ver 7.09 AVX10.2のYMMレジスタの埋め込み丸め対応
|
||||||
|
2024/10/07 ver 7.08 rdfabaseなどサポート
|
||||||
|
2024/08/29 ver 7.07.1 xchgの仕様をnasm 2.16.03の挙動に合わせる。
|
||||||
|
2024/06/11 ver 7.07 xresldtrk/xsusldtrkサポート
|
||||||
|
2024/03/07 ver 7.06 util::Cpuのキャッシュ判定周りがAMD CPU対応
|
||||||
|
2024/02/11 ver 7.05.1 util::CpuのextractBit()とautoGrowモードでのalign()の修正
|
||||||
|
2024/01/03 ver 7.05 APX対応RAO-INT
|
||||||
|
2023/12/28 ver 7.04 2バイトオペコードのrex2対応
|
||||||
|
2023/12/26 ver 7.03 dfvのデフォルト値を0に設定
|
||||||
|
2023/12/20 ver 7.02 SHA*のAPX対応
|
||||||
|
2023/12/19 ver 7.01 AESKLE, WIDE_KL, KEYLOCKER, KEYLOCKER_WIDE対応 APX10/APX判定対応
|
||||||
|
2023/12/01 ver 7.00 APX対応
|
||||||
|
2023/08/07 ver 6.73 sha512/sm3/sm4/avx-vnni-int16追加
|
||||||
|
2023/08/02 ver 6.72 xabort, xbegin, xend追加
|
||||||
|
2023/07/27 ver 6.71 Allocatorでhuge pageを考慮する。
|
||||||
|
2023/07/05 ver 6.70 vpclmulqdqのailas追加
|
||||||
|
2023/06/27 ver 6.69.2 `TypeT operator|`にconstexpr追加(thanks to Wunkolo)
|
||||||
|
2023/03/23 ver 6.69.1 xsave判定追加(thanks to Wunkolo)
|
||||||
|
2023/02/20 ver 6.69 util::CpuがAMD対応 UINTR命令対応
|
||||||
|
2022/12/07 ver 6.68 prefetchit{0,1}サポート
|
||||||
|
2022/11/30 ver 6.67 CMPccXADDサポート
|
||||||
|
2022/11/25 ver 6.66 RAO-INTサポート
|
||||||
|
2022/11/22 ver 6.65 x32動作確認
|
||||||
|
2022/11/04 ver 6.64 vmov*命令をmaskつきアドレッシング対応修正
|
||||||
|
2022/10/06 ver 6.63 AVX-IFMA用のvpmadd52{h,l}uq対応
|
||||||
|
2022/10/05 amx_fp16/avx_vnni_int8/avx_ne_convertt対応とsetDefaultEncoding()追加
|
||||||
|
2022/09/15 ver 6.62 serialize追加
|
||||||
|
2022/08/02 ver 6.61.1 noexceptはVisual Studio 2015以降対応
|
||||||
|
2022/07/29 ver 6.61 movzx eax, ahがエラーになるのを修正
|
||||||
|
2022/06/16 ver 6.60.2 GFNI, VAES, VPCLMULQDQの判定修正
|
||||||
|
2022/06/15 ver 6.60.1 Visual Studio /O0でXbyak::util::Cpuがリンクエラーになるのに対応
|
||||||
|
2022/06/06 ver 6.60 バージョンのつけ方を数値が戻らないように変更
|
||||||
|
2022/06/01 ver 6.06 Cpu::TypeクラスのリファクタリングとXBYAK_USE_MEMFDが定義されたときのMmapAllocatorの改善
|
||||||
|
2022/05/20 ver 6.052 Cpu::operator==()を正しく定義
|
||||||
|
2022/05/13 ver 6.051 XYBAK_NO_EXCEPTIONを定義したときのCpuクラスのコンパイルエラー修正
|
||||||
|
2022/05/12 ver 6.05 movdiri, movdir64b, clwb, cldemoteを追加
|
||||||
|
2022/04/05 ver 6.04 tpause, umonitor, umwaitを追加
|
||||||
|
2022/03/08 ver 6.03 MmapAllocatorがmemfd用のユーザ定義文字列をサポート
|
||||||
|
2022/01/28 ver 6.02 dispacementの32bit範囲チェックの厳密化
|
||||||
|
2021/12/14 ver 6.01 T_FAR jump/callとretfをサポート
|
||||||
|
2021/09/14 ver 6.00 AVX512-FP16を完全サポート
|
||||||
|
2021/09/09 ver 5.997 vrndscale*を{sae}をサポートするよう修正
|
||||||
|
2021/09/03 ver 5.996 v{add,sub,mul,div,max,min}{sd,ss}をT_rd_saeなどをサポートするよう修正
|
||||||
|
2021/08/15 ver 5.995 Linux上でXBYAK_USE_MEMFDが定義されたなら/proc/self/mapsにラベル追加
|
||||||
|
2021/06/17 ver 5.994 マスクレジスタ用のvcmpXX{ps,pd,ss,sd}のalias追加
|
||||||
|
2021/06/06 ver 5.993 gather/scatterのレジスタの組み合わせの厳密なチェック
|
||||||
|
2021/05/09 ver 5.992 endbr32とendbr64のサポート
|
||||||
|
2020/11/16 ver 5.991 g++-5のC++14でconstexpr機能の抑制
|
||||||
|
2020/10/19 ver 5.99 VNNI命令サポート(Thanks to akharito)
|
||||||
|
2020/10/17 ver 5.98 [scale * reg]のサポート
|
||||||
|
2020/09/08 ver 5.97 uint32などをuint32_tに置換
|
||||||
|
2020/08/28 ver 5.95 レジスタクラスのコンストラクタがconstexprに対応(C++14以降)
|
||||||
|
2020/08/04 ver 5.941 `CodeGenerator::reset()`が`ClearError()`を呼ぶように変更
|
||||||
|
2020/07/28 ver 5.94 #include <winsock2.h>の削除 (only windows)
|
||||||
|
2020/07/21 ver 5.93 例外なしモード追加
|
||||||
|
2020/06/30 ver 5.92 Intel AMX命令サポート (Thanks to nshustrov)
|
||||||
|
2020/06/19 ver 5.913 32ビット環境でXBYAK64を定義したときのmov(r64, imm64)を修正
|
||||||
|
2020/06/19 ver 5.912 macOSの古いXcodeでもMAP_JITを有効にする(Thanks to rsdubtso)
|
||||||
|
2020/05/10 ver 5.911 Linux/macOSでXBYAK_USE_MMAP_ALLOCATORがデフォルト有効になる
|
||||||
|
2020/04/20 ver 5.91 マスクレジスタk0を受け入れる(マスクをしない)
|
||||||
|
2020/04/09 ver 5.90 kmov{b,w,d,q}がサポートされないレジスタを受けると例外を投げる
|
||||||
|
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(<label>)
|
||||||
|
2010/06/17 ver 2.28 move some member functions to public
|
||||||
|
2010/06/01 ver 2.27 support encoding of mov(reg64, imm) like yasm(not nasm)
|
||||||
|
2010/05/24 ver 2.26 fix sub(rsp, 1000)
|
||||||
|
2010/04/26 ver 2.25 add jc/jnc(I forgot to implement them...)
|
||||||
|
2010/04/16 ver 2.24 change the prototype of rewrite() method
|
||||||
|
2010/04/15 ver 2.23 fix align() and xbyak_util.h for Mac
|
||||||
|
2010/02/16 ver 2.22 fix inLocalLabel()/outLocalLabel()
|
||||||
|
2009/12/09 ver 2.21 support cygwin(gcc 4.3.2)
|
||||||
|
2009/11/28 ver 2.20 FPUの一部命令サポート
|
||||||
|
2009/06/25 ver 2.11 64bitモードでの mov(qword[rax], imm); 修正(thanks to Martinさん)
|
||||||
|
2009/03/10 ver 2.10 jmp/call reg64の冗長なREG.W削除
|
||||||
|
2009/02/24 ver 2.09 movq reg64, mmx/xmm; movq mmx/xmm, reg64追加
|
||||||
|
2009/02/13 ver 2.08 movd(xmm7, dword[eax])が0x66を落とすバグ修正(thanks to Gabestさん)
|
||||||
|
2008/12/30 ver 2.07 call()の相対アドレスが8bit以下のときのバグ修正(thanks to katoさん)
|
||||||
|
2008/09/18 ver 2.06 @@, @f, @bとラベルの局所化機能追加(thanks to nobu-qさん)
|
||||||
|
2008/09/18 ver 2.05 ptr [rip + 32bit offset]サポート(thanks to 団子厨(Dango-Chu)さん)
|
||||||
|
2008/06/03 ver 2.04 align()のポカミス修正。mov(ptr[eax],1);などをエラーに
|
||||||
|
2008/06/02 ver 2.03 ユーザ定義メモリインタフェースサポート
|
||||||
|
2008/05/26 ver 2.02 protect()(on Linux)で不正な設定になることがあるのを修正(thanks to sinichiro_hさん)
|
||||||
|
2008/04/30 ver 2.01 cmpxchg16b, cdqe追加
|
||||||
|
2008/04/29 ver 2.00 x86/x64-64版公開
|
||||||
|
2008/04/25 ver 1.90 x64版β公開
|
||||||
|
2008/04/18 ver 1.12 コード整理
|
||||||
|
2008/04/14 ver 1.11 コード整理
|
||||||
|
2008/03/12 ver 1.10 bsf/bsr追加(忘れていた)
|
||||||
|
2008/02/14 ver 1.09 sub eax, 1234が16bitモードで出力されていたのを修正(thanks to Robertさん)
|
||||||
|
2007/11/05 ver 1.08 lock, xadd, xchg追加
|
||||||
|
2007/11/02 ver 1.07 SSSE3/SSE4対応(thanks to 団子厨(Dango-Chu)さん)
|
||||||
|
2007/09/25 ver 1.06 call((int)関数ポインタ); jmp((int)関数ポインタ);のサポート
|
||||||
|
2007/08/04 ver 1.05 細かい修正
|
||||||
|
2007/02/04 後方へのジャンプでT_NEARをつけないときに8bit相対アドレスに入らない
|
||||||
|
場合に例外が発生しないバグの修正
|
||||||
|
2007/01/21 [disp]の形のアドレス生成のバグ修正
|
||||||
|
mov (eax|ax|al, [disp]); mov([disp], eax|ax|al);の短い表現選択
|
||||||
|
2007/01/17 webページ作成
|
||||||
|
2007/01/04 公開開始
|
||||||
|
|
||||||
|
-----------------------------------------------------------------------------
|
||||||
|
◎著作権者
|
||||||
|
|
||||||
|
光成滋生(MITSUNARI Shigeo, herumi@nifty.com)
|
||||||
142
external/xbyak/sample/Makefile
vendored
Normal file
142
external/xbyak/sample/Makefile
vendored
Normal file
@@ -0,0 +1,142 @@
|
|||||||
|
XBYAK_INC=../xbyak/xbyak.h
|
||||||
|
CXX?=g++
|
||||||
|
CXX_32=$(CXX) -m32
|
||||||
|
CXX_64=$(CXX) -m64
|
||||||
|
|
||||||
|
BOOST_EXIST=$(shell echo "#include <boost/spirit/core.hpp>" | $(CXX) -x c++ -c - 2>/dev/null && echo 1)
|
||||||
|
UNAME_M=$(shell uname -m)
|
||||||
|
|
||||||
|
ONLY_64BIT=0
|
||||||
|
ifeq ($(shell uname -s),Darwin)
|
||||||
|
ONLY_64BIT=1
|
||||||
|
OS=mac
|
||||||
|
ifeq ($(UNAME_M),x86_64)
|
||||||
|
BIT=64
|
||||||
|
endif
|
||||||
|
ifeq ($(UNAME_M),i386)
|
||||||
|
BIT=32
|
||||||
|
endif
|
||||||
|
ifeq ($(shell sw_vers -productVersion | cut -c1-4 | sed 's/\.//'),105)
|
||||||
|
ifeq ($(shell sysctl -n hw.cpu64bit_capable),1)
|
||||||
|
BIT=64
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
BIT=32
|
||||||
|
ifeq ($(UNAME_M),x86_64)
|
||||||
|
BIT=64
|
||||||
|
endif
|
||||||
|
ifeq ($(UNAME_M),amd64)
|
||||||
|
BIT=64
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(BIT),64)
|
||||||
|
TARGET += test64 bf64 memfunc64 test_util64 jmp_table64 zero_upper ccmp no_flags
|
||||||
|
ifeq ($(BOOST_EXIST),1)
|
||||||
|
TARGET += calc64 #calc2_64
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq ($(OS),mac)
|
||||||
|
TARGET += static_buf64
|
||||||
|
TARGET += memfd
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
ifneq ($(ONLY_64BIT),1)
|
||||||
|
TARGET += test quantize bf toyvm test_util memfunc static_buf jmp_table
|
||||||
|
ifeq ($(BOOST_EXIST),1)
|
||||||
|
TARGET += calc #calc2
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
all: $(TARGET)
|
||||||
|
|
||||||
|
CFLAGS_WARN=$(shell cat ../test/CFLAGS_WARN.cfg)
|
||||||
|
|
||||||
|
CFLAGS=-g -O2 -fomit-frame-pointer -Wall -I../ $(CFLAGS_WARN) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS)
|
||||||
|
|
||||||
|
test:
|
||||||
|
$(CXX_32) $(CFLAGS) test0.cpp -o $@
|
||||||
|
|
||||||
|
quantize:
|
||||||
|
$(CXX_32) $(CFLAGS) quantize.cpp -o $@
|
||||||
|
|
||||||
|
calc:
|
||||||
|
$(CXX_32) $(CFLAGS) calc.cpp -o $@
|
||||||
|
calc64:
|
||||||
|
$(CXX_64) $(CFLAGS) calc.cpp -o $@
|
||||||
|
calc2:
|
||||||
|
$(CXX_32) $(CFLAGS) calc2.cpp -o $@
|
||||||
|
calc2_64:
|
||||||
|
$(CXX_64) $(CFLAGS) calc2.cpp -o $@
|
||||||
|
|
||||||
|
bf:
|
||||||
|
$(CXX_32) $(CFLAGS) bf.cpp -o $@
|
||||||
|
bf64:
|
||||||
|
$(CXX_64) $(CFLAGS) bf.cpp -o $@
|
||||||
|
|
||||||
|
memfunc:
|
||||||
|
$(CXX_32) $(CFLAGS) memfunc.cpp -o $@
|
||||||
|
memfunc64:
|
||||||
|
$(CXX_64) $(CFLAGS) memfunc.cpp -o $@
|
||||||
|
|
||||||
|
toyvm:
|
||||||
|
$(CXX_32) $(CFLAGS) toyvm.cpp -o $@
|
||||||
|
|
||||||
|
test64:
|
||||||
|
$(CXX_64) $(CFLAGS) test0.cpp -o $@
|
||||||
|
test_util:
|
||||||
|
$(CXX_32) $(CFLAGS) test_util.cpp -o $@
|
||||||
|
test_util64:
|
||||||
|
$(CXX_64) $(CFLAGS) test_util.cpp -o $@
|
||||||
|
static_buf:
|
||||||
|
$(CXX_32) $(CFLAGS) static_buf.cpp -o $@
|
||||||
|
static_buf64:
|
||||||
|
$(CXX_64) $(CFLAGS) static_buf.cpp -o $@
|
||||||
|
jmp_table:
|
||||||
|
$(CXX_32) $(CFLAGS) jmp_table.cpp -o $@
|
||||||
|
jmp_table64:
|
||||||
|
$(CXX_64) $(CFLAGS) jmp_table.cpp -o $@
|
||||||
|
memfd:
|
||||||
|
$(CXX_64) $(CFLAGS) memfd.cpp -o $@
|
||||||
|
profiler: profiler.cpp ../xbyak/xbyak_util.h
|
||||||
|
$(CXX) $(CFLAGS) profiler.cpp -o $@
|
||||||
|
profiler-vtune: profiler.cpp ../xbyak/xbyak_util.h
|
||||||
|
$(CXX) $(CFLAGS) profiler.cpp -o $@ -DXBYAK_USE_VTUNE -I /opt/intel/vtune_amplifier/include/ -L /opt/intel/vtune_amplifier/lib64 -ljitprofiling -ldl
|
||||||
|
zero_upper: zero_upper.cpp $(XBYAK_INC)
|
||||||
|
$(CXX) $(CFLAGS) zero_upper.cpp -o $@
|
||||||
|
test_zero_upper: zero_upper
|
||||||
|
sde -future -- ./zero_upper
|
||||||
|
ccmp: ccmp.cpp $(XBYAK_INC)
|
||||||
|
$(CXX) $(CFLAGS) ccmp.cpp -o $@
|
||||||
|
test_ccmp: ccmp
|
||||||
|
sde -future -- ./ccmp
|
||||||
|
no_flags: no_flags.cpp $(XBYAK_INC)
|
||||||
|
$(CXX) $(CFLAGS) no_flags.cpp -o $@
|
||||||
|
test_no_flags: no_flags
|
||||||
|
sde -future -- ./no_flags
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf $(TARGET) profiler profiler-vtune
|
||||||
|
|
||||||
|
test : test0.cpp $(XBYAK_INC)
|
||||||
|
test64: test0.cpp $(XBYAK_INC)
|
||||||
|
quantize : quantize.cpp $(XBYAK_INC)
|
||||||
|
calc : calc.cpp $(XBYAK_INC)
|
||||||
|
calc64 : calc.cpp $(XBYAK_INC)
|
||||||
|
calc2 : calc2.cpp $(XBYAK_INC)
|
||||||
|
calc2_64 : calc2.cpp $(XBYAK_INC)
|
||||||
|
bf : bf.cpp $(XBYAK_INC)
|
||||||
|
bf64 : bf.cpp $(XBYAK_INC)
|
||||||
|
memfunc : memfunc.cpp $(XBYAK_INC)
|
||||||
|
memfunc64 : memfunc.cpp $(XBYAK_INC)
|
||||||
|
toyvm : toyvm.cpp $(XBYAK_INC)
|
||||||
|
static_buf: static_buf.cpp $(XBYAK_INC)
|
||||||
|
static_buf64: static_buf.cpp $(XBYAK_INC)
|
||||||
|
test_util : test_util.cpp $(XBYAK_INC) ../xbyak/xbyak_util.h
|
||||||
|
test_util64 : test_util.cpp $(XBYAK_INC) ../xbyak/xbyak_util.h
|
||||||
|
jmp_table: jmp_table.cpp $(XBYAK_INC)
|
||||||
|
jmp_table64: jmp_table.cpp $(XBYAK_INC)
|
||||||
|
memfd: memfd.cpp $(XBYAK_INC)
|
||||||
222
external/xbyak/sample/bf.cpp
vendored
Normal file
222
external/xbyak/sample/bf.cpp
vendored
Normal file
@@ -0,0 +1,222 @@
|
|||||||
|
#include "xbyak/xbyak.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stack>
|
||||||
|
#include <fstream>
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(disable : 4996) // scanf
|
||||||
|
#define snprintf _snprintf_s
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class Brainfuck : public Xbyak::CodeGenerator {
|
||||||
|
public:
|
||||||
|
int getContinuousChar(std::istream& is, char c)
|
||||||
|
{
|
||||||
|
int count = 1;
|
||||||
|
char p;
|
||||||
|
while (is >> p) {
|
||||||
|
if (p != c) break;
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
is.unget();
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
Brainfuck(std::istream& is) : CodeGenerator(100000)
|
||||||
|
{
|
||||||
|
// void (*)(void* putchar, void* getchar, int *stack)
|
||||||
|
using namespace Xbyak;
|
||||||
|
#ifdef XBYAK32
|
||||||
|
const Reg32& pPutchar(esi);
|
||||||
|
const Reg32& pGetchar(edi);
|
||||||
|
const Reg32& stack(ebp);
|
||||||
|
const Address cur = byte [stack];
|
||||||
|
push(ebp); // stack
|
||||||
|
push(esi);
|
||||||
|
push(edi);
|
||||||
|
const int P_ = 4 * 3;
|
||||||
|
mov(pPutchar, ptr[esp + P_ + 4]); // putchar
|
||||||
|
mov(pGetchar, ptr[esp + P_ + 8]); // getchar
|
||||||
|
mov(stack, ptr[esp + P_ + 12]); // stack
|
||||||
|
#elif defined(XBYAK64_WIN)
|
||||||
|
const Reg64& pPutchar(rsi);
|
||||||
|
const Reg64& pGetchar(rdi);
|
||||||
|
const Reg64& stack(rbp); // stack
|
||||||
|
const Address cur = byte [stack];
|
||||||
|
push(rsi);
|
||||||
|
push(rdi);
|
||||||
|
push(rbp);
|
||||||
|
mov(pPutchar, rcx); // putchar
|
||||||
|
mov(pGetchar, rdx); // getchar
|
||||||
|
mov(stack, r8); // stack
|
||||||
|
#else
|
||||||
|
const Reg64& pPutchar(rbx);
|
||||||
|
const Reg64& pGetchar(rbp);
|
||||||
|
const Reg64& stack(r12); // stack
|
||||||
|
const Address cur = byte [stack];
|
||||||
|
push(rbx);
|
||||||
|
push(rbp);
|
||||||
|
push(r12);
|
||||||
|
mov(pPutchar, rdi); // putchar
|
||||||
|
mov(pGetchar, rsi); // getchar
|
||||||
|
mov(stack, rdx); // stack
|
||||||
|
#endif
|
||||||
|
std::stack<Label> labelF, labelB;
|
||||||
|
char c;
|
||||||
|
while (is >> c) {
|
||||||
|
switch (c) {
|
||||||
|
case '+':
|
||||||
|
case '-':
|
||||||
|
{
|
||||||
|
int count = getContinuousChar(is, c);
|
||||||
|
if (count == 1) {
|
||||||
|
c == '+' ? inc(cur) : dec(cur);
|
||||||
|
} else {
|
||||||
|
add(cur, (c == '+' ? count : -count));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case '>':
|
||||||
|
case '<':
|
||||||
|
{
|
||||||
|
int count = getContinuousChar(is, c);
|
||||||
|
add(stack, (c == '>' ? count : -count));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case '.':
|
||||||
|
#ifdef XBYAK32
|
||||||
|
push(cur);
|
||||||
|
call(pPutchar);
|
||||||
|
pop(eax);
|
||||||
|
#elif defined(XBYAK64_WIN)
|
||||||
|
movzx(ecx, cur);
|
||||||
|
sub(rsp, 32);
|
||||||
|
call(pPutchar);
|
||||||
|
add(rsp, 32);
|
||||||
|
#else
|
||||||
|
movzx(edi, cur);
|
||||||
|
call(pPutchar);
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
case ',':
|
||||||
|
#if defined(XBYAK32) || defined(XBYAK64_GCC)
|
||||||
|
call(pGetchar);
|
||||||
|
#elif defined(XBYAK64_WIN)
|
||||||
|
sub(rsp, 32);
|
||||||
|
call(pGetchar);
|
||||||
|
add(rsp, 32);
|
||||||
|
#endif
|
||||||
|
mov(cur, al);
|
||||||
|
break;
|
||||||
|
case '[':
|
||||||
|
{
|
||||||
|
Label B = L();
|
||||||
|
labelB.push(B);
|
||||||
|
movzx(eax, cur);
|
||||||
|
test(eax, eax);
|
||||||
|
Label F;
|
||||||
|
jz(F, T_NEAR);
|
||||||
|
labelF.push(F);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ']':
|
||||||
|
{
|
||||||
|
Label B = labelB.top(); labelB.pop();
|
||||||
|
jmp(B);
|
||||||
|
Label F = labelF.top(); labelF.pop();
|
||||||
|
L(F);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#ifdef XBYAK32
|
||||||
|
pop(edi);
|
||||||
|
pop(esi);
|
||||||
|
pop(ebp);
|
||||||
|
#elif defined(XBYAK64_WIN)
|
||||||
|
pop(rbp);
|
||||||
|
pop(rdi);
|
||||||
|
pop(rsi);
|
||||||
|
#else
|
||||||
|
pop(r12);
|
||||||
|
pop(rbp);
|
||||||
|
pop(rbx);
|
||||||
|
#endif
|
||||||
|
ret();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void dump(const uint8_t *code, size_t size)
|
||||||
|
{
|
||||||
|
puts("#include <stdio.h>\nstatic int stack[128 * 1024];");
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
printf("static __declspec(align(4096)) ");
|
||||||
|
#else
|
||||||
|
printf("static __attribute__((aligned(4096)))");
|
||||||
|
#endif
|
||||||
|
puts("const unsigned char code[] = {");
|
||||||
|
for (size_t i = 0; i < size; i++) {
|
||||||
|
printf("0x%02x,", code[i]); if ((i % 16) == 15) putchar('\n');
|
||||||
|
}
|
||||||
|
puts("\n};");
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
puts("#include <windows.h>");
|
||||||
|
#else
|
||||||
|
puts("#include <unistd.h>");
|
||||||
|
puts("#include <sys/mman.h>");
|
||||||
|
#endif
|
||||||
|
puts("int main()\n{");
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
puts("\tDWORD oldProtect;");
|
||||||
|
puts("\tVirtualProtect((void*)code, sizeof(code), PAGE_EXECUTE_READWRITE, &oldProtect);");
|
||||||
|
#else
|
||||||
|
puts("\tlong pageSize = sysconf(_SC_PAGESIZE) - 1;");
|
||||||
|
puts("\tmprotect((void*)code, (sizeof(code) + pageSize) & ~pageSize, PROT_READ | PROT_EXEC);");
|
||||||
|
#endif
|
||||||
|
puts(
|
||||||
|
"\t((void (*)(void*, void*, int *))code)((void*)putchar, (void*)getchar, stack);\n"
|
||||||
|
"}"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
#ifdef XBYAK32
|
||||||
|
fprintf(stderr, "32bit mode\n");
|
||||||
|
#else
|
||||||
|
fprintf(stderr, "64bit mode\n");
|
||||||
|
#endif
|
||||||
|
if (argc == 1) {
|
||||||
|
fprintf(stderr, "bf filename.bf [0|1|2]\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
std::ifstream ifs(argv[1]);
|
||||||
|
int mode = argc == 3 ? atoi(argv[2]) : 0;
|
||||||
|
try {
|
||||||
|
Brainfuck bf(ifs);
|
||||||
|
switch (mode) {
|
||||||
|
case 0: {
|
||||||
|
static int stack[128 * 1024];
|
||||||
|
bf.getCode<void (*)(const void*, const void*, int *)>()(reinterpret_cast<const void*>(putchar), reinterpret_cast<const void*>(getchar), stack);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 1: {
|
||||||
|
dump(bf.getCode(), bf.getSize());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
const char *dumpName = "bf.dump";
|
||||||
|
printf("dump to %s\n", dumpName);
|
||||||
|
std::ofstream ofs(dumpName, std::ios::binary);
|
||||||
|
ofs.write((const char*)bf.getCode(), bf.getSize());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (std::exception& e) {
|
||||||
|
printf("ERR:%s\n", e.what());
|
||||||
|
} catch (...) {
|
||||||
|
printf("unknown error\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
228
external/xbyak/sample/bf.vcxproj
vendored
Normal file
228
external/xbyak/sample/bf.vcxproj
vendored
Normal file
@@ -0,0 +1,228 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{654BD79B-59D3-4B10-BBAA-158BAB272828}</ProjectGuid>
|
||||||
|
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<PlatformToolset>v141</PlatformToolset>
|
||||||
|
<UseOfMfc>false</UseOfMfc>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<PlatformToolset>v141</PlatformToolset>
|
||||||
|
<UseOfMfc>false</UseOfMfc>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<PlatformToolset>v141</PlatformToolset>
|
||||||
|
<UseOfMfc>false</UseOfMfc>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<PlatformToolset>v141</PlatformToolset>
|
||||||
|
<UseOfMfc>false</UseOfMfc>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<_ProjectFileVersion>15.0.27924.0</_ProjectFileVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<IntDir>$(ProjectName)\$(Configuration)\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
<IntDir>$(ProjectName)\$(Configuration)\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<IntDir>$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
<IntDir>$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<Midl>
|
||||||
|
<TypeLibraryName>.\Release/bf.tlb</TypeLibraryName>
|
||||||
|
<HeaderFileName />
|
||||||
|
</Midl>
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||||
|
<AdditionalIncludeDirectories>../;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<StringPooling>true</StringPooling>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<PrecompiledHeaderOutputFile>.\Release/bf.pch</PrecompiledHeaderOutputFile>
|
||||||
|
<WarningLevel>Level4</WarningLevel>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
</ClCompile>
|
||||||
|
<ResourceCompile>
|
||||||
|
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<Culture>0x0411</Culture>
|
||||||
|
</ResourceCompile>
|
||||||
|
<Link>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||||
|
<DataExecutionPrevention />
|
||||||
|
<TargetMachine>MachineX86</TargetMachine>
|
||||||
|
</Link>
|
||||||
|
<Bscmake>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
</Bscmake>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<Midl>
|
||||||
|
<TypeLibraryName>.\Debug/bf.tlb</TypeLibraryName>
|
||||||
|
<HeaderFileName />
|
||||||
|
</Midl>
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<AdditionalIncludeDirectories>../;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<MinimalRebuild>true</MinimalRebuild>
|
||||||
|
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
<PrecompiledHeaderOutputFile>.\Debug/bf.pch</PrecompiledHeaderOutputFile>
|
||||||
|
<WarningLevel>Level4</WarningLevel>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
</ClCompile>
|
||||||
|
<ResourceCompile>
|
||||||
|
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<Culture>0x0411</Culture>
|
||||||
|
</ResourceCompile>
|
||||||
|
<Link>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<ProgramDatabaseFile>.\Debug/bf.pdb</ProgramDatabaseFile>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||||
|
<DataExecutionPrevention />
|
||||||
|
<TargetMachine>MachineX86</TargetMachine>
|
||||||
|
</Link>
|
||||||
|
<Bscmake>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
</Bscmake>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<Midl>
|
||||||
|
<TargetEnvironment>X64</TargetEnvironment>
|
||||||
|
<TypeLibraryName>.\Release/bf.tlb</TypeLibraryName>
|
||||||
|
<HeaderFileName />
|
||||||
|
</Midl>
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||||
|
<AdditionalIncludeDirectories>../;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<StringPooling>true</StringPooling>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<PrecompiledHeaderOutputFile>.\Release/bf.pch</PrecompiledHeaderOutputFile>
|
||||||
|
<WarningLevel>Level4</WarningLevel>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
</ClCompile>
|
||||||
|
<ResourceCompile>
|
||||||
|
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<Culture>0x0411</Culture>
|
||||||
|
</ResourceCompile>
|
||||||
|
<Link>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||||
|
<DataExecutionPrevention />
|
||||||
|
<TargetMachine>MachineX64</TargetMachine>
|
||||||
|
</Link>
|
||||||
|
<Bscmake>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
</Bscmake>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<Midl>
|
||||||
|
<TargetEnvironment>X64</TargetEnvironment>
|
||||||
|
<TypeLibraryName>.\Debug/bf.tlb</TypeLibraryName>
|
||||||
|
<HeaderFileName />
|
||||||
|
</Midl>
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<AdditionalIncludeDirectories>../;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<MinimalRebuild>true</MinimalRebuild>
|
||||||
|
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
<PrecompiledHeaderOutputFile>.\Debug/bf.pch</PrecompiledHeaderOutputFile>
|
||||||
|
<WarningLevel>Level4</WarningLevel>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
|
</ClCompile>
|
||||||
|
<ResourceCompile>
|
||||||
|
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<Culture>0x0411</Culture>
|
||||||
|
</ResourceCompile>
|
||||||
|
<Link>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<ProgramDatabaseFile>.\Debug/bf.pdb</ProgramDatabaseFile>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||||
|
<DataExecutionPrevention />
|
||||||
|
<TargetMachine>MachineX64</TargetMachine>
|
||||||
|
</Link>
|
||||||
|
<Bscmake>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
</Bscmake>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="bf.cpp" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
||||||
228
external/xbyak/sample/calc.cpp
vendored
Normal file
228
external/xbyak/sample/calc.cpp
vendored
Normal file
@@ -0,0 +1,228 @@
|
|||||||
|
/*
|
||||||
|
@author herumi
|
||||||
|
|
||||||
|
tiny calculator
|
||||||
|
This program generates a function to calc the value of
|
||||||
|
polynomial given by user in run-time.
|
||||||
|
use boost::spirit::classic
|
||||||
|
see calc2.cpp for new version of boost::spirit
|
||||||
|
*/
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <sstream>
|
||||||
|
#include <map>
|
||||||
|
#include "xbyak/xbyak.h"
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(disable : 4127) // for boost(constant condition)
|
||||||
|
#pragma warning(disable : 4512) // for boost
|
||||||
|
#endif
|
||||||
|
#include <boost/spirit/include/classic_file_iterator.hpp>
|
||||||
|
#include <boost/spirit/include/classic_core.hpp>
|
||||||
|
#include <boost/bind.hpp>
|
||||||
|
|
||||||
|
enum Error {
|
||||||
|
UNDEFINED_VARIABLE = 1
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
JIT assemble of given polynomial for VC or gcc
|
||||||
|
*/
|
||||||
|
class FuncGen : public Xbyak::CodeGenerator {
|
||||||
|
public:
|
||||||
|
typedef std::map<std::string, int> Map;
|
||||||
|
private:
|
||||||
|
enum {
|
||||||
|
MAX_CONST_NUM = 32
|
||||||
|
};
|
||||||
|
double constTbl_[MAX_CONST_NUM];
|
||||||
|
size_t constTblPos_;
|
||||||
|
int regIdx_;
|
||||||
|
Map varMap_; // map var name to index
|
||||||
|
#ifdef XBYAK32
|
||||||
|
const Xbyak::Reg32& valTbl_;
|
||||||
|
const Xbyak::Reg32& tbl_;
|
||||||
|
#else
|
||||||
|
const Xbyak::Reg64& valTbl_;
|
||||||
|
const Xbyak::Reg64& tbl_;
|
||||||
|
#endif
|
||||||
|
public:
|
||||||
|
/*
|
||||||
|
@param y [out] the value of f(var)
|
||||||
|
@param var [in] table of input variables
|
||||||
|
func(double *y, const double var[]);
|
||||||
|
@note func does not return double to avoid difference of compiler
|
||||||
|
*/
|
||||||
|
FuncGen(const std::vector<std::string>& varTbl)
|
||||||
|
: constTblPos_(0)
|
||||||
|
, regIdx_(-1)
|
||||||
|
#ifdef XBYAK32
|
||||||
|
, valTbl_(eax)
|
||||||
|
, tbl_(edx)
|
||||||
|
#elif defined(XBYAK64_WIN)
|
||||||
|
, valTbl_(rcx)
|
||||||
|
, tbl_(rdx)
|
||||||
|
#else
|
||||||
|
, valTbl_(rdi)
|
||||||
|
, tbl_(rsi)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
#ifdef XBYAK32
|
||||||
|
mov(valTbl_, ptr[esp+8]); // eax == varTbl
|
||||||
|
mov(tbl_, (size_t)constTbl_);
|
||||||
|
#else
|
||||||
|
#ifdef XBYAK64_WIN
|
||||||
|
movaps(ptr [rsp + 8], xm6); // save xm6, xm7
|
||||||
|
movaps(ptr [rsp + 8 + 16], xm7);
|
||||||
|
#endif
|
||||||
|
mov(tbl_, (size_t)constTbl_);
|
||||||
|
#endif
|
||||||
|
for (int i = 0, n = static_cast<int>(varTbl.size()); i < n; i++) {
|
||||||
|
varMap_[varTbl[i]] = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// use edx
|
||||||
|
void genPush(double n)
|
||||||
|
{
|
||||||
|
if (constTblPos_ >= MAX_CONST_NUM) throw;
|
||||||
|
constTbl_[constTblPos_] = n;
|
||||||
|
if (regIdx_ == 7) throw;
|
||||||
|
movsd(Xbyak::Xmm(++regIdx_), ptr[tbl_ + (int)(constTblPos_ * sizeof(double))]);
|
||||||
|
constTblPos_++;
|
||||||
|
}
|
||||||
|
// use eax
|
||||||
|
void genVal(const char *begin, const char *end)
|
||||||
|
{
|
||||||
|
std::string var(begin, end);
|
||||||
|
if (varMap_.find(var) == varMap_.end()) throw UNDEFINED_VARIABLE;
|
||||||
|
if (regIdx_ == 7) throw;
|
||||||
|
movsd(Xbyak::Xmm(++regIdx_), ptr[valTbl_ + varMap_[var] * sizeof(double)]);
|
||||||
|
}
|
||||||
|
void genAdd(const char*, const char*)
|
||||||
|
{
|
||||||
|
addsd(Xbyak::Xmm(regIdx_ - 1), Xbyak::Xmm(regIdx_)); regIdx_--;
|
||||||
|
}
|
||||||
|
void genSub(const char*, const char*)
|
||||||
|
{
|
||||||
|
subsd(Xbyak::Xmm(regIdx_ - 1), Xbyak::Xmm(regIdx_)); regIdx_--;
|
||||||
|
}
|
||||||
|
void genMul(const char*, const char*)
|
||||||
|
{
|
||||||
|
mulsd(Xbyak::Xmm(regIdx_ - 1), Xbyak::Xmm(regIdx_)); regIdx_--;
|
||||||
|
}
|
||||||
|
void genDiv(const char*, const char*)
|
||||||
|
{
|
||||||
|
divsd(Xbyak::Xmm(regIdx_ - 1), Xbyak::Xmm(regIdx_)); regIdx_--;
|
||||||
|
}
|
||||||
|
void complete()
|
||||||
|
{
|
||||||
|
#ifdef XBYAK32
|
||||||
|
mov(eax, ptr [esp + 4]); // eax = valTbl
|
||||||
|
movsd(ptr [eax], xm0);
|
||||||
|
#else
|
||||||
|
#ifdef XBYAK64_WIN
|
||||||
|
movaps(xm6, ptr [rsp + 8]);
|
||||||
|
movaps(xm7, ptr [rsp + 8 + 16]);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
ret();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Grammar : public boost::spirit::classic::grammar<Grammar> {
|
||||||
|
FuncGen& f_;
|
||||||
|
Grammar(FuncGen& f) : f_(f) { }
|
||||||
|
template<typename ScannerT>
|
||||||
|
struct definition {
|
||||||
|
boost::spirit::classic::rule<ScannerT> poly0, poly1, poly2, var;
|
||||||
|
|
||||||
|
definition(const Grammar& self)
|
||||||
|
{
|
||||||
|
using namespace boost;
|
||||||
|
using namespace boost::spirit::classic;
|
||||||
|
|
||||||
|
poly0 = poly1 >> *(('+' >> poly1)[bind(&FuncGen::genAdd, ref(self.f_), _1, _2)]
|
||||||
|
| ('-' >> poly1)[bind(&FuncGen::genSub, ref(self.f_), _1, _2)]);
|
||||||
|
poly1 = poly2 >> *(('*' >> poly2)[bind(&FuncGen::genMul, ref(self.f_), _1, _2)]
|
||||||
|
| ('/' >> poly2)[bind(&FuncGen::genDiv, ref(self.f_), _1, _2)]);
|
||||||
|
var = (+alpha_p)[bind(&FuncGen::genVal, ref(self.f_), _1, _2)];
|
||||||
|
poly2 = real_p[bind(&FuncGen::genPush, ref(self.f_), _1)]
|
||||||
|
| var
|
||||||
|
| '(' >> poly0 >> ')';
|
||||||
|
}
|
||||||
|
const boost::spirit::classic::rule<ScannerT>& start() const { return poly0; }
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
void put(const std::vector<double>& x)
|
||||||
|
{
|
||||||
|
for (size_t i = 0, n = x.size(); i < n; i++) {
|
||||||
|
if (i > 0) printf(", ");
|
||||||
|
printf("%f", x[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
if (argc <= 2) {
|
||||||
|
fprintf(stderr, "calc \"var1 var2 ...\" \"function of var\"\n");
|
||||||
|
fprintf(stderr, "eg. calc x \"x*x\"\n");
|
||||||
|
fprintf(stderr, "eg. calc \"x y z\" \"x*x + y - z\"\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
const char *poly = argv[2];
|
||||||
|
try {
|
||||||
|
std::vector<std::string> varTbl;
|
||||||
|
|
||||||
|
// get varTbl from argv[1]
|
||||||
|
{
|
||||||
|
std::istringstream is(argv[1]);
|
||||||
|
int i = 0;
|
||||||
|
printf("varTbl = { ");
|
||||||
|
while (is) {
|
||||||
|
std::string var;
|
||||||
|
is >> var;
|
||||||
|
if (var.empty()) break;
|
||||||
|
printf("%s:%d, ", var.c_str(), i);
|
||||||
|
varTbl.push_back(var);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
printf("}\n");
|
||||||
|
}
|
||||||
|
FuncGen funcGen(varTbl);
|
||||||
|
Grammar calc(funcGen);
|
||||||
|
boost::spirit::classic::parse_info<> r = parse(poly, calc, boost::spirit::classic::space_p);
|
||||||
|
if (!r.full) {
|
||||||
|
printf("err poly=%s\n", poly);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
funcGen.complete();
|
||||||
|
std::vector<double> valTbl;
|
||||||
|
valTbl.resize(varTbl.size());
|
||||||
|
#ifdef XBYAK32
|
||||||
|
puts("32bit mode");
|
||||||
|
void (*func)(double *ret, const double *valTbl) = funcGen.getCode<void (*)(double *, const double*)>();
|
||||||
|
#else
|
||||||
|
puts("64bit mode");
|
||||||
|
double (*func)(const double *valTbl) = funcGen.getCode<double (*)(const double*)>();
|
||||||
|
#endif
|
||||||
|
for (int i = 0; i < 10; i++) {
|
||||||
|
for (size_t j = 0, n = valTbl.size(); j < n; j++) {
|
||||||
|
valTbl[j] = rand() % 7;
|
||||||
|
}
|
||||||
|
double y;
|
||||||
|
#ifdef XBYAK32
|
||||||
|
func(&y, &valTbl[0]);
|
||||||
|
#else
|
||||||
|
y = func(&valTbl[0]);
|
||||||
|
#endif
|
||||||
|
printf("f("); put(valTbl); printf(")=%f\n", y);
|
||||||
|
}
|
||||||
|
} catch (std::exception& e) {
|
||||||
|
printf("ERR:%s\n", e.what());
|
||||||
|
} catch (Error err) {
|
||||||
|
printf("ERR:%d\n", err);
|
||||||
|
} catch (...) {
|
||||||
|
printf("unknown error\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
228
external/xbyak/sample/calc.vcxproj
vendored
Normal file
228
external/xbyak/sample/calc.vcxproj
vendored
Normal file
@@ -0,0 +1,228 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{5FDDFAA6-B947-491D-A17E-BBD863846579}</ProjectGuid>
|
||||||
|
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<PlatformToolset>v141</PlatformToolset>
|
||||||
|
<UseOfMfc>false</UseOfMfc>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<PlatformToolset>v141</PlatformToolset>
|
||||||
|
<UseOfMfc>false</UseOfMfc>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<PlatformToolset>v141</PlatformToolset>
|
||||||
|
<UseOfMfc>false</UseOfMfc>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<PlatformToolset>v141</PlatformToolset>
|
||||||
|
<UseOfMfc>false</UseOfMfc>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<_ProjectFileVersion>15.0.27924.0</_ProjectFileVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<IntDir>$(ProjectName)\$(Configuration)\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
<IntDir>$(ProjectName)\$(Configuration)\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<IntDir>$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
<IntDir>$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<Midl>
|
||||||
|
<TypeLibraryName>.\Release/calc.tlb</TypeLibraryName>
|
||||||
|
<HeaderFileName />
|
||||||
|
</Midl>
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||||
|
<AdditionalIncludeDirectories>../;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<StringPooling>true</StringPooling>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<PrecompiledHeaderOutputFile>.\Release/calc.pch</PrecompiledHeaderOutputFile>
|
||||||
|
<WarningLevel>Level4</WarningLevel>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
</ClCompile>
|
||||||
|
<ResourceCompile>
|
||||||
|
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<Culture>0x0411</Culture>
|
||||||
|
</ResourceCompile>
|
||||||
|
<Link>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||||
|
<DataExecutionPrevention />
|
||||||
|
<TargetMachine>MachineX86</TargetMachine>
|
||||||
|
</Link>
|
||||||
|
<Bscmake>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
</Bscmake>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<Midl>
|
||||||
|
<TypeLibraryName>.\Debug/calc.tlb</TypeLibraryName>
|
||||||
|
<HeaderFileName />
|
||||||
|
</Midl>
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<AdditionalIncludeDirectories>../;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<MinimalRebuild>true</MinimalRebuild>
|
||||||
|
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
<PrecompiledHeaderOutputFile>.\Debug/calc.pch</PrecompiledHeaderOutputFile>
|
||||||
|
<WarningLevel>Level4</WarningLevel>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
</ClCompile>
|
||||||
|
<ResourceCompile>
|
||||||
|
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<Culture>0x0411</Culture>
|
||||||
|
</ResourceCompile>
|
||||||
|
<Link>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<ProgramDatabaseFile>.\Debug/calc.pdb</ProgramDatabaseFile>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||||
|
<DataExecutionPrevention />
|
||||||
|
<TargetMachine>MachineX86</TargetMachine>
|
||||||
|
</Link>
|
||||||
|
<Bscmake>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
</Bscmake>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<Midl>
|
||||||
|
<TargetEnvironment>X64</TargetEnvironment>
|
||||||
|
<TypeLibraryName>.\Release/calc.tlb</TypeLibraryName>
|
||||||
|
<HeaderFileName />
|
||||||
|
</Midl>
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||||
|
<AdditionalIncludeDirectories>../;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<StringPooling>true</StringPooling>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<PrecompiledHeaderOutputFile>.\Release/calc.pch</PrecompiledHeaderOutputFile>
|
||||||
|
<WarningLevel>Level4</WarningLevel>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
</ClCompile>
|
||||||
|
<ResourceCompile>
|
||||||
|
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<Culture>0x0411</Culture>
|
||||||
|
</ResourceCompile>
|
||||||
|
<Link>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||||
|
<DataExecutionPrevention />
|
||||||
|
<TargetMachine>MachineX64</TargetMachine>
|
||||||
|
</Link>
|
||||||
|
<Bscmake>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
</Bscmake>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<Midl>
|
||||||
|
<TargetEnvironment>X64</TargetEnvironment>
|
||||||
|
<TypeLibraryName>.\Debug/calc.tlb</TypeLibraryName>
|
||||||
|
<HeaderFileName />
|
||||||
|
</Midl>
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<AdditionalIncludeDirectories>../;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<MinimalRebuild>true</MinimalRebuild>
|
||||||
|
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
<PrecompiledHeaderOutputFile>.\Debug/calc.pch</PrecompiledHeaderOutputFile>
|
||||||
|
<WarningLevel>Level4</WarningLevel>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
|
</ClCompile>
|
||||||
|
<ResourceCompile>
|
||||||
|
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<Culture>0x0411</Culture>
|
||||||
|
</ResourceCompile>
|
||||||
|
<Link>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<ProgramDatabaseFile>.\Debug/calc.pdb</ProgramDatabaseFile>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||||
|
<DataExecutionPrevention />
|
||||||
|
<TargetMachine>MachineX64</TargetMachine>
|
||||||
|
</Link>
|
||||||
|
<Bscmake>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
</Bscmake>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="calc.cpp" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
||||||
301
external/xbyak/sample/calc2.cpp
vendored
Normal file
301
external/xbyak/sample/calc2.cpp
vendored
Normal file
@@ -0,0 +1,301 @@
|
|||||||
|
/*
|
||||||
|
@author herumi
|
||||||
|
|
||||||
|
tiny calculator 2
|
||||||
|
This program generates a function to calc the value of
|
||||||
|
polynomial given by user in run-time.
|
||||||
|
use boost::spirit::qi
|
||||||
|
*/
|
||||||
|
#ifdef _WIN32
|
||||||
|
#pragma warning(disable : 4127) // for boost(constant condition)
|
||||||
|
#pragma warning(disable : 4512) // for boost
|
||||||
|
#pragma warning(disable : 4819)
|
||||||
|
#endif
|
||||||
|
#include <boost/config/warning_disable.hpp>
|
||||||
|
#include <boost/spirit/include/qi.hpp>
|
||||||
|
#include <boost/spirit/include/phoenix_core.hpp>
|
||||||
|
#include <boost/spirit/include/phoenix_container.hpp>
|
||||||
|
#include <boost/spirit/include/phoenix_bind.hpp>
|
||||||
|
#include <boost/timer.hpp>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include "xbyak/xbyak.h"
|
||||||
|
|
||||||
|
enum Operand {
|
||||||
|
OpAdd,
|
||||||
|
OpSub,
|
||||||
|
OpMul,
|
||||||
|
OpDiv,
|
||||||
|
OpNeg,
|
||||||
|
OpImm,
|
||||||
|
OpVarX
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Code {
|
||||||
|
Operand op_;
|
||||||
|
double val_;
|
||||||
|
Code(Operand op)
|
||||||
|
: op_(op)
|
||||||
|
, val_(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
Code(double val)
|
||||||
|
: op_(OpImm)
|
||||||
|
, val_(val)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef std::vector<Code> CodeSet;
|
||||||
|
|
||||||
|
struct Vm {
|
||||||
|
CodeSet code_;
|
||||||
|
double operator()(double x) const
|
||||||
|
{
|
||||||
|
const size_t maxStack = 16;
|
||||||
|
double stack[maxStack];
|
||||||
|
double *p = stack;
|
||||||
|
CodeSet::const_iterator pc = code_.begin();
|
||||||
|
|
||||||
|
while (pc != code_.end()) {
|
||||||
|
switch (pc->op_) {
|
||||||
|
case OpVarX:
|
||||||
|
*p++ = x;
|
||||||
|
break;
|
||||||
|
case OpImm:
|
||||||
|
*p++ = pc->val_;
|
||||||
|
break;
|
||||||
|
case OpNeg:
|
||||||
|
p[-1] = -p[-1];
|
||||||
|
break;
|
||||||
|
case OpAdd:
|
||||||
|
--p;
|
||||||
|
p[-1] += p[0];
|
||||||
|
break;
|
||||||
|
case OpSub:
|
||||||
|
--p;
|
||||||
|
p[-1] -= p[0];
|
||||||
|
break;
|
||||||
|
case OpMul:
|
||||||
|
--p;
|
||||||
|
p[-1] *= p[0];
|
||||||
|
break;
|
||||||
|
case OpDiv:
|
||||||
|
--p;
|
||||||
|
p[-1] /= p[0];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
++pc;
|
||||||
|
assert(p < stack + maxStack);
|
||||||
|
}
|
||||||
|
return p[-1];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class Jit : public Xbyak::CodeGenerator {
|
||||||
|
private:
|
||||||
|
enum {
|
||||||
|
MAX_CONST_NUM = 32
|
||||||
|
};
|
||||||
|
MIE_ALIGN(16) double constTbl_[MAX_CONST_NUM];
|
||||||
|
Xbyak::uint64_t negConst_;
|
||||||
|
size_t constTblPos_;
|
||||||
|
#ifdef XBYAK32
|
||||||
|
const Xbyak::Reg32& varTbl_;
|
||||||
|
const Xbyak::Reg32& tbl_;
|
||||||
|
#else
|
||||||
|
const Xbyak::Reg64& tbl_;
|
||||||
|
#endif
|
||||||
|
int regIdx_;
|
||||||
|
public:
|
||||||
|
/*
|
||||||
|
double jit(double x);
|
||||||
|
@note 32bit: x : [esp+4], return fp0
|
||||||
|
64bit: x [rcx](win), xmm0(gcc), return xmm0
|
||||||
|
*/
|
||||||
|
Jit()
|
||||||
|
: negConst_(Xbyak::uint64_t(1) << 63)
|
||||||
|
, constTblPos_(0)
|
||||||
|
#ifdef XBYAK32
|
||||||
|
, varTbl_(eax)
|
||||||
|
, tbl_(edx)
|
||||||
|
#elif defined(XBYAK64_WIN)
|
||||||
|
, tbl_(rcx)
|
||||||
|
#else
|
||||||
|
, tbl_(rdi)
|
||||||
|
#endif
|
||||||
|
, regIdx_(-1)
|
||||||
|
{
|
||||||
|
#ifdef XBYAK32
|
||||||
|
lea(varTbl_, ptr [esp+4]);
|
||||||
|
#else
|
||||||
|
#ifdef XBYAK64_WIN
|
||||||
|
movaps(ptr [rsp + 8], xm6); // save xm6, xm7
|
||||||
|
movaps(ptr [rsp + 8 + 16], xm7);
|
||||||
|
#endif
|
||||||
|
movaps(xm7, xm0); // save xm0
|
||||||
|
#endif
|
||||||
|
mov(tbl_, (size_t)constTbl_);
|
||||||
|
}
|
||||||
|
void genPush(double n)
|
||||||
|
{
|
||||||
|
if (constTblPos_ >= MAX_CONST_NUM) throw;
|
||||||
|
constTbl_[constTblPos_] = n;
|
||||||
|
if (regIdx_ == 7) throw;
|
||||||
|
movsd(Xbyak::Xmm(++regIdx_), ptr[tbl_ + constTblPos_ * sizeof(double)]);
|
||||||
|
constTblPos_++;
|
||||||
|
}
|
||||||
|
void genVarX()
|
||||||
|
{
|
||||||
|
#ifdef XBYAK32
|
||||||
|
if (regIdx_ == 7) throw;
|
||||||
|
movsd(Xbyak::Xmm(++regIdx_), ptr[varTbl_]);
|
||||||
|
#else
|
||||||
|
if (regIdx_ == 6) throw;
|
||||||
|
movsd(Xbyak::Xmm(++regIdx_), xm7);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
void genAdd()
|
||||||
|
{
|
||||||
|
addsd(Xbyak::Xmm(regIdx_ - 1), Xbyak::Xmm(regIdx_)); regIdx_--;
|
||||||
|
}
|
||||||
|
void genSub()
|
||||||
|
{
|
||||||
|
subsd(Xbyak::Xmm(regIdx_ - 1), Xbyak::Xmm(regIdx_)); regIdx_--;
|
||||||
|
}
|
||||||
|
void genMul()
|
||||||
|
{
|
||||||
|
mulsd(Xbyak::Xmm(regIdx_ - 1), Xbyak::Xmm(regIdx_)); regIdx_--;
|
||||||
|
}
|
||||||
|
void genDiv()
|
||||||
|
{
|
||||||
|
divsd(Xbyak::Xmm(regIdx_ - 1), Xbyak::Xmm(regIdx_)); regIdx_--;
|
||||||
|
}
|
||||||
|
void genNeg()
|
||||||
|
{
|
||||||
|
xorpd(Xbyak::Xmm(regIdx_), ptr [tbl_ + MAX_CONST_NUM * sizeof(double)]);
|
||||||
|
}
|
||||||
|
void complete()
|
||||||
|
{
|
||||||
|
#ifdef XBYAK32
|
||||||
|
sub(esp, 8);
|
||||||
|
movsd(ptr [esp], xm0);
|
||||||
|
fld(qword [esp]);
|
||||||
|
add(esp, 8);
|
||||||
|
#else
|
||||||
|
#ifdef XBYAK64_WIN
|
||||||
|
movaps(xm6, ptr [rsp + 8]);
|
||||||
|
movaps(xm7, ptr [rsp + 8 + 16]);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
ret();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename Iterator>
|
||||||
|
struct Parser : boost::spirit::qi::grammar<Iterator, boost::spirit::ascii::space_type> {
|
||||||
|
boost::spirit::qi::rule<Iterator, boost::spirit::ascii::space_type> expression, term, factor;
|
||||||
|
CodeSet& code_;
|
||||||
|
Parser(CodeSet& code)
|
||||||
|
: Parser::base_type(expression)
|
||||||
|
, code_(code)
|
||||||
|
{
|
||||||
|
namespace qi = boost::spirit::qi;
|
||||||
|
using namespace qi::labels;
|
||||||
|
|
||||||
|
using boost::phoenix::ref;
|
||||||
|
using boost::phoenix::push_back;
|
||||||
|
|
||||||
|
expression = term >> *(('+' > term[push_back(ref(code_), OpAdd)])
|
||||||
|
| ('-' > term[push_back(ref(code_), OpSub)]));
|
||||||
|
|
||||||
|
term = factor >> *(('*' > factor[push_back(ref(code_), OpMul)])
|
||||||
|
| ('/' > factor[push_back(ref(code_), OpDiv)]));
|
||||||
|
|
||||||
|
factor = qi::double_[push_back(ref(code_), _1)]
|
||||||
|
| qi::lit('x')[push_back(ref(code_), OpVarX)]
|
||||||
|
| ('(' > expression > ')')
|
||||||
|
| ('-' > factor[push_back(ref(code_), OpNeg)])
|
||||||
|
| ('+' > factor);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename Iterator>
|
||||||
|
struct ParserJit : boost::spirit::qi::grammar<Iterator, boost::spirit::ascii::space_type> {
|
||||||
|
boost::spirit::qi::rule<Iterator, boost::spirit::ascii::space_type> expression, term, factor;
|
||||||
|
Jit code_;
|
||||||
|
ParserJit()
|
||||||
|
: ParserJit::base_type(expression)
|
||||||
|
{
|
||||||
|
namespace qi = boost::spirit::qi;
|
||||||
|
using namespace qi::labels;
|
||||||
|
|
||||||
|
using boost::phoenix::ref;
|
||||||
|
using boost::phoenix::push_back;
|
||||||
|
using boost::phoenix::bind;
|
||||||
|
|
||||||
|
expression = term >> *(('+' > term[bind(&Jit::genAdd, ref(code_))])
|
||||||
|
| ('-' > term[bind(&Jit::genSub, ref(code_))]));
|
||||||
|
|
||||||
|
term = factor >> *(('*' > factor[bind(&Jit::genMul, ref(code_))])
|
||||||
|
| ('/' > factor[bind(&Jit::genDiv, ref(code_))]));
|
||||||
|
|
||||||
|
factor = qi::double_[bind(&Jit::genPush, ref(code_), _1)]
|
||||||
|
| qi::lit('x')[bind(&Jit::genVarX, ref(code_))]
|
||||||
|
| ('(' > expression > ')')
|
||||||
|
| ('-' > factor[bind(&Jit::genNeg, ref(code_))])
|
||||||
|
| ('+' > factor);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class Func>
|
||||||
|
void Test(const char *msg, const Func& f)
|
||||||
|
{
|
||||||
|
printf("%s:", msg);
|
||||||
|
boost::timer t;
|
||||||
|
double sum = 0;
|
||||||
|
for (double x = 0; x < 1000; x += 0.0001) {
|
||||||
|
sum += f(x);
|
||||||
|
}
|
||||||
|
printf("sum=%f, %fsec\n", sum, t.elapsed());
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
if (argc < 2) {
|
||||||
|
fprintf(stderr, "input formula\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
const std::string str(argv[1]);
|
||||||
|
|
||||||
|
try {
|
||||||
|
Vm vm;
|
||||||
|
Parser<std::string::const_iterator> parser(vm.code_);
|
||||||
|
ParserJit<std::string::const_iterator> parserJit;
|
||||||
|
|
||||||
|
const std::string::const_iterator end = str.end();
|
||||||
|
|
||||||
|
std::string::const_iterator i = str.begin();
|
||||||
|
if (!phrase_parse(i, end, parser, boost::spirit::ascii::space) || i != end) {
|
||||||
|
puts("err 1");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
printf("ret=%f\n", vm(2.3));
|
||||||
|
|
||||||
|
i = str.begin();
|
||||||
|
if (!phrase_parse(i, end, parserJit, boost::spirit::ascii::space) || i != end) {
|
||||||
|
puts("err 2");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
parserJit.code_.complete();
|
||||||
|
double (*jit)(double) = parserJit.code_.getCode<double (*)(double)>();
|
||||||
|
|
||||||
|
Test("VM ", vm);
|
||||||
|
Test("JIT", jit);
|
||||||
|
} catch (...) {
|
||||||
|
fprintf(stderr, "err\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
68
external/xbyak/sample/ccmp.cpp
vendored
Normal file
68
external/xbyak/sample/ccmp.cpp
vendored
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
An example of ccmp
|
||||||
|
> g++ ccmp.cpp -I ../xbyak
|
||||||
|
> sde -future -- ./a.out
|
||||||
|
*/
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <xbyak/xbyak.h>
|
||||||
|
#include <xbyak/xbyak_util.h>
|
||||||
|
|
||||||
|
using namespace Xbyak;
|
||||||
|
|
||||||
|
struct Code1 : Xbyak::CodeGenerator {
|
||||||
|
Code1()
|
||||||
|
{
|
||||||
|
Xbyak::util::StackFrame sf(this, 2);
|
||||||
|
const auto& p1 = sf.p[0];
|
||||||
|
const auto& p2 = sf.p[1];
|
||||||
|
int dfv = 0;
|
||||||
|
cmp(p1, 3);
|
||||||
|
ctesta(p2, 1, dfv); // eflags = (p1 > 3) ? ((p2 & 1) == 0) : dfv;
|
||||||
|
setz(al|T_zu);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Code2 : Xbyak::CodeGenerator {
|
||||||
|
Code2()
|
||||||
|
{
|
||||||
|
Xbyak::util::StackFrame sf(this, 3);
|
||||||
|
const auto& p1 = sf.p[0];
|
||||||
|
const auto& p2 = sf.p[1];
|
||||||
|
const auto& p3 = sf.p[2];
|
||||||
|
int dfv = 0;
|
||||||
|
cmp(p1, 1);
|
||||||
|
ccmpe(p2, 2, dfv); // eflags = p1==1 ? p2==2 : dfv;
|
||||||
|
ccmpe(p3, 3, dfv); // eflags = (p1==1 && p2==2) ? p3==3 : dfv;
|
||||||
|
setz(al|T_zu); // p1==1 && p2==2 && p3==3
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
int main()
|
||||||
|
try
|
||||||
|
{
|
||||||
|
{
|
||||||
|
puts("(p1 > 3) && ((p2 & 1) == 0)");
|
||||||
|
Code1 c;
|
||||||
|
auto f = c.getCode<int (*)(int, int)>();
|
||||||
|
for (int p1 = 2; p1 < 5; p1++) {
|
||||||
|
for (int p2 = 0; p2 < 3; p2++) {
|
||||||
|
printf("p1=%d p2=%d ret=%d (%d)\n", p1, p2, f(p1, p2), p1 > 3 && ((p2&1) == 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
puts("p1 == 1 && p2 == 2 && p3 == 3");
|
||||||
|
Code2 c;
|
||||||
|
auto f = c.getCode<int (*)(int, int, int)>();
|
||||||
|
for (int p1 = 0; p1 < 3; p1++) {
|
||||||
|
for (int p2 = 1; p2 < 4; p2++) {
|
||||||
|
for (int p3 = 2; p3 < 5; p3++) {
|
||||||
|
printf("p1=%d p2=%d p3=%d ret=%d (%d)\n", p1, p2, p3, f(p1, p2, p3), p1==1 && p2==2 && p3==3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (std::exception& e) {
|
||||||
|
printf("ERR %s\n", e.what());
|
||||||
|
}
|
||||||
2
external/xbyak/sample/cpuid/adl.txt
vendored
Normal file
2
external/xbyak/sample/cpuid/adl.txt
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
vendor intel
|
||||||
|
mmx mmx2 cmov sse sse2 sse3 ssse3 sse41 sse42 popcnt aesni rdtscp xsave(xgetvb) osxsave pclmulqdq avx fma avx2 bmi1 bmi2 lzcnt prefetchw enh_rep rdrand adx rdseed smap sha f16c movbe gfni vaes vpclmulqdq avx_vnni waitpkg clflushopt cldemote clwb movdiri movdir64b serialize aeskle wide_kl keylocker keylocker_wide
|
||||||
2
external/xbyak/sample/cpuid/arl.txt
vendored
Normal file
2
external/xbyak/sample/cpuid/arl.txt
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
vendor intel
|
||||||
|
mmx mmx2 cmov sse sse2 sse3 ssse3 sse41 sse42 popcnt aesni rdtscp xsave(xgetvb) osxsave pclmulqdq avx fma avx2 bmi1 bmi2 lzcnt prefetchw enh_rep rdrand adx rdseed smap sha f16c movbe gfni vaes vpclmulqdq avx_vnni waitpkg clflushopt cldemote clwb movdiri movdir64b uintr serialize avx_vnni_int8 avx_ne_convert avx_ifma cmpccxadd sha512 sm3 sm4 avx_vnni_int16 aeskle wide_kl keylocker keylocker_wide
|
||||||
2
external/xbyak/sample/cpuid/bdw.txt
vendored
Normal file
2
external/xbyak/sample/cpuid/bdw.txt
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
vendor intel
|
||||||
|
mmx mmx2 cmov sse sse2 sse3 ssse3 sse41 sse42 popcnt aesni rdtscp xsave(xgetvb) osxsave pclmulqdq avx fma avx2 bmi1 bmi2 lzcnt prefetchw enh_rep rdrand adx rdseed smap f16c movbe
|
||||||
2
external/xbyak/sample/cpuid/clx.txt
vendored
Normal file
2
external/xbyak/sample/cpuid/clx.txt
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
vendor intel
|
||||||
|
mmx mmx2 cmov sse sse2 sse3 ssse3 sse41 sse42 popcnt aesni rdtscp xsave(xgetvb) osxsave pclmulqdq avx fma avx2 bmi1 bmi2 lzcnt prefetchw enh_rep rdrand adx rdseed smap f16c movbe avx512f avx512dq avx512cd avx512bw avx512vl avx512_vnni clflushopt clwb
|
||||||
2
external/xbyak/sample/cpuid/cnl.txt
vendored
Normal file
2
external/xbyak/sample/cpuid/cnl.txt
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
vendor intel
|
||||||
|
mmx mmx2 cmov sse sse2 sse3 ssse3 sse41 sse42 popcnt aesni rdtscp xsave(xgetvb) osxsave pclmulqdq avx fma avx2 bmi1 bmi2 lzcnt prefetchw enh_rep rdrand adx rdseed smap sha f16c movbe avx512f avx512dq avx512_ifma avx512cd avx512bw avx512vl avx512_vbmi clflushopt
|
||||||
25
external/xbyak/sample/cpuid/cpuid.sh
vendored
Executable file
25
external/xbyak/sample/cpuid/cpuid.sh
vendored
Executable file
@@ -0,0 +1,25 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
UPDATE=0
|
||||||
|
if [ $# -eq 1 ]; then
|
||||||
|
UPDATE=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $UPDATE == 1 ]; then
|
||||||
|
echo "UPDATE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
make -C ../ test_util64
|
||||||
|
|
||||||
|
cpus=(p4p mrm pnr nhm wsm snb ivb hsw bdw slt slm glm glp tnt skl cnl icl skx clx cpx icx tgl adl mtl rpl spr emr gnr dmr srf arl lnl ptl cwf)
|
||||||
|
|
||||||
|
for cpu in ${cpus[@]} ; do
|
||||||
|
echo $cpu
|
||||||
|
if [ $UPDATE == 1 ]; then
|
||||||
|
~/bin/sde -$cpu -- ../test_util64 -cpuid > $cpu.txt
|
||||||
|
else
|
||||||
|
~/bin/sde -$cpu -- ../test_util64 -cpuid > tmp.txt
|
||||||
|
diff $cpu.txt tmp.txt
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
2
external/xbyak/sample/cpuid/cpx.txt
vendored
Normal file
2
external/xbyak/sample/cpuid/cpx.txt
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
vendor intel
|
||||||
|
mmx mmx2 cmov sse sse2 sse3 ssse3 sse41 sse42 popcnt aesni rdtscp xsave(xgetvb) osxsave pclmulqdq avx fma avx2 bmi1 bmi2 lzcnt prefetchw enh_rep rdrand adx rdseed smap f16c movbe avx512f avx512dq avx512cd avx512bw avx512vl avx512_vnni avx512_bf16 clflushopt clwb amx_fp8 amx_transpose amx_tf32 amx_avx512
|
||||||
2
external/xbyak/sample/cpuid/cwf.txt
vendored
Normal file
2
external/xbyak/sample/cpuid/cwf.txt
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
vendor intel
|
||||||
|
mmx mmx2 cmov sse sse2 sse3 ssse3 sse41 sse42 popcnt aesni rdtscp xsave(xgetvb) osxsave pclmulqdq avx fma avx2 bmi1 bmi2 lzcnt enh_rep rdrand adx rdseed smap sha f16c movbe gfni vaes vpclmulqdq avx_vnni waitpkg clflushopt cldemote clwb movdiri movdir64b uintr serialize avx_vnni_int8 avx_ne_convert avx_ifma cmpccxadd prefetchiti sha512 sm3 sm4 avx_vnni_int16 aeskle wide_kl keylocker keylocker_wide
|
||||||
2
external/xbyak/sample/cpuid/dmr.txt
vendored
Normal file
2
external/xbyak/sample/cpuid/dmr.txt
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
vendor intel
|
||||||
|
mmx mmx2 cmov sse sse2 sse3 ssse3 sse41 sse42 popcnt aesni rdtscp xsave(xgetvb) osxsave pclmulqdq avx fma avx2 bmi1 bmi2 lzcnt prefetchw enh_rep rdrand adx rdseed smap sha f16c movbe avx512f avx512dq avx512_ifma avx512cd avx512bw avx512vl avx512_vbmi avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq avx512_bf16 amx(tile) amx(int8) amx(bf16) avx_vnni avx512_fp16 waitpkg clflushopt cldemote clwb movdiri movdir64b uintr serialize amx_fp16 avx_vnni_int8 avx_ne_convert avx_ifma cmpccxadd prefetchiti sha512 sm3 sm4 avx_vnni_int16 apx_f avx10 amx_fp8 amx_transpose amx_tf32 amx_avx512 amx_movrs movrs
|
||||||
2
external/xbyak/sample/cpuid/emr.txt
vendored
Normal file
2
external/xbyak/sample/cpuid/emr.txt
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
vendor intel
|
||||||
|
mmx mmx2 cmov sse sse2 sse3 ssse3 sse41 sse42 popcnt aesni rdtscp xsave(xgetvb) osxsave pclmulqdq avx fma avx2 bmi1 bmi2 lzcnt prefetchw enh_rep rdrand adx rdseed smap sha f16c movbe avx512f avx512dq avx512_ifma avx512cd avx512bw avx512vl avx512_vbmi avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq avx512_bf16 amx(tile) amx(int8) amx(bf16) avx_vnni avx512_fp16 waitpkg clflushopt cldemote clwb movdiri movdir64b uintr serialize
|
||||||
2
external/xbyak/sample/cpuid/glm.txt
vendored
Normal file
2
external/xbyak/sample/cpuid/glm.txt
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
vendor intel
|
||||||
|
mmx mmx2 cmov sse sse2 sse3 ssse3 sse41 sse42 popcnt aesni rdtscp xsave(xgetvb) osxsave pclmulqdq enh_rep rdrand rdseed smap sha movbe clflushopt
|
||||||
2
external/xbyak/sample/cpuid/glp.txt
vendored
Normal file
2
external/xbyak/sample/cpuid/glp.txt
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
vendor intel
|
||||||
|
mmx mmx2 cmov sse sse2 sse3 ssse3 sse41 sse42 popcnt aesni rdtscp xsave(xgetvb) osxsave pclmulqdq enh_rep rdrand rdseed smap sha movbe clflushopt
|
||||||
2
external/xbyak/sample/cpuid/gnr.txt
vendored
Normal file
2
external/xbyak/sample/cpuid/gnr.txt
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
vendor intel
|
||||||
|
mmx mmx2 cmov sse sse2 sse3 ssse3 sse41 sse42 popcnt aesni rdtscp xsave(xgetvb) osxsave pclmulqdq avx fma avx2 bmi1 bmi2 lzcnt prefetchw enh_rep rdrand adx rdseed smap sha f16c movbe avx512f avx512dq avx512_ifma avx512cd avx512bw avx512vl avx512_vbmi avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq avx512_bf16 amx(tile) amx(int8) amx(bf16) avx_vnni avx512_fp16 waitpkg clflushopt cldemote clwb movdiri movdir64b uintr serialize amx_fp16 prefetchiti avx10
|
||||||
2
external/xbyak/sample/cpuid/hsw.txt
vendored
Normal file
2
external/xbyak/sample/cpuid/hsw.txt
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
vendor intel
|
||||||
|
mmx mmx2 cmov sse sse2 sse3 ssse3 sse41 sse42 popcnt aesni rdtscp xsave(xgetvb) osxsave pclmulqdq avx fma avx2 bmi1 bmi2 lzcnt enh_rep rdrand f16c movbe
|
||||||
2
external/xbyak/sample/cpuid/icl.txt
vendored
Normal file
2
external/xbyak/sample/cpuid/icl.txt
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
vendor intel
|
||||||
|
mmx mmx2 cmov sse sse2 sse3 ssse3 sse41 sse42 popcnt aesni rdtscp xsave(xgetvb) osxsave pclmulqdq avx fma avx2 bmi1 bmi2 lzcnt prefetchw enh_rep rdrand adx rdseed smap sha f16c movbe avx512f avx512dq avx512_ifma avx512cd avx512bw avx512vl avx512_vbmi avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq clflushopt clwb
|
||||||
2
external/xbyak/sample/cpuid/icx.txt
vendored
Normal file
2
external/xbyak/sample/cpuid/icx.txt
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
vendor intel
|
||||||
|
mmx mmx2 cmov sse sse2 sse3 ssse3 sse41 sse42 popcnt aesni rdtscp xsave(xgetvb) osxsave pclmulqdq avx fma avx2 bmi1 bmi2 lzcnt prefetchw enh_rep rdrand adx rdseed smap sha f16c movbe avx512f avx512dq avx512_ifma avx512cd avx512bw avx512vl avx512_vbmi avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq clflushopt clwb
|
||||||
2
external/xbyak/sample/cpuid/ivb.txt
vendored
Normal file
2
external/xbyak/sample/cpuid/ivb.txt
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
vendor intel
|
||||||
|
mmx mmx2 cmov sse sse2 sse3 ssse3 sse41 sse42 popcnt aesni rdtscp xsave(xgetvb) osxsave pclmulqdq avx enh_rep rdrand f16c
|
||||||
2
external/xbyak/sample/cpuid/lnl.txt
vendored
Normal file
2
external/xbyak/sample/cpuid/lnl.txt
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
vendor intel
|
||||||
|
mmx mmx2 cmov sse sse2 sse3 ssse3 sse41 sse42 popcnt aesni rdtscp xsave(xgetvb) osxsave pclmulqdq avx fma avx2 bmi1 bmi2 lzcnt prefetchw enh_rep rdrand adx rdseed smap sha f16c movbe gfni vaes vpclmulqdq avx_vnni waitpkg clflushopt cldemote clwb movdiri movdir64b uintr serialize avx_vnni_int8 avx_ne_convert avx_ifma cmpccxadd sha512 sm3 sm4 avx_vnni_int16 aeskle wide_kl keylocker keylocker_wide
|
||||||
2
external/xbyak/sample/cpuid/mrm.txt
vendored
Normal file
2
external/xbyak/sample/cpuid/mrm.txt
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
vendor intel
|
||||||
|
mmx mmx2 cmov sse sse2 sse3 ssse3
|
||||||
2
external/xbyak/sample/cpuid/mtl.txt
vendored
Normal file
2
external/xbyak/sample/cpuid/mtl.txt
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
vendor intel
|
||||||
|
mmx mmx2 cmov sse sse2 sse3 ssse3 sse41 sse42 popcnt aesni rdtscp xsave(xgetvb) osxsave pclmulqdq avx fma avx2 bmi1 bmi2 lzcnt prefetchw enh_rep rdrand adx rdseed smap sha f16c movbe gfni vaes vpclmulqdq avx_vnni waitpkg clflushopt cldemote clwb movdiri movdir64b serialize aeskle wide_kl keylocker keylocker_wide
|
||||||
2
external/xbyak/sample/cpuid/nhm.txt
vendored
Normal file
2
external/xbyak/sample/cpuid/nhm.txt
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
vendor intel
|
||||||
|
mmx mmx2 cmov sse sse2 sse3 ssse3 sse41 sse42 popcnt rdtscp
|
||||||
2
external/xbyak/sample/cpuid/p4p.txt
vendored
Normal file
2
external/xbyak/sample/cpuid/p4p.txt
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
vendor intel
|
||||||
|
mmx mmx2 cmov sse sse2 sse3
|
||||||
2
external/xbyak/sample/cpuid/pnr.txt
vendored
Normal file
2
external/xbyak/sample/cpuid/pnr.txt
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
vendor intel
|
||||||
|
mmx mmx2 cmov sse sse2 sse3 ssse3 sse41
|
||||||
2
external/xbyak/sample/cpuid/ptl.txt
vendored
Normal file
2
external/xbyak/sample/cpuid/ptl.txt
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
vendor intel
|
||||||
|
mmx mmx2 cmov sse sse2 sse3 ssse3 sse41 sse42 popcnt aesni rdtscp xsave(xgetvb) osxsave pclmulqdq avx fma avx2 bmi1 bmi2 lzcnt prefetchw enh_rep rdrand adx rdseed smap sha f16c movbe gfni vaes vpclmulqdq avx_vnni waitpkg clflushopt cldemote clwb movdiri movdir64b uintr serialize avx_vnni_int8 avx_ne_convert avx_ifma cmpccxadd sha512 sm3 sm4 avx_vnni_int16 aeskle wide_kl keylocker keylocker_wide
|
||||||
2
external/xbyak/sample/cpuid/rpl.txt
vendored
Normal file
2
external/xbyak/sample/cpuid/rpl.txt
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
vendor intel
|
||||||
|
mmx mmx2 cmov sse sse2 sse3 ssse3 sse41 sse42 popcnt aesni rdtscp xsave(xgetvb) osxsave pclmulqdq avx fma avx2 bmi1 bmi2 lzcnt prefetchw enh_rep rdrand adx rdseed smap sha f16c movbe gfni vaes vpclmulqdq avx_vnni waitpkg clflushopt cldemote clwb movdiri movdir64b serialize aeskle wide_kl keylocker keylocker_wide
|
||||||
2
external/xbyak/sample/cpuid/skl.txt
vendored
Normal file
2
external/xbyak/sample/cpuid/skl.txt
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
vendor intel
|
||||||
|
mmx mmx2 cmov sse sse2 sse3 ssse3 sse41 sse42 popcnt aesni rdtscp xsave(xgetvb) osxsave pclmulqdq avx fma avx2 bmi1 bmi2 lzcnt prefetchw enh_rep rdrand adx rdseed smap f16c movbe clflushopt
|
||||||
2
external/xbyak/sample/cpuid/skx.txt
vendored
Normal file
2
external/xbyak/sample/cpuid/skx.txt
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
vendor intel
|
||||||
|
mmx mmx2 cmov sse sse2 sse3 ssse3 sse41 sse42 popcnt aesni rdtscp xsave(xgetvb) osxsave pclmulqdq avx fma avx2 bmi1 bmi2 lzcnt prefetchw enh_rep rdrand adx rdseed smap f16c movbe avx512f avx512dq avx512cd avx512bw avx512vl clflushopt clwb
|
||||||
2
external/xbyak/sample/cpuid/slm.txt
vendored
Normal file
2
external/xbyak/sample/cpuid/slm.txt
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
vendor intel
|
||||||
|
mmx mmx2 cmov sse sse2 sse3 ssse3 sse41 sse42 popcnt aesni rdtscp pclmulqdq prefetchw enh_rep rdrand movbe
|
||||||
2
external/xbyak/sample/cpuid/slt.txt
vendored
Normal file
2
external/xbyak/sample/cpuid/slt.txt
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
vendor intel
|
||||||
|
mmx mmx2 cmov sse sse2 sse3 ssse3 movbe
|
||||||
2
external/xbyak/sample/cpuid/snb.txt
vendored
Normal file
2
external/xbyak/sample/cpuid/snb.txt
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
vendor intel
|
||||||
|
mmx mmx2 cmov sse sse2 sse3 ssse3 sse41 sse42 popcnt aesni rdtscp xsave(xgetvb) osxsave pclmulqdq avx
|
||||||
2
external/xbyak/sample/cpuid/spr.txt
vendored
Normal file
2
external/xbyak/sample/cpuid/spr.txt
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
vendor intel
|
||||||
|
mmx mmx2 cmov sse sse2 sse3 ssse3 sse41 sse42 popcnt aesni rdtscp xsave(xgetvb) osxsave pclmulqdq avx fma avx2 bmi1 bmi2 lzcnt prefetchw enh_rep rdrand adx rdseed smap sha f16c movbe avx512f avx512dq avx512_ifma avx512cd avx512bw avx512vl avx512_vbmi avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq avx512_bf16 amx(tile) amx(int8) amx(bf16) avx_vnni avx512_fp16 waitpkg clflushopt cldemote clwb movdiri movdir64b uintr serialize
|
||||||
2
external/xbyak/sample/cpuid/srf.txt
vendored
Normal file
2
external/xbyak/sample/cpuid/srf.txt
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
vendor intel
|
||||||
|
mmx mmx2 cmov sse sse2 sse3 ssse3 sse41 sse42 popcnt aesni rdtscp xsave(xgetvb) osxsave pclmulqdq avx fma avx2 bmi1 bmi2 lzcnt enh_rep rdrand adx rdseed smap sha f16c movbe gfni vaes vpclmulqdq avx_vnni waitpkg clflushopt cldemote clwb movdiri movdir64b uintr serialize avx_vnni_int8 avx_ne_convert avx_ifma cmpccxadd aeskle wide_kl keylocker keylocker_wide
|
||||||
2
external/xbyak/sample/cpuid/tgl.txt
vendored
Normal file
2
external/xbyak/sample/cpuid/tgl.txt
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
vendor intel
|
||||||
|
mmx mmx2 cmov sse sse2 sse3 ssse3 sse41 sse42 popcnt aesni rdtscp xsave(xgetvb) osxsave pclmulqdq avx fma avx2 bmi1 bmi2 lzcnt prefetchw enh_rep rdrand adx rdseed smap sha f16c movbe avx512f avx512dq avx512_ifma avx512cd avx512bw avx512vl avx512_vbmi avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq avx512_vp2intersect clflushopt clwb movdiri movdir64b aeskle wide_kl keylocker keylocker_wide
|
||||||
2
external/xbyak/sample/cpuid/tnt.txt
vendored
Normal file
2
external/xbyak/sample/cpuid/tnt.txt
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
vendor intel
|
||||||
|
mmx mmx2 cmov sse sse2 sse3 ssse3 sse41 sse42 popcnt aesni rdtscp xsave(xgetvb) osxsave pclmulqdq enh_rep rdrand rdseed smap sha movbe gfni clflushopt cldemote clwb
|
||||||
2
external/xbyak/sample/cpuid/wsm.txt
vendored
Normal file
2
external/xbyak/sample/cpuid/wsm.txt
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
vendor intel
|
||||||
|
mmx mmx2 cmov sse sse2 sse3 ssse3 sse41 sse42 popcnt aesni rdtscp pclmulqdq
|
||||||
5
external/xbyak/sample/echo.bf
vendored
Normal file
5
external/xbyak/sample/echo.bf
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
>>++++++++[->++++++++<]>>>>+++++++++[->++++++++++<]>[<<,[->+<<+<<+>>>]<<<[
|
||||||
|
->>>+<<<]>>>>>[->+>>+<<<]>[<<[->+>>+<<<]>>>[-<<<+>>>]<<[[-]<->]>-]>>[-<<<+
|
||||||
|
>>>]<<<<<<<[-<+<<+>>>]<[>>[-<+<<+>>>]<<<[->>>+<<<]>>[[-]>-<]<-]<<[->>>+<<<
|
||||||
|
]>>>>><[[-]>++++++++++++++++++++++++++++++++>[[-]<------------------------
|
||||||
|
-------->]<<]>>[-]<.>>]
|
||||||
19
external/xbyak/sample/fizzbuzz.bf
vendored
Normal file
19
external/xbyak/sample/fizzbuzz.bf
vendored
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
++++++[->++++>>+>+>-<<<<<]>
|
||||||
|
[<++++>>+++>++++>>+++>+++++>+++++>>>>>>++>>++<<<<<<<<<<<<<<-]
|
||||||
|
<++++>+++>-->+++>->>--->++>>>+++++[->++>++<<]<<<<<<<<<<
|
||||||
|
|
||||||
|
[->
|
||||||
|
-[>>>>>>>]>[<+++>.>.>>>>..>>>+<]<<<<<
|
||||||
|
-[>>>>]>[<+++++>.>.>..>>>+<]>>>>
|
||||||
|
|
||||||
|
+<-[<<<]<[
|
||||||
|
[-<<+>>]>>>+>+<<<<<<[->>+>+>-<<<<]<
|
||||||
|
]>>
|
||||||
|
|
||||||
|
[[-]<]>[
|
||||||
|
>>>[>.<<.<<<]<[.<<<<]>
|
||||||
|
]
|
||||||
|
|
||||||
|
>.<<<<<<<<<<<
|
||||||
|
]
|
||||||
|
|
||||||
3
external/xbyak/sample/hello.bf
vendored
Normal file
3
external/xbyak/sample/hello.bf
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
>+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-]>++++++++[<++
|
||||||
|
++>-]<.>+++++++++++[<+++++>-]<.>++++++++[<+++>-]<.+++.------.--------.[-]>
|
||||||
|
++++++++[<++++>-]<+.[-]++++++++++.
|
||||||
127
external/xbyak/sample/jmp_table.cpp
vendored
Normal file
127
external/xbyak/sample/jmp_table.cpp
vendored
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
/*
|
||||||
|
sample of move(reg, LABEL);, L(LABEL), putL(LABEL);
|
||||||
|
*/
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <xbyak/xbyak.h>
|
||||||
|
|
||||||
|
const int expectTbl[] = {
|
||||||
|
5, 9, 12
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Code : Xbyak::CodeGenerator {
|
||||||
|
explicit Code(int mode, size_t size, void *p)
|
||||||
|
: Xbyak::CodeGenerator(size, p)
|
||||||
|
{
|
||||||
|
inLocalLabel();
|
||||||
|
#ifdef XBYAK64
|
||||||
|
const Xbyak::Reg64& a = rax;
|
||||||
|
const Xbyak::Reg64& c = rcx;
|
||||||
|
#ifdef XBYAK64_WIN
|
||||||
|
mov(rax, rcx);
|
||||||
|
#else
|
||||||
|
mov(rax, rdi);
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
const Xbyak::Reg32& a = eax;
|
||||||
|
const Xbyak::Reg32& c = ecx;
|
||||||
|
mov(a, ptr [esp + 4]);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
switch (mode) {
|
||||||
|
case 0:
|
||||||
|
mov(c, ".jmp_table");
|
||||||
|
lea(c, ptr [c + a * 8]);
|
||||||
|
jmp(c);
|
||||||
|
align(8);
|
||||||
|
L(".jmp_table");
|
||||||
|
mov(a, expectTbl[0]);
|
||||||
|
ret();
|
||||||
|
align(8);
|
||||||
|
mov(a, expectTbl[1]);
|
||||||
|
ret();
|
||||||
|
align(8);
|
||||||
|
mov(a, expectTbl[2]);
|
||||||
|
ret();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
/*
|
||||||
|
the label for putL is defined when called
|
||||||
|
*/
|
||||||
|
mov(c, ".jmp_table");
|
||||||
|
jmp(ptr [c + a * (int)sizeof(size_t)]);
|
||||||
|
L(".label1");
|
||||||
|
mov(a, expectTbl[0]);
|
||||||
|
jmp(".end");
|
||||||
|
L(".label2");
|
||||||
|
mov(a, expectTbl[1]);
|
||||||
|
jmp(".end");
|
||||||
|
L(".label3");
|
||||||
|
mov(a, expectTbl[2]);
|
||||||
|
jmp(".end");
|
||||||
|
L(".end");
|
||||||
|
ret();
|
||||||
|
ud2();
|
||||||
|
|
||||||
|
align(8);
|
||||||
|
L(".jmp_table");
|
||||||
|
putL(".label1");
|
||||||
|
putL(".label2");
|
||||||
|
putL(".label3");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
/*
|
||||||
|
the label for putL is not defined when called
|
||||||
|
*/
|
||||||
|
jmp(".in");
|
||||||
|
ud2();
|
||||||
|
align(8);
|
||||||
|
L(".jmp_table");
|
||||||
|
putL(".label1");
|
||||||
|
putL(".label2");
|
||||||
|
putL(".label3");
|
||||||
|
L(".in");
|
||||||
|
mov(c, ".jmp_table");
|
||||||
|
jmp(ptr [c + a * (int)sizeof(size_t)]);
|
||||||
|
L(".label1");
|
||||||
|
mov(a, expectTbl[0]);
|
||||||
|
jmp(".end");
|
||||||
|
L(".label2");
|
||||||
|
mov(a, expectTbl[1]);
|
||||||
|
jmp(".end");
|
||||||
|
L(".label3");
|
||||||
|
mov(a, expectTbl[2]);
|
||||||
|
jmp(".end");
|
||||||
|
L(".end");
|
||||||
|
ret();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
outLocalLabel();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
int main()
|
||||||
|
try
|
||||||
|
{
|
||||||
|
for (int mode = 0; mode < 3; mode++) {
|
||||||
|
printf("mode=%d\n", mode);
|
||||||
|
for (int grow = 0; grow < 2; grow++) {
|
||||||
|
printf("auto grow=%s\n", grow ? "on" : "off");
|
||||||
|
Code c(mode, grow ? 30 : 4096, grow ? Xbyak::AutoGrow : 0);
|
||||||
|
int (*f)(int) = c.getCode<int (*)(int)>();
|
||||||
|
c.ready();
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
const int a = expectTbl[i];
|
||||||
|
const int b = f(i);
|
||||||
|
if (a != b) {
|
||||||
|
printf("ERR i=%d, a=%d, b=%d\n", i, a, b);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
puts("ok");
|
||||||
|
} catch (std::exception& e) {
|
||||||
|
printf("ERR %s\n", e.what());
|
||||||
|
}
|
||||||
41
external/xbyak/sample/memfd.cpp
vendored
Normal file
41
external/xbyak/sample/memfd.cpp
vendored
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
a sample to use MmapAllocator with an user-defined name
|
||||||
|
cat /proc/`pidof ./memfd`/maps
|
||||||
|
|
||||||
|
7fca70b44000-7fca70b4a000 rw-p 00000000 00:00 0
|
||||||
|
7fca70b67000-7fca70b68000 rwxs 00000000 00:05 19960170 /memfd:xyz (deleted)
|
||||||
|
7fca70b68000-7fca70b69000 rwxs 00000000 00:05 19960169 /memfd:abc (deleted)
|
||||||
|
7fca70b69000-7fca70b6a000 r--p 00029000 103:03 19136541 /lib/x86_64-linux-gnu/ld-2.27.so
|
||||||
|
7fca70b6a000-7fca70b6b000 rw-p 0002a000 103:03 19136541 /lib/x86_64-linux-gnu/ld-2.27.so
|
||||||
|
*/
|
||||||
|
#define XBYAK_USE_MEMFD
|
||||||
|
#include <xbyak/xbyak.h>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
class Code : Xbyak::MmapAllocator, public Xbyak::CodeGenerator {
|
||||||
|
public:
|
||||||
|
Code(const char *name, int v)
|
||||||
|
: Xbyak::MmapAllocator(name)
|
||||||
|
, Xbyak::CodeGenerator(4096, nullptr, this /* specify external MmapAllocator */)
|
||||||
|
{
|
||||||
|
mov(eax, v);
|
||||||
|
ret();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
printf("pid=%d\n", getpid());
|
||||||
|
Code c1("Xbyak::abc", 123);
|
||||||
|
Code c2("Xbyak::xyz", 456);
|
||||||
|
printf("c1 %d\n", c1.getCode<int (*)()>()());
|
||||||
|
printf("c2 %d\n", c2.getCode<int (*)()>()());
|
||||||
|
std::ifstream ifs("/proc/self/maps", std::ios::binary);
|
||||||
|
if (ifs) {
|
||||||
|
std::string line;
|
||||||
|
while (std::getline(ifs, line)) {
|
||||||
|
printf("%s\n", line.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
getchar();
|
||||||
|
}
|
||||||
110
external/xbyak/sample/memfunc.cpp
vendored
Normal file
110
external/xbyak/sample/memfunc.cpp
vendored
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <memory.h>
|
||||||
|
#include <xbyak/xbyak.h>
|
||||||
|
|
||||||
|
struct A {
|
||||||
|
int x_;
|
||||||
|
int y_;
|
||||||
|
A() : x_(3), y_(5) {}
|
||||||
|
int func(int a, int b, int c, int d, int e) const { return x_ + y_ + a + b + c + d + e; }
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(disable : 4510 4512 4610)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct Code : public Xbyak::CodeGenerator {
|
||||||
|
Code()
|
||||||
|
{
|
||||||
|
using namespace Xbyak;
|
||||||
|
|
||||||
|
int RET_ADJ = 0;
|
||||||
|
#ifdef XBYAK32
|
||||||
|
#ifdef _WIN32
|
||||||
|
const int PARA_ADJ = 0;
|
||||||
|
RET_ADJ = 5 * 4;
|
||||||
|
#else
|
||||||
|
const int PARA_ADJ = 4;
|
||||||
|
mov(ecx, ptr [esp + 4]);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
const struct {
|
||||||
|
#ifdef XBYAK32
|
||||||
|
const Reg32& self;
|
||||||
|
#else
|
||||||
|
const Reg64& self;
|
||||||
|
#endif
|
||||||
|
const Operand& a;
|
||||||
|
const Operand& b;
|
||||||
|
const Operand& c;
|
||||||
|
const Operand& d;
|
||||||
|
const Operand& e;
|
||||||
|
} para = {
|
||||||
|
#if defined(XBYAK64_WIN)
|
||||||
|
rcx,
|
||||||
|
edx,
|
||||||
|
r8d,
|
||||||
|
r9d,
|
||||||
|
ptr [rsp + 8 * 5],
|
||||||
|
ptr [rsp + 8 * 6],
|
||||||
|
#elif defined(XBYAK64_GCC)
|
||||||
|
rdi,
|
||||||
|
esi,
|
||||||
|
edx,
|
||||||
|
ecx,
|
||||||
|
r8d,
|
||||||
|
r9d,
|
||||||
|
#else
|
||||||
|
ecx,
|
||||||
|
ptr [esp + 4 + PARA_ADJ],
|
||||||
|
ptr [esp + 8 + PARA_ADJ],
|
||||||
|
ptr [esp + 12 + PARA_ADJ],
|
||||||
|
ptr [esp + 16 + PARA_ADJ],
|
||||||
|
ptr [esp + 20 + PARA_ADJ],
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
mov(eax, ptr [para.self]);
|
||||||
|
add(eax, ptr [para.self + 4]);
|
||||||
|
add(eax, para.a);
|
||||||
|
add(eax, para.b);
|
||||||
|
add(eax, para.c);
|
||||||
|
add(eax, para.d);
|
||||||
|
add(eax, para.e);
|
||||||
|
ret(RET_ADJ);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
#ifdef XBYAK64
|
||||||
|
printf("64bit");
|
||||||
|
#else
|
||||||
|
printf("32bit");
|
||||||
|
#endif
|
||||||
|
#ifdef _WIN32
|
||||||
|
puts(" win");
|
||||||
|
#else
|
||||||
|
puts(" linux");
|
||||||
|
#endif
|
||||||
|
try {
|
||||||
|
Code code;
|
||||||
|
int (A::*p)(int, int, int, int, int) const = 0;
|
||||||
|
const void *addr = code.getCode<void*>();
|
||||||
|
memcpy(&p, &addr, sizeof(void*));
|
||||||
|
for (int i = 0; i < 10; i++) {
|
||||||
|
A a;
|
||||||
|
int t1, t2, t3, t4, t5, x, y;
|
||||||
|
a.x_ = rand(); a.y_ = rand();
|
||||||
|
t1 = rand(); t2 = rand(); t3 = rand();
|
||||||
|
t4 = rand(); t5 = rand();
|
||||||
|
x = a.func(t1, t2, t3, t4, t5);
|
||||||
|
y = (a.*p)(t1, t2, t3, t4, t5);
|
||||||
|
printf("%c %d, %d\n", x == y ? 'o' : 'x', x, y);
|
||||||
|
}
|
||||||
|
} catch (std::exception& e) {
|
||||||
|
printf("err=%s\n", e.what());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
25
external/xbyak/sample/no_flags.cpp
vendored
Normal file
25
external/xbyak/sample/no_flags.cpp
vendored
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <xbyak/xbyak.h>
|
||||||
|
|
||||||
|
struct Code : Xbyak::CodeGenerator {
|
||||||
|
Code(bool nf) {
|
||||||
|
xor_(eax, eax); // CF = 0
|
||||||
|
mov(eax, -1);
|
||||||
|
if (nf) {
|
||||||
|
puts("no flags (with T_nf)");
|
||||||
|
add(eax|T_nf, eax, 1); // does not change CF
|
||||||
|
} else {
|
||||||
|
puts("change flags (without T_nf)");
|
||||||
|
add(eax, eax, 1); // CF = 1
|
||||||
|
}
|
||||||
|
adc(eax, 0); // eax = CF ? 1 : 0
|
||||||
|
ret();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
for (int i = 0; i < 2; i++) {
|
||||||
|
Code c(i);
|
||||||
|
printf("i=%d ret=%d\n", i, c.getCode<int(*)()>()());
|
||||||
|
}
|
||||||
|
}
|
||||||
90
external/xbyak/sample/profiler.cpp
vendored
Normal file
90
external/xbyak/sample/profiler.cpp
vendored
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
/*
|
||||||
|
How to profile JIT-code with perf or VTune
|
||||||
|
sudo perf record ./profiler 1
|
||||||
|
amplxe-cl -collect hotspots -result-dir r001hs -quiet ./profiler-vtune 2
|
||||||
|
*/
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include <xbyak/xbyak_util.h>
|
||||||
|
|
||||||
|
const int N = 3000000;
|
||||||
|
struct Code : public Xbyak::CodeGenerator {
|
||||||
|
Code()
|
||||||
|
{
|
||||||
|
mov(eax, N);
|
||||||
|
Xbyak::Label lp = L();
|
||||||
|
for (int i = 0; i < 10; i++) {
|
||||||
|
sub(eax, 1);
|
||||||
|
}
|
||||||
|
jg(lp);
|
||||||
|
mov(eax, 1);
|
||||||
|
ret();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Code2 : public Xbyak::CodeGenerator {
|
||||||
|
Code2()
|
||||||
|
{
|
||||||
|
mov(eax, N);
|
||||||
|
Xbyak::Label lp = L();
|
||||||
|
for (int i = 0; i < 10; i++) {
|
||||||
|
xorps(xm0, xm0);
|
||||||
|
}
|
||||||
|
sub(eax, 1);
|
||||||
|
jg(lp);
|
||||||
|
mov(eax, 1);
|
||||||
|
ret();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
double s1(int n)
|
||||||
|
{
|
||||||
|
double r = 0;
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
r += 1.0 / (i + 1);
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
double s2(int n)
|
||||||
|
{
|
||||||
|
double r = 0;
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
r += 1.0 / (i * i + 1) + 2.0 / (i + 3);
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int mode = argc == 1 ? 0 : atoi(argv[1]);
|
||||||
|
Code c;
|
||||||
|
Code2 c2;
|
||||||
|
int (*f)() = (int (*)())c.getCode();
|
||||||
|
int (*g)() = (int (*)())c2.getCode();
|
||||||
|
|
||||||
|
printf("f:%p, %d\n", (const void*)f, (int)c.getSize());
|
||||||
|
printf("g:%p, %d\n", (const void*)g, (int)c2.getSize());
|
||||||
|
Xbyak::util::Profiler prof;
|
||||||
|
printf("mode=%d\n", mode);
|
||||||
|
prof.init(mode);
|
||||||
|
prof.set("f", (const void*)f, c.getSize());
|
||||||
|
prof.set("g", (const void*)g, c2.getSize());
|
||||||
|
|
||||||
|
double sum = 0;
|
||||||
|
for (int i = 0; i < 20000; i++) {
|
||||||
|
sum += s1(i);
|
||||||
|
sum += s2(i);
|
||||||
|
}
|
||||||
|
printf("sum=%f\n", sum);
|
||||||
|
for (int i = 0; i < 2000; i++) {
|
||||||
|
sum += f();
|
||||||
|
}
|
||||||
|
printf("f=%f\n", sum);
|
||||||
|
for (int i = 0; i < 2000; i++) {
|
||||||
|
sum += g();
|
||||||
|
}
|
||||||
|
printf("g=%f\n", sum);
|
||||||
|
puts("end");
|
||||||
|
}
|
||||||
69
external/xbyak/sample/protect-re.cpp
vendored
Normal file
69
external/xbyak/sample/protect-re.cpp
vendored
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
#include <xbyak/xbyak.h>
|
||||||
|
|
||||||
|
struct Code1 : Xbyak::CodeGenerator {
|
||||||
|
Code1()
|
||||||
|
: Xbyak::CodeGenerator(4096, Xbyak::DontSetProtectRWE)
|
||||||
|
{
|
||||||
|
mov(eax, 123);
|
||||||
|
ret();
|
||||||
|
}
|
||||||
|
void update()
|
||||||
|
{
|
||||||
|
db(0);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void test1(bool updateCode)
|
||||||
|
{
|
||||||
|
Code1 c;
|
||||||
|
c.setProtectModeRE();
|
||||||
|
if (updateCode) c.update(); // segmentation fault
|
||||||
|
int (*f)() = c.getCode<int (*)()>();
|
||||||
|
printf("f=%d\n", f());
|
||||||
|
|
||||||
|
c.setProtectModeRW();
|
||||||
|
c.update();
|
||||||
|
puts("ok");
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Code2 : Xbyak::CodeGenerator {
|
||||||
|
Code2()
|
||||||
|
: Xbyak::CodeGenerator(4096, Xbyak::AutoGrow)
|
||||||
|
{
|
||||||
|
mov(eax, 123);
|
||||||
|
ret();
|
||||||
|
}
|
||||||
|
void update()
|
||||||
|
{
|
||||||
|
db(0);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void test2(bool updateCode)
|
||||||
|
{
|
||||||
|
Code2 c;
|
||||||
|
c.readyRE();
|
||||||
|
if (updateCode) c.update(); // segmentation fault
|
||||||
|
int (*f)() = c.getCode<int (*)()>();
|
||||||
|
printf("f=%d\n", f());
|
||||||
|
|
||||||
|
c.setProtectModeRW();
|
||||||
|
c.update();
|
||||||
|
puts("ok");
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
if (argc < 2) {
|
||||||
|
fprintf(stderr, "%s <testNum> [update]\n", argv[0]);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
bool update = argc == 3;
|
||||||
|
int n = atoi(argv[1]);
|
||||||
|
printf("n=%d update=%d\n", n, update);
|
||||||
|
switch (n) {
|
||||||
|
case 1: test1(update); break;
|
||||||
|
case 2: test2(update); break;
|
||||||
|
default: fprintf(stderr, "no test %d\n", n); break;
|
||||||
|
}
|
||||||
|
}
|
||||||
225
external/xbyak/sample/quantize.cpp
vendored
Normal file
225
external/xbyak/sample/quantize.cpp
vendored
Normal file
@@ -0,0 +1,225 @@
|
|||||||
|
/*
|
||||||
|
@author herumi
|
||||||
|
|
||||||
|
JPEG quantize sample
|
||||||
|
This program generates a quantization routine by using fast division algorithm in run-time.
|
||||||
|
|
||||||
|
time(sec)
|
||||||
|
quality 1(high) 10 50 100(low)
|
||||||
|
VC2005 8.0 8.0 8.0 8.0
|
||||||
|
Xbyak 1.6 0.8 0.5 0.5
|
||||||
|
|
||||||
|
|
||||||
|
; generated code at q = 1
|
||||||
|
push esi
|
||||||
|
push edi
|
||||||
|
mov edi,dword ptr [esp+0Ch]
|
||||||
|
mov esi,dword ptr [esp+10h]
|
||||||
|
mov eax,dword ptr [esi]
|
||||||
|
shr eax,4
|
||||||
|
mov dword ptr [edi],eax
|
||||||
|
mov eax,dword ptr [esi+4]
|
||||||
|
mov edx,0BA2E8BA3h
|
||||||
|
mul eax,edx
|
||||||
|
shr edx,3
|
||||||
|
...
|
||||||
|
|
||||||
|
; generated code at q = 100
|
||||||
|
push esi
|
||||||
|
push edi
|
||||||
|
mov edi,dword ptr [esp+0Ch]
|
||||||
|
mov esi,dword ptr [esp+10h]
|
||||||
|
mov eax,dword ptr [esi]
|
||||||
|
mov dword ptr [edi],eax
|
||||||
|
mov eax,dword ptr [esi+4]
|
||||||
|
mov dword ptr [edi+4],eax
|
||||||
|
mov eax,dword ptr [esi+8]
|
||||||
|
mov dword ptr [edi+8],eax
|
||||||
|
mov eax,dword ptr [esi+0Ch]
|
||||||
|
...
|
||||||
|
|
||||||
|
*/
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include "xbyak/xbyak.h"
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(disable : 4996) // scanf
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const int N = 64;
|
||||||
|
|
||||||
|
class Quantize : public Xbyak::CodeGenerator {
|
||||||
|
static int ilog2(int x)
|
||||||
|
{
|
||||||
|
int shift = 0;
|
||||||
|
while ((1 << shift) <= x) shift++;
|
||||||
|
return shift - 1;
|
||||||
|
}
|
||||||
|
public:
|
||||||
|
/*
|
||||||
|
input : esi
|
||||||
|
output : eax = [esi+offset] / dividend
|
||||||
|
destroy : edx
|
||||||
|
*/
|
||||||
|
void udiv(uint32_t dividend, int offset)
|
||||||
|
{
|
||||||
|
mov(eax, ptr[esi + offset]);
|
||||||
|
|
||||||
|
/* dividend = odd x 2^exponent */
|
||||||
|
int exponent = 0, odd = dividend;
|
||||||
|
while ((odd & 1) == 0) {
|
||||||
|
odd >>= 1; exponent++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (odd == 1) { // trivial case
|
||||||
|
if (exponent) {
|
||||||
|
shr(eax, exponent);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t mLow, mHigh;
|
||||||
|
int len = ilog2(odd) + 1;
|
||||||
|
{
|
||||||
|
uint64_t roundUp = uint64_t(1) << (32 + len);
|
||||||
|
uint64_t k = roundUp / (0xFFFFFFFFL - (0xFFFFFFFFL % odd));
|
||||||
|
mLow = roundUp / odd;
|
||||||
|
mHigh = (roundUp + k) / odd;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (((mLow >> 1) < (mHigh >> 1)) && (len > 0)) {
|
||||||
|
mLow >>= 1; mHigh >>= 1; len--;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t m; int a;
|
||||||
|
if ((mHigh >> 32) == 0) {
|
||||||
|
m = mHigh; a = 0;
|
||||||
|
} else {
|
||||||
|
len = ilog2(odd);
|
||||||
|
uint64_t roundDown = uint64_t(1) << (32 + len);
|
||||||
|
mLow = roundDown / odd;
|
||||||
|
int r = (int)(roundDown % odd);
|
||||||
|
m = (r <= (odd >> 1)) ? mLow : mLow + 1;
|
||||||
|
a = 1;
|
||||||
|
}
|
||||||
|
while ((m & 1) == 0) {
|
||||||
|
m >>= 1; len--;
|
||||||
|
}
|
||||||
|
len += exponent;
|
||||||
|
|
||||||
|
mov(edx, int(m));
|
||||||
|
mul(edx);
|
||||||
|
if (a) {
|
||||||
|
add(eax, int(m));
|
||||||
|
adc(edx, 0);
|
||||||
|
}
|
||||||
|
if (len) {
|
||||||
|
shr(edx, len);
|
||||||
|
}
|
||||||
|
mov(eax, edx);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
quantize(uint32_t dest[64], const uint32_t src[64]);
|
||||||
|
*/
|
||||||
|
Quantize(const uint32_t qTbl[64])
|
||||||
|
{
|
||||||
|
push(esi);
|
||||||
|
push(edi);
|
||||||
|
const int P_ = 4 * 2;
|
||||||
|
mov(edi, ptr [esp+P_+4]); // dest
|
||||||
|
mov(esi, ptr [esp+P_+8]); // src
|
||||||
|
for (int i = 0; i < N; i++) {
|
||||||
|
udiv(qTbl[i], i * 4);
|
||||||
|
mov(ptr[edi+i*4], eax);
|
||||||
|
}
|
||||||
|
pop(edi);
|
||||||
|
pop(esi);
|
||||||
|
ret();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void quantize(uint32_t dest[64], const uint32_t src[64], const uint32_t qTbl[64])
|
||||||
|
{
|
||||||
|
for (int i = 0; i < N; i++) {
|
||||||
|
dest[i] = src[i] / qTbl[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef XBYAK64
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
puts("not implemented for 64bit");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int q;
|
||||||
|
if (argc > 1) {
|
||||||
|
q = atoi(argv[1]);
|
||||||
|
} else {
|
||||||
|
printf("input quantize=");
|
||||||
|
if (scanf("%d", &q) != 1) {
|
||||||
|
fprintf(stderr, "bad number\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("q=%d\n", q);
|
||||||
|
uint32_t qTbl[] = {
|
||||||
|
16, 11, 10, 16, 24, 40, 51, 61,
|
||||||
|
12, 12, 14, 19, 26, 58, 60, 55,
|
||||||
|
14, 13, 16, 24, 40, 57, 69, 56,
|
||||||
|
14, 17, 22, 29, 51, 87, 80, 62,
|
||||||
|
18, 22, 37, 56, 68, 109, 103, 77,
|
||||||
|
24, 35, 55, 64, 81, 104, 113, 92,
|
||||||
|
49, 64, 78, 87, 103, 121, 120, 101,
|
||||||
|
72, 92, 95, 98, 112, 100, 103, 99
|
||||||
|
};
|
||||||
|
|
||||||
|
for (int i = 0; i < N; i++) {
|
||||||
|
qTbl[i] /= q;
|
||||||
|
if (qTbl[i] == 0) qTbl[i] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
uint32_t src[N];
|
||||||
|
uint32_t dest[N];
|
||||||
|
uint32_t dest2[N];
|
||||||
|
for (int i = 0; i < N; i++) {
|
||||||
|
src[i] = rand() % 2048;
|
||||||
|
}
|
||||||
|
|
||||||
|
Quantize jit(qTbl);
|
||||||
|
//printf("jit size=%d, ptr=%p\n", jit.getSize(), jit.getCode());
|
||||||
|
void (*quantize2)(uint32_t*, const uint32_t*, const uint32_t *) = jit.getCode<void (*)(uint32_t*, const uint32_t*, const uint32_t *)>();
|
||||||
|
|
||||||
|
quantize(dest, src, qTbl);
|
||||||
|
quantize2(dest2, src, qTbl);
|
||||||
|
for (int i = 0; i < N; i++) {
|
||||||
|
if (dest[i] != dest2[i]) {
|
||||||
|
printf("err[%d] %u %u\n", i, dest[i], dest2[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const int count = 10000000;
|
||||||
|
int begin;
|
||||||
|
|
||||||
|
begin = clock();
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
quantize(dest, src, qTbl);
|
||||||
|
}
|
||||||
|
printf("time=%.1fsec\n", (clock() - begin) / double(CLOCKS_PER_SEC));
|
||||||
|
|
||||||
|
begin = clock();
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
quantize2(dest, src, qTbl);
|
||||||
|
}
|
||||||
|
printf("time=%.1fsec\n", (clock() - begin) / double(CLOCKS_PER_SEC));
|
||||||
|
} catch (std::exception& e) {
|
||||||
|
printf("ERR:%s\n", e.what());
|
||||||
|
} catch (...) {
|
||||||
|
printf("unknown error\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
228
external/xbyak/sample/quantize.vcxproj
vendored
Normal file
228
external/xbyak/sample/quantize.vcxproj
vendored
Normal file
@@ -0,0 +1,228 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{D06753BF-E1F3-4578-9B18-08673327F77C}</ProjectGuid>
|
||||||
|
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<PlatformToolset>v141</PlatformToolset>
|
||||||
|
<UseOfMfc>false</UseOfMfc>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<PlatformToolset>v141</PlatformToolset>
|
||||||
|
<UseOfMfc>false</UseOfMfc>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<PlatformToolset>v141</PlatformToolset>
|
||||||
|
<UseOfMfc>false</UseOfMfc>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<PlatformToolset>v141</PlatformToolset>
|
||||||
|
<UseOfMfc>false</UseOfMfc>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<_ProjectFileVersion>15.0.27924.0</_ProjectFileVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
<IntDir>$(ProjectName)\$(Configuration)\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<IntDir>$(ProjectName)\$(Configuration)\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
<IntDir>$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<IntDir>$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<Midl>
|
||||||
|
<TypeLibraryName>.\Debug/quantize.tlb</TypeLibraryName>
|
||||||
|
<HeaderFileName />
|
||||||
|
</Midl>
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<AdditionalIncludeDirectories>../;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<MinimalRebuild>true</MinimalRebuild>
|
||||||
|
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
<PrecompiledHeaderOutputFile>.\Debug/quantize.pch</PrecompiledHeaderOutputFile>
|
||||||
|
<WarningLevel>Level4</WarningLevel>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
</ClCompile>
|
||||||
|
<ResourceCompile>
|
||||||
|
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<Culture>0x0411</Culture>
|
||||||
|
</ResourceCompile>
|
||||||
|
<Link>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<ProgramDatabaseFile>.\Debug/quantize.pdb</ProgramDatabaseFile>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||||
|
<DataExecutionPrevention />
|
||||||
|
<TargetMachine>MachineX86</TargetMachine>
|
||||||
|
</Link>
|
||||||
|
<Bscmake>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
</Bscmake>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<Midl>
|
||||||
|
<TypeLibraryName>.\Release/quantize.tlb</TypeLibraryName>
|
||||||
|
<HeaderFileName />
|
||||||
|
</Midl>
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||||
|
<AdditionalIncludeDirectories>../;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<StringPooling>true</StringPooling>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<PrecompiledHeaderOutputFile>.\Release/quantize.pch</PrecompiledHeaderOutputFile>
|
||||||
|
<WarningLevel>Level4</WarningLevel>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
</ClCompile>
|
||||||
|
<ResourceCompile>
|
||||||
|
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<Culture>0x0411</Culture>
|
||||||
|
</ResourceCompile>
|
||||||
|
<Link>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||||
|
<DataExecutionPrevention />
|
||||||
|
<TargetMachine>MachineX86</TargetMachine>
|
||||||
|
</Link>
|
||||||
|
<Bscmake>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
</Bscmake>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<Midl>
|
||||||
|
<TargetEnvironment>X64</TargetEnvironment>
|
||||||
|
<TypeLibraryName>.\Debug/quantize.tlb</TypeLibraryName>
|
||||||
|
<HeaderFileName />
|
||||||
|
</Midl>
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<AdditionalIncludeDirectories>../;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<MinimalRebuild>true</MinimalRebuild>
|
||||||
|
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
<PrecompiledHeaderOutputFile>.\Debug/quantize.pch</PrecompiledHeaderOutputFile>
|
||||||
|
<WarningLevel>Level4</WarningLevel>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
|
</ClCompile>
|
||||||
|
<ResourceCompile>
|
||||||
|
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<Culture>0x0411</Culture>
|
||||||
|
</ResourceCompile>
|
||||||
|
<Link>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<ProgramDatabaseFile>.\Debug/quantize.pdb</ProgramDatabaseFile>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||||
|
<DataExecutionPrevention />
|
||||||
|
<TargetMachine>MachineX64</TargetMachine>
|
||||||
|
</Link>
|
||||||
|
<Bscmake>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
</Bscmake>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<Midl>
|
||||||
|
<TargetEnvironment>X64</TargetEnvironment>
|
||||||
|
<TypeLibraryName>.\Release/quantize.tlb</TypeLibraryName>
|
||||||
|
<HeaderFileName />
|
||||||
|
</Midl>
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||||
|
<AdditionalIncludeDirectories>../;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<StringPooling>true</StringPooling>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<PrecompiledHeaderOutputFile>.\Release/quantize.pch</PrecompiledHeaderOutputFile>
|
||||||
|
<WarningLevel>Level4</WarningLevel>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
</ClCompile>
|
||||||
|
<ResourceCompile>
|
||||||
|
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<Culture>0x0411</Culture>
|
||||||
|
</ResourceCompile>
|
||||||
|
<Link>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||||
|
<DataExecutionPrevention />
|
||||||
|
<TargetMachine>MachineX64</TargetMachine>
|
||||||
|
</Link>
|
||||||
|
<Bscmake>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
</Bscmake>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="quantize.cpp" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
||||||
28
external/xbyak/sample/stackframe.cpp
vendored
Normal file
28
external/xbyak/sample/stackframe.cpp
vendored
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
#include <xbyak/xbyak_util.h>
|
||||||
|
|
||||||
|
#ifdef XBYAK32
|
||||||
|
#error "this sample is for only 64-bit mode"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct Code : public Xbyak::CodeGenerator {
|
||||||
|
Code()
|
||||||
|
{
|
||||||
|
// see xbyak/sample/sf_test.cpp for how to use other parameter
|
||||||
|
Xbyak::util::StackFrame sf(this, 3);
|
||||||
|
mov(rax, sf.p[0]);
|
||||||
|
add(rax, sf.p[1]);
|
||||||
|
add(rax, sf.p[2]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
Code c;
|
||||||
|
int (*f)(int, int, int) = c.getCode<int(*) (int, int, int)>();
|
||||||
|
int ret = f(3, 5, 2);
|
||||||
|
if (ret == 3 + 5 + 2) {
|
||||||
|
puts("ok");
|
||||||
|
} else {
|
||||||
|
puts("ng");
|
||||||
|
}
|
||||||
|
}
|
||||||
44
external/xbyak/sample/static_buf.cpp
vendored
Normal file
44
external/xbyak/sample/static_buf.cpp
vendored
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
sample to use static memory
|
||||||
|
*/
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "xbyak/xbyak.h"
|
||||||
|
|
||||||
|
MIE_ALIGN(4096) char buf[4096];
|
||||||
|
|
||||||
|
struct Code : Xbyak::CodeGenerator {
|
||||||
|
Code()
|
||||||
|
: Xbyak::CodeGenerator(sizeof(buf), buf)
|
||||||
|
{
|
||||||
|
puts("generate");
|
||||||
|
printf("ptr=%p, %p\n", getCode(), buf);
|
||||||
|
#ifdef XBYAK32
|
||||||
|
mov(eax, ptr [esp + 4]);
|
||||||
|
add(eax, ptr [esp + 8]);
|
||||||
|
#elif defined(XBYAK64_WIN)
|
||||||
|
lea(rax, ptr [rcx + rdx]);
|
||||||
|
#else
|
||||||
|
lea(rax, ptr [rdi + rsi]);
|
||||||
|
#endif
|
||||||
|
ret();
|
||||||
|
Xbyak::CodeArray::protect(buf, sizeof(buf), Xbyak::CodeArray::PROTECT_RE);
|
||||||
|
}
|
||||||
|
~Code()
|
||||||
|
{
|
||||||
|
Xbyak::CodeArray::protect(buf, sizeof(buf), Xbyak::CodeArray::PROTECT_RW);
|
||||||
|
}
|
||||||
|
} s_code;
|
||||||
|
|
||||||
|
inline int add(int a, int b)
|
||||||
|
{
|
||||||
|
return reinterpret_cast<int (*)(int, int)>(buf)(a, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
int sum = 0;
|
||||||
|
for (int i = 0; i < 10; i++) {
|
||||||
|
sum += add(i, 5);
|
||||||
|
}
|
||||||
|
printf("sum=%d\n", sum);
|
||||||
|
}
|
||||||
189
external/xbyak/sample/test0.cpp
vendored
Normal file
189
external/xbyak/sample/test0.cpp
vendored
Normal file
@@ -0,0 +1,189 @@
|
|||||||
|
#if defined(_MSC_VER) && (_MSC_VER <= 1200)
|
||||||
|
#pragma warning(disable:4514)
|
||||||
|
#pragma warning(disable:4786)
|
||||||
|
#endif
|
||||||
|
#if defined(_MSC_VER) && (_MSC_VER >= 1900)
|
||||||
|
#pragma warning(disable:4456)
|
||||||
|
#endif
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "xbyak/xbyak.h"
|
||||||
|
|
||||||
|
class Sample : public Xbyak::CodeGenerator {
|
||||||
|
void operator=(const Sample&);
|
||||||
|
public:
|
||||||
|
Sample(void *userPtr = 0, size_t size = Xbyak::DEFAULT_MAX_CODE_SIZE) : Xbyak::CodeGenerator(size, userPtr)
|
||||||
|
{
|
||||||
|
inLocalLabel(); // use local label for multiple instance
|
||||||
|
#ifdef XBYAK32
|
||||||
|
mov(ecx, ptr [esp + 4]); // n
|
||||||
|
#elif defined(XBYAK64_GCC)
|
||||||
|
mov(ecx, edi); // n
|
||||||
|
#else
|
||||||
|
// n = ecx
|
||||||
|
#endif
|
||||||
|
xor_(eax, eax); // sum
|
||||||
|
test(ecx, ecx);
|
||||||
|
jz(".exit");
|
||||||
|
xor_(edx, edx); // i
|
||||||
|
L(".lp");
|
||||||
|
add(eax, edx);
|
||||||
|
inc(edx);
|
||||||
|
|
||||||
|
cmp(edx, ecx);
|
||||||
|
jbe(".lp"); // jmp to previous @@
|
||||||
|
L(".exit"); // <B>
|
||||||
|
ret();
|
||||||
|
outLocalLabel(); // end of local label
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class AddFunc : public Xbyak::CodeGenerator {
|
||||||
|
void operator=(const AddFunc&);
|
||||||
|
public:
|
||||||
|
AddFunc(int y)
|
||||||
|
{
|
||||||
|
#ifdef XBYAK32
|
||||||
|
mov(eax, ptr [esp + 4]);
|
||||||
|
add(eax, y);
|
||||||
|
#elif defined(XBYAK64_WIN)
|
||||||
|
lea(rax, ptr [rcx + y]);
|
||||||
|
#else
|
||||||
|
lea(eax, ptr [edi + y]);
|
||||||
|
#endif
|
||||||
|
ret();
|
||||||
|
}
|
||||||
|
int (*get() const)(int) { return getCode<int(*)(int)>(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
class CallAtoi : public Xbyak::CodeGenerator {
|
||||||
|
void operator=(const CallAtoi&);
|
||||||
|
public:
|
||||||
|
CallAtoi()
|
||||||
|
{
|
||||||
|
#ifdef XBYAK64
|
||||||
|
#ifdef XBYAK64_WIN
|
||||||
|
sub(rsp, 32); // return-address is destroied if 64bit debug mode
|
||||||
|
#endif
|
||||||
|
mov(rax, (size_t)atoi);
|
||||||
|
call(rax);
|
||||||
|
#ifdef XBYAK64_WIN
|
||||||
|
add(rsp, 32);
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
mov(eax, ptr [esp + 4]);
|
||||||
|
push(eax);
|
||||||
|
#ifdef XBYAK_VARIADIC_TEMPLATE
|
||||||
|
call(atoi);
|
||||||
|
#else
|
||||||
|
call(reinterpret_cast<const void*>(atoi));
|
||||||
|
#endif
|
||||||
|
add(esp, 4);
|
||||||
|
#endif
|
||||||
|
ret();
|
||||||
|
}
|
||||||
|
int (*get() const)(const char *) { return getCode<int (*)(const char *)>(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
class JmpAtoi : public Xbyak::CodeGenerator {
|
||||||
|
void operator=(const JmpAtoi&);
|
||||||
|
public:
|
||||||
|
JmpAtoi()
|
||||||
|
{
|
||||||
|
/* already pushed "456" */
|
||||||
|
#ifdef XBYAK64
|
||||||
|
mov(rax, (size_t)atoi);
|
||||||
|
jmp(rax);
|
||||||
|
#else
|
||||||
|
jmp(reinterpret_cast<const void*>(atoi));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
int (*get() const)(const char *) { return getCode<int (*)(const char *)>(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Reset : public Xbyak::CodeGenerator {
|
||||||
|
void init(int n)
|
||||||
|
{
|
||||||
|
xor_(eax, eax);
|
||||||
|
mov(ecx, n);
|
||||||
|
test(ecx, ecx);
|
||||||
|
jnz("@f");
|
||||||
|
ret();
|
||||||
|
L("@@");
|
||||||
|
for (int i = 0; i < 10 - n; i++) {
|
||||||
|
add(eax, ecx);
|
||||||
|
}
|
||||||
|
sub(ecx, 1);
|
||||||
|
jnz("@b");
|
||||||
|
ret();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void testReset()
|
||||||
|
{
|
||||||
|
puts("testReset");
|
||||||
|
Reset code;
|
||||||
|
int (*f)(int) = code.getCode<int(*)(int)>();
|
||||||
|
for (int i = 0; i < 10; i++) {
|
||||||
|
code.init(i);
|
||||||
|
int v = f(i);
|
||||||
|
printf("%d %d\n", i, v);
|
||||||
|
code.reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
Sample s;
|
||||||
|
printf("Xbyak version=%s\n", s.getVersionString());
|
||||||
|
#ifdef XBYAK64_GCC
|
||||||
|
puts("64bit mode(gcc)");
|
||||||
|
#elif defined(XBYAK64_WIN)
|
||||||
|
puts("64bit mode(win)");
|
||||||
|
#else
|
||||||
|
puts("32bit");
|
||||||
|
#endif
|
||||||
|
int (*func)(int) = s.getCode<int (*)(int)>();
|
||||||
|
for (int i = 0; i <= 10; i++) {
|
||||||
|
printf("0 + ... + %d = %d\n", i, func(i));
|
||||||
|
}
|
||||||
|
for (int i = 0; i < 10; i++) {
|
||||||
|
AddFunc a(i);
|
||||||
|
int (*add)(int) = a.get();
|
||||||
|
int y = add(i);
|
||||||
|
printf("%d + %d = %d\n", i, i, y);
|
||||||
|
}
|
||||||
|
CallAtoi c;
|
||||||
|
printf("call atoi(\"123\") = %d\n", c.get()("123"));
|
||||||
|
JmpAtoi j;
|
||||||
|
printf("jmp atoi(\"456\") = %d\n", j.get()("456"));
|
||||||
|
{
|
||||||
|
// use memory allocated by user
|
||||||
|
using namespace Xbyak;
|
||||||
|
const size_t codeSize = 4096;
|
||||||
|
uint8_t buf[codeSize + 16];
|
||||||
|
uint8_t *p = CodeArray::getAlignedAddress(buf);
|
||||||
|
Sample s(p, codeSize);
|
||||||
|
if (!CodeArray::protect(p, codeSize, CodeArray::PROTECT_RWE)) {
|
||||||
|
fprintf(stderr, "can't protect\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
int (*func)(int) = s.getCode<int (*)(int)>();
|
||||||
|
const uint8_t *funcp = reinterpret_cast<const uint8_t*>(func);
|
||||||
|
if (funcp != p) {
|
||||||
|
fprintf(stderr, "internal error %p %p\n", p, funcp);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
printf("0 + ... + %d = %d\n", 100, func(100));
|
||||||
|
CodeArray::protect(p, codeSize, CodeArray::PROTECT_RW);
|
||||||
|
}
|
||||||
|
puts("OK");
|
||||||
|
testReset();
|
||||||
|
} catch (std::exception& e) {
|
||||||
|
printf("ERR:%s\n", e.what());
|
||||||
|
} catch (...) {
|
||||||
|
printf("unknown error\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
228
external/xbyak/sample/test0.vcxproj
vendored
Normal file
228
external/xbyak/sample/test0.vcxproj
vendored
Normal file
@@ -0,0 +1,228 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{1CDE4D2A-BE3A-4B9B-B28F-524A23084A8E}</ProjectGuid>
|
||||||
|
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<PlatformToolset>v141</PlatformToolset>
|
||||||
|
<UseOfMfc>false</UseOfMfc>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<PlatformToolset>v141</PlatformToolset>
|
||||||
|
<UseOfMfc>false</UseOfMfc>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<PlatformToolset>v141</PlatformToolset>
|
||||||
|
<UseOfMfc>false</UseOfMfc>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<PlatformToolset>v141</PlatformToolset>
|
||||||
|
<UseOfMfc>false</UseOfMfc>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<_ProjectFileVersion>15.0.27924.0</_ProjectFileVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
<IntDir>$(ProjectName)\$(Configuration)\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<IntDir>$(ProjectName)\$(Configuration)\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
<IntDir>$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<IntDir>$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<Midl>
|
||||||
|
<TypeLibraryName>.\Debug/test0.tlb</TypeLibraryName>
|
||||||
|
<HeaderFileName />
|
||||||
|
</Midl>
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<AdditionalIncludeDirectories>../;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<MinimalRebuild>true</MinimalRebuild>
|
||||||
|
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
<PrecompiledHeaderOutputFile>.\Debug/test0.pch</PrecompiledHeaderOutputFile>
|
||||||
|
<WarningLevel>Level4</WarningLevel>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
</ClCompile>
|
||||||
|
<ResourceCompile>
|
||||||
|
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<Culture>0x0411</Culture>
|
||||||
|
</ResourceCompile>
|
||||||
|
<Link>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<ProgramDatabaseFile>.\Debug/test0.pdb</ProgramDatabaseFile>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||||
|
<DataExecutionPrevention />
|
||||||
|
<TargetMachine>MachineX86</TargetMachine>
|
||||||
|
</Link>
|
||||||
|
<Bscmake>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
</Bscmake>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<Midl>
|
||||||
|
<TypeLibraryName>.\Release/test0.tlb</TypeLibraryName>
|
||||||
|
<HeaderFileName />
|
||||||
|
</Midl>
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||||
|
<AdditionalIncludeDirectories>../;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<StringPooling>true</StringPooling>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<PrecompiledHeaderOutputFile>.\Release/test0.pch</PrecompiledHeaderOutputFile>
|
||||||
|
<WarningLevel>Level4</WarningLevel>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
</ClCompile>
|
||||||
|
<ResourceCompile>
|
||||||
|
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<Culture>0x0411</Culture>
|
||||||
|
</ResourceCompile>
|
||||||
|
<Link>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||||
|
<DataExecutionPrevention />
|
||||||
|
<TargetMachine>MachineX86</TargetMachine>
|
||||||
|
</Link>
|
||||||
|
<Bscmake>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
</Bscmake>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<Midl>
|
||||||
|
<TargetEnvironment>X64</TargetEnvironment>
|
||||||
|
<TypeLibraryName>.\Debug/test0.tlb</TypeLibraryName>
|
||||||
|
<HeaderFileName />
|
||||||
|
</Midl>
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<AdditionalIncludeDirectories>../;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<MinimalRebuild>true</MinimalRebuild>
|
||||||
|
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
<PrecompiledHeaderOutputFile>.\Debug/test0.pch</PrecompiledHeaderOutputFile>
|
||||||
|
<WarningLevel>Level4</WarningLevel>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
|
</ClCompile>
|
||||||
|
<ResourceCompile>
|
||||||
|
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<Culture>0x0411</Culture>
|
||||||
|
</ResourceCompile>
|
||||||
|
<Link>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<ProgramDatabaseFile>.\Debug/test0.pdb</ProgramDatabaseFile>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||||
|
<DataExecutionPrevention />
|
||||||
|
<TargetMachine>MachineX64</TargetMachine>
|
||||||
|
</Link>
|
||||||
|
<Bscmake>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
</Bscmake>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<Midl>
|
||||||
|
<TargetEnvironment>X64</TargetEnvironment>
|
||||||
|
<TypeLibraryName>.\Release/test0.tlb</TypeLibraryName>
|
||||||
|
<HeaderFileName />
|
||||||
|
</Midl>
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||||
|
<AdditionalIncludeDirectories>../;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<StringPooling>true</StringPooling>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<PrecompiledHeaderOutputFile>.\Release/test0.pch</PrecompiledHeaderOutputFile>
|
||||||
|
<WarningLevel>Level4</WarningLevel>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
</ClCompile>
|
||||||
|
<ResourceCompile>
|
||||||
|
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<Culture>0x0411</Culture>
|
||||||
|
</ResourceCompile>
|
||||||
|
<Link>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||||
|
<DataExecutionPrevention />
|
||||||
|
<TargetMachine>MachineX64</TargetMachine>
|
||||||
|
</Link>
|
||||||
|
<Bscmake>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
</Bscmake>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="test0.cpp" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
||||||
173
external/xbyak/sample/test_util.cpp
vendored
Normal file
173
external/xbyak/sample/test_util.cpp
vendored
Normal file
@@ -0,0 +1,173 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include "xbyak/xbyak_util.h"
|
||||||
|
|
||||||
|
#define NUM_OF_ARRAY(x) (sizeof(x) / sizeof(x[0]))
|
||||||
|
|
||||||
|
struct PopCountTest : public Xbyak::CodeGenerator {
|
||||||
|
PopCountTest(int n)
|
||||||
|
: Xbyak::CodeGenerator(4096, Xbyak::DontSetProtectRWE)
|
||||||
|
{
|
||||||
|
mov(eax, n);
|
||||||
|
popcnt(eax, eax);
|
||||||
|
ret();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void putCPUinfo(bool onlyCpuidFeature)
|
||||||
|
{
|
||||||
|
using namespace Xbyak::util;
|
||||||
|
Cpu cpu;
|
||||||
|
printf("vendor %s\n", cpu.has(Cpu::tINTEL) ? "intel" : "amd");
|
||||||
|
static const struct {
|
||||||
|
Cpu::Type type;
|
||||||
|
const char *str;
|
||||||
|
} tbl[] = {
|
||||||
|
{ Cpu::tMMX, "mmx" },
|
||||||
|
{ Cpu::tMMX2, "mmx2" },
|
||||||
|
{ Cpu::tCMOV, "cmov" },
|
||||||
|
{ Cpu::tSSE, "sse" },
|
||||||
|
{ Cpu::tSSE2, "sse2" },
|
||||||
|
{ Cpu::tSSE3, "sse3" },
|
||||||
|
{ Cpu::tSSSE3, "ssse3" },
|
||||||
|
{ Cpu::tSSE41, "sse41" },
|
||||||
|
{ Cpu::tSSE42, "sse42" },
|
||||||
|
{ Cpu::tSSE4a, "sse4a" },
|
||||||
|
{ Cpu::tPOPCNT, "popcnt" },
|
||||||
|
{ Cpu::t3DN, "3dn" },
|
||||||
|
{ Cpu::tE3DN, "e3dn" },
|
||||||
|
{ Cpu::tAESNI, "aesni" },
|
||||||
|
{ Cpu::tRDTSCP, "rdtscp" },
|
||||||
|
{ Cpu::tXSAVE, "xsave(xgetvb)" },
|
||||||
|
{ Cpu::tOSXSAVE, "osxsave" },
|
||||||
|
{ Cpu::tPCLMULQDQ, "pclmulqdq" },
|
||||||
|
{ Cpu::tAVX, "avx" },
|
||||||
|
{ Cpu::tFMA, "fma" },
|
||||||
|
{ Cpu::tAVX2, "avx2" },
|
||||||
|
{ Cpu::tBMI1, "bmi1" },
|
||||||
|
{ Cpu::tBMI2, "bmi2" },
|
||||||
|
{ Cpu::tLZCNT, "lzcnt" },
|
||||||
|
{ Cpu::tPREFETCHW, "prefetchw" },
|
||||||
|
{ Cpu::tENHANCED_REP, "enh_rep" },
|
||||||
|
{ Cpu::tRDRAND, "rdrand" },
|
||||||
|
{ Cpu::tADX, "adx" },
|
||||||
|
{ Cpu::tRDSEED, "rdseed" },
|
||||||
|
{ Cpu::tSMAP, "smap" },
|
||||||
|
{ Cpu::tHLE, "hle" },
|
||||||
|
{ Cpu::tRTM, "rtm" },
|
||||||
|
{ Cpu::tMPX, "mpx" },
|
||||||
|
{ Cpu::tSHA, "sha" },
|
||||||
|
{ Cpu::tPREFETCHWT1, "prefetchwt1" },
|
||||||
|
{ Cpu::tF16C, "f16c" },
|
||||||
|
{ Cpu::tMOVBE, "movbe" },
|
||||||
|
{ Cpu::tAVX512F, "avx512f" },
|
||||||
|
{ Cpu::tAVX512DQ, "avx512dq" },
|
||||||
|
{ Cpu::tAVX512IFMA, "avx512_ifma" },
|
||||||
|
{ Cpu::tAVX512PF, "avx512pf" },
|
||||||
|
{ Cpu::tAVX512ER, "avx512er" },
|
||||||
|
{ Cpu::tAVX512CD, "avx512cd" },
|
||||||
|
{ Cpu::tAVX512BW, "avx512bw" },
|
||||||
|
{ Cpu::tAVX512VL, "avx512vl" },
|
||||||
|
{ Cpu::tAVX512VBMI, "avx512_vbmi" },
|
||||||
|
{ Cpu::tAVX512_4VNNIW, "avx512_4vnniw" },
|
||||||
|
{ Cpu::tAVX512_4FMAPS, "avx512_4fmaps" },
|
||||||
|
|
||||||
|
{ Cpu::tAVX512_VBMI2, "avx512_vbmi2" },
|
||||||
|
{ Cpu::tGFNI, "gfni" },
|
||||||
|
{ Cpu::tVAES, "vaes" },
|
||||||
|
{ Cpu::tVPCLMULQDQ, "vpclmulqdq" },
|
||||||
|
{ Cpu::tAVX512_VNNI, "avx512_vnni" },
|
||||||
|
{ Cpu::tAVX512_BITALG, "avx512_bitalg" },
|
||||||
|
{ Cpu::tAVX512_VPOPCNTDQ, "avx512_vpopcntdq" },
|
||||||
|
{ Cpu::tAVX512_BF16, "avx512_bf16" },
|
||||||
|
{ Cpu::tAVX512_VP2INTERSECT, "avx512_vp2intersect" },
|
||||||
|
{ Cpu::tAMX_TILE, "amx(tile)" },
|
||||||
|
{ Cpu::tAMX_INT8, "amx(int8)" },
|
||||||
|
{ Cpu::tAMX_BF16, "amx(bf16)" },
|
||||||
|
{ Cpu::tAVX_VNNI, "avx_vnni" },
|
||||||
|
{ Cpu::tAVX512_FP16, "avx512_fp16" },
|
||||||
|
{ Cpu::tWAITPKG, "waitpkg" },
|
||||||
|
{ Cpu::tCLFLUSHOPT, "clflushopt" },
|
||||||
|
{ Cpu::tCLDEMOTE, "cldemote" },
|
||||||
|
{ Cpu::tCLWB, "clwb" },
|
||||||
|
{ Cpu::tMOVDIRI, "movdiri" },
|
||||||
|
{ Cpu::tMOVDIR64B, "movdir64b" },
|
||||||
|
{ Cpu::tUINTR, "uintr" },
|
||||||
|
{ Cpu::tSERIALIZE, "serialize" },
|
||||||
|
{ Cpu::tCLZERO, "clzero" },
|
||||||
|
{ Cpu::tAMX_FP16, "amx_fp16" },
|
||||||
|
{ Cpu::tAVX_VNNI_INT8, "avx_vnni_int8" },
|
||||||
|
{ Cpu::tAVX_NE_CONVERT, "avx_ne_convert" },
|
||||||
|
{ Cpu::tAVX_IFMA, "avx_ifma" },
|
||||||
|
{ Cpu::tRAO_INT, "rao-int" },
|
||||||
|
{ Cpu::tCMPCCXADD, "cmpccxadd" },
|
||||||
|
{ Cpu::tPREFETCHITI, "prefetchiti" },
|
||||||
|
{ Cpu::tSHA512, "sha512" },
|
||||||
|
{ Cpu::tSM3, "sm3" },
|
||||||
|
{ Cpu::tSM4, "sm4" },
|
||||||
|
{ Cpu::tAVX_VNNI_INT16, "avx_vnni_int16" },
|
||||||
|
{ Cpu::tAPX_F, "apx_f" },
|
||||||
|
{ Cpu::tAVX10, "avx10" },
|
||||||
|
{ Cpu::tAESKLE, "aeskle" },
|
||||||
|
{ Cpu::tWIDE_KL, "wide_kl" },
|
||||||
|
{ Cpu::tKEYLOCKER, "keylocker" },
|
||||||
|
{ Cpu::tKEYLOCKER_WIDE, "keylocker_wide" },
|
||||||
|
{ Cpu::tTSXLDTRK, "tsxldtrk" },
|
||||||
|
{ Cpu::tAMX_FP8, "amx_fp8" },
|
||||||
|
{ Cpu::tAMX_TRANSPOSE, "amx_transpose" },
|
||||||
|
{ Cpu::tAMX_TF32, "amx_tf32" },
|
||||||
|
{ Cpu::tAMX_AVX512, "amx_avx512" },
|
||||||
|
{ Cpu::tAMX_MOVRS, "amx_movrs" },
|
||||||
|
{ Cpu::tMOVRS, "movrs" },
|
||||||
|
};
|
||||||
|
for (size_t i = 0; i < NUM_OF_ARRAY(tbl); i++) {
|
||||||
|
if (cpu.has(tbl[i].type)) printf(" %s", tbl[i].str);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
if (onlyCpuidFeature) return;
|
||||||
|
if (cpu.has(Cpu::tAVX10)) {
|
||||||
|
printf("AVX10 version %d\n", cpu.getAVX10version());
|
||||||
|
}
|
||||||
|
if (cpu.has(Cpu::tPOPCNT)) {
|
||||||
|
const int n = 0x12345678; // bitcount = 13
|
||||||
|
const int ok = 13;
|
||||||
|
PopCountTest code(n);
|
||||||
|
code.setProtectModeRE();
|
||||||
|
int (*f)() = code.getCode<int (*)()>();
|
||||||
|
int r = f();
|
||||||
|
if (r == ok) {
|
||||||
|
puts("popcnt ok");
|
||||||
|
} else {
|
||||||
|
printf("popcnt ng %d %d\n", r, ok);
|
||||||
|
}
|
||||||
|
code.setProtectModeRW();
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
displayFamily displayModel
|
||||||
|
Opteron 2376 10 4
|
||||||
|
Core2 Duo T7100 6 F
|
||||||
|
Core i3-2120T 6 2A
|
||||||
|
Core i7-2600 6 2A
|
||||||
|
Xeon X5650 6 2C
|
||||||
|
Core i7-3517 6 3A
|
||||||
|
Core i7-3930K 6 2D
|
||||||
|
*/
|
||||||
|
cpu.putFamily();
|
||||||
|
for (unsigned int i = 0; i < cpu.getDataCacheLevels(); i++) {
|
||||||
|
printf("cache level=%u data cache size=%u cores sharing data cache=%u\n", i, cpu.getDataCacheSize(i), cpu.getCoresSharingDataCache(i));
|
||||||
|
}
|
||||||
|
printf("SmtLevel =%u\n", cpu.getNumCores(Xbyak::util::SmtLevel));
|
||||||
|
printf("CoreLevel=%u\n", cpu.getNumCores(Xbyak::util::CoreLevel));
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
bool onlyCpuidFeature = argc == 2 && strcmp(argv[1], "-cpuid") == 0;
|
||||||
|
if (!onlyCpuidFeature) {
|
||||||
|
#ifdef XBYAK32
|
||||||
|
puts("32bit");
|
||||||
|
#else
|
||||||
|
puts("64bit");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
putCPUinfo(onlyCpuidFeature);
|
||||||
|
}
|
||||||
228
external/xbyak/sample/test_util.vcxproj
vendored
Normal file
228
external/xbyak/sample/test_util.vcxproj
vendored
Normal file
@@ -0,0 +1,228 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{CFC9B272-FDA1-4C87-B4EF-CDCA9B57F4DD}</ProjectGuid>
|
||||||
|
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<PlatformToolset>v141</PlatformToolset>
|
||||||
|
<UseOfMfc>false</UseOfMfc>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<PlatformToolset>v141</PlatformToolset>
|
||||||
|
<UseOfMfc>false</UseOfMfc>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<PlatformToolset>v141</PlatformToolset>
|
||||||
|
<UseOfMfc>false</UseOfMfc>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<PlatformToolset>v141</PlatformToolset>
|
||||||
|
<UseOfMfc>false</UseOfMfc>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<_ProjectFileVersion>15.0.27924.0</_ProjectFileVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
<IntDir>$(ProjectName)\$(Configuration)\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
<IntDir>$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<IntDir>$(ProjectName)\$(Configuration)\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<IntDir>$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<Midl>
|
||||||
|
<TypeLibraryName>.\Debug/test_util.tlb</TypeLibraryName>
|
||||||
|
<HeaderFileName />
|
||||||
|
</Midl>
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<AdditionalIncludeDirectories>../;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<MinimalRebuild>true</MinimalRebuild>
|
||||||
|
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
<PrecompiledHeaderOutputFile>.\Debug/test_util.pch</PrecompiledHeaderOutputFile>
|
||||||
|
<WarningLevel>Level4</WarningLevel>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
</ClCompile>
|
||||||
|
<ResourceCompile>
|
||||||
|
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<Culture>0x0411</Culture>
|
||||||
|
</ResourceCompile>
|
||||||
|
<Link>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<ProgramDatabaseFile>.\Debug/test_util.pdb</ProgramDatabaseFile>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||||
|
<DataExecutionPrevention />
|
||||||
|
<TargetMachine>MachineX86</TargetMachine>
|
||||||
|
</Link>
|
||||||
|
<Bscmake>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
</Bscmake>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<Midl>
|
||||||
|
<TargetEnvironment>X64</TargetEnvironment>
|
||||||
|
<TypeLibraryName>.\Debug/test_util.tlb</TypeLibraryName>
|
||||||
|
<HeaderFileName />
|
||||||
|
</Midl>
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<AdditionalIncludeDirectories>../;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<MinimalRebuild>true</MinimalRebuild>
|
||||||
|
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
<PrecompiledHeaderOutputFile>.\Debug/test_util.pch</PrecompiledHeaderOutputFile>
|
||||||
|
<WarningLevel>Level4</WarningLevel>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
|
</ClCompile>
|
||||||
|
<ResourceCompile>
|
||||||
|
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<Culture>0x0411</Culture>
|
||||||
|
</ResourceCompile>
|
||||||
|
<Link>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<ProgramDatabaseFile>.\Debug/test_util.pdb</ProgramDatabaseFile>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||||
|
<DataExecutionPrevention />
|
||||||
|
<TargetMachine>MachineX64</TargetMachine>
|
||||||
|
</Link>
|
||||||
|
<Bscmake>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
</Bscmake>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<Midl>
|
||||||
|
<TypeLibraryName>.\Release/test_util.tlb</TypeLibraryName>
|
||||||
|
<HeaderFileName />
|
||||||
|
</Midl>
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||||
|
<AdditionalIncludeDirectories>../;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<StringPooling>true</StringPooling>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<PrecompiledHeaderOutputFile>.\Release/test_util.pch</PrecompiledHeaderOutputFile>
|
||||||
|
<WarningLevel>Level4</WarningLevel>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
</ClCompile>
|
||||||
|
<ResourceCompile>
|
||||||
|
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<Culture>0x0411</Culture>
|
||||||
|
</ResourceCompile>
|
||||||
|
<Link>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||||
|
<DataExecutionPrevention />
|
||||||
|
<TargetMachine>MachineX86</TargetMachine>
|
||||||
|
</Link>
|
||||||
|
<Bscmake>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
</Bscmake>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<Midl>
|
||||||
|
<TargetEnvironment>X64</TargetEnvironment>
|
||||||
|
<TypeLibraryName>.\Release/test_util.tlb</TypeLibraryName>
|
||||||
|
<HeaderFileName />
|
||||||
|
</Midl>
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||||
|
<AdditionalIncludeDirectories>../;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<StringPooling>true</StringPooling>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<PrecompiledHeaderOutputFile>.\Release/test_util.pch</PrecompiledHeaderOutputFile>
|
||||||
|
<WarningLevel>Level4</WarningLevel>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
</ClCompile>
|
||||||
|
<ResourceCompile>
|
||||||
|
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<Culture>0x0411</Culture>
|
||||||
|
</ResourceCompile>
|
||||||
|
<Link>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||||
|
<DataExecutionPrevention />
|
||||||
|
<TargetMachine>MachineX64</TargetMachine>
|
||||||
|
</Link>
|
||||||
|
<Bscmake>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
</Bscmake>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="test_util.cpp" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
||||||
383
external/xbyak/sample/toyvm.cpp
vendored
Normal file
383
external/xbyak/sample/toyvm.cpp
vendored
Normal file
@@ -0,0 +1,383 @@
|
|||||||
|
/*
|
||||||
|
toy vm
|
||||||
|
register A, B : 32bit
|
||||||
|
PC : program counter
|
||||||
|
|
||||||
|
mem_ 4byte x 65536
|
||||||
|
|
||||||
|
all instructions are fixed at 4 bytes.
|
||||||
|
all immediate values are 16-bit.
|
||||||
|
|
||||||
|
R = A or B
|
||||||
|
vldiR, imm ; R = imm
|
||||||
|
vldR, idx ; R = mem_[idx]
|
||||||
|
vstR, idx ; mem_[idx] = R
|
||||||
|
vaddiR, imm ; R += imm
|
||||||
|
vsubiR, imm ; R -= imm
|
||||||
|
vaddR, idx ; R += mem_[idx]
|
||||||
|
vsubR, idx ; R -= mem_[idx]
|
||||||
|
vputR ; print R
|
||||||
|
vjnzR, offset; if (R != 0) then jmp(PC += offset(signed))
|
||||||
|
*/
|
||||||
|
#if defined(_MSC_VER) && (_MSC_VER <= 1200)
|
||||||
|
#pragma warning(disable:4514)
|
||||||
|
#pragma warning(disable:4786)
|
||||||
|
#endif
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" // wrong detection in recompile()
|
||||||
|
#endif
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <memory.h>
|
||||||
|
#include <vector>
|
||||||
|
#include "xbyak/xbyak.h"
|
||||||
|
#include "xbyak/xbyak_util.h"
|
||||||
|
#define NUM_OF_ARRAY(x) (sizeof(x) / sizeof(x[0]))
|
||||||
|
|
||||||
|
#ifdef XBYAK64
|
||||||
|
#error "only 32bit"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
using namespace Xbyak;
|
||||||
|
|
||||||
|
class ToyVm : public Xbyak::CodeGenerator {
|
||||||
|
typedef std::vector<uint32_t> Buffer;
|
||||||
|
public:
|
||||||
|
enum Reg {
|
||||||
|
A, B
|
||||||
|
};
|
||||||
|
enum Code {
|
||||||
|
LD, LDI, ST, ADD, ADDI, SUB, SUBI, PUT, JNZ,
|
||||||
|
END_OF_CODE
|
||||||
|
};
|
||||||
|
ToyVm()
|
||||||
|
: mark_(0)
|
||||||
|
{
|
||||||
|
::memset(mem_, 0, sizeof(mem_));
|
||||||
|
}
|
||||||
|
void vldi(Reg r, uint16_t imm) { encode(LDI, r, imm); }
|
||||||
|
void vld(Reg r, uint16_t idx) { encode(LD, r, idx); }
|
||||||
|
void vst(Reg r, uint16_t idx) { encode(ST, r, idx); }
|
||||||
|
void vadd(Reg r, uint16_t idx) { encode(ADD, r, idx); }
|
||||||
|
void vaddi(Reg r, uint16_t imm) { encode(ADDI, r, imm); }
|
||||||
|
void vsub(Reg r, uint16_t idx) { encode(SUB, r, idx); }
|
||||||
|
void vsubi(Reg r, uint16_t imm) { encode(SUBI, r, imm); }
|
||||||
|
void vjnz(Reg r, int offset) { encode(JNZ, r, static_cast<uint16_t>(offset)); }
|
||||||
|
void vput(Reg r) { encode(PUT, r); }
|
||||||
|
void setMark()
|
||||||
|
{
|
||||||
|
mark_ = (int)code_.size();
|
||||||
|
}
|
||||||
|
int getMarkOffset()
|
||||||
|
{
|
||||||
|
return mark_ - (int)code_.size() - 1;
|
||||||
|
}
|
||||||
|
void run()
|
||||||
|
{
|
||||||
|
bool debug = false;//true;
|
||||||
|
uint32_t reg[2] = { 0, 0 };
|
||||||
|
const size_t end = code_.size();
|
||||||
|
uint32_t pc = 0;
|
||||||
|
for (;;) {
|
||||||
|
uint32_t x = code_[pc];
|
||||||
|
uint32_t code, r, imm;
|
||||||
|
decode(code, r, imm, x);
|
||||||
|
if (debug) {
|
||||||
|
printf("---\n");
|
||||||
|
printf("A %08x B %08x\n", reg[0], reg[1]);
|
||||||
|
printf("mem_[] = %08x %08x %08x\n", mem_[0], mem_[1], mem_[2]);
|
||||||
|
printf("pc=%4d, code=%02x, r=%d, imm=%04x\n", pc, code, r, imm);
|
||||||
|
}
|
||||||
|
switch (code) {
|
||||||
|
case LDI:
|
||||||
|
reg[r] = imm;
|
||||||
|
break;
|
||||||
|
case LD:
|
||||||
|
reg[r] = mem_[imm];
|
||||||
|
break;
|
||||||
|
case ST:
|
||||||
|
mem_[imm] = reg[r];
|
||||||
|
break;
|
||||||
|
case ADD:
|
||||||
|
reg[r] += mem_[imm];
|
||||||
|
break;
|
||||||
|
case ADDI:
|
||||||
|
reg[r] += imm;
|
||||||
|
break;
|
||||||
|
case SUB:
|
||||||
|
reg[r] -= mem_[imm];
|
||||||
|
break;
|
||||||
|
case SUBI:
|
||||||
|
reg[r] -= imm;
|
||||||
|
break;
|
||||||
|
case PUT:
|
||||||
|
printf("%c %8u(0x%08x)\n", 'A' + r, reg[r], reg[r]);
|
||||||
|
break;
|
||||||
|
case JNZ:
|
||||||
|
if (reg[r] != 0) pc += static_cast<signed short>(imm);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
assert(0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
pc++;
|
||||||
|
if (pc >= end) break;
|
||||||
|
} // for (;;)
|
||||||
|
}
|
||||||
|
void recompile()
|
||||||
|
{
|
||||||
|
using namespace Xbyak;
|
||||||
|
/*
|
||||||
|
esi : A
|
||||||
|
edi : B
|
||||||
|
ebx : mem_
|
||||||
|
for speed up
|
||||||
|
mem_[0] : eax
|
||||||
|
mem_[1] : ecx
|
||||||
|
mem_[2] : edx
|
||||||
|
*/
|
||||||
|
push(ebx);
|
||||||
|
push(esi);
|
||||||
|
push(edi);
|
||||||
|
|
||||||
|
const Reg32 reg[2] = { esi, edi };
|
||||||
|
const Reg32 mem(ebx);
|
||||||
|
|
||||||
|
const Reg32 memTbl[] = { eax, ecx, edx };
|
||||||
|
const size_t memTblNum = NUM_OF_ARRAY(memTbl);
|
||||||
|
for (size_t i = 0; i < memTblNum; i++) xor_(memTbl[i], memTbl[i]);
|
||||||
|
|
||||||
|
xor_(esi, esi);
|
||||||
|
xor_(edi, edi);
|
||||||
|
mov(mem, (size_t)mem_);
|
||||||
|
const size_t end = code_.size();
|
||||||
|
uint32_t pc = 0;
|
||||||
|
uint32_t labelNum = 0;
|
||||||
|
for (;;) {
|
||||||
|
uint32_t x = code_[pc];
|
||||||
|
uint32_t code, r, imm;
|
||||||
|
decode(code, r, imm, x);
|
||||||
|
L(Label::toStr(labelNum++));
|
||||||
|
switch (code) {
|
||||||
|
case LDI:
|
||||||
|
mov(reg[r], imm);
|
||||||
|
break;
|
||||||
|
case LD:
|
||||||
|
if (imm < memTblNum) {
|
||||||
|
mov(reg[r], memTbl[imm]);
|
||||||
|
} else {
|
||||||
|
mov(reg[r], ptr[mem + imm * 4]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ST:
|
||||||
|
if (imm < memTblNum) {
|
||||||
|
mov(memTbl[imm], reg[r]);
|
||||||
|
} else {
|
||||||
|
mov(ptr [mem + imm * 4], reg[r]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ADD:
|
||||||
|
if (imm < memTblNum) {
|
||||||
|
add(reg[r], memTbl[imm]);
|
||||||
|
} else {
|
||||||
|
add(reg[r], ptr [mem + imm * 4]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ADDI:
|
||||||
|
add(reg[r], imm);
|
||||||
|
break;
|
||||||
|
case SUB:
|
||||||
|
if (imm < memTblNum) {
|
||||||
|
sub(reg[r], memTbl[imm]);
|
||||||
|
} else {
|
||||||
|
sub(reg[r], ptr [mem + imm * 4]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SUBI:
|
||||||
|
sub(reg[r], imm);
|
||||||
|
break;
|
||||||
|
case PUT:
|
||||||
|
{
|
||||||
|
static const char *str = "%c %8d(0x%08x)\n";
|
||||||
|
push(eax);
|
||||||
|
push(edx);
|
||||||
|
push(ecx);
|
||||||
|
push(reg[r]);
|
||||||
|
push(reg[r]);
|
||||||
|
push('A' + r);
|
||||||
|
push((int)str);
|
||||||
|
call(reinterpret_cast<const void*>(printf));
|
||||||
|
add(esp, 4 * 4);
|
||||||
|
pop(ecx);
|
||||||
|
pop(edx);
|
||||||
|
pop(eax);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case JNZ:
|
||||||
|
test(reg[r], reg[r]);
|
||||||
|
jnz(Label::toStr(labelNum + static_cast<signed short>(imm)));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
assert(0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
pc++;
|
||||||
|
if (pc >= end) break;
|
||||||
|
} // for (;;)
|
||||||
|
|
||||||
|
pop(edi);
|
||||||
|
pop(esi);
|
||||||
|
pop(ebx);
|
||||||
|
ret();
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
uint32_t mem_[65536];
|
||||||
|
Buffer code_;
|
||||||
|
int mark_;
|
||||||
|
void decode(uint32_t& code, uint32_t& r, uint32_t& imm, uint32_t x)
|
||||||
|
{
|
||||||
|
code = x >> 24;
|
||||||
|
r = (x >> 16) & 0xff;
|
||||||
|
imm = x & 0xffff;
|
||||||
|
}
|
||||||
|
void encode(Code code, Reg r, uint16_t imm = 0)
|
||||||
|
{
|
||||||
|
uint32_t x = (code << 24) | (r << 16) | imm;
|
||||||
|
code_.push_back(x);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class Fib : public ToyVm {
|
||||||
|
public:
|
||||||
|
Fib(int n)
|
||||||
|
{
|
||||||
|
if (n >= 65536) {
|
||||||
|
fprintf(stderr, "current version support only imm16\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
A : c
|
||||||
|
B : temporary
|
||||||
|
mem_[0] : p
|
||||||
|
mem_[1] : t
|
||||||
|
mem_[2] : n
|
||||||
|
*/
|
||||||
|
vldi(A, 1); // c
|
||||||
|
vst(A, 0); // p(1)
|
||||||
|
vldi(B, static_cast<uint16_t>(n));
|
||||||
|
vst(B, 2); // n
|
||||||
|
// lp
|
||||||
|
setMark();
|
||||||
|
vst(A, 1); // t = c
|
||||||
|
vadd(A, 0); // c += p
|
||||||
|
vld(B, 1);
|
||||||
|
vst(B, 0); // p = t
|
||||||
|
// vput(A);
|
||||||
|
vld(B, 2);
|
||||||
|
vsubi(B, 1);
|
||||||
|
vst(B, 2); // n--
|
||||||
|
vjnz(B, getMarkOffset());
|
||||||
|
vput(A);
|
||||||
|
}
|
||||||
|
void runByJIT()
|
||||||
|
{
|
||||||
|
getCode<void (*)()>();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void fibC(uint32_t n)
|
||||||
|
{
|
||||||
|
uint32_t p, c, t;
|
||||||
|
p = 1;
|
||||||
|
c = 1;
|
||||||
|
lp:
|
||||||
|
t = c;
|
||||||
|
c += p;
|
||||||
|
p = t;
|
||||||
|
n--;
|
||||||
|
if (n != 0) goto lp;
|
||||||
|
printf("c=%u(0x%08x)\n", c, c);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
const int n = 10000;
|
||||||
|
Fib fib(n);
|
||||||
|
|
||||||
|
fib.recompile();
|
||||||
|
|
||||||
|
{
|
||||||
|
Xbyak::util::Clock clk;
|
||||||
|
clk.begin();
|
||||||
|
fib.run();
|
||||||
|
clk.end();
|
||||||
|
printf("vm %.2fKclk\n", clk.getClock() * 1e-3);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
Xbyak::util::Clock clk;
|
||||||
|
clk.begin();
|
||||||
|
fib.runByJIT();
|
||||||
|
clk.end();
|
||||||
|
printf("jit %.2fKclk\n", clk.getClock() * 1e-3);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
Xbyak::util::Clock clk;
|
||||||
|
clk.begin();
|
||||||
|
fibC(n);
|
||||||
|
clk.end();
|
||||||
|
printf("native C %.2fKclk\n", clk.getClock() * 1e-3);
|
||||||
|
}
|
||||||
|
} catch (std::exception& e) {
|
||||||
|
printf("ERR:%s\n", e.what());
|
||||||
|
} catch (...) {
|
||||||
|
printf("unknown error\n");
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
the code generated by Xbyak
|
||||||
|
push ebx
|
||||||
|
push esi
|
||||||
|
push edi
|
||||||
|
xor eax,eax
|
||||||
|
xor ecx,ecx
|
||||||
|
xor edx,edx
|
||||||
|
xor esi,esi
|
||||||
|
xor edi,edi
|
||||||
|
mov ebx,0EFF58h
|
||||||
|
mov esi,1
|
||||||
|
mov eax,esi
|
||||||
|
mov edi,2710h
|
||||||
|
mov edx,edi
|
||||||
|
.lp:
|
||||||
|
mov ecx,esi
|
||||||
|
add esi,eax
|
||||||
|
mov edi,ecx
|
||||||
|
mov eax,edi
|
||||||
|
mov edi,edx
|
||||||
|
sub edi,1
|
||||||
|
mov edx,edi
|
||||||
|
test edi,edi
|
||||||
|
jne .lp
|
||||||
|
push eax
|
||||||
|
push edx
|
||||||
|
push ecx
|
||||||
|
push esi
|
||||||
|
push esi
|
||||||
|
push 41h
|
||||||
|
push 42C434h
|
||||||
|
call printf (409342h)
|
||||||
|
add esp,10h
|
||||||
|
pop ecx
|
||||||
|
pop edx
|
||||||
|
pop eax
|
||||||
|
pop edi
|
||||||
|
pop esi
|
||||||
|
pop ebx
|
||||||
|
ret
|
||||||
|
*/
|
||||||
228
external/xbyak/sample/toyvm.vcxproj
vendored
Normal file
228
external/xbyak/sample/toyvm.vcxproj
vendored
Normal file
@@ -0,0 +1,228 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{2E41C7AF-39FF-454C-B081-37445378DCB3}</ProjectGuid>
|
||||||
|
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<PlatformToolset>v141</PlatformToolset>
|
||||||
|
<UseOfMfc>false</UseOfMfc>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<PlatformToolset>v141</PlatformToolset>
|
||||||
|
<UseOfMfc>false</UseOfMfc>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<PlatformToolset>v141</PlatformToolset>
|
||||||
|
<UseOfMfc>false</UseOfMfc>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<PlatformToolset>v141</PlatformToolset>
|
||||||
|
<UseOfMfc>false</UseOfMfc>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<_ProjectFileVersion>15.0.27924.0</_ProjectFileVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
<IntDir>$(ProjectName)\$(Configuration)\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<IntDir>$(ProjectName)\$(Configuration)\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
<IntDir>$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<IntDir>$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<Midl>
|
||||||
|
<TypeLibraryName>.\Debug/toyvm.tlb</TypeLibraryName>
|
||||||
|
<HeaderFileName />
|
||||||
|
</Midl>
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<AdditionalIncludeDirectories>../;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<MinimalRebuild>true</MinimalRebuild>
|
||||||
|
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
<PrecompiledHeaderOutputFile>.\Debug/toyvm.pch</PrecompiledHeaderOutputFile>
|
||||||
|
<WarningLevel>Level4</WarningLevel>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
</ClCompile>
|
||||||
|
<ResourceCompile>
|
||||||
|
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<Culture>0x0411</Culture>
|
||||||
|
</ResourceCompile>
|
||||||
|
<Link>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<ProgramDatabaseFile>.\Debug/toyvm.pdb</ProgramDatabaseFile>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||||
|
<DataExecutionPrevention />
|
||||||
|
<TargetMachine>MachineX86</TargetMachine>
|
||||||
|
</Link>
|
||||||
|
<Bscmake>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
</Bscmake>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<Midl>
|
||||||
|
<TypeLibraryName>.\Release/toyvm.tlb</TypeLibraryName>
|
||||||
|
<HeaderFileName />
|
||||||
|
</Midl>
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||||
|
<AdditionalIncludeDirectories>../;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<StringPooling>true</StringPooling>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<PrecompiledHeaderOutputFile>.\Release/toyvm.pch</PrecompiledHeaderOutputFile>
|
||||||
|
<WarningLevel>Level4</WarningLevel>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
</ClCompile>
|
||||||
|
<ResourceCompile>
|
||||||
|
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<Culture>0x0411</Culture>
|
||||||
|
</ResourceCompile>
|
||||||
|
<Link>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||||
|
<DataExecutionPrevention />
|
||||||
|
<TargetMachine>MachineX86</TargetMachine>
|
||||||
|
</Link>
|
||||||
|
<Bscmake>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
</Bscmake>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<Midl>
|
||||||
|
<TargetEnvironment>X64</TargetEnvironment>
|
||||||
|
<TypeLibraryName>.\Debug/toyvm.tlb</TypeLibraryName>
|
||||||
|
<HeaderFileName />
|
||||||
|
</Midl>
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<AdditionalIncludeDirectories>../;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<MinimalRebuild>true</MinimalRebuild>
|
||||||
|
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
<PrecompiledHeaderOutputFile>.\Debug/toyvm.pch</PrecompiledHeaderOutputFile>
|
||||||
|
<WarningLevel>Level4</WarningLevel>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
|
</ClCompile>
|
||||||
|
<ResourceCompile>
|
||||||
|
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<Culture>0x0411</Culture>
|
||||||
|
</ResourceCompile>
|
||||||
|
<Link>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<ProgramDatabaseFile>.\Debug/toyvm.pdb</ProgramDatabaseFile>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||||
|
<DataExecutionPrevention />
|
||||||
|
<TargetMachine>MachineX64</TargetMachine>
|
||||||
|
</Link>
|
||||||
|
<Bscmake>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
</Bscmake>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<Midl>
|
||||||
|
<TargetEnvironment>X64</TargetEnvironment>
|
||||||
|
<TypeLibraryName>.\Release/toyvm.tlb</TypeLibraryName>
|
||||||
|
<HeaderFileName />
|
||||||
|
</Midl>
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||||
|
<AdditionalIncludeDirectories>../;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<StringPooling>true</StringPooling>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<PrecompiledHeaderOutputFile>.\Release/toyvm.pch</PrecompiledHeaderOutputFile>
|
||||||
|
<WarningLevel>Level4</WarningLevel>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
</ClCompile>
|
||||||
|
<ResourceCompile>
|
||||||
|
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<Culture>0x0411</Culture>
|
||||||
|
</ResourceCompile>
|
||||||
|
<Link>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||||
|
<DataExecutionPrevention />
|
||||||
|
<TargetMachine>MachineX64</TargetMachine>
|
||||||
|
</Link>
|
||||||
|
<Bscmake>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
</Bscmake>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="toyvm.cpp" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
||||||
48
external/xbyak/sample/zero_upper.cpp
vendored
Normal file
48
external/xbyak/sample/zero_upper.cpp
vendored
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
An example of T_zu (zero upper) flag
|
||||||
|
> g++ zero_upper.cpp -I ../xbyak
|
||||||
|
> sde -future -- ./a.out
|
||||||
|
*/
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <xbyak/xbyak.h>
|
||||||
|
|
||||||
|
using namespace Xbyak;
|
||||||
|
|
||||||
|
struct Code : Xbyak::CodeGenerator {
|
||||||
|
Code(int mode)
|
||||||
|
{
|
||||||
|
mov(eax, 0x12345678);
|
||||||
|
cmp(eax, eax); // ZF=1
|
||||||
|
switch (mode) {
|
||||||
|
case 0: // imul
|
||||||
|
puts("imul");
|
||||||
|
imul(ax,ax, 0x1234);
|
||||||
|
break;
|
||||||
|
case 1: // imul+zu
|
||||||
|
puts("imul+zu");
|
||||||
|
imul(ax|T_zu, ax, 0x1234);
|
||||||
|
break;
|
||||||
|
case 2: // setz
|
||||||
|
puts("setz");
|
||||||
|
setz(al);
|
||||||
|
break;
|
||||||
|
case 3: // setz+zu
|
||||||
|
puts("setz+zu");
|
||||||
|
setz(al|T_zu);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
ret();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
int main()
|
||||||
|
try
|
||||||
|
{
|
||||||
|
for (int mode = 0; mode < 4; mode++) {
|
||||||
|
Code c(mode);
|
||||||
|
auto f = c.getCode<int (*)()>();
|
||||||
|
printf("ret=%08x\n", f());
|
||||||
|
}
|
||||||
|
} catch (std::exception& e) {
|
||||||
|
printf("ERR %s\n", e.what());
|
||||||
|
}
|
||||||
1
external/xbyak/test/CFLAGS_WARN.cfg
vendored
Normal file
1
external/xbyak/test/CFLAGS_WARN.cfg
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
-Wall -Wextra -Wsuggest-override -Wformat=2 -Wcast-qual -Wwrite-strings -Wfloat-equal -Wpointer-arith
|
||||||
141
external/xbyak/test/Makefile
vendored
Normal file
141
external/xbyak/test/Makefile
vendored
Normal file
@@ -0,0 +1,141 @@
|
|||||||
|
# To compile with -m32
|
||||||
|
# apt install g++-multilib
|
||||||
|
CXX_32 = $(CXX) -m32
|
||||||
|
CXX_64 = $(CXX) -m64
|
||||||
|
TARGET = make_nm normalize_prefix bad_address misc cvt_test cvt_test32 noexception misc32 detect_x32 avx10_test
|
||||||
|
XBYAK_INC=../xbyak/xbyak.h ../xbyak/xbyak_mnemonic.h ../xbyak/xbyak_util.h
|
||||||
|
UNAME_S=$(shell uname -s)
|
||||||
|
ifeq ($(shell ./detect_x32),x32)
|
||||||
|
X32?=1
|
||||||
|
endif
|
||||||
|
BIT=32
|
||||||
|
ifeq ($(shell uname -m),x86_64)
|
||||||
|
BIT=64
|
||||||
|
endif
|
||||||
|
ONLY_64BIT=0
|
||||||
|
ifeq ($(UNAME_S),Darwin)
|
||||||
|
# 32-bit binary is not supported
|
||||||
|
ONLY_64BIT=1
|
||||||
|
endif
|
||||||
|
ifeq ($(findstring MINGW64,$(UNAME_S)),MINGW64)
|
||||||
|
ONLY_64BIT=1
|
||||||
|
endif
|
||||||
|
ifeq ($(ONLY_64BIT),0)
|
||||||
|
TARGET += jmp address
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(BIT),64)
|
||||||
|
TARGET += jmp64 address64 apx
|
||||||
|
TARGET += sf_test
|
||||||
|
endif
|
||||||
|
|
||||||
|
all: $(TARGET)
|
||||||
|
|
||||||
|
CFLAGS_WARN=$(shell cat CFLAGS_WARN.cfg)
|
||||||
|
|
||||||
|
CFLAGS=-O2 -Wall -I.. -I. $(CFLAGS_WARN) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) #-std=c++0x
|
||||||
|
make_nm:
|
||||||
|
$(CXX) $(CFLAGS) make_nm.cpp -o $@
|
||||||
|
normalize_prefix: normalize_prefix.cpp $(XBYAK_INC)
|
||||||
|
$(CXX) $(CFLAGS) normalize_prefix.cpp -o $@
|
||||||
|
test_mmx: test_mmx.cpp $(XBYAK_INC)
|
||||||
|
$(CXX) $(CFLAGS) test_mmx.cpp -o $@ -lpthread
|
||||||
|
jmp: jmp.cpp $(XBYAK_INC)
|
||||||
|
$(CXX_32) $(CFLAGS) $< -o $@
|
||||||
|
jmp64: jmp.cpp $(XBYAK_INC)
|
||||||
|
$(CXX_64) $(CFLAGS) $< -o $@
|
||||||
|
address: address.cpp $(XBYAK_INC)
|
||||||
|
$(CXX_32) $(CFLAGS) $< -o $@
|
||||||
|
address64: address.cpp $(XBYAK_INC)
|
||||||
|
$(CXX_64) $(CFLAGS) $< -o $@
|
||||||
|
bad_address: bad_address.cpp $(XBYAK_INC)
|
||||||
|
$(CXX) $(CFLAGS) $< -o $@
|
||||||
|
misc: misc.cpp $(XBYAK_INC)
|
||||||
|
$(CXX) $(CFLAGS) $< -o $@
|
||||||
|
misc32: misc.cpp $(XBYAK_INC)
|
||||||
|
$(CXX) $(CFLAGS) $< -o $@ -DXBYAK32
|
||||||
|
cvt_test: cvt_test.cpp $(XBYAK_INC)
|
||||||
|
$(CXX) $(CFLAGS) $< -o $@
|
||||||
|
cvt_test32: cvt_test.cpp $(XBYAK_INC)
|
||||||
|
$(CXX) $(CFLAGS) $< -o $@ -DXBYAK32
|
||||||
|
noexception: noexception.cpp $(XBYAK_INC)
|
||||||
|
$(CXX) $(CFLAGS) $< -o $@ -fno-exceptions
|
||||||
|
apx: apx.cpp $(XBYAK_INC)
|
||||||
|
$(CXX) $(CFLAGS) $< -o $@
|
||||||
|
avx10_test: avx10_test.cpp $(XBYAK_INC)
|
||||||
|
$(CXX) $(CFLAGS) $< -o $@ -DXBYAK64
|
||||||
|
sf_test: sf_test.cpp $(XBYAK_INC)
|
||||||
|
$(CXX) $(CFLAGS) $< -o $@ -DXBYAK64
|
||||||
|
|
||||||
|
TEST_FILES=old.txt bf16.txt comp.txt misc.txt convert.txt minmax.txt saturation.txt apx.txt amx.txt
|
||||||
|
xed_test:
|
||||||
|
@set -e; \
|
||||||
|
for target in $(addprefix dataset/, $(TEST_FILES)); do \
|
||||||
|
./test_by_xed.sh $$target || exit 1; \
|
||||||
|
done
|
||||||
|
|
||||||
|
test_nm: normalize_prefix $(TARGET)
|
||||||
|
$(MAKE) -C ../gen
|
||||||
|
ifneq ($(ONLY_64BIT),1)
|
||||||
|
CXX=$(CXX) ./test_nm.sh
|
||||||
|
CXX=$(CXX) ./test_nm.sh noexcept
|
||||||
|
CXX=$(CXX) ./test_nm.sh Y
|
||||||
|
CXX=$(CXX) ./test_nm.sh avx512
|
||||||
|
CXX=$(CXX) ./test_address.sh
|
||||||
|
./jmp
|
||||||
|
./cvt_test32
|
||||||
|
endif
|
||||||
|
./bad_address
|
||||||
|
./misc
|
||||||
|
./misc32
|
||||||
|
./cvt_test
|
||||||
|
ifeq ($(BIT),64)
|
||||||
|
CXX=$(CXX) ./test_address.sh 64
|
||||||
|
ifneq ($(X32),1)
|
||||||
|
CXX=$(CXX) ./test_nm.sh 64
|
||||||
|
CXX=$(CXX) ./test_nm.sh Y64
|
||||||
|
endif
|
||||||
|
./jmp64
|
||||||
|
./apx
|
||||||
|
./avx10_test
|
||||||
|
endif
|
||||||
|
|
||||||
|
test_avx: normalize_prefix
|
||||||
|
ifneq ($(ONLY_64BIT),0)
|
||||||
|
CXX=$(CXX) ./test_avx.sh
|
||||||
|
CXX=$(CXX) ./test_avx.sh Y
|
||||||
|
endif
|
||||||
|
ifeq ($(BIT),64)
|
||||||
|
CXX=$(CXX) ./test_avx.sh 64
|
||||||
|
ifneq ($(X32),1)
|
||||||
|
CXX=$(CXX) ./test_avx.sh Y64
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
test_avx512: normalize_prefix
|
||||||
|
ifneq ($(ONLY_64BIT),0)
|
||||||
|
CXX=$(CXX) ./test_avx512.sh
|
||||||
|
endif
|
||||||
|
ifeq ($(BIT),64)
|
||||||
|
CXX=$(CXX) ./test_avx512.sh 64
|
||||||
|
endif
|
||||||
|
|
||||||
|
test_avx10: avx10_test
|
||||||
|
./avx10_test
|
||||||
|
|
||||||
|
detect_x32: detect_x32.c
|
||||||
|
$(CC) $< -o $@
|
||||||
|
|
||||||
|
test: detect_x32
|
||||||
|
$(MAKE) test_nm
|
||||||
|
$(MAKE) test_avx
|
||||||
|
$(MAKE) test_avx512
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) a.asm *.lst *.obj *.o $(TARGET) lib_run nm.cpp nm_frame make_512 avx10_test detect_x32
|
||||||
|
|
||||||
|
lib_run: lib_test.cpp lib_run.cpp lib.h
|
||||||
|
$(CXX) $(CFLAGS) lib_run.cpp lib_test.cpp -o lib_run
|
||||||
|
make_nm: make_nm.cpp $(XBYAK_INC)
|
||||||
|
|
||||||
|
.PHONY: test
|
||||||
14
external/xbyak/test/Makefile.win
vendored
Normal file
14
external/xbyak/test/Makefile.win
vendored
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
OPT=/EHsc -I../xbyak /W4 -D_CRT_SECURE_NO_WARNINGS -I ../
|
||||||
|
../xbyak/xbyak_mnemonic.h: ../gen/gen_code.exe ../gen/gen_avx512.exe
|
||||||
|
../gen/gen_code.exe > $@
|
||||||
|
../gen/gen_avx512.exe >> $@
|
||||||
|
|
||||||
|
../gen/gen_code.exe: ../gen/gen_code.cpp #../xbyak/xbyak.h
|
||||||
|
cl ../gen/gen_code.cpp $(OPT) /Fe:../gen/gen_code.exe
|
||||||
|
|
||||||
|
../gen/gen_avx512.exe: ../gen/gen_avx512.cpp #../xbyak/xbyak.h
|
||||||
|
cl ../gen/gen_avx512.cpp $(OPT) /Fe:../gen/gen_avx512.exe
|
||||||
|
|
||||||
|
SUB_HEADER=../xbyak/xbyak_mnemonic.h
|
||||||
|
|
||||||
|
all: $(SUB_HEADER)
|
||||||
9
external/xbyak/test/a.bat
vendored
Normal file
9
external/xbyak/test/a.bat
vendored
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
@echo off
|
||||||
|
echo 32bit
|
||||||
|
rm -rf a.lst b.lst
|
||||||
|
echo nasm
|
||||||
|
nasm -l a.lst -f win32 -DWIN32 test.asm
|
||||||
|
cat a.lst
|
||||||
|
echo yasm
|
||||||
|
yasm -l b.lst -f win32 -DWIN32 test.asm
|
||||||
|
cat b.lst
|
||||||
155
external/xbyak/test/address.cpp
vendored
Normal file
155
external/xbyak/test/address.cpp
vendored
Normal file
@@ -0,0 +1,155 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#define NUM_OF_ARRAY(x) (sizeof(x) / sizeof(x[0]))
|
||||||
|
|
||||||
|
void genVsibSub(bool isJIT, const char *name, const char *tbl[], size_t tblSize)
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < tblSize; i++) {
|
||||||
|
if (isJIT) {
|
||||||
|
printf("%s (ymm7, ptr[", name);
|
||||||
|
} else {
|
||||||
|
printf("%s ymm7, [", name);
|
||||||
|
}
|
||||||
|
printf("%s", tbl[i]);
|
||||||
|
if (isJIT) {
|
||||||
|
printf("], ymm4); dump();\n");
|
||||||
|
} else {
|
||||||
|
printf("], ymm4\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void genVsib(bool isJIT)
|
||||||
|
{
|
||||||
|
if (isJIT) puts("void genVsib() {");
|
||||||
|
const char *vm32xTbl[] = {
|
||||||
|
"xmm0",
|
||||||
|
"xmm0 * 1",
|
||||||
|
"xmm0 + 4",
|
||||||
|
"xmm0 + eax",
|
||||||
|
"xmm0 * 4 + ecx",
|
||||||
|
"xmm3 * 8 + edi + 123",
|
||||||
|
"xmm2 * 2 + 5",
|
||||||
|
"eax + xmm0",
|
||||||
|
"esp + xmm2",
|
||||||
|
};
|
||||||
|
const char *vm32yTbl[] = {
|
||||||
|
"ymm0",
|
||||||
|
"ymm0 * 1",
|
||||||
|
"ymm0 + 4",
|
||||||
|
"ymm0 + eax",
|
||||||
|
"ymm0 * 4 + ecx",
|
||||||
|
"ymm3 * 8 + edi + 123",
|
||||||
|
"ymm2 * 2 + 5",
|
||||||
|
"eax + ymm0",
|
||||||
|
"esp + ymm2",
|
||||||
|
};
|
||||||
|
genVsibSub(isJIT, "vgatherdpd", vm32xTbl, NUM_OF_ARRAY(vm32xTbl));
|
||||||
|
genVsibSub(isJIT, "vgatherqpd", vm32yTbl, NUM_OF_ARRAY(vm32yTbl));
|
||||||
|
#ifdef XBYAK64
|
||||||
|
const char *vm32x64Tbl[] = {
|
||||||
|
"xmm0 + r11",
|
||||||
|
"r13 + xmm15",
|
||||||
|
"123 + rsi + xmm2 * 4",
|
||||||
|
};
|
||||||
|
genVsibSub(isJIT, "vgatherdpd", vm32x64Tbl, NUM_OF_ARRAY(vm32x64Tbl));
|
||||||
|
#endif
|
||||||
|
if (isJIT) puts("}");
|
||||||
|
}
|
||||||
|
|
||||||
|
void genAddress(bool isJIT, const char regTbl[][5], size_t regTblNum)
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
int funcNum = 1;
|
||||||
|
if (isJIT) {
|
||||||
|
puts("void gen0(){");
|
||||||
|
}
|
||||||
|
for (size_t i = 0; i < regTblNum + 1; i++) {
|
||||||
|
const char *base = regTbl[i];
|
||||||
|
for (size_t j = 0; j < regTblNum + 1; j++) {
|
||||||
|
if (j == 4) continue; /* esp is not index register */
|
||||||
|
const char *index = regTbl[j];
|
||||||
|
static const int scaleTbl[] = { 0, 1, 2, 4, 8 };
|
||||||
|
for (size_t k = 0; k < NUM_OF_ARRAY(scaleTbl); k++) {
|
||||||
|
int scale = scaleTbl[k];
|
||||||
|
static const int dispTbl[] = { 0, 1, 1000, -1, -1000 };
|
||||||
|
for (size_t m = 0; m < NUM_OF_ARRAY(dispTbl); m++) {
|
||||||
|
int disp = dispTbl[m];
|
||||||
|
bool isFirst = true;
|
||||||
|
if (isJIT) {
|
||||||
|
printf("mov (ecx, ptr[");
|
||||||
|
} else {
|
||||||
|
printf("mov ecx, [");
|
||||||
|
}
|
||||||
|
if (i < regTblNum) {
|
||||||
|
printf("%s", base);
|
||||||
|
isFirst = false;
|
||||||
|
}
|
||||||
|
if (j < regTblNum) {
|
||||||
|
if (!isFirst) putchar('+');
|
||||||
|
printf("%s", index);
|
||||||
|
if (scale) printf("*%d", scale);
|
||||||
|
isFirst = false;
|
||||||
|
}
|
||||||
|
if (isFirst) {
|
||||||
|
if (isJIT) printf("(void*)");
|
||||||
|
printf("%d", disp);
|
||||||
|
} else {
|
||||||
|
if (disp >= 0) {
|
||||||
|
putchar('+');
|
||||||
|
}
|
||||||
|
printf("%d", disp);
|
||||||
|
isFirst = false;
|
||||||
|
}
|
||||||
|
if (isJIT) {
|
||||||
|
printf("]); dump();\n");
|
||||||
|
} else {
|
||||||
|
printf("]\n");
|
||||||
|
}
|
||||||
|
if (isJIT) {
|
||||||
|
count++;
|
||||||
|
if ((count % 100) == 0) {
|
||||||
|
printf("}\n void gen%d(){\n", funcNum++);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isJIT) puts("}");
|
||||||
|
genVsib(isJIT);
|
||||||
|
if (isJIT) {
|
||||||
|
printf("void gen(){\n");
|
||||||
|
for (int i = 0; i < funcNum; i++) {
|
||||||
|
printf(" gen%d();\n", i);
|
||||||
|
}
|
||||||
|
puts("genVsib();");
|
||||||
|
printf("}\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
argc--, argv++;
|
||||||
|
bool phase = argc > 0 && strcmp(*argv, "1") == 0;
|
||||||
|
bool isJIT = (argc > 1);
|
||||||
|
fprintf(stderr, "phase:%c %s\n", phase ? '1' : '2', isJIT ? "jit" : "asm");
|
||||||
|
if (phase) {
|
||||||
|
fprintf(stderr, "32bit reg\n");
|
||||||
|
static const char reg32Tbl[][5] = {
|
||||||
|
"eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi",
|
||||||
|
#ifdef XBYAK64
|
||||||
|
"r9d", "r10d", "r11d", "r12d", "r13d", "r14d", "r15d",
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
genAddress(isJIT, reg32Tbl, NUM_OF_ARRAY(reg32Tbl));
|
||||||
|
} else {
|
||||||
|
#ifdef XBYAK64
|
||||||
|
fprintf(stderr, "64bit reg\n");
|
||||||
|
static const char reg64Tbl[][5] = {
|
||||||
|
"rax", "rcx", "rdx", "rbx", "rsp", "rbp", "rsi", "rdi", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
|
||||||
|
};
|
||||||
|
genAddress(isJIT, reg64Tbl, NUM_OF_ARRAY(reg64Tbl));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
1964
external/xbyak/test/apx.cpp
vendored
Normal file
1964
external/xbyak/test/apx.cpp
vendored
Normal file
File diff suppressed because it is too large
Load Diff
53
external/xbyak/test/avx10_test.cpp
vendored
Normal file
53
external/xbyak/test/avx10_test.cpp
vendored
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <string>
|
||||||
|
#include <xbyak/xbyak.h>
|
||||||
|
#include <xbyak/xbyak_util.h>
|
||||||
|
#include <cybozu/inttype.hpp>
|
||||||
|
#include <cybozu/test.hpp>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
using namespace Xbyak;
|
||||||
|
|
||||||
|
// ymm with sae is not supported from avx10.2 rev 4.0.
|
||||||
|
CYBOZU_TEST_AUTO(ymm_with_sae)
|
||||||
|
{
|
||||||
|
struct Code : Xbyak::CodeGenerator {
|
||||||
|
Code()
|
||||||
|
{
|
||||||
|
CYBOZU_TEST_EXCEPTION(vaddpd(ymm1, ymm2, ymm3 |T_rn_sae), std::exception);
|
||||||
|
CYBOZU_TEST_EXCEPTION(vcvtph2ibs(xmm1, xmm31 | T_rd_sae), std::exception);
|
||||||
|
CYBOZU_TEST_EXCEPTION(vcvtph2ibs(ymm1, ymm31 | T_rd_sae), std::exception);
|
||||||
|
CYBOZU_TEST_EXCEPTION(vcvt2ps2phx(ymm1, ymm2, ymm3 | T_rd_sae), std::exception);
|
||||||
|
CYBOZU_TEST_EXCEPTION(vminmaxpd(ymm1, ymm2, ymm3 | T_sae, 1), std::exception);
|
||||||
|
CYBOZU_TEST_EXCEPTION(vminmaxph(ymm1, ymm2, ymm3 | T_sae, 2), std::exception);
|
||||||
|
CYBOZU_TEST_EXCEPTION(vminmaxps(ymm1, ymm2, ymm3 | T_sae, 3), std::exception);
|
||||||
|
CYBOZU_TEST_EXCEPTION(vcvtps2ibs(ym1, ym2|T_rd_sae), std::exception);
|
||||||
|
CYBOZU_TEST_EXCEPTION(vcvtps2ibs(xm1, xm2|T_rd_sae), std::exception);
|
||||||
|
}
|
||||||
|
} c;
|
||||||
|
}
|
||||||
|
|
||||||
|
CYBOZU_TEST_AUTO(vmpsadbw)
|
||||||
|
{
|
||||||
|
struct Code : Xbyak::CodeGenerator {
|
||||||
|
Code()
|
||||||
|
{
|
||||||
|
setDefaultEncodingAVX10();
|
||||||
|
vmpsadbw(xm1, xm3, xm15, 3); // vex(avx)
|
||||||
|
vmpsadbw(ym1, ym3, ptr[rax+128], 3); // vex(avx2)
|
||||||
|
setDefaultEncodingAVX10(AVX10v2Encoding);
|
||||||
|
vmpsadbw(ym1, ym3, ym15, 3); // evex(avx10.2)
|
||||||
|
vmpsadbw(ym1, ym3, ptr[rax+128], 3); // evex(avx10.2)
|
||||||
|
}
|
||||||
|
} c;
|
||||||
|
const uint8_t tbl[] = {
|
||||||
|
0xc4, 0xc3, 0x61, 0x42, 0xcf, 0x03,
|
||||||
|
0xc4, 0xe3, 0x65, 0x42, 0x88, 0x80, 0x00, 0x00, 0x00, 0x03,
|
||||||
|
0x62, 0xd3, 0x66, 0x28, 0x42, 0xcf, 0x03,
|
||||||
|
0x62, 0xf3, 0x66, 0x28, 0x42, 0x48, 0x04, 0x03,
|
||||||
|
};
|
||||||
|
const size_t n = sizeof(tbl) / sizeof(tbl[0]);
|
||||||
|
CYBOZU_TEST_EQUAL(c.getSize(), n);
|
||||||
|
CYBOZU_TEST_EQUAL_ARRAY(c.getCode(), tbl, n);
|
||||||
|
}
|
||||||
28
external/xbyak/test/bad_address.cpp
vendored
Normal file
28
external/xbyak/test/bad_address.cpp
vendored
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
#include <xbyak/xbyak.h>
|
||||||
|
#include <cybozu/test.hpp>
|
||||||
|
|
||||||
|
struct Code : Xbyak::CodeGenerator {
|
||||||
|
Code()
|
||||||
|
{
|
||||||
|
CYBOZU_TEST_EXCEPTION(mov(eax, ptr [esp + esp]), std::exception);
|
||||||
|
CYBOZU_TEST_EXCEPTION(mov(eax, ptr [ax]), std::exception); // not support
|
||||||
|
CYBOZU_TEST_EXCEPTION(mov(eax, ptr [esp * 4]), std::exception);
|
||||||
|
CYBOZU_TEST_EXCEPTION(mov(eax, ptr [eax * 16]), std::exception);
|
||||||
|
CYBOZU_TEST_EXCEPTION(mov(eax, ptr [eax + eax + eax]), std::exception);
|
||||||
|
CYBOZU_TEST_EXCEPTION(mov(eax, ptr [eax * 2 + ecx * 4]), std::exception);
|
||||||
|
CYBOZU_TEST_EXCEPTION(mov(eax, ptr [eax * 2 + ecx * 4]), std::exception);
|
||||||
|
CYBOZU_TEST_EXCEPTION(mov(eax, ptr [xmm0]), std::exception);
|
||||||
|
CYBOZU_TEST_EXCEPTION(fld(dword [xmm0]), std::exception);
|
||||||
|
CYBOZU_TEST_EXCEPTION(vgatherdpd(xmm0, ptr [eax * 2], ymm3), std::exception);
|
||||||
|
CYBOZU_TEST_EXCEPTION(vgatherdpd(xmm0, ptr [xmm0 + xmm1], ymm3), std::exception);
|
||||||
|
#ifdef XBYAK64
|
||||||
|
CYBOZU_TEST_EXCEPTION(mov(eax, ptr [rax + eax]), std::exception);
|
||||||
|
CYBOZU_TEST_EXCEPTION(mov(eax, ptr [xmm0 + ymm0]), std::exception);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
CYBOZU_TEST_AUTO(exception)
|
||||||
|
{
|
||||||
|
Code c;
|
||||||
|
}
|
||||||
191
external/xbyak/test/cvt_test.cpp
vendored
Normal file
191
external/xbyak/test/cvt_test.cpp
vendored
Normal file
@@ -0,0 +1,191 @@
|
|||||||
|
#define XBYAK_NO_OP_NAMES
|
||||||
|
#include <xbyak/xbyak.h>
|
||||||
|
#include <cybozu/inttype.hpp>
|
||||||
|
#include <cybozu/test.hpp>
|
||||||
|
|
||||||
|
using namespace Xbyak;
|
||||||
|
using namespace Xbyak::util;
|
||||||
|
|
||||||
|
#ifdef XBYAK64
|
||||||
|
const struct Ptn {
|
||||||
|
const Reg8 *reg8;
|
||||||
|
Reg16 reg16;
|
||||||
|
Reg32 reg32;
|
||||||
|
Reg64 reg64;
|
||||||
|
Xmm x;
|
||||||
|
Ymm y;
|
||||||
|
Zmm z;
|
||||||
|
} tbl[] = {
|
||||||
|
{ &al, ax, eax, rax, xmm0, ymm0, zmm0 },
|
||||||
|
{ &bl, bx, ebx, rbx, xmm3, ymm3, zmm3 },
|
||||||
|
{ &cl, cx, ecx, rcx, xmm1, ymm1, zmm1 },
|
||||||
|
{ &dl, dx, edx, rdx, xmm2, ymm2, zmm2 },
|
||||||
|
{ &sil, si, esi, rsi, xmm6, ymm6, zmm6 },
|
||||||
|
{ &dil, di, edi, rdi, xmm7, ymm7, zmm7 },
|
||||||
|
{ &bpl, bp, ebp, rbp, xmm5, ymm5, zmm5 },
|
||||||
|
{ &spl, sp, esp, rsp, xmm4, ymm4, zmm4 },
|
||||||
|
{ &r8b, r8w, r8d, r8, xmm8, ymm8, zmm8 },
|
||||||
|
{ &r9b, r9w, r9d, r9, xmm9, ymm9, zmm9 },
|
||||||
|
{ &r10b, r10w, r10d, r10, xmm10, ymm10, zmm10 },
|
||||||
|
{ &r11b, r11w, r11d, r11, xmm11, ymm11, zmm11 },
|
||||||
|
{ &r12b, r12w, r12d, r12, xmm12, ymm12, zmm12 },
|
||||||
|
{ &r13b, r13w, r13d, r13, xmm13, ymm13, zmm13 },
|
||||||
|
{ &r14b, r14w, r14d, r14, xmm14, ymm14, zmm14 },
|
||||||
|
{ &r15b, r15w, r15d, r15, xmm15, ymm15, zmm15 },
|
||||||
|
{ &r31b, r31w, r31d, r31, xmm31, ymm31, zmm31 },
|
||||||
|
};
|
||||||
|
#else
|
||||||
|
const struct Ptn {
|
||||||
|
const Reg8 *reg8;
|
||||||
|
Reg16 reg16;
|
||||||
|
Reg32 reg32;
|
||||||
|
Xmm x;
|
||||||
|
Ymm y;
|
||||||
|
Zmm z;
|
||||||
|
} tbl[] = {
|
||||||
|
{ &al, ax, eax, xmm0, ymm0, zmm0 },
|
||||||
|
{ &bl, bx, ebx, xmm3, ymm3, zmm3 },
|
||||||
|
{ &cl, cx, ecx, xmm1, ymm1, zmm1 },
|
||||||
|
{ &dl, dx, edx, xmm2, ymm2, zmm2 },
|
||||||
|
{ 0, si, esi, xmm6, ymm6, zmm6 },
|
||||||
|
{ 0, di, edi, xmm7, ymm7, zmm7 },
|
||||||
|
{ 0, bp, ebp, xmm5, ymm5, zmm5 },
|
||||||
|
{ 0, sp, esp, xmm4, ymm4, zmm4 },
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
CYBOZU_TEST_AUTO(cvt)
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < sizeof(tbl) / sizeof(tbl[0]); i++) {
|
||||||
|
if (tbl[i].reg8) {
|
||||||
|
CYBOZU_TEST_ASSERT(tbl[i].reg8->cvt8() == *tbl[i].reg8);
|
||||||
|
CYBOZU_TEST_ASSERT(tbl[i].reg8->cvt16() == tbl[i].reg16);
|
||||||
|
CYBOZU_TEST_ASSERT(tbl[i].reg8->cvt32() == tbl[i].reg32);
|
||||||
|
CYBOZU_TEST_ASSERT(tbl[i].reg8->cvt128() == tbl[i].x);
|
||||||
|
CYBOZU_TEST_ASSERT(tbl[i].reg8->cvt256() == tbl[i].y);
|
||||||
|
CYBOZU_TEST_ASSERT(tbl[i].reg8->cvt512() == tbl[i].z);
|
||||||
|
CYBOZU_TEST_ASSERT(tbl[i].reg16.cvt8() == *tbl[i].reg8);
|
||||||
|
CYBOZU_TEST_ASSERT(tbl[i].reg32.cvt8() == *tbl[i].reg8);
|
||||||
|
CYBOZU_TEST_ASSERT(tbl[i].x.cvt8() == *tbl[i].reg8);
|
||||||
|
CYBOZU_TEST_ASSERT(tbl[i].y.cvt8() == *tbl[i].reg8);
|
||||||
|
CYBOZU_TEST_ASSERT(tbl[i].z.cvt8() == *tbl[i].reg8);
|
||||||
|
}
|
||||||
|
CYBOZU_TEST_ASSERT(tbl[i].reg16.cvt16() == tbl[i].reg16);
|
||||||
|
CYBOZU_TEST_ASSERT(tbl[i].reg16.cvt32() == tbl[i].reg32);
|
||||||
|
CYBOZU_TEST_ASSERT(tbl[i].reg16.cvt128() == tbl[i].x);
|
||||||
|
CYBOZU_TEST_ASSERT(tbl[i].reg16.cvt256() == tbl[i].y);
|
||||||
|
CYBOZU_TEST_ASSERT(tbl[i].reg16.cvt512() == tbl[i].z);
|
||||||
|
CYBOZU_TEST_ASSERT(tbl[i].reg32.cvt16() == tbl[i].reg16);
|
||||||
|
CYBOZU_TEST_ASSERT(tbl[i].reg32.cvt32() == tbl[i].reg32);
|
||||||
|
CYBOZU_TEST_ASSERT(tbl[i].reg32.cvt128() == tbl[i].x);
|
||||||
|
CYBOZU_TEST_ASSERT(tbl[i].reg32.cvt256() == tbl[i].y);
|
||||||
|
CYBOZU_TEST_ASSERT(tbl[i].reg32.cvt512() == tbl[i].z);
|
||||||
|
CYBOZU_TEST_ASSERT(tbl[i].x.cvt16() == tbl[i].reg16);
|
||||||
|
CYBOZU_TEST_ASSERT(tbl[i].x.cvt32() == tbl[i].reg32);
|
||||||
|
CYBOZU_TEST_ASSERT(tbl[i].x.cvt128() == tbl[i].x);
|
||||||
|
CYBOZU_TEST_ASSERT(tbl[i].x.cvt256() == tbl[i].y);
|
||||||
|
CYBOZU_TEST_ASSERT(tbl[i].x.cvt512() == tbl[i].z);
|
||||||
|
CYBOZU_TEST_ASSERT(tbl[i].y.cvt16() == tbl[i].reg16);
|
||||||
|
CYBOZU_TEST_ASSERT(tbl[i].y.cvt32() == tbl[i].reg32);
|
||||||
|
CYBOZU_TEST_ASSERT(tbl[i].y.cvt128() == tbl[i].x);
|
||||||
|
CYBOZU_TEST_ASSERT(tbl[i].y.cvt256() == tbl[i].y);
|
||||||
|
CYBOZU_TEST_ASSERT(tbl[i].y.cvt512() == tbl[i].z);
|
||||||
|
CYBOZU_TEST_ASSERT(tbl[i].z.cvt16() == tbl[i].reg16);
|
||||||
|
CYBOZU_TEST_ASSERT(tbl[i].z.cvt32() == tbl[i].reg32);
|
||||||
|
CYBOZU_TEST_ASSERT(tbl[i].z.cvt128() == tbl[i].x);
|
||||||
|
CYBOZU_TEST_ASSERT(tbl[i].z.cvt256() == tbl[i].y);
|
||||||
|
CYBOZU_TEST_ASSERT(tbl[i].y.cvt512() == tbl[i].z);
|
||||||
|
#ifdef XBYAK64
|
||||||
|
if (tbl[i].reg8) {
|
||||||
|
CYBOZU_TEST_ASSERT(tbl[i].reg64.cvt8() == *tbl[i].reg8);
|
||||||
|
CYBOZU_TEST_ASSERT(tbl[i].reg8->cvt64() == tbl[i].reg64);
|
||||||
|
}
|
||||||
|
CYBOZU_TEST_ASSERT(tbl[i].reg64.cvt16() == tbl[i].reg16);
|
||||||
|
CYBOZU_TEST_ASSERT(tbl[i].reg64.cvt32() == tbl[i].reg32);
|
||||||
|
CYBOZU_TEST_ASSERT(tbl[i].reg64.cvt64() == tbl[i].reg64);
|
||||||
|
CYBOZU_TEST_ASSERT(tbl[i].reg64.cvt128() == tbl[i].x);
|
||||||
|
CYBOZU_TEST_ASSERT(tbl[i].reg64.cvt256() == tbl[i].y);
|
||||||
|
CYBOZU_TEST_ASSERT(tbl[i].reg64.cvt512() == tbl[i].z);
|
||||||
|
CYBOZU_TEST_ASSERT(tbl[i].reg16.cvt64() == tbl[i].reg64);
|
||||||
|
CYBOZU_TEST_ASSERT(tbl[i].reg32.cvt64() == tbl[i].reg64);
|
||||||
|
CYBOZU_TEST_ASSERT(tbl[i].x.cvt64() == tbl[i].reg64);
|
||||||
|
CYBOZU_TEST_ASSERT(tbl[i].y.cvt64() == tbl[i].reg64);
|
||||||
|
CYBOZU_TEST_ASSERT(tbl[i].z.cvt64() == tbl[i].reg64);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
{
|
||||||
|
const Reg8 errTbl[] = {
|
||||||
|
ah, bh, ch, dh
|
||||||
|
};
|
||||||
|
for (size_t i = 0; i < sizeof(errTbl) / sizeof(errTbl[0]); i++) {
|
||||||
|
CYBOZU_TEST_EXCEPTION(errTbl[i].cvt16(), std::exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#ifdef XBYAK32
|
||||||
|
{
|
||||||
|
const Reg16 errTbl[] = {
|
||||||
|
si, di, bp, sp
|
||||||
|
};
|
||||||
|
for (size_t i = 0; i < sizeof(errTbl) / sizeof(errTbl[0]); i++) {
|
||||||
|
CYBOZU_TEST_EXCEPTION(errTbl[i].cvt8(), std::exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
CYBOZU_TEST_AUTO(changeBit)
|
||||||
|
{
|
||||||
|
using namespace Xbyak::util;
|
||||||
|
#ifdef XBYAK64
|
||||||
|
const size_t N = 7;
|
||||||
|
const Reg* tbl[][N] = {
|
||||||
|
{ &al, &ax, &eax, &rax, &xmm0, &ymm0, &zmm0 },
|
||||||
|
{ &cl, &cx, &ecx, &rcx, &xmm1, &ymm1, &zmm1 },
|
||||||
|
{ &dl, &dx, &edx, &rdx, &xmm2, &ymm2, &zmm2 },
|
||||||
|
{ &bl, &bx, &ebx, &rbx, &xmm3, &ymm3, &zmm3 },
|
||||||
|
{ &spl, &sp, &esp, &rsp, &xmm4, &ymm4, &zmm4 },
|
||||||
|
{ &bpl, &bp, &ebp, &rbp, &xmm5, &ymm5, &zmm5 },
|
||||||
|
{ &sil, &si, &esi, &rsi, &xmm6, &ymm6, &zmm6 },
|
||||||
|
{ &dil, &di, &edi, &rdi, &xmm7, &ymm7, &zmm7 },
|
||||||
|
{ &r8b, &r8w, &r8d, &r8, &xmm8, &ymm8, &zmm8 },
|
||||||
|
{ &r15b, &r15w, &r15d, &r15, &xmm15, &ymm15, &zmm15 },
|
||||||
|
{ &r16b, &r16w, &r16d, &r16, &xmm16, &ymm16, &zmm16 },
|
||||||
|
{ &r31b, &r31w, &r31d, &r31, &xmm31, &ymm31, &zmm31 },
|
||||||
|
};
|
||||||
|
const int bitTbl[N] = { 8, 16, 32, 64, 128, 256, 512 };
|
||||||
|
#else
|
||||||
|
const size_t N = 6;
|
||||||
|
const Reg* tbl[][N] = {
|
||||||
|
{ &al, &ax, &eax, &xmm0, &ymm0, &zmm0 },
|
||||||
|
{ &cl, &cx, &ecx, &xmm1, &ymm1, &zmm1 },
|
||||||
|
{ &dl, &dx, &edx, &xmm2, &ymm2, &zmm2 },
|
||||||
|
{ &bl, &bx, &ebx, &xmm3, &ymm3, &zmm3 },
|
||||||
|
{ 0, &sp, &esp, &xmm4, &ymm4, &zmm4 },
|
||||||
|
{ 0, &bp, &ebp, &xmm5, &ymm5, &zmm5 },
|
||||||
|
{ 0, &si, &esi, &xmm6, &ymm6, &zmm6 },
|
||||||
|
{ 0, &di, &edi, &xmm7, &ymm7, &zmm7 },
|
||||||
|
};
|
||||||
|
const int bitTbl[N] = { 8, 16, 32, 128, 256, 512 };
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (size_t i = 0; i < CYBOZU_NUM_OF_ARRAY(tbl); i++) {
|
||||||
|
for (size_t j = 0; j < N; j++) {
|
||||||
|
const Reg *r1 = tbl[i][j];
|
||||||
|
if (r1 == 0) continue;
|
||||||
|
for (size_t k = 0; k < N; k++) {
|
||||||
|
if (tbl[i][k]) {
|
||||||
|
CYBOZU_TEST_ASSERT(*tbl[i][k] == r1->changeBit(bitTbl[k]));
|
||||||
|
// printf("%s->changeBit(%d)=%s %s\n", r1->toString(), bitTbl[k], r1->changeBit(bitTbl[k]).toString(), tbl[i][k]->toString());
|
||||||
|
} else {
|
||||||
|
CYBOZU_TEST_EXCEPTION(r1->changeBit(bitTbl[k]), std::exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#ifdef XBYAK64
|
||||||
|
const Reg8 *special8bitTbl[] = { &ah, &bh, &ch, &dh };
|
||||||
|
for (size_t i = 0; i < CYBOZU_NUM_OF_ARRAY(special8bitTbl); i++) {
|
||||||
|
CYBOZU_TEST_EXCEPTION(special8bitTbl[i]->changeBit(16), std::exception);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
163
external/xbyak/test/cybozu/inttype.hpp
vendored
Normal file
163
external/xbyak/test/cybozu/inttype.hpp
vendored
Normal file
@@ -0,0 +1,163 @@
|
|||||||
|
#pragma once
|
||||||
|
/**
|
||||||
|
@file
|
||||||
|
@brief int type definition and macros
|
||||||
|
@author MITSUNARI Shigeo(@herumi)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(_MSC_VER) && (MSC_VER <= 1500) && !defined(CYBOZU_DEFINED_INTXX)
|
||||||
|
#define CYBOZU_DEFINED_INTXX
|
||||||
|
typedef __int64 int64_t;
|
||||||
|
typedef unsigned __int64 uint64_t;
|
||||||
|
typedef unsigned int uint32_t;
|
||||||
|
typedef int int32_t;
|
||||||
|
typedef unsigned short uint16_t;
|
||||||
|
typedef short int16_t;
|
||||||
|
typedef unsigned char uint8_t;
|
||||||
|
typedef signed char int8_t;
|
||||||
|
#else
|
||||||
|
#include <stdint.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#ifndef CYBOZU_DEFINED_SSIZE_T
|
||||||
|
#define CYBOZU_DEFINED_SSIZE_T
|
||||||
|
#ifdef _WIN64
|
||||||
|
typedef int64_t ssize_t;
|
||||||
|
#else
|
||||||
|
typedef int32_t ssize_t;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#include <unistd.h> // for ssize_t
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CYBOZU_ALIGN
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#define CYBOZU_ALIGN(x) __declspec(align(x))
|
||||||
|
#else
|
||||||
|
#define CYBOZU_ALIGN(x) __attribute__((aligned(x)))
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#ifndef CYBOZU_FORCE_INLINE
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#define CYBOZU_FORCE_INLINE __forceinline
|
||||||
|
#else
|
||||||
|
#define CYBOZU_FORCE_INLINE __attribute__((always_inline))
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#ifndef CYBOZU_UNUSED
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#define CYBOZU_UNUSED __attribute__((unused))
|
||||||
|
#else
|
||||||
|
#define CYBOZU_UNUSED
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#ifndef CYBOZU_ALLOCA
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#include <malloc.h>
|
||||||
|
#define CYBOZU_ALLOCA(x) _malloca(x)
|
||||||
|
#else
|
||||||
|
#define CYBOZU_ALLOCA(x) __builtin_alloca(x)
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#ifndef CYBOZU_NUM_OF_ARRAY
|
||||||
|
#define CYBOZU_NUM_OF_ARRAY(x) (sizeof(x) / sizeof(*x))
|
||||||
|
#endif
|
||||||
|
#ifndef CYBOZU_SNPRINTF
|
||||||
|
#if defined(_MSC_VER) && (_MSC_VER < 1900)
|
||||||
|
#define CYBOZU_SNPRINTF(x, len, ...) (void)_snprintf_s(x, len, len - 1, __VA_ARGS__)
|
||||||
|
#else
|
||||||
|
#define CYBOZU_SNPRINTF(x, len, ...) (void)snprintf(x, len, __VA_ARGS__)
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define CYBOZU_CPP_VERSION_CPP03 0
|
||||||
|
#define CYBOZU_CPP_VERSION_TR1 1
|
||||||
|
#define CYBOZU_CPP_VERSION_CPP11 2
|
||||||
|
#define CYBOZU_CPP_VERSION_CPP14 3
|
||||||
|
#define CYBOZU_CPP_VERSION_CPP17 4
|
||||||
|
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#define CYBOZU_GNUC_PREREQ(major, minor) ((__GNUC__) * 100 + (__GNUC_MINOR__) >= (major) * 100 + (minor))
|
||||||
|
#else
|
||||||
|
#define CYBOZU_GNUC_PREREQ(major, minor) 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (__cplusplus >= 201703)
|
||||||
|
#define CYBOZU_CPP_VERSION CYBOZU_CPP_VERSION_CPP17
|
||||||
|
#elif (__cplusplus >= 201402)
|
||||||
|
#define CYBOZU_CPP_VERSION CYBOZU_CPP_VERSION_CPP14
|
||||||
|
#elif (__cplusplus >= 201103) || (_MSC_VER >= 1500) || defined(__GXX_EXPERIMENTAL_CXX0X__)
|
||||||
|
#if defined(_MSC_VER) && (_MSC_VER <= 1600)
|
||||||
|
#define CYBOZU_CPP_VERSION CYBOZU_CPP_VERSION_TR1
|
||||||
|
#else
|
||||||
|
#define CYBOZU_CPP_VERSION CYBOZU_CPP_VERSION_CPP11
|
||||||
|
#endif
|
||||||
|
#elif CYBOZU_GNUC_PREREQ(4, 5) || (CYBOZU_GNUC_PREREQ(4, 2) && __GLIBCXX__ >= 20070719) || defined(__INTEL_COMPILER) || (__clang_major__ >= 3)
|
||||||
|
#define CYBOZU_CPP_VERSION CYBOZU_CPP_VERSION_TR1
|
||||||
|
#else
|
||||||
|
#define CYBOZU_CPP_VERSION CYBOZU_CPP_VERSION_CPP03
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CYBOZU_USE_BOOST
|
||||||
|
#define CYBOZU_NAMESPACE_STD boost
|
||||||
|
#define CYBOZU_NAMESPACE_TR1_BEGIN
|
||||||
|
#define CYBOZU_NAMESPACE_TR1_END
|
||||||
|
#elif (CYBOZU_CPP_VERSION == CYBOZU_CPP_VERSION_TR1) && !defined(__APPLE__)
|
||||||
|
#define CYBOZU_NAMESPACE_STD std::tr1
|
||||||
|
#define CYBOZU_NAMESPACE_TR1_BEGIN namespace tr1 {
|
||||||
|
#define CYBOZU_NAMESPACE_TR1_END }
|
||||||
|
#else
|
||||||
|
#define CYBOZU_NAMESPACE_STD std
|
||||||
|
#define CYBOZU_NAMESPACE_TR1_BEGIN
|
||||||
|
#define CYBOZU_NAMESPACE_TR1_END
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CYBOZU_OS_BIT
|
||||||
|
#if defined(_WIN64) || defined(__x86_64__) || defined(__AARCH64EL__) || defined(__EMSCRIPTEN__)
|
||||||
|
#define CYBOZU_OS_BIT 64
|
||||||
|
#else
|
||||||
|
#define CYBOZU_OS_BIT 32
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CYBOZU_HOST
|
||||||
|
#define CYBOZU_HOST_UNKNOWN 0
|
||||||
|
#define CYBOZU_HOST_INTEL 1
|
||||||
|
#define CYBOZU_HOST_ARM 2
|
||||||
|
#if defined(_M_IX86) || defined(_M_AMD64) || defined(__x86_64__) || defined(__i386__)
|
||||||
|
#define CYBOZU_HOST CYBOZU_HOST_INTEL
|
||||||
|
#elif defined(__arm__) || defined(__AARCH64EL__)
|
||||||
|
#define CYBOZU_HOST CYBOZU_HOST_ARM
|
||||||
|
#else
|
||||||
|
#define CYBOZU_HOST CYBOZU_HOST_UNKNOWN
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CYBOZU_ENDIAN
|
||||||
|
#define CYBOZU_ENDIAN_UNKNOWN 0
|
||||||
|
#define CYBOZU_ENDIAN_LITTLE 1
|
||||||
|
#define CYBOZU_ENDIAN_BIG 2
|
||||||
|
#if (CYBOZU_HOST == CYBOZU_HOST_INTEL)
|
||||||
|
#define CYBOZU_ENDIAN CYBOZU_ENDIAN_LITTLE
|
||||||
|
#elif (CYBOZU_HOST == CYBOZU_HOST_ARM) && (defined(__ARM_EABI__) || defined(__AARCH64EL__))
|
||||||
|
#define CYBOZU_ENDIAN CYBOZU_ENDIAN_LITTLE
|
||||||
|
#else
|
||||||
|
#define CYBOZU_ENDIAN CYBOZU_ENDIAN_UNKNOWN
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if CYBOZU_CPP_VERSION >= CYBOZU_CPP_VERSION_CPP11
|
||||||
|
#define CYBOZU_NOEXCEPT noexcept
|
||||||
|
#else
|
||||||
|
#define CYBOZU_NOEXCEPT throw()
|
||||||
|
#endif
|
||||||
|
namespace cybozu {
|
||||||
|
template<class T>
|
||||||
|
void disable_warning_unused_variable(const T&) { }
|
||||||
|
template<class T, class S>
|
||||||
|
T cast(const S* ptr) { return static_cast<T>(static_cast<const void*>(ptr)); }
|
||||||
|
template<class T, class S>
|
||||||
|
T cast(S* ptr) { return static_cast<T>(static_cast<void*>(ptr)); }
|
||||||
|
} // cybozu
|
||||||
373
external/xbyak/test/cybozu/test.hpp
vendored
Normal file
373
external/xbyak/test/cybozu/test.hpp
vendored
Normal file
@@ -0,0 +1,373 @@
|
|||||||
|
#pragma once
|
||||||
|
/**
|
||||||
|
@file
|
||||||
|
@brief unit test class
|
||||||
|
|
||||||
|
@author MITSUNARI Shigeo(@herumi)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <string>
|
||||||
|
#include <list>
|
||||||
|
#include <iostream>
|
||||||
|
#include <utility>
|
||||||
|
#if defined(_MSC_VER) && (MSC_VER <= 1500)
|
||||||
|
#include <cybozu/inttype.hpp>
|
||||||
|
#else
|
||||||
|
#include <stdint.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace cybozu { namespace test {
|
||||||
|
|
||||||
|
class AutoRun {
|
||||||
|
typedef void (*Func)();
|
||||||
|
typedef std::list<std::pair<const char*, Func> > UnitTestList;
|
||||||
|
public:
|
||||||
|
AutoRun()
|
||||||
|
: init_(0)
|
||||||
|
, term_(0)
|
||||||
|
, okCount_(0)
|
||||||
|
, ngCount_(0)
|
||||||
|
, exceptionCount_(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
void setup(Func init, Func term)
|
||||||
|
{
|
||||||
|
init_ = init;
|
||||||
|
term_ = term;
|
||||||
|
}
|
||||||
|
void append(const char *name, Func func)
|
||||||
|
{
|
||||||
|
list_.push_back(std::make_pair(name, func));
|
||||||
|
}
|
||||||
|
void set(bool isOK)
|
||||||
|
{
|
||||||
|
if (isOK) {
|
||||||
|
okCount_++;
|
||||||
|
} else {
|
||||||
|
ngCount_++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::string getBaseName(const std::string& name) const
|
||||||
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
const char sep = '\\';
|
||||||
|
#else
|
||||||
|
const char sep = '/';
|
||||||
|
#endif
|
||||||
|
size_t pos = name.find_last_of(sep);
|
||||||
|
std::string ret = name.substr(pos + 1);
|
||||||
|
pos = ret.find('.');
|
||||||
|
return ret.substr(0, pos);
|
||||||
|
}
|
||||||
|
int run(int, char *argv[])
|
||||||
|
{
|
||||||
|
std::string msg;
|
||||||
|
try {
|
||||||
|
if (init_) init_();
|
||||||
|
for (UnitTestList::const_iterator i = list_.begin(), ie = list_.end(); i != ie; ++i) {
|
||||||
|
std::cout << "ctest:module=" << i->first << std::endl;
|
||||||
|
try {
|
||||||
|
(i->second)();
|
||||||
|
} catch (std::exception& e) {
|
||||||
|
exceptionCount_++;
|
||||||
|
std::cout << "ctest: " << i->first << " is stopped by exception " << e.what() << std::endl;
|
||||||
|
} catch (...) {
|
||||||
|
exceptionCount_++;
|
||||||
|
std::cout << "ctest: " << i->first << " is stopped by unknown exception" << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (term_) term_();
|
||||||
|
} catch (std::exception& e) {
|
||||||
|
msg = std::string("ctest:err:") + e.what();
|
||||||
|
} catch (...) {
|
||||||
|
msg = "ctest:err: catch unknown exception";
|
||||||
|
}
|
||||||
|
fflush(stdout);
|
||||||
|
if (msg.empty()) {
|
||||||
|
int err = ngCount_ + exceptionCount_;
|
||||||
|
int total = okCount_ + err;
|
||||||
|
std::cout << "ctest:name=" << getBaseName(*argv)
|
||||||
|
<< ", module=" << list_.size()
|
||||||
|
<< ", total=" << total
|
||||||
|
<< ", ok=" << okCount_
|
||||||
|
<< ", ng=" << ngCount_
|
||||||
|
<< ", exception=" << exceptionCount_ << std::endl;
|
||||||
|
return err > 0 ? 1 : 0;
|
||||||
|
} else {
|
||||||
|
std::cout << msg << std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static inline AutoRun& getInstance()
|
||||||
|
{
|
||||||
|
static AutoRun instance;
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
Func init_;
|
||||||
|
Func term_;
|
||||||
|
int okCount_;
|
||||||
|
int ngCount_;
|
||||||
|
int exceptionCount_;
|
||||||
|
UnitTestList list_;
|
||||||
|
};
|
||||||
|
|
||||||
|
static AutoRun& autoRun = AutoRun::getInstance();
|
||||||
|
|
||||||
|
inline void test(bool ret, const std::string& msg, const std::string& param, const char *file, int line)
|
||||||
|
{
|
||||||
|
autoRun.set(ret);
|
||||||
|
if (!ret) {
|
||||||
|
printf("%s(%d):ctest:%s(%s);\n", file, line, msg.c_str(), param.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T, typename U>
|
||||||
|
bool isEqual(const T& lhs, const U& rhs)
|
||||||
|
{
|
||||||
|
return lhs == rhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
// avoid warning of comparision of integers of different signs
|
||||||
|
inline bool isEqual(size_t lhs, int rhs)
|
||||||
|
{
|
||||||
|
return lhs == size_t(rhs);
|
||||||
|
}
|
||||||
|
inline bool isEqual(int lhs, size_t rhs)
|
||||||
|
{
|
||||||
|
return size_t(lhs) == rhs;
|
||||||
|
}
|
||||||
|
inline bool isEqual(const char *lhs, const char *rhs)
|
||||||
|
{
|
||||||
|
return strcmp(lhs, rhs) == 0;
|
||||||
|
}
|
||||||
|
inline bool isEqual(char *lhs, const char *rhs)
|
||||||
|
{
|
||||||
|
return strcmp(lhs, rhs) == 0;
|
||||||
|
}
|
||||||
|
inline bool isEqual(const char *lhs, char *rhs)
|
||||||
|
{
|
||||||
|
return strcmp(lhs, rhs) == 0;
|
||||||
|
}
|
||||||
|
inline bool isEqual(char *lhs, char *rhs)
|
||||||
|
{
|
||||||
|
return strcmp(lhs, rhs) == 0;
|
||||||
|
}
|
||||||
|
// avoid to compare float directly
|
||||||
|
inline bool isEqual(float lhs, float rhs)
|
||||||
|
{
|
||||||
|
union fi {
|
||||||
|
float f;
|
||||||
|
uint32_t i;
|
||||||
|
} lfi, rfi;
|
||||||
|
lfi.f = lhs;
|
||||||
|
rfi.f = rhs;
|
||||||
|
return lfi.i == rfi.i;
|
||||||
|
}
|
||||||
|
// avoid to compare double directly
|
||||||
|
inline bool isEqual(double lhs, double rhs)
|
||||||
|
{
|
||||||
|
union di {
|
||||||
|
double d;
|
||||||
|
uint64_t i;
|
||||||
|
} ldi, rdi;
|
||||||
|
ldi.d = lhs;
|
||||||
|
rdi.d = rhs;
|
||||||
|
return ldi.i == rdi.i;
|
||||||
|
}
|
||||||
|
|
||||||
|
} } // cybozu::test
|
||||||
|
|
||||||
|
#ifndef CYBOZU_TEST_DISABLE_AUTO_RUN
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
return cybozu::test::autoRun.run(argc, argv);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
alert if !x
|
||||||
|
@param x [in]
|
||||||
|
*/
|
||||||
|
#define CYBOZU_TEST_ASSERT(x) cybozu::test::test(!!(x), "CYBOZU_TEST_ASSERT", #x, __FILE__, __LINE__)
|
||||||
|
|
||||||
|
/**
|
||||||
|
alert if x != y
|
||||||
|
@param x [in]
|
||||||
|
@param y [in]
|
||||||
|
*/
|
||||||
|
#define CYBOZU_TEST_EQUAL(x, y) { \
|
||||||
|
bool _cybozu_eq = cybozu::test::isEqual(x, y); \
|
||||||
|
cybozu::test::test(_cybozu_eq, "CYBOZU_TEST_EQUAL", #x ", " #y, __FILE__, __LINE__); \
|
||||||
|
if (!_cybozu_eq) { \
|
||||||
|
std::cout << "ctest: lhs=" << (x) << std::endl; \
|
||||||
|
std::cout << "ctest: rhs=" << (y) << std::endl; \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
alert if fabs(x, y) >= eps
|
||||||
|
@param x [in]
|
||||||
|
@param y [in]
|
||||||
|
*/
|
||||||
|
#define CYBOZU_TEST_NEAR(x, y, eps) { \
|
||||||
|
bool _cybozu_isNear = fabs((x) - (y)) < eps; \
|
||||||
|
cybozu::test::test(_cybozu_isNear, "CYBOZU_TEST_NEAR", #x ", " #y, __FILE__, __LINE__); \
|
||||||
|
if (!_cybozu_isNear) { \
|
||||||
|
std::cout << "ctest: lhs=" << (x) << std::endl; \
|
||||||
|
std::cout << "ctest: rhs=" << (y) << std::endl; \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define CYBOZU_TEST_EQUAL_POINTER(x, y) { \
|
||||||
|
bool _cybozu_eq = x == y; \
|
||||||
|
cybozu::test::test(_cybozu_eq, "CYBOZU_TEST_EQUAL_POINTER", #x ", " #y, __FILE__, __LINE__); \
|
||||||
|
if (!_cybozu_eq) { \
|
||||||
|
std::cout << "ctest: lhs=" << static_cast<const void*>(x) << std::endl; \
|
||||||
|
std::cout << "ctest: rhs=" << static_cast<const void*>(y) << std::endl; \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
alert if x[] != y[]
|
||||||
|
@param x [in]
|
||||||
|
@param y [in]
|
||||||
|
@param n [in]
|
||||||
|
*/
|
||||||
|
#define CYBOZU_TEST_EQUAL_ARRAY(x, y, n) { \
|
||||||
|
for (size_t _cybozu_test_i = 0, _cybozu_ie = (size_t)(n); _cybozu_test_i < _cybozu_ie; _cybozu_test_i++) { \
|
||||||
|
bool _cybozu_eq = cybozu::test::isEqual((x)[_cybozu_test_i], (y)[_cybozu_test_i]); \
|
||||||
|
cybozu::test::test(_cybozu_eq, "CYBOZU_TEST_EQUAL_ARRAY", #x ", " #y ", " #n, __FILE__, __LINE__); \
|
||||||
|
if (!_cybozu_eq) { \
|
||||||
|
std::cout << "ctest: i=" << _cybozu_test_i << std::endl; \
|
||||||
|
std::cout << "ctest: lhs=" << (x)[_cybozu_test_i] << std::endl; \
|
||||||
|
std::cout << "ctest: rhs=" << (y)[_cybozu_test_i] << std::endl; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
always alert
|
||||||
|
@param msg [in]
|
||||||
|
*/
|
||||||
|
#define CYBOZU_TEST_FAIL(msg) cybozu::test::test(false, "CYBOZU_TEST_FAIL", msg, __FILE__, __LINE__)
|
||||||
|
|
||||||
|
/**
|
||||||
|
verify message in exception
|
||||||
|
*/
|
||||||
|
#define CYBOZU_TEST_EXCEPTION_MESSAGE(statement, Exception, msg) \
|
||||||
|
{ \
|
||||||
|
int _cybozu_ret = 0; \
|
||||||
|
std::string _cybozu_errMsg; \
|
||||||
|
try { \
|
||||||
|
statement; \
|
||||||
|
_cybozu_ret = 1; \
|
||||||
|
} catch (const Exception& _cybozu_e) { \
|
||||||
|
_cybozu_errMsg = _cybozu_e.what(); \
|
||||||
|
if (_cybozu_errMsg.find(msg) == std::string::npos) { \
|
||||||
|
_cybozu_ret = 2; \
|
||||||
|
} \
|
||||||
|
} catch (...) { \
|
||||||
|
_cybozu_ret = 3; \
|
||||||
|
} \
|
||||||
|
if (_cybozu_ret) { \
|
||||||
|
cybozu::test::test(false, "CYBOZU_TEST_EXCEPTION_MESSAGE", #statement ", " #Exception ", " #msg, __FILE__, __LINE__); \
|
||||||
|
if (_cybozu_ret == 1) { \
|
||||||
|
std::cout << "ctest: no exception" << std::endl; \
|
||||||
|
} else if (_cybozu_ret == 2) { \
|
||||||
|
std::cout << "ctest: bad exception msg:" << _cybozu_errMsg << std::endl; \
|
||||||
|
} else { \
|
||||||
|
std::cout << "ctest: unexpected exception" << std::endl; \
|
||||||
|
} \
|
||||||
|
} else { \
|
||||||
|
cybozu::test::autoRun.set(true); \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define CYBOZU_TEST_EXCEPTION(statement, Exception) \
|
||||||
|
{ \
|
||||||
|
int _cybozu_ret = 0; \
|
||||||
|
try { \
|
||||||
|
statement; \
|
||||||
|
_cybozu_ret = 1; \
|
||||||
|
} catch (const Exception&) { \
|
||||||
|
} catch (...) { \
|
||||||
|
_cybozu_ret = 2; \
|
||||||
|
} \
|
||||||
|
if (_cybozu_ret) { \
|
||||||
|
cybozu::test::test(false, "CYBOZU_TEST_EXCEPTION", #statement ", " #Exception, __FILE__, __LINE__); \
|
||||||
|
if (_cybozu_ret == 1) { \
|
||||||
|
std::cout << "ctest: no exception" << std::endl; \
|
||||||
|
} else { \
|
||||||
|
std::cout << "ctest: unexpected exception" << std::endl; \
|
||||||
|
} \
|
||||||
|
} else { \
|
||||||
|
cybozu::test::autoRun.set(true); \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
verify statement does not throw
|
||||||
|
*/
|
||||||
|
#define CYBOZU_TEST_NO_EXCEPTION(statement) \
|
||||||
|
try { \
|
||||||
|
statement; \
|
||||||
|
cybozu::test::autoRun.set(true); \
|
||||||
|
} catch (...) { \
|
||||||
|
cybozu::test::test(false, "CYBOZU_TEST_NO_EXCEPTION", #statement, __FILE__, __LINE__); \
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
append auto unit test
|
||||||
|
@param name [in] module name
|
||||||
|
*/
|
||||||
|
#define CYBOZU_TEST_AUTO(name) \
|
||||||
|
void cybozu_test_ ## name(); \
|
||||||
|
struct cybozu_test_local_ ## name { \
|
||||||
|
cybozu_test_local_ ## name() \
|
||||||
|
{ \
|
||||||
|
cybozu::test::autoRun.append(#name, cybozu_test_ ## name); \
|
||||||
|
} \
|
||||||
|
} cybozu_test_local_instance_ ## name; \
|
||||||
|
void cybozu_test_ ## name()
|
||||||
|
|
||||||
|
/**
|
||||||
|
append auto unit test with fixture
|
||||||
|
@param name [in] module name
|
||||||
|
*/
|
||||||
|
#define CYBOZU_TEST_AUTO_WITH_FIXTURE(name, Fixture) \
|
||||||
|
void cybozu_test_ ## name(); \
|
||||||
|
void cybozu_test_real_ ## name() \
|
||||||
|
{ \
|
||||||
|
Fixture f; \
|
||||||
|
cybozu_test_ ## name(); \
|
||||||
|
} \
|
||||||
|
struct cybozu_test_local_ ## name { \
|
||||||
|
cybozu_test_local_ ## name() \
|
||||||
|
{ \
|
||||||
|
cybozu::test::autoRun.append(#name, cybozu_test_real_ ## name); \
|
||||||
|
} \
|
||||||
|
} cybozu_test_local_instance_ ## name; \
|
||||||
|
void cybozu_test_ ## name()
|
||||||
|
|
||||||
|
/**
|
||||||
|
setup fixture
|
||||||
|
@param Fixture [in] class name of fixture
|
||||||
|
@note cstr of Fixture is called before test and dstr of Fixture is called after test
|
||||||
|
*/
|
||||||
|
#define CYBOZU_TEST_SETUP_FIXTURE(Fixture) \
|
||||||
|
Fixture *cybozu_test_local_fixture; \
|
||||||
|
void cybozu_test_local_init() \
|
||||||
|
{ \
|
||||||
|
cybozu_test_local_fixture = new Fixture(); \
|
||||||
|
} \
|
||||||
|
void cybozu_test_local_term() \
|
||||||
|
{ \
|
||||||
|
delete cybozu_test_local_fixture; \
|
||||||
|
} \
|
||||||
|
struct cybozu_test_local_fixture_setup_ { \
|
||||||
|
cybozu_test_local_fixture_setup_() \
|
||||||
|
{ \
|
||||||
|
cybozu::test::autoRun.setup(cybozu_test_local_init, cybozu_test_local_term); \
|
||||||
|
} \
|
||||||
|
} cybozu_test_local_fixture_setup_instance_;
|
||||||
94
external/xbyak/test/dataset/amx.txt
vendored
Normal file
94
external/xbyak/test/dataset/amx.txt
vendored
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
ldtilecfg(ptr[rax + rcx * 4 + 64]);
|
||||||
|
ldtilecfg(ptr [r30+r29*4+0x12]);
|
||||||
|
ldtilecfg(ptr [rax]);
|
||||||
|
sttilecfg(ptr[rsp + rax * 8 + 128]);
|
||||||
|
sttilecfg(ptr [r30+r29*4+0x12]);
|
||||||
|
sttilecfg(ptr [r30]);
|
||||||
|
tileloadd(tmm3, ptr[rdi + rdx * 2 + 8]);
|
||||||
|
tileloadd(tmm2, ptr [r30+r29*4+0x12]);
|
||||||
|
tileloaddt1(tmm4, ptr[r8 + r9 + 32]);
|
||||||
|
tileloaddt1(tmm7, ptr [r30+r29*4+0x12]);
|
||||||
|
tilerelease();
|
||||||
|
tilestored(ptr[r10 + r11 * 2 + 32], tmm2);
|
||||||
|
tilestored(ptr [r30+r29*4+0x12], tmm1);
|
||||||
|
tilezero(tmm7);
|
||||||
|
tdpbssd(tmm1, tmm2, tmm3);
|
||||||
|
tdpbsud(tmm2, tmm3, tmm4);
|
||||||
|
tdpbusd(tmm3, tmm4, tmm5);
|
||||||
|
tdpbuud(tmm4, tmm5, tmm6);
|
||||||
|
tdpfp16ps(tmm5, tmm6, tmm7);
|
||||||
|
tdpbf16ps(tmm5, tmm6, tmm7);
|
||||||
|
tileloadd(tmm1, ptr[r8+r8]);
|
||||||
|
tileloadd(tmm1, ptr[rax+rcx*4]);
|
||||||
|
tileloadd(tmm1, ptr[r8+r9*1+0x40]);
|
||||||
|
tileloadd(tmm1, ptr[r30+r29*1+0x80]);
|
||||||
|
tileloaddrs(tmm3, ptr[rdi + rdx * 2 + 8]);
|
||||||
|
tileloaddrs(tmm7, ptr[r31 + rdx * 2 + 8]);
|
||||||
|
tileloaddrst1(tmm4, ptr[r8 + r9 + 32]);
|
||||||
|
tileloaddrst1(tmm4, ptr[r25 + r9 + 32]);
|
||||||
|
|
||||||
|
tdpbf8ps(tmm1, tmm2, tmm3);
|
||||||
|
tdpbhf8ps(tmm1, tmm2, tmm3);
|
||||||
|
tdphbf8ps(tmm1, tmm2, tmm3);
|
||||||
|
tdphf8ps(tmm1, tmm2, tmm3);
|
||||||
|
|
||||||
|
tmmultf32ps(tmm1, tmm2, tmm3);
|
||||||
|
|
||||||
|
t2rpntlvwz0(tmm1, ptr[rax+r8*2+0x80]);
|
||||||
|
t2rpntlvwz0(tmm7, ptr[r30+r8*2+0x80]);
|
||||||
|
|
||||||
|
t2rpntlvwz0t1(tmm1, ptr[rax+r8*2+0x80]);
|
||||||
|
t2rpntlvwz0t1(tmm7, ptr[r30+r8*2+0x80]);
|
||||||
|
|
||||||
|
t2rpntlvwz1(tmm1, ptr[rax+r8*2+0x80]);
|
||||||
|
t2rpntlvwz1(tmm7, ptr[r30+r8*2+0x80]);
|
||||||
|
|
||||||
|
t2rpntlvwz1t1(tmm1, ptr[rax+r8*2+0x80]);
|
||||||
|
t2rpntlvwz1t1(tmm7, ptr[r30+r8*2+0x80]);
|
||||||
|
|
||||||
|
t2rpntlvwz0rs(tmm1, ptr[rax+r8*2+0x80]);
|
||||||
|
t2rpntlvwz0rs(tmm7, ptr[r30+r8*2+0x80]);
|
||||||
|
|
||||||
|
t2rpntlvwz0rst1(tmm1, ptr[rax+r8*2+0x80]);
|
||||||
|
t2rpntlvwz0rst1(tmm7, ptr[r30+r8*2+0x80]);
|
||||||
|
|
||||||
|
t2rpntlvwz1rs(tmm1, ptr[rax+r8*2+0x80]);
|
||||||
|
t2rpntlvwz1rs(tmm7, ptr[r30+r8*2+0x80]);
|
||||||
|
|
||||||
|
t2rpntlvwz1rst1(tmm1, ptr[rax+r8*2+0x80]);
|
||||||
|
t2rpntlvwz1rst1(tmm7, ptr[r30+r8*2+0x80]);
|
||||||
|
|
||||||
|
tcmmimfp16ps(tmm1, tmm2, tmm3);
|
||||||
|
tcmmrlfp16ps(tmm1, tmm2, tmm3);
|
||||||
|
|
||||||
|
tconjtcmmimfp16ps(tmm1, tmm2, tmm3);
|
||||||
|
|
||||||
|
tconjtfp16(tmm1, tmm2);
|
||||||
|
|
||||||
|
tcvtrowps2bf16h(zmm1, tmm2, r30d);
|
||||||
|
tcvtrowps2bf16h(zmm29, tmm2, 0x12);
|
||||||
|
|
||||||
|
tcvtrowps2bf16l(zmm1, tmm2, r30d);
|
||||||
|
tcvtrowps2bf16l(zmm29, tmm2, 0x12);
|
||||||
|
|
||||||
|
tcvtrowps2phh(zmm1, tmm2, r30d);
|
||||||
|
tcvtrowps2phh(zmm29, tmm2, 0x12);
|
||||||
|
|
||||||
|
tcvtrowps2phl(zmm1, tmm2, r30d);
|
||||||
|
tcvtrowps2phl(zmm29, tmm2, 0x12);
|
||||||
|
|
||||||
|
tilemovrow(zmm1, tmm2, r30d);
|
||||||
|
tilemovrow(zmm29, tmm2, 0x12);
|
||||||
|
|
||||||
|
ttcmmimfp16ps(tmm1, tmm2, tmm3);
|
||||||
|
ttcmmrlfp16ps(tmm1, tmm2, tmm3);
|
||||||
|
|
||||||
|
ttdpbf16ps(tmm1, tmm2, tmm3);
|
||||||
|
ttdpfp16ps(tmm1, tmm2, tmm3);
|
||||||
|
|
||||||
|
ttmmultf32ps(tmm1, tmm2, tmm3);
|
||||||
|
|
||||||
|
ttransposed(tmm1, tmm2);
|
||||||
|
|
||||||
|
tcvtrowd2ps(zmm20, tmm1, r30d);
|
||||||
|
tcvtrowd2ps(zmm20, tmm1, 0x12);
|
||||||
21
external/xbyak/test/dataset/apx.txt
vendored
Normal file
21
external/xbyak/test/dataset/apx.txt
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
// https://github.com/herumi/xbyak/pull/202
|
||||||
|
sal(rax, r8, 1);
|
||||||
|
sar(rax, r9, 4);
|
||||||
|
shl(rax, rdi, 8);
|
||||||
|
shr(rax, rsi, 12);
|
||||||
|
rcl(rax, r10, 16);
|
||||||
|
rcr(rax, r11, 20);
|
||||||
|
rol(rax, r14, 24);
|
||||||
|
ror(rax, r15, 28);
|
||||||
|
sal(rcx, qword[r8], 32);
|
||||||
|
sar(rcx, qword[r9], 36);
|
||||||
|
sal(rcx, qword[rdi], 40);
|
||||||
|
sar(rcx, qword[rsi], 44);
|
||||||
|
rcl(rcx, qword[r10], 48);
|
||||||
|
rcr(rcx, qword[r11], 52);
|
||||||
|
rol(rcx, qword[r14], 56);
|
||||||
|
ror(rcx, qword[r15], 60);
|
||||||
|
|
||||||
|
imul(rax, rdx, r10);
|
||||||
|
imul(rcx, r15, qword[rdi]);
|
||||||
|
|
||||||
210
external/xbyak/test/dataset/bf16.txt
vendored
Normal file
210
external/xbyak/test/dataset/bf16.txt
vendored
Normal file
@@ -0,0 +1,210 @@
|
|||||||
|
vaddbf16(xm1, xm2, xm3);
|
||||||
|
vaddbf16(ym1|k1, ym2, ptr[rax+128]);
|
||||||
|
vaddbf16(ym1|k1, ym2, ptr_b[rax+128]);
|
||||||
|
vaddbf16(zm1|k2|T_z, zm2, ptr_b[rax+128]);
|
||||||
|
|
||||||
|
vdivbf16(xm1, xm2, xm3);
|
||||||
|
vdivbf16(ym1|k1, ym2, ptr[rax+128]);
|
||||||
|
vdivbf16(ym1|k1, ym2, ptr_b[rax+128]);
|
||||||
|
vdivbf16(zm1|k2|T_z, zm2, ptr_b[rax+128]);
|
||||||
|
|
||||||
|
vmaxbf16(xm1, xm2, xm3);
|
||||||
|
vmaxbf16(ym1|k1, ym2, ptr[rax+128]);
|
||||||
|
vmaxbf16(ym1|k1, ym2, ptr_b[rax+128]);
|
||||||
|
vmaxbf16(zm1|k2|T_z, zm2, ptr_b[rax+128]);
|
||||||
|
|
||||||
|
vminbf16(xm1, xm2, xm3);
|
||||||
|
vminbf16(ym1|k1, ym2, ptr[rax+128]);
|
||||||
|
vminbf16(ym1|k1, ym2, ptr_b[rax+128]);
|
||||||
|
vminbf16(zm1|k2|T_z, zm2, ptr_b[rax+128]);
|
||||||
|
|
||||||
|
vmulbf16(xm1, xm2, xm3);
|
||||||
|
vmulbf16(ym1|k1, ym2, ptr[rax+128]);
|
||||||
|
vmulbf16(ym1|k1, ym2, ptr_b[rax+128]);
|
||||||
|
vmulbf16(zm1|k2|T_z, zm2, ptr_b[rax+128]);
|
||||||
|
|
||||||
|
vscalefbf16(xm1, xm2, xm3);
|
||||||
|
vscalefbf16(ym1|k1, ym2, ptr[rax+128]);
|
||||||
|
vscalefbf16(ym1|k1, ym2, ptr_b[rax+128]);
|
||||||
|
vscalefbf16(zm1|k2|T_z, zm2, ptr_b[rax+128]);
|
||||||
|
|
||||||
|
vsubbf16(xm1, xm2, xm3);
|
||||||
|
vsubbf16(ym1|k1, ym2, ptr[rax+128]);
|
||||||
|
vsubbf16(ym1|k1, ym2, ptr_b[rax+128]);
|
||||||
|
vsubbf16(zm1|k2|T_z, zm2, ptr_b[rax+128]);
|
||||||
|
// madd
|
||||||
|
vfmadd132bf16(xm1, xm2, xm3);
|
||||||
|
vfmadd132bf16(ym1|k1, ym2, ptr[rax+128]);
|
||||||
|
vfmadd132bf16(ym1|k1, ym2, ptr_b[rax+128]);
|
||||||
|
vfmadd132bf16(zm1|k2|T_z, zm2, ptr_b[rax+128]);
|
||||||
|
|
||||||
|
vfmadd213bf16(xm1, xm2, xm3);
|
||||||
|
vfmadd213bf16(ym1|k1, ym2, ptr[rax+128]);
|
||||||
|
vfmadd213bf16(ym1|k1, ym2, ptr_b[rax+128]);
|
||||||
|
vfmadd213bf16(zm1|k2|T_z, zm2, ptr_b[rax+128]);
|
||||||
|
|
||||||
|
vfmadd231bf16(xm1, xm2, xm3);
|
||||||
|
vfmadd231bf16(ym1|k1, ym2, ptr[rax+128]);
|
||||||
|
vfmadd231bf16(ym1|k1, ym2, ptr_b[rax+128]);
|
||||||
|
vfmadd231bf16(zm1|k2|T_z, zm2, ptr_b[rax+128]);
|
||||||
|
// nmadd
|
||||||
|
vfnmadd132bf16(xm1, xm2, xm3);
|
||||||
|
vfnmadd132bf16(ym1|k1, ym2, ptr[rax+128]);
|
||||||
|
vfnmadd132bf16(ym1|k1, ym2, ptr_b[rax+128]);
|
||||||
|
vfnmadd132bf16(zm1|k2|T_z, zm2, ptr_b[rax+128]);
|
||||||
|
|
||||||
|
vfnmadd213bf16(xm1, xm2, xm3);
|
||||||
|
vfnmadd213bf16(ym1|k1, ym2, ptr[rax+128]);
|
||||||
|
vfnmadd213bf16(ym1|k1, ym2, ptr_b[rax+128]);
|
||||||
|
vfnmadd213bf16(zm1|k2|T_z, zm2, ptr_b[rax+128]);
|
||||||
|
|
||||||
|
vfnmadd231bf16(xm1, xm2, xm3);
|
||||||
|
vfnmadd231bf16(ym1|k1, ym2, ptr[rax+128]);
|
||||||
|
vfnmadd231bf16(ym1|k1, ym2, ptr_b[rax+128]);
|
||||||
|
vfnmadd231bf16(zm1|k2|T_z, zm2, ptr_b[rax+128]);
|
||||||
|
// msub
|
||||||
|
vfmsub132bf16(xm1, xm2, xm3);
|
||||||
|
vfmsub132bf16(ym1|k1, ym2, ptr[rax+128]);
|
||||||
|
vfmsub132bf16(ym1|k1, ym2, ptr_b[rax+128]);
|
||||||
|
vfmsub132bf16(zm1|k2|T_z, zm2, ptr_b[rax+128]);
|
||||||
|
|
||||||
|
vfmsub213bf16(xm1, xm2, xm3);
|
||||||
|
vfmsub213bf16(ym1|k1, ym2, ptr[rax+128]);
|
||||||
|
vfmsub213bf16(ym1|k1, ym2, ptr_b[rax+128]);
|
||||||
|
vfmsub213bf16(zm1|k2|T_z, zm2, ptr_b[rax+128]);
|
||||||
|
|
||||||
|
vfmsub231bf16(xm1, xm2, xm3);
|
||||||
|
vfmsub231bf16(ym1|k1, ym2, ptr[rax+128]);
|
||||||
|
vfmsub231bf16(ym1|k1, ym2, ptr_b[rax+128]);
|
||||||
|
vfmsub231bf16(zm1|k2|T_z, zm2, ptr_b[rax+128]);
|
||||||
|
// nmsub
|
||||||
|
vfnmsub132bf16(xm1, xm2, xm3);
|
||||||
|
vfnmsub132bf16(ym1|k1, ym2, ptr[rax+128]);
|
||||||
|
vfnmsub132bf16(ym1|k1, ym2, ptr_b[rax+128]);
|
||||||
|
vfnmsub132bf16(zm1|k2|T_z, zm2, ptr_b[rax+128]);
|
||||||
|
|
||||||
|
vfnmsub213bf16(xm1, xm2, xm3);
|
||||||
|
vfnmsub213bf16(ym1|k1, ym2, ptr[rax+128]);
|
||||||
|
vfnmsub213bf16(ym1|k1, ym2, ptr_b[rax+128]);
|
||||||
|
vfnmsub213bf16(zm1|k2|T_z, zm2, ptr_b[rax+128]);
|
||||||
|
|
||||||
|
vfnmsub231bf16(xm1, xm2, xm3);
|
||||||
|
vfnmsub231bf16(ym1|k1, ym2, ptr[rax+128]);
|
||||||
|
vfnmsub231bf16(ym1|k1, ym2, ptr_b[rax+128]);
|
||||||
|
vfnmsub231bf16(zm1|k2|T_z, zm2, ptr_b[rax+128]);
|
||||||
|
|
||||||
|
vcmpbf16(k1, xm5, xm4, 5);
|
||||||
|
vcmpbf16(k2, ym5, ym4, 6);
|
||||||
|
vcmpbf16(k3, ym15, ptr_b[rax+128], 7);
|
||||||
|
vcmpbf16(k4, zm30, zm20, 8);
|
||||||
|
vcmpbf16(k5, zm1, ptr[rax+128], 9);
|
||||||
|
vcmpbf16(k6, zm10, ptr_b[rax+128], 10);
|
||||||
|
|
||||||
|
vfpclassbf16(k1, xm4, 5);
|
||||||
|
vfpclassbf16(k2|k5, ym4, 6);
|
||||||
|
vfpclassbf16(k3|k5, zm20, 7);
|
||||||
|
vfpclassbf16(k3|k5, xword[rax+128], 8);
|
||||||
|
vfpclassbf16(k3, xword_b[rax+128], 9);
|
||||||
|
vfpclassbf16(k5|k5, yword[rax+128], 10);
|
||||||
|
vfpclassbf16(k6|k5, yword_b[rax+128], 11);
|
||||||
|
vfpclassbf16(k7|k5, zword[rax+128], 12);
|
||||||
|
vfpclassbf16(k7|k5, zword_b[rax+128], 13);
|
||||||
|
|
||||||
|
vcomisbf16(xm2, xm3);
|
||||||
|
vcomisbf16(xm2, ptr[rax+128]);
|
||||||
|
|
||||||
|
vgetexpbf16(xm1|k3, xmm2);
|
||||||
|
vgetexpbf16(xm1|k3, ptr[rax+128]);
|
||||||
|
vgetexpbf16(xm1|k3, ptr_b[rax+128]);
|
||||||
|
|
||||||
|
vgetexpbf16(ym1|k3, ymm2);
|
||||||
|
vgetexpbf16(ym1|k3, ptr[rax+128]);
|
||||||
|
vgetexpbf16(ym1|k3, ptr_b[rax+128]);
|
||||||
|
|
||||||
|
vgetexpbf16(zm1|k3, zmm2);
|
||||||
|
vgetexpbf16(zm1|k3, ptr[rax+128]);
|
||||||
|
vgetexpbf16(zm1|k3, ptr_b[rax+128]);
|
||||||
|
|
||||||
|
vgetmantbf16(xm1|k3, xmm2, 3);
|
||||||
|
vgetmantbf16(xm1|k3, ptr[rax+128], 5);
|
||||||
|
vgetmantbf16(xm1|k3, ptr_b[rax+128], 9);
|
||||||
|
|
||||||
|
vgetmantbf16(ym1|k3, ymm2, 3);
|
||||||
|
vgetmantbf16(ym1|k3, ptr[rax+128], 5);
|
||||||
|
vgetmantbf16(ym1|k3, ptr_b[rax+128], 9);
|
||||||
|
|
||||||
|
vgetmantbf16(zm1|k3, zmm2, 3);
|
||||||
|
vgetmantbf16(zm1|k3, ptr[rax+128], 5);
|
||||||
|
vgetmantbf16(zm1|k3, ptr_b[rax+128], 9);
|
||||||
|
|
||||||
|
vrcpbf16(xm1|k5, xm2);
|
||||||
|
vrcpbf16(xm1|k5, ptr[rcx+128]);
|
||||||
|
vrcpbf16(xm1|k5, ptr_b[rcx+128]);
|
||||||
|
|
||||||
|
vrcpbf16(ym1|k5, ym2);
|
||||||
|
vrcpbf16(ym1|k5, ptr[rcx+128]);
|
||||||
|
vrcpbf16(ym1|k5, ptr_b[rcx+128]);
|
||||||
|
|
||||||
|
vrcpbf16(zm1|k5, zm2);
|
||||||
|
vrcpbf16(zm1|k5, ptr[rcx+128]);
|
||||||
|
vrcpbf16(zm1|k5, ptr_b[rcx+128]);
|
||||||
|
|
||||||
|
vreducebf16(xm1|k4, xm2, 1);
|
||||||
|
vreducebf16(xm1|k4, ptr[rax+128], 1);
|
||||||
|
vreducebf16(xm1|k4, ptr_b[rax+128], 1);
|
||||||
|
|
||||||
|
vreducebf16(ym1|k4, ym2, 1);
|
||||||
|
vreducebf16(ym1|k4, ptr[rax+128], 1);
|
||||||
|
vreducebf16(ym1|k4, ptr_b[rax+128], 1);
|
||||||
|
|
||||||
|
vreducebf16(zm1|k4, zm2, 1);
|
||||||
|
vreducebf16(zm1|k4, ptr[rax+128], 1);
|
||||||
|
vreducebf16(zm1|k4, ptr_b[rax+128], 1);
|
||||||
|
|
||||||
|
vrndscalebf16(xm1|k4, xm2, 1);
|
||||||
|
vrndscalebf16(xm1|k4, ptr[rax+128], 1);
|
||||||
|
vrndscalebf16(xm1|k4, ptr_b[rax+128], 1);
|
||||||
|
|
||||||
|
vrndscalebf16(ym1|k4, ym2, 1);
|
||||||
|
vrndscalebf16(ym1|k4, ptr[rax+128], 1);
|
||||||
|
vrndscalebf16(ym1|k4, ptr_b[rax+128], 1);
|
||||||
|
|
||||||
|
vrndscalebf16(zm1|k4, zm2, 1);
|
||||||
|
vrndscalebf16(zm1|k4, ptr[rax+128], 1);
|
||||||
|
vrndscalebf16(zm1|k4, ptr_b[rax+128], 1);
|
||||||
|
|
||||||
|
vrsqrtbf16(xm1|k5, xm2);
|
||||||
|
vrsqrtbf16(xm1|k5, ptr[rcx+128]);
|
||||||
|
vrsqrtbf16(xm1|k5, ptr_b[rcx+128]);
|
||||||
|
|
||||||
|
vrsqrtbf16(ym1|k5, ym2);
|
||||||
|
vrsqrtbf16(ym1|k5, ptr[rcx+128]);
|
||||||
|
vrsqrtbf16(ym1|k5, ptr_b[rcx+128]);
|
||||||
|
|
||||||
|
vrsqrtbf16(zm1|k5, zm2);
|
||||||
|
vrsqrtbf16(zm1|k5, ptr[rcx+128]);
|
||||||
|
vrsqrtbf16(zm1|k5, ptr_b[rcx+128]);
|
||||||
|
|
||||||
|
vscalefbf16(xm1|k5, xm5, xm2);
|
||||||
|
vscalefbf16(xm1|k5, xm5, ptr[rcx+128]);
|
||||||
|
vscalefbf16(xm1|k5, xm5, ptr_b[rcx+128]);
|
||||||
|
|
||||||
|
vscalefbf16(ym1|k5, ym9, ym2);
|
||||||
|
vscalefbf16(ym1|k5, ym9, ptr[rcx+128]);
|
||||||
|
vscalefbf16(ym1|k5, ym9, ptr_b[rcx+128]);
|
||||||
|
|
||||||
|
vscalefbf16(zm1|k5, zm30, zm2);
|
||||||
|
vscalefbf16(zm1|k5, zm30, ptr[rcx+128]);
|
||||||
|
vscalefbf16(zm1|k5, zm30, ptr_b[rcx+128]);
|
||||||
|
|
||||||
|
vsqrtbf16(xm5|k3, xmm4);
|
||||||
|
vsqrtbf16(xm5|k3, ptr[rax+128]);
|
||||||
|
vsqrtbf16(xm5|k3, ptr_b[rax+128]);
|
||||||
|
|
||||||
|
vsqrtbf16(ym5|k3, ymm4);
|
||||||
|
vsqrtbf16(ym5|k3, ptr[rax+128]);
|
||||||
|
vsqrtbf16(ym5|k3, ptr_b[rax+128]);
|
||||||
|
|
||||||
|
vsqrtbf16(zm5|k3, zmm4);
|
||||||
|
vsqrtbf16(zm5|k3, ptr[rax+128]);
|
||||||
|
vsqrtbf16(zm5|k3, ptr_b[rax+128]);
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user