diff --git a/CMakeLists.txt b/CMakeLists.txt index 9af9741..ece9377 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,8 +37,6 @@ src/soft_aes.cpp src/virtual_memory.cpp src/vm_interpreted.cpp src/allocator.cpp -src/assembly_generator_x86.cpp -src/instruction.cpp src/randomx.cpp src/superscalar.cpp src/vm_compiled.cpp @@ -91,7 +89,12 @@ function(add_flag flag) endfunction() # x86-64 -if (ARCH_ID STREQUAL "x86_64" OR ARCH_ID STREQUAL "x86-64" OR ARCH_ID STREQUAL "amd64") +if (CMAKE_C_COMPILER_ID MATCHES MSVC) + enable_language(ASM_MASM) + list(APPEND randomx_sources + src/jit_compiler_x86_static.asm + src/jit_compiler_x86.cpp) +elseif (ARCH_ID STREQUAL "x86_64" OR ARCH_ID STREQUAL "x86-64" OR ARCH_ID STREQUAL "amd64") list(APPEND randomx_sources src/jit_compiler_x86_static.S src/jit_compiler_x86.cpp) @@ -132,21 +135,6 @@ set_property(TARGET randomx PROPERTY POSITION_INDEPENDENT_CODE ON) set_property(TARGET randomx PROPERTY CXX_STANDARD 11) set_property(TARGET randomx PROPERTY CXX_STANDARD_REQUIRED ON) -add_executable(randomx-tests - src/tests/tests.cpp) -target_link_libraries(randomx-tests - PRIVATE randomx) -set_property(TARGET randomx-tests PROPERTY POSITION_INDEPENDENT_CODE ON) -set_property(TARGET randomx-tests PROPERTY CXX_STANDARD 11) - -add_executable(randomx-codegen - src/tests/code-generator.cpp) -target_link_libraries(randomx-codegen - PRIVATE randomx) - -set_property(TARGET randomx-codegen PROPERTY POSITION_INDEPENDENT_CODE ON) -set_property(TARGET randomx-codegen PROPERTY CXX_STANDARD 11) - if (NOT Threads_FOUND AND UNIX AND NOT APPLE) set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads) diff --git a/randomx.sln b/randomx.sln deleted file mode 100644 index 3f003b7..0000000 --- a/randomx.sln +++ /dev/null @@ -1,177 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.28307.572 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "randomx", "vcxproj\randomx.vcxproj", "{3346A4AD-C438-4324-8B77-47A16452954B}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{4A4A689F-86AF-41C0-A974-1080506D0923}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "superscalar-avalanche", "vcxproj\superscalar-avalanche.vcxproj", "{CF34A7EF-7DC9-4077-94A5-76F5425EA938}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "superscalar-init", "vcxproj\superscalar-init.vcxproj", "{E59DC709-9B12-4A53-BAF3-79398821C376}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "superscalar-stats", "vcxproj\superscalar-stats.vcxproj", "{0173D560-8C12-46B3-B467-0C6E7573AA0B}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "benchmark", "vcxproj\benchmark.vcxproj", "{1E8A2E2F-9F9F-43AA-BB19-9107FEC64A70}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "api-example1", "vcxproj\api-example1.vcxproj", "{83EA3E54-5D91-4E01-8EF6-C1E718334F83}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "api-example2", "vcxproj\api-example2.vcxproj", "{44947B9C-E6B1-4C06-BD01-F8EF43B59223}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "code-generator", "vcxproj\code-generator.vcxproj", "{3E490DEC-1874-43AA-92DA-1AC57C217EAC}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "scratchpad-entropy", "vcxproj\scratchpad-entropy.vcxproj", "{FF8BD408-AFD8-43C6-BE98-4D03B37E840B}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jit-performance", "vcxproj\jit-performance.vcxproj", "{535F2111-FA81-4C76-A354-EDD2F9AA00E3}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "perf-simulation", "vcxproj\perf-simulation.vcxproj", "{F1FC7AC0-2773-4A57-AFA7-56BB07216AA2}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "runtime-distr", "vcxproj\runtime-distr.vcxproj", "{F207EC8C-C55F-46C0-8851-887A71574F54}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "randomx-dll", "vcxproj\randomx-dll.vcxproj", "{59560AD8-18E3-463E-A941-BBD808EC7C83}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tests", "vcxproj\tests.vcxproj", "{41F3F4DF-8113-4029-9915-FDDC44C43D49}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {3346A4AD-C438-4324-8B77-47A16452954B}.Debug|x64.ActiveCfg = Debug|x64 - {3346A4AD-C438-4324-8B77-47A16452954B}.Debug|x64.Build.0 = Debug|x64 - {3346A4AD-C438-4324-8B77-47A16452954B}.Debug|x86.ActiveCfg = Debug|Win32 - {3346A4AD-C438-4324-8B77-47A16452954B}.Debug|x86.Build.0 = Debug|Win32 - {3346A4AD-C438-4324-8B77-47A16452954B}.Release|x64.ActiveCfg = Release|x64 - {3346A4AD-C438-4324-8B77-47A16452954B}.Release|x64.Build.0 = Release|x64 - {3346A4AD-C438-4324-8B77-47A16452954B}.Release|x86.ActiveCfg = Release|Win32 - {3346A4AD-C438-4324-8B77-47A16452954B}.Release|x86.Build.0 = Release|Win32 - {CF34A7EF-7DC9-4077-94A5-76F5425EA938}.Debug|x64.ActiveCfg = Debug|x64 - {CF34A7EF-7DC9-4077-94A5-76F5425EA938}.Debug|x64.Build.0 = Debug|x64 - {CF34A7EF-7DC9-4077-94A5-76F5425EA938}.Debug|x86.ActiveCfg = Debug|Win32 - {CF34A7EF-7DC9-4077-94A5-76F5425EA938}.Debug|x86.Build.0 = Debug|Win32 - {CF34A7EF-7DC9-4077-94A5-76F5425EA938}.Release|x64.ActiveCfg = Release|x64 - {CF34A7EF-7DC9-4077-94A5-76F5425EA938}.Release|x64.Build.0 = Release|x64 - {CF34A7EF-7DC9-4077-94A5-76F5425EA938}.Release|x86.ActiveCfg = Release|Win32 - {CF34A7EF-7DC9-4077-94A5-76F5425EA938}.Release|x86.Build.0 = Release|Win32 - {E59DC709-9B12-4A53-BAF3-79398821C376}.Debug|x64.ActiveCfg = Debug|x64 - {E59DC709-9B12-4A53-BAF3-79398821C376}.Debug|x64.Build.0 = Debug|x64 - {E59DC709-9B12-4A53-BAF3-79398821C376}.Debug|x86.ActiveCfg = Debug|Win32 - {E59DC709-9B12-4A53-BAF3-79398821C376}.Debug|x86.Build.0 = Debug|Win32 - {E59DC709-9B12-4A53-BAF3-79398821C376}.Release|x64.ActiveCfg = Release|x64 - {E59DC709-9B12-4A53-BAF3-79398821C376}.Release|x64.Build.0 = Release|x64 - {E59DC709-9B12-4A53-BAF3-79398821C376}.Release|x86.ActiveCfg = Release|Win32 - {E59DC709-9B12-4A53-BAF3-79398821C376}.Release|x86.Build.0 = Release|Win32 - {0173D560-8C12-46B3-B467-0C6E7573AA0B}.Debug|x64.ActiveCfg = Debug|x64 - {0173D560-8C12-46B3-B467-0C6E7573AA0B}.Debug|x64.Build.0 = Debug|x64 - {0173D560-8C12-46B3-B467-0C6E7573AA0B}.Debug|x86.ActiveCfg = Debug|Win32 - {0173D560-8C12-46B3-B467-0C6E7573AA0B}.Debug|x86.Build.0 = Debug|Win32 - {0173D560-8C12-46B3-B467-0C6E7573AA0B}.Release|x64.ActiveCfg = Release|x64 - {0173D560-8C12-46B3-B467-0C6E7573AA0B}.Release|x64.Build.0 = Release|x64 - {0173D560-8C12-46B3-B467-0C6E7573AA0B}.Release|x86.ActiveCfg = Release|Win32 - {0173D560-8C12-46B3-B467-0C6E7573AA0B}.Release|x86.Build.0 = Release|Win32 - {1E8A2E2F-9F9F-43AA-BB19-9107FEC64A70}.Debug|x64.ActiveCfg = Debug|x64 - {1E8A2E2F-9F9F-43AA-BB19-9107FEC64A70}.Debug|x64.Build.0 = Debug|x64 - {1E8A2E2F-9F9F-43AA-BB19-9107FEC64A70}.Debug|x86.ActiveCfg = Debug|Win32 - {1E8A2E2F-9F9F-43AA-BB19-9107FEC64A70}.Debug|x86.Build.0 = Debug|Win32 - {1E8A2E2F-9F9F-43AA-BB19-9107FEC64A70}.Release|x64.ActiveCfg = Release|x64 - {1E8A2E2F-9F9F-43AA-BB19-9107FEC64A70}.Release|x64.Build.0 = Release|x64 - {1E8A2E2F-9F9F-43AA-BB19-9107FEC64A70}.Release|x86.ActiveCfg = Release|Win32 - {1E8A2E2F-9F9F-43AA-BB19-9107FEC64A70}.Release|x86.Build.0 = Release|Win32 - {83EA3E54-5D91-4E01-8EF6-C1E718334F83}.Debug|x64.ActiveCfg = Debug|x64 - {83EA3E54-5D91-4E01-8EF6-C1E718334F83}.Debug|x64.Build.0 = Debug|x64 - {83EA3E54-5D91-4E01-8EF6-C1E718334F83}.Debug|x86.ActiveCfg = Debug|Win32 - {83EA3E54-5D91-4E01-8EF6-C1E718334F83}.Debug|x86.Build.0 = Debug|Win32 - {83EA3E54-5D91-4E01-8EF6-C1E718334F83}.Release|x64.ActiveCfg = Release|x64 - {83EA3E54-5D91-4E01-8EF6-C1E718334F83}.Release|x64.Build.0 = Release|x64 - {83EA3E54-5D91-4E01-8EF6-C1E718334F83}.Release|x86.ActiveCfg = Release|Win32 - {83EA3E54-5D91-4E01-8EF6-C1E718334F83}.Release|x86.Build.0 = Release|Win32 - {44947B9C-E6B1-4C06-BD01-F8EF43B59223}.Debug|x64.ActiveCfg = Debug|x64 - {44947B9C-E6B1-4C06-BD01-F8EF43B59223}.Debug|x64.Build.0 = Debug|x64 - {44947B9C-E6B1-4C06-BD01-F8EF43B59223}.Debug|x86.ActiveCfg = Debug|Win32 - {44947B9C-E6B1-4C06-BD01-F8EF43B59223}.Debug|x86.Build.0 = Debug|Win32 - {44947B9C-E6B1-4C06-BD01-F8EF43B59223}.Release|x64.ActiveCfg = Release|x64 - {44947B9C-E6B1-4C06-BD01-F8EF43B59223}.Release|x64.Build.0 = Release|x64 - {44947B9C-E6B1-4C06-BD01-F8EF43B59223}.Release|x86.ActiveCfg = Release|Win32 - {44947B9C-E6B1-4C06-BD01-F8EF43B59223}.Release|x86.Build.0 = Release|Win32 - {3E490DEC-1874-43AA-92DA-1AC57C217EAC}.Debug|x64.ActiveCfg = Debug|x64 - {3E490DEC-1874-43AA-92DA-1AC57C217EAC}.Debug|x64.Build.0 = Debug|x64 - {3E490DEC-1874-43AA-92DA-1AC57C217EAC}.Debug|x86.ActiveCfg = Debug|Win32 - {3E490DEC-1874-43AA-92DA-1AC57C217EAC}.Debug|x86.Build.0 = Debug|Win32 - {3E490DEC-1874-43AA-92DA-1AC57C217EAC}.Release|x64.ActiveCfg = Release|x64 - {3E490DEC-1874-43AA-92DA-1AC57C217EAC}.Release|x64.Build.0 = Release|x64 - {3E490DEC-1874-43AA-92DA-1AC57C217EAC}.Release|x86.ActiveCfg = Release|Win32 - {3E490DEC-1874-43AA-92DA-1AC57C217EAC}.Release|x86.Build.0 = Release|Win32 - {FF8BD408-AFD8-43C6-BE98-4D03B37E840B}.Debug|x64.ActiveCfg = Debug|x64 - {FF8BD408-AFD8-43C6-BE98-4D03B37E840B}.Debug|x64.Build.0 = Debug|x64 - {FF8BD408-AFD8-43C6-BE98-4D03B37E840B}.Debug|x86.ActiveCfg = Debug|Win32 - {FF8BD408-AFD8-43C6-BE98-4D03B37E840B}.Debug|x86.Build.0 = Debug|Win32 - {FF8BD408-AFD8-43C6-BE98-4D03B37E840B}.Release|x64.ActiveCfg = Release|x64 - {FF8BD408-AFD8-43C6-BE98-4D03B37E840B}.Release|x64.Build.0 = Release|x64 - {FF8BD408-AFD8-43C6-BE98-4D03B37E840B}.Release|x86.ActiveCfg = Release|Win32 - {FF8BD408-AFD8-43C6-BE98-4D03B37E840B}.Release|x86.Build.0 = Release|Win32 - {535F2111-FA81-4C76-A354-EDD2F9AA00E3}.Debug|x64.ActiveCfg = Debug|x64 - {535F2111-FA81-4C76-A354-EDD2F9AA00E3}.Debug|x64.Build.0 = Debug|x64 - {535F2111-FA81-4C76-A354-EDD2F9AA00E3}.Debug|x86.ActiveCfg = Debug|Win32 - {535F2111-FA81-4C76-A354-EDD2F9AA00E3}.Debug|x86.Build.0 = Debug|Win32 - {535F2111-FA81-4C76-A354-EDD2F9AA00E3}.Release|x64.ActiveCfg = Release|x64 - {535F2111-FA81-4C76-A354-EDD2F9AA00E3}.Release|x64.Build.0 = Release|x64 - {535F2111-FA81-4C76-A354-EDD2F9AA00E3}.Release|x86.ActiveCfg = Release|Win32 - {535F2111-FA81-4C76-A354-EDD2F9AA00E3}.Release|x86.Build.0 = Release|Win32 - {F1FC7AC0-2773-4A57-AFA7-56BB07216AA2}.Debug|x64.ActiveCfg = Debug|x64 - {F1FC7AC0-2773-4A57-AFA7-56BB07216AA2}.Debug|x64.Build.0 = Debug|x64 - {F1FC7AC0-2773-4A57-AFA7-56BB07216AA2}.Debug|x86.ActiveCfg = Debug|Win32 - {F1FC7AC0-2773-4A57-AFA7-56BB07216AA2}.Debug|x86.Build.0 = Debug|Win32 - {F1FC7AC0-2773-4A57-AFA7-56BB07216AA2}.Release|x64.ActiveCfg = Release|x64 - {F1FC7AC0-2773-4A57-AFA7-56BB07216AA2}.Release|x64.Build.0 = Release|x64 - {F1FC7AC0-2773-4A57-AFA7-56BB07216AA2}.Release|x86.ActiveCfg = Release|Win32 - {F1FC7AC0-2773-4A57-AFA7-56BB07216AA2}.Release|x86.Build.0 = Release|Win32 - {F207EC8C-C55F-46C0-8851-887A71574F54}.Debug|x64.ActiveCfg = Debug|x64 - {F207EC8C-C55F-46C0-8851-887A71574F54}.Debug|x64.Build.0 = Debug|x64 - {F207EC8C-C55F-46C0-8851-887A71574F54}.Debug|x86.ActiveCfg = Debug|Win32 - {F207EC8C-C55F-46C0-8851-887A71574F54}.Debug|x86.Build.0 = Debug|Win32 - {F207EC8C-C55F-46C0-8851-887A71574F54}.Release|x64.ActiveCfg = Release|x64 - {F207EC8C-C55F-46C0-8851-887A71574F54}.Release|x64.Build.0 = Release|x64 - {F207EC8C-C55F-46C0-8851-887A71574F54}.Release|x86.ActiveCfg = Release|Win32 - {F207EC8C-C55F-46C0-8851-887A71574F54}.Release|x86.Build.0 = Release|Win32 - {59560AD8-18E3-463E-A941-BBD808EC7C83}.Debug|x64.ActiveCfg = Debug|x64 - {59560AD8-18E3-463E-A941-BBD808EC7C83}.Debug|x64.Build.0 = Debug|x64 - {59560AD8-18E3-463E-A941-BBD808EC7C83}.Debug|x86.ActiveCfg = Debug|Win32 - {59560AD8-18E3-463E-A941-BBD808EC7C83}.Debug|x86.Build.0 = Debug|Win32 - {59560AD8-18E3-463E-A941-BBD808EC7C83}.Release|x64.ActiveCfg = Release|x64 - {59560AD8-18E3-463E-A941-BBD808EC7C83}.Release|x64.Build.0 = Release|x64 - {59560AD8-18E3-463E-A941-BBD808EC7C83}.Release|x86.ActiveCfg = Release|Win32 - {59560AD8-18E3-463E-A941-BBD808EC7C83}.Release|x86.Build.0 = Release|Win32 - {41F3F4DF-8113-4029-9915-FDDC44C43D49}.Debug|x64.ActiveCfg = Debug|x64 - {41F3F4DF-8113-4029-9915-FDDC44C43D49}.Debug|x64.Build.0 = Debug|x64 - {41F3F4DF-8113-4029-9915-FDDC44C43D49}.Debug|x86.ActiveCfg = Debug|Win32 - {41F3F4DF-8113-4029-9915-FDDC44C43D49}.Debug|x86.Build.0 = Debug|Win32 - {41F3F4DF-8113-4029-9915-FDDC44C43D49}.Release|x64.ActiveCfg = Release|x64 - {41F3F4DF-8113-4029-9915-FDDC44C43D49}.Release|x64.Build.0 = Release|x64 - {41F3F4DF-8113-4029-9915-FDDC44C43D49}.Release|x86.ActiveCfg = Release|Win32 - {41F3F4DF-8113-4029-9915-FDDC44C43D49}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {CF34A7EF-7DC9-4077-94A5-76F5425EA938} = {4A4A689F-86AF-41C0-A974-1080506D0923} - {E59DC709-9B12-4A53-BAF3-79398821C376} = {4A4A689F-86AF-41C0-A974-1080506D0923} - {0173D560-8C12-46B3-B467-0C6E7573AA0B} = {4A4A689F-86AF-41C0-A974-1080506D0923} - {1E8A2E2F-9F9F-43AA-BB19-9107FEC64A70} = {4A4A689F-86AF-41C0-A974-1080506D0923} - {83EA3E54-5D91-4E01-8EF6-C1E718334F83} = {4A4A689F-86AF-41C0-A974-1080506D0923} - {44947B9C-E6B1-4C06-BD01-F8EF43B59223} = {4A4A689F-86AF-41C0-A974-1080506D0923} - {3E490DEC-1874-43AA-92DA-1AC57C217EAC} = {4A4A689F-86AF-41C0-A974-1080506D0923} - {FF8BD408-AFD8-43C6-BE98-4D03B37E840B} = {4A4A689F-86AF-41C0-A974-1080506D0923} - {535F2111-FA81-4C76-A354-EDD2F9AA00E3} = {4A4A689F-86AF-41C0-A974-1080506D0923} - {F1FC7AC0-2773-4A57-AFA7-56BB07216AA2} = {4A4A689F-86AF-41C0-A974-1080506D0923} - {F207EC8C-C55F-46C0-8851-887A71574F54} = {4A4A689F-86AF-41C0-A974-1080506D0923} - {41F3F4DF-8113-4029-9915-FDDC44C43D49} = {4A4A689F-86AF-41C0-A974-1080506D0923} - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {4EBC03DB-AE37-4141-8147-692F16E0ED02} - EndGlobalSection -EndGlobal diff --git a/src/assembly_generator_x86.cpp b/src/assembly_generator_x86.cpp deleted file mode 100644 index a5082e1..0000000 --- a/src/assembly_generator_x86.cpp +++ /dev/null @@ -1,577 +0,0 @@ -/* -Copyright (c) 2018-2019, tevador - -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 holder 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 HOLDER 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. -*/ - -#include -#include "assembly_generator_x86.hpp" -#include "common.hpp" -#include "reciprocal.h" -#include "program.hpp" -#include "superscalar.hpp" - -namespace randomx { - - static const char* regR[] = { "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15" }; - static const char* regR32[] = { "r8d", "r9d", "r10d", "r11d", "r12d", "r13d", "r14d", "r15d" }; - static const char* regFE[] = { "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7" }; - static const char* regF[] = { "xmm0", "xmm1", "xmm2", "xmm3" }; - static const char* regE[] = { "xmm4", "xmm5", "xmm6", "xmm7" }; - static const char* regA[] = { "xmm8", "xmm9", "xmm10", "xmm11" }; - - static const char* tempRegx = "xmm12"; - static const char* mantissaMaskReg = "xmm13"; - static const char* exponentMaskReg = "xmm14"; - static const char* scaleMaskReg = "xmm15"; - static const char* regIc = "rbx"; - static const char* regIc32 = "ebx"; - static const char* regIc8 = "bl"; - static const char* regScratchpadAddr = "rsi"; - - void AssemblyGeneratorX86::generateProgram(Program& prog) { - for (unsigned i = 0; i < RegistersCount; ++i) { - registerUsage[i] = -1; - } - asmCode.str(std::string()); //clear - for (unsigned i = 0; i < prog.getSize(); ++i) { - asmCode << "randomx_isn_" << i << ":" << std::endl; - Instruction& instr = prog(i); - instr.src %= RegistersCount; - instr.dst %= RegistersCount; - generateCode(instr, i); - } - } - - void AssemblyGeneratorX86::generateAsm(SuperscalarProgram& prog) { - asmCode.str(std::string()); //clear -#ifdef RANDOMX_ALIGN - asmCode << "ALIGN 16" << std::endl; -#endif - for (unsigned i = 0; i < prog.getSize(); ++i) { - Instruction& instr = prog(i); - switch ((SuperscalarInstructionType)instr.opcode) - { - case SuperscalarInstructionType::ISUB_R: - asmCode << "sub " << regR[instr.dst] << ", " << regR[instr.src] << std::endl; - break; - case SuperscalarInstructionType::IXOR_R: - asmCode << "xor " << regR[instr.dst] << ", " << regR[instr.src] << std::endl; - break; - case SuperscalarInstructionType::IADD_RS: - asmCode << "lea " << regR[instr.dst] << ", [" << regR[instr.dst] << "+" << regR[instr.src] << "*" << (1 << (instr.getModShift())) << "]" << std::endl; - break; - case SuperscalarInstructionType::IMUL_R: - asmCode << "imul " << regR[instr.dst] << ", " << regR[instr.src] << std::endl; - break; - case SuperscalarInstructionType::IROR_C: - asmCode << "ror " << regR[instr.dst] << ", " << instr.getImm32() << std::endl; - break; - case SuperscalarInstructionType::IADD_C7: - asmCode << "add " << regR[instr.dst] << ", " << (int32_t)instr.getImm32() << std::endl; - break; - case SuperscalarInstructionType::IXOR_C7: - asmCode << "xor " << regR[instr.dst] << ", " << (int32_t)instr.getImm32() << std::endl; - break; - case SuperscalarInstructionType::IADD_C8: - asmCode << "add " << regR[instr.dst] << ", " << (int32_t)instr.getImm32() << std::endl; -#ifdef RANDOMX_ALIGN - asmCode << "nop" << std::endl; -#endif - break; - case SuperscalarInstructionType::IXOR_C8: - asmCode << "xor " << regR[instr.dst] << ", " << (int32_t)instr.getImm32() << std::endl; -#ifdef RANDOMX_ALIGN - asmCode << "nop" << std::endl; -#endif - break; - case SuperscalarInstructionType::IADD_C9: - asmCode << "add " << regR[instr.dst] << ", " << (int32_t)instr.getImm32() << std::endl; -#ifdef RANDOMX_ALIGN - asmCode << "xchg ax, ax ;nop" << std::endl; -#endif - break; - case SuperscalarInstructionType::IXOR_C9: - asmCode << "xor " << regR[instr.dst] << ", " << (int32_t)instr.getImm32() << std::endl; -#ifdef RANDOMX_ALIGN - asmCode << "xchg ax, ax ;nop" << std::endl; -#endif - break; - case SuperscalarInstructionType::IMULH_R: - asmCode << "mov rax, " << regR[instr.dst] << std::endl; - asmCode << "mul " << regR[instr.src] << std::endl; - asmCode << "mov " << regR[instr.dst] << ", rdx" << std::endl; - break; - case SuperscalarInstructionType::ISMULH_R: - asmCode << "mov rax, " << regR[instr.dst] << std::endl; - asmCode << "imul " << regR[instr.src] << std::endl; - asmCode << "mov " << regR[instr.dst] << ", rdx" << std::endl; - break; - case SuperscalarInstructionType::IMUL_RCP: - asmCode << "mov rax, " << (int64_t)randomx_reciprocal(instr.getImm32()) << std::endl; - asmCode << "imul " << regR[instr.dst] << ", rax" << std::endl; - break; - default: - UNREACHABLE; - } - } - } - - void AssemblyGeneratorX86::generateC(SuperscalarProgram& prog) { - asmCode.str(std::string()); //clear - asmCode << "#include " << std::endl; - asmCode << "#if defined(__SIZEOF_INT128__)" << std::endl; - asmCode << " static inline uint64_t mulh(uint64_t a, uint64_t b) {" << std::endl; - asmCode << " return ((unsigned __int128)a * b) >> 64;" << std::endl; - asmCode << " }" << std::endl; - asmCode << " static inline int64_t smulh(int64_t a, int64_t b) {" << std::endl; - asmCode << " return ((__int128)a * b) >> 64;" << std::endl; - asmCode << " }" << std::endl; - asmCode << " #define HAVE_MULH" << std::endl; - asmCode << " #define HAVE_SMULH" << std::endl; - asmCode << "#endif" << std::endl; - asmCode << "#if defined(_MSC_VER)" << std::endl; - asmCode << " #define HAS_VALUE(X) X ## 0" << std::endl; - asmCode << " #define EVAL_DEFINE(X) HAS_VALUE(X)" << std::endl; - asmCode << " #include " << std::endl; - asmCode << " #include " << std::endl; - asmCode << " static __inline uint64_t rotr(uint64_t x , int c) {" << std::endl; - asmCode << " return _rotr64(x, c);" << std::endl; - asmCode << " }" << std::endl; - asmCode << " #define HAVE_ROTR" << std::endl; - asmCode << " #if EVAL_DEFINE(__MACHINEARM64_X64(1))" << std::endl; - asmCode << " static __inline uint64_t mulh(uint64_t a, uint64_t b) {" << std::endl; - asmCode << " return __umulh(a, b);" << std::endl; - asmCode << " }" << std::endl; - asmCode << " #define HAVE_MULH" << std::endl; - asmCode << " #endif" << std::endl; - asmCode << " #if EVAL_DEFINE(__MACHINEX64(1))" << std::endl; - asmCode << " static __inline int64_t smulh(int64_t a, int64_t b) {" << std::endl; - asmCode << " int64_t hi;" << std::endl; - asmCode << " _mul128(a, b, &hi);" << std::endl; - asmCode << " return hi;" << std::endl; - asmCode << " }" << std::endl; - asmCode << " #define HAVE_SMULH" << std::endl; - asmCode << " #endif" << std::endl; - asmCode << "#endif" << std::endl; - asmCode << "#ifndef HAVE_ROTR" << std::endl; - asmCode << " static inline uint64_t rotr(uint64_t a, int b) {" << std::endl; - asmCode << " return (a >> b) | (a << (64 - b));" << std::endl; - asmCode << " }" << std::endl; - asmCode << " #define HAVE_ROTR" << std::endl; - asmCode << "#endif" << std::endl; - asmCode << "#if !defined(HAVE_MULH) || !defined(HAVE_SMULH) || !defined(HAVE_ROTR)" << std::endl; - asmCode << " #error \"Required functions are not defined\"" << std::endl; - asmCode << "#endif" << std::endl; - asmCode << "void superScalar(uint64_t r[8]) {" << std::endl; - asmCode << "uint64_t r8 = r[0], r9 = r[1], r10 = r[2], r11 = r[3], r12 = r[4], r13 = r[5], r14 = r[6], r15 = r[7];" << std::endl; - for (unsigned i = 0; i < prog.getSize(); ++i) { - Instruction& instr = prog(i); - switch ((SuperscalarInstructionType)instr.opcode) - { - case SuperscalarInstructionType::ISUB_R: - asmCode << regR[instr.dst] << " -= " << regR[instr.src] << ";" << std::endl; - break; - case SuperscalarInstructionType::IXOR_R: - asmCode << regR[instr.dst] << " ^= " << regR[instr.src] << ";" << std::endl; - break; - case SuperscalarInstructionType::IADD_RS: - asmCode << regR[instr.dst] << " += " << regR[instr.src] << "*" << (1 << (instr.getModShift())) << ";" << std::endl; - break; - case SuperscalarInstructionType::IMUL_R: - asmCode << regR[instr.dst] << " *= " << regR[instr.src] << ";" << std::endl; - break; - case SuperscalarInstructionType::IROR_C: - asmCode << regR[instr.dst] << " = rotr(" << regR[instr.dst] << ", " << instr.getImm32() << ");" << std::endl; - break; - case SuperscalarInstructionType::IADD_C7: - case SuperscalarInstructionType::IADD_C8: - case SuperscalarInstructionType::IADD_C9: - asmCode << regR[instr.dst] << " += " << (int32_t)instr.getImm32() << ";" << std::endl; - break; - case SuperscalarInstructionType::IXOR_C7: - case SuperscalarInstructionType::IXOR_C8: - case SuperscalarInstructionType::IXOR_C9: - asmCode << regR[instr.dst] << " ^= " << (int32_t)instr.getImm32() << ";" << std::endl; - break; - case SuperscalarInstructionType::IMULH_R: - asmCode << regR[instr.dst] << " = mulh(" << regR[instr.dst] << ", " << regR[instr.src] << ");" << std::endl; - break; - case SuperscalarInstructionType::ISMULH_R: - asmCode << regR[instr.dst] << " = smulh(" << regR[instr.dst] << ", " << regR[instr.src] << ");" << std::endl; - break; - case SuperscalarInstructionType::IMUL_RCP: - asmCode << regR[instr.dst] << " *= " << (int64_t)randomx_reciprocal(instr.getImm32()) << ";" << std::endl; - break; - default: - UNREACHABLE; - } - } - asmCode << "r[0] = r8; r[1] = r9; r[2] = r10; r[3] = r11; r[4] = r12; r[5] = r13; r[6] = r14; r[7] = r15;" << std::endl; - asmCode << "}" << std::endl; - } - - void AssemblyGeneratorX86::traceint(Instruction& instr) { - if (trace) { - asmCode << "\tpush " << regR[instr.dst] << std::endl; - } - } - - void AssemblyGeneratorX86::traceflt(Instruction& instr) { - if (trace) { - asmCode << "\tpush 0" << std::endl; - } - } - - void AssemblyGeneratorX86::tracenop(Instruction& instr) { - if (trace) { - asmCode << "\tpush 0" << std::endl; - } - } - - void AssemblyGeneratorX86::generateCode(Instruction& instr, int i) { - asmCode << "\t; " << instr; - auto generator = engine[instr.opcode]; - (this->*generator)(instr, i); - } - - void AssemblyGeneratorX86::genAddressReg(Instruction& instr, const char* reg = "eax") { - asmCode << "\tlea " << reg << ", [" << regR32[instr.src] << std::showpos << (int32_t)instr.getImm32() << std::noshowpos << "]" << std::endl; - asmCode << "\tand " << reg << ", " << ((instr.getModMem()) ? ScratchpadL1Mask : ScratchpadL2Mask) << std::endl; - } - - void AssemblyGeneratorX86::genAddressRegDst(Instruction& instr, int maskAlign = 8) { - asmCode << "\tlea eax, [" << regR32[instr.dst] << std::showpos << (int32_t)instr.getImm32() << std::noshowpos << "]" << std::endl; - int mask; - if (instr.getModCond() < StoreL3Condition) { - mask = instr.getModMem() ? ScratchpadL1Mask : ScratchpadL2Mask; - } - else { - mask = ScratchpadL3Mask; - } - asmCode << "\tand eax" << ", " << (mask & (-maskAlign)) << std::endl; - } - - int32_t AssemblyGeneratorX86::genAddressImm(Instruction& instr) { - return (int32_t)instr.getImm32() & ScratchpadL3Mask; - } - - void AssemblyGeneratorX86::h_IADD_RS(Instruction& instr, int i) { - registerUsage[instr.dst] = i; - if(instr.dst == RegisterNeedsDisplacement) - asmCode << "\tlea " << regR[instr.dst] << ", [" << regR[instr.dst] << "+" << regR[instr.src] << "*" << (1 << (instr.getModShift())) << std::showpos << (int32_t)instr.getImm32() << std::noshowpos << "]" << std::endl; - else - asmCode << "\tlea " << regR[instr.dst] << ", [" << regR[instr.dst] << "+" << regR[instr.src] << "*" << (1 << (instr.getModShift())) << "]" << std::endl; - traceint(instr); - } - - void AssemblyGeneratorX86::h_IADD_M(Instruction& instr, int i) { - registerUsage[instr.dst] = i; - if (instr.src != instr.dst) { - genAddressReg(instr); - asmCode << "\tadd " << regR[instr.dst] << ", qword ptr [" << regScratchpadAddr << "+rax]" << std::endl; - } - else { - asmCode << "\tadd " << regR[instr.dst] << ", qword ptr [" << regScratchpadAddr << "+" << genAddressImm(instr) << "]" << std::endl; - } - traceint(instr); - } - - void AssemblyGeneratorX86::h_ISUB_R(Instruction& instr, int i) { - registerUsage[instr.dst] = i; - if (instr.src != instr.dst) { - asmCode << "\tsub " << regR[instr.dst] << ", " << regR[instr.src] << std::endl; - } - else { - asmCode << "\tsub " << regR[instr.dst] << ", " << (int32_t)instr.getImm32() << std::endl; - } - traceint(instr); - } - - void AssemblyGeneratorX86::h_ISUB_M(Instruction& instr, int i) { - registerUsage[instr.dst] = i; - if (instr.src != instr.dst) { - genAddressReg(instr); - asmCode << "\tsub " << regR[instr.dst] << ", qword ptr [" << regScratchpadAddr << "+rax]" << std::endl; - } - else { - asmCode << "\tsub " << regR[instr.dst] << ", qword ptr [" << regScratchpadAddr << "+" << genAddressImm(instr) << "]" << std::endl; - } - traceint(instr); - } - - void AssemblyGeneratorX86::h_IMUL_R(Instruction& instr, int i) { - registerUsage[instr.dst] = i; - if (instr.src != instr.dst) { - asmCode << "\timul " << regR[instr.dst] << ", " << regR[instr.src] << std::endl; - } - else { - asmCode << "\timul " << regR[instr.dst] << ", " << (int32_t)instr.getImm32() << std::endl; - } - traceint(instr); - } - - void AssemblyGeneratorX86::h_IMUL_M(Instruction& instr, int i) { - registerUsage[instr.dst] = i; - if (instr.src != instr.dst) { - genAddressReg(instr); - asmCode << "\timul " << regR[instr.dst] << ", qword ptr [" << regScratchpadAddr << "+rax]" << std::endl; - } - else { - asmCode << "\timul " << regR[instr.dst] << ", qword ptr [" << regScratchpadAddr << "+" << genAddressImm(instr) << "]" << std::endl; - } - traceint(instr); - } - - void AssemblyGeneratorX86::h_IMULH_R(Instruction& instr, int i) { - registerUsage[instr.dst] = i; - asmCode << "\tmov rax, " << regR[instr.dst] << std::endl; - asmCode << "\tmul " << regR[instr.src] << std::endl; - asmCode << "\tmov " << regR[instr.dst] << ", rdx" << std::endl; - traceint(instr); - } - - void AssemblyGeneratorX86::h_IMULH_M(Instruction& instr, int i) { - registerUsage[instr.dst] = i; - if (instr.src != instr.dst) { - genAddressReg(instr, "ecx"); - asmCode << "\tmov rax, " << regR[instr.dst] << std::endl; - asmCode << "\tmul qword ptr [" << regScratchpadAddr << "+rcx]" << std::endl; - } - else { - asmCode << "\tmov rax, " << regR[instr.dst] << std::endl; - asmCode << "\tmul qword ptr [" << regScratchpadAddr << "+" << genAddressImm(instr) << "]" << std::endl; - } - asmCode << "\tmov " << regR[instr.dst] << ", rdx" << std::endl; - traceint(instr); - } - - void AssemblyGeneratorX86::h_ISMULH_R(Instruction& instr, int i) { - registerUsage[instr.dst] = i; - asmCode << "\tmov rax, " << regR[instr.dst] << std::endl; - asmCode << "\timul " << regR[instr.src] << std::endl; - asmCode << "\tmov " << regR[instr.dst] << ", rdx" << std::endl; - traceint(instr); - } - - void AssemblyGeneratorX86::h_ISMULH_M(Instruction& instr, int i) { - registerUsage[instr.dst] = i; - if (instr.src != instr.dst) { - genAddressReg(instr, "ecx"); - asmCode << "\tmov rax, " << regR[instr.dst] << std::endl; - asmCode << "\timul qword ptr [" << regScratchpadAddr << "+rcx]" << std::endl; - } - else { - asmCode << "\tmov rax, " << regR[instr.dst] << std::endl; - asmCode << "\timul qword ptr [" << regScratchpadAddr << "+" << genAddressImm(instr) << "]" << std::endl; - } - asmCode << "\tmov " << regR[instr.dst] << ", rdx" << std::endl; - traceint(instr); - } - - void AssemblyGeneratorX86::h_INEG_R(Instruction& instr, int i) { - registerUsage[instr.dst] = i; - asmCode << "\tneg " << regR[instr.dst] << std::endl; - traceint(instr); - } - - void AssemblyGeneratorX86::h_IXOR_R(Instruction& instr, int i) { - registerUsage[instr.dst] = i; - if (instr.src != instr.dst) { - asmCode << "\txor " << regR[instr.dst] << ", " << regR[instr.src] << std::endl; - } - else { - asmCode << "\txor " << regR[instr.dst] << ", " << (int32_t)instr.getImm32() << std::endl; - } - traceint(instr); - } - - void AssemblyGeneratorX86::h_IXOR_M(Instruction& instr, int i) { - registerUsage[instr.dst] = i; - if (instr.src != instr.dst) { - genAddressReg(instr); - asmCode << "\txor " << regR[instr.dst] << ", qword ptr [" << regScratchpadAddr << "+rax]" << std::endl; - } - else { - asmCode << "\txor " << regR[instr.dst] << ", qword ptr [" << regScratchpadAddr << "+" << genAddressImm(instr) << "]" << std::endl; - } - traceint(instr); - } - - void AssemblyGeneratorX86::h_IROR_R(Instruction& instr, int i) { - registerUsage[instr.dst] = i; - if (instr.src != instr.dst) { - asmCode << "\tmov ecx, " << regR32[instr.src] << std::endl; - asmCode << "\tror " << regR[instr.dst] << ", cl" << std::endl; - } - else { - asmCode << "\tror " << regR[instr.dst] << ", " << (instr.getImm32() & 63) << std::endl; - } - traceint(instr); - } - - void AssemblyGeneratorX86::h_IROL_R(Instruction& instr, int i) { - registerUsage[instr.dst] = i; - if (instr.src != instr.dst) { - asmCode << "\tmov ecx, " << regR32[instr.src] << std::endl; - asmCode << "\trol " << regR[instr.dst] << ", cl" << std::endl; - } - else { - asmCode << "\trol " << regR[instr.dst] << ", " << (instr.getImm32() & 63) << std::endl; - } - traceint(instr); - } - - void AssemblyGeneratorX86::h_IMUL_RCP(Instruction& instr, int i) { - uint64_t divisor = instr.getImm32(); - if (!isPowerOf2(divisor)) { - registerUsage[instr.dst] = i; - asmCode << "\tmov rax, " << randomx_reciprocal(divisor) << std::endl; - asmCode << "\timul " << regR[instr.dst] << ", rax" << std::endl; - traceint(instr); - } - else { - tracenop(instr); - } - } - - void AssemblyGeneratorX86::h_ISWAP_R(Instruction& instr, int i) { - if (instr.src != instr.dst) { - registerUsage[instr.dst] = i; - registerUsage[instr.src] = i; - asmCode << "\txchg " << regR[instr.dst] << ", " << regR[instr.src] << std::endl; - traceint(instr); - } - else { - tracenop(instr); - } - } - - void AssemblyGeneratorX86::h_FSWAP_R(Instruction& instr, int i) { - asmCode << "\tshufpd " << regFE[instr.dst] << ", " << regFE[instr.dst] << ", 1" << std::endl; - traceflt(instr); - } - - void AssemblyGeneratorX86::h_FADD_R(Instruction& instr, int i) { - instr.dst %= RegisterCountFlt; - instr.src %= RegisterCountFlt; - asmCode << "\taddpd " << regF[instr.dst] << ", " << regA[instr.src] << std::endl; - traceflt(instr); - } - - void AssemblyGeneratorX86::h_FADD_M(Instruction& instr, int i) { - instr.dst %= RegisterCountFlt; - genAddressReg(instr); - asmCode << "\tcvtdq2pd " << tempRegx << ", qword ptr [" << regScratchpadAddr << "+rax]" << std::endl; - asmCode << "\taddpd " << regF[instr.dst] << ", " << tempRegx << std::endl; - traceflt(instr); - } - - void AssemblyGeneratorX86::h_FSUB_R(Instruction& instr, int i) { - instr.dst %= RegisterCountFlt; - instr.src %= RegisterCountFlt; - asmCode << "\tsubpd " << regF[instr.dst] << ", " << regA[instr.src] << std::endl; - traceflt(instr); - } - - void AssemblyGeneratorX86::h_FSUB_M(Instruction& instr, int i) { - instr.dst %= RegisterCountFlt; - genAddressReg(instr); - asmCode << "\tcvtdq2pd " << tempRegx << ", qword ptr [" << regScratchpadAddr << "+rax]" << std::endl; - asmCode << "\tsubpd " << regF[instr.dst] << ", " << tempRegx << std::endl; - traceflt(instr); - } - - void AssemblyGeneratorX86::h_FSCAL_R(Instruction& instr, int i) { - instr.dst %= RegisterCountFlt; - asmCode << "\txorps " << regF[instr.dst] << ", " << scaleMaskReg << std::endl; - traceflt(instr); - } - - void AssemblyGeneratorX86::h_FMUL_R(Instruction& instr, int i) { - instr.dst %= RegisterCountFlt; - instr.src %= RegisterCountFlt; - asmCode << "\tmulpd " << regE[instr.dst] << ", " << regA[instr.src] << std::endl; - traceflt(instr); - } - - void AssemblyGeneratorX86::h_FDIV_M(Instruction& instr, int i) { - instr.dst %= RegisterCountFlt; - genAddressReg(instr); - asmCode << "\tcvtdq2pd " << tempRegx << ", qword ptr [" << regScratchpadAddr << "+rax]" << std::endl; - asmCode << "\tandps " << tempRegx << ", " << mantissaMaskReg << std::endl; - asmCode << "\torps " << tempRegx << ", " << exponentMaskReg << std::endl; - asmCode << "\tdivpd " << regE[instr.dst] << ", " << tempRegx << std::endl; - traceflt(instr); - } - - void AssemblyGeneratorX86::h_FSQRT_R(Instruction& instr, int i) { - instr.dst %= RegisterCountFlt; - asmCode << "\tsqrtpd " << regE[instr.dst] << ", " << regE[instr.dst] << std::endl; - traceflt(instr); - } - - void AssemblyGeneratorX86::h_CFROUND(Instruction& instr, int i) { - asmCode << "\tmov rax, " << regR[instr.src] << std::endl; - int rotate = (13 - (instr.getImm32() & 63)) & 63; - if (rotate != 0) - asmCode << "\trol rax, " << rotate << std::endl; - asmCode << "\tand eax, 24576" << std::endl; - asmCode << "\tor eax, 40896" << std::endl; - asmCode << "\tpush rax" << std::endl; - asmCode << "\tldmxcsr dword ptr [rsp]" << std::endl; - asmCode << "\tpop rax" << std::endl; - tracenop(instr); - } - - void AssemblyGeneratorX86::h_CBRANCH(Instruction& instr, int i) { - int reg = instr.dst; - int target = registerUsage[reg] + 1; - int shift = instr.getModCond() + RandomX_CurrentConfig.JumpOffset; - int32_t imm = instr.getImm32() | (1L << shift); - if (RandomX_CurrentConfig.JumpOffset > 0 || shift > 0) - imm &= ~(1L << (shift - 1)); - asmCode << "\tadd " << regR[reg] << ", " << imm << std::endl; - asmCode << "\ttest " << regR[reg] << ", " << (RandomX_CurrentConfig.ConditionMask_Calculated << shift) << std::endl; - asmCode << "\tjz randomx_isn_" << target << std::endl; - //mark all registers as used - for (unsigned j = 0; j < RegistersCount; ++j) { - registerUsage[j] = i; - } - } - - void AssemblyGeneratorX86::h_ISTORE(Instruction& instr, int i) { - genAddressRegDst(instr); - asmCode << "\tmov qword ptr [" << regScratchpadAddr << "+rax], " << regR[instr.src] << std::endl; - tracenop(instr); - } - - void AssemblyGeneratorX86::h_NOP(Instruction& instr, int i) { - asmCode << "\tnop" << std::endl; - tracenop(instr); - } - - InstructionGenerator AssemblyGeneratorX86::engine[256] = {}; -} diff --git a/src/assembly_generator_x86.hpp b/src/assembly_generator_x86.hpp deleted file mode 100644 index 11966d8..0000000 --- a/src/assembly_generator_x86.hpp +++ /dev/null @@ -1,94 +0,0 @@ -/* -Copyright (c) 2018-2019, tevador - -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 holder 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 HOLDER 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. -*/ - -#pragma once - -#include "common.hpp" -#include - -namespace randomx { - - class Program; - class SuperscalarProgram; - class AssemblyGeneratorX86; - class Instruction; - - typedef void(AssemblyGeneratorX86::*InstructionGenerator)(Instruction&, int); - - class AssemblyGeneratorX86 { - public: - void generateProgram(Program& prog); - void generateAsm(SuperscalarProgram& prog); - void generateC(SuperscalarProgram& prog); - void printCode(std::ostream& os) { - os << asmCode.rdbuf(); - } - - void genAddressReg(Instruction&, const char*); - void genAddressRegDst(Instruction&, int); - int32_t genAddressImm(Instruction&); - void generateCode(Instruction&, int); - void traceint(Instruction&); - void traceflt(Instruction&); - void tracenop(Instruction&); - void h_IADD_RS(Instruction&, int); - void h_IADD_M(Instruction&, int); - void h_ISUB_R(Instruction&, int); - void h_ISUB_M(Instruction&, int); - void h_IMUL_R(Instruction&, int); - void h_IMUL_M(Instruction&, int); - void h_IMULH_R(Instruction&, int); - void h_IMULH_M(Instruction&, int); - void h_ISMULH_R(Instruction&, int); - void h_ISMULH_M(Instruction&, int); - void h_IMUL_RCP(Instruction&, int); - void h_INEG_R(Instruction&, int); - void h_IXOR_R(Instruction&, int); - void h_IXOR_M(Instruction&, int); - void h_IROR_R(Instruction&, int); - void h_IROL_R(Instruction&, int); - void h_ISWAP_R(Instruction&, int); - void h_FSWAP_R(Instruction&, int); - void h_FADD_R(Instruction&, int); - void h_FADD_M(Instruction&, int); - void h_FSUB_R(Instruction&, int); - void h_FSUB_M(Instruction&, int); - void h_FSCAL_R(Instruction&, int); - void h_FMUL_R(Instruction&, int); - void h_FDIV_M(Instruction&, int); - void h_FSQRT_R(Instruction&, int); - void h_CBRANCH(Instruction&, int); - void h_CFROUND(Instruction&, int); - void h_ISTORE(Instruction&, int); - void h_NOP(Instruction&, int); - - static InstructionGenerator engine[256]; - std::stringstream asmCode; - int registerUsage[RegistersCount]; - }; -} \ No newline at end of file diff --git a/src/configuration.h b/src/configuration.h index eade696..678cb2f 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -40,5 +40,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Increase it if some configs use larger dataset #define RANDOMX_DATASET_MAX_SIZE 2181038080 +// Increase it if some configs use larger programs +#define RANDOMX_PROGRAM_MAX_SIZE 512 + // Increase it if some configs use larger scratchpad #define RANDOMX_SCRATCHPAD_L3_MAX_SIZE 2097152 diff --git a/src/instruction.cpp b/src/instruction.cpp deleted file mode 100644 index ed7e2cf..0000000 --- a/src/instruction.cpp +++ /dev/null @@ -1,323 +0,0 @@ -/* -Copyright (c) 2018-2019, tevador - -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 holder 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 HOLDER 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. -*/ - -#include "instruction.hpp" -#include "common.hpp" - -namespace randomx { - - void Instruction::print(std::ostream& os) const { - os << names[opcode] << " "; - auto handler = engine[opcode]; - (this->*handler)(os); - } - - void Instruction::genAddressReg(std::ostream& os, int srcIndex) const { - os << (getModMem() ? "L1" : "L2") << "[r" << srcIndex << std::showpos << (int32_t)getImm32() << std::noshowpos << "]"; - } - - void Instruction::genAddressRegDst(std::ostream& os, int dstIndex) const { - if (getModCond() < StoreL3Condition) - os << (getModMem() ? "L1" : "L2"); - else - os << "L3"; - os << "[r" << dstIndex << std::showpos << (int32_t)getImm32() << std::noshowpos << "]"; - } - - void Instruction::genAddressImm(std::ostream& os) const { - os << "L3" << "[" << (getImm32() & ScratchpadL3Mask) << "]"; - } - - void Instruction::h_IADD_RS(std::ostream& os) const { - auto dstIndex = dst % RegistersCount; - auto srcIndex = src % RegistersCount; - os << "r" << dstIndex << ", r" << srcIndex; - if(dstIndex == RegisterNeedsDisplacement) { - os << ", " << (int32_t)getImm32(); - } - os << ", SHFT " << getModShift() << std::endl; - } - - void Instruction::h_IADD_M(std::ostream& os) const { - auto dstIndex = dst % RegistersCount; - auto srcIndex = src % RegistersCount; - if (dstIndex != srcIndex) { - os << "r" << dstIndex << ", "; - genAddressReg(os, srcIndex); - os << std::endl; - } - else { - os << "r" << dstIndex << ", "; - genAddressImm(os); - os << std::endl; - } - } - - void Instruction::h_ISUB_R(std::ostream& os) const { - auto dstIndex = dst % RegistersCount; - auto srcIndex = src % RegistersCount; - if (dstIndex != srcIndex) { - os << "r" << dstIndex << ", r" << srcIndex << std::endl; - } - else { - os << "r" << dstIndex << ", " << (int32_t)getImm32() << std::endl; - } - } - - void Instruction::h_ISUB_M(std::ostream& os) const { - auto dstIndex = dst % RegistersCount; - auto srcIndex = src % RegistersCount; - if (dstIndex != srcIndex) { - os << "r" << dstIndex << ", "; - genAddressReg(os, srcIndex); - os << std::endl; - } - else { - os << "r" << dstIndex << ", "; - genAddressImm(os); - os << std::endl; - } - } - - void Instruction::h_IMUL_R(std::ostream& os) const { - auto dstIndex = dst % RegistersCount; - auto srcIndex = src % RegistersCount; - if (dstIndex != srcIndex) { - os << "r" << dstIndex << ", r" << srcIndex << std::endl; - } - else { - os << "r" << dstIndex << ", " << (int32_t)getImm32() << std::endl; - } - } - - void Instruction::h_IMUL_M(std::ostream& os) const { - auto dstIndex = dst % RegistersCount; - auto srcIndex = src % RegistersCount; - if (dstIndex != srcIndex) { - os << "r" << dstIndex << ", "; - genAddressReg(os, srcIndex); - os << std::endl; - } - else { - os << "r" << dstIndex << ", "; - genAddressImm(os); - os << std::endl; - } - } - - void Instruction::h_IMULH_R(std::ostream& os) const { - auto dstIndex = dst % RegistersCount; - auto srcIndex = src % RegistersCount; - os << "r" << dstIndex << ", r" << srcIndex << std::endl; - } - - void Instruction::h_IMULH_M(std::ostream& os) const { - auto dstIndex = dst % RegistersCount; - auto srcIndex = src % RegistersCount; - if (dstIndex != srcIndex) { - os << "r" << dstIndex << ", "; - genAddressReg(os, srcIndex); - os << std::endl; - } - else { - os << "r" << dstIndex << ", "; - genAddressImm(os); - os << std::endl; - } - } - - void Instruction::h_ISMULH_R(std::ostream& os) const { - auto dstIndex = dst % RegistersCount; - auto srcIndex = src % RegistersCount; - os << "r" << dstIndex << ", r" << srcIndex << std::endl; - } - - void Instruction::h_ISMULH_M(std::ostream& os) const { - auto dstIndex = dst % RegistersCount; - auto srcIndex = src % RegistersCount; - if (dstIndex != srcIndex) { - os << "r" << dstIndex << ", "; - genAddressReg(os, srcIndex); - os << std::endl; - } - else { - os << "r" << dstIndex << ", "; - genAddressImm(os); - os << std::endl; - } - } - - void Instruction::h_INEG_R(std::ostream& os) const { - auto dstIndex = dst % RegistersCount; - os << "r" << dstIndex << std::endl; - } - - void Instruction::h_IXOR_R(std::ostream& os) const { - auto dstIndex = dst % RegistersCount; - auto srcIndex = src % RegistersCount; - if (dstIndex != srcIndex) { - os << "r" << dstIndex << ", r" << srcIndex << std::endl; - } - else { - os << "r" << dstIndex << ", " << (int32_t)getImm32() << std::endl; - } - } - - void Instruction::h_IXOR_M(std::ostream& os) const { - auto dstIndex = dst % RegistersCount; - auto srcIndex = src % RegistersCount; - if (dstIndex != srcIndex) { - os << "r" << dstIndex << ", "; - genAddressReg(os, srcIndex); - os << std::endl; - } - else { - os << "r" << dstIndex << ", "; - genAddressImm(os); - os << std::endl; - } - } - - void Instruction::h_IROR_R(std::ostream& os) const { - auto dstIndex = dst % RegistersCount; - auto srcIndex = src % RegistersCount; - if (dstIndex != srcIndex) { - os << "r" << dstIndex << ", r" << srcIndex << std::endl; - } - else { - os << "r" << dstIndex << ", " << (getImm32() & 63) << std::endl; - } - } - - void Instruction::h_IROL_R(std::ostream& os) const { - auto dstIndex = dst % RegistersCount; - auto srcIndex = src % RegistersCount; - if (dstIndex != srcIndex) { - os << "r" << dstIndex << ", r" << srcIndex << std::endl; - } - else { - os << "r" << dstIndex << ", " << (getImm32() & 63) << std::endl; - } - } - - void Instruction::h_IMUL_RCP(std::ostream& os) const { - auto dstIndex = dst % RegistersCount; - os << "r" << dstIndex << ", " << getImm32() << std::endl; - } - - void Instruction::h_ISWAP_R(std::ostream& os) const { - auto dstIndex = dst % RegistersCount; - auto srcIndex = src % RegistersCount; - os << "r" << dstIndex << ", r" << srcIndex << std::endl; - } - - void Instruction::h_FSWAP_R(std::ostream& os) const { - auto dstIndex = dst % RegistersCount; - const char reg = (dstIndex >= RegisterCountFlt) ? 'e' : 'f'; - dstIndex %= RegisterCountFlt; - os << reg << dstIndex << std::endl; - } - - void Instruction::h_FADD_R(std::ostream& os) const { - auto dstIndex = dst % RegisterCountFlt; - auto srcIndex = src % RegisterCountFlt; - os << "f" << dstIndex << ", a" << srcIndex << std::endl; - } - - void Instruction::h_FADD_M(std::ostream& os) const { - auto dstIndex = dst % RegisterCountFlt; - auto srcIndex = src % RegistersCount; - os << "f" << dstIndex << ", "; - genAddressReg(os, srcIndex); - os << std::endl; - } - - void Instruction::h_FSUB_R(std::ostream& os) const { - auto dstIndex = dst % RegisterCountFlt; - auto srcIndex = src % RegisterCountFlt; - os << "f" << dstIndex << ", a" << srcIndex << std::endl; - } - - void Instruction::h_FSUB_M(std::ostream& os) const { - auto dstIndex = dst % RegisterCountFlt; - auto srcIndex = src % RegistersCount; - os << "f" << dstIndex << ", "; - genAddressReg(os, srcIndex); - os << std::endl; - } - - void Instruction::h_FSCAL_R(std::ostream& os) const { - auto dstIndex = dst % RegisterCountFlt; - os << "f" << dstIndex << std::endl; - } - - void Instruction::h_FMUL_R(std::ostream& os) const { - auto dstIndex = dst % RegisterCountFlt; - auto srcIndex = src % RegisterCountFlt; - os << "e" << dstIndex << ", a" << srcIndex << std::endl; - } - - void Instruction::h_FDIV_M(std::ostream& os) const { - auto dstIndex = dst % RegisterCountFlt; - auto srcIndex = src % RegistersCount; - os << "e" << dstIndex << ", "; - genAddressReg(os, srcIndex); - os << std::endl; - } - - void Instruction::h_FSQRT_R(std::ostream& os) const { - auto dstIndex = dst % RegisterCountFlt; - os << "e" << dstIndex << std::endl; - } - - void Instruction::h_CFROUND(std::ostream& os) const { - auto srcIndex = src % RegistersCount; - os << "r" << srcIndex << ", " << (getImm32() & 63) << std::endl; - } - - void Instruction::h_CBRANCH(std::ostream& os) const { - auto dstIndex = dst % RegistersCount; - auto srcIndex = src % RegistersCount; - os << "r" << dstIndex << ", " << (int32_t)getImm32() << ", COND " << (int)(getModCond()) << std::endl; - } - - void Instruction::h_ISTORE(std::ostream& os) const { - auto dstIndex = dst % RegistersCount; - auto srcIndex = src % RegistersCount; - genAddressRegDst(os, dstIndex); - os << ", r" << srcIndex << std::endl; - } - - void Instruction::h_NOP(std::ostream& os) const { - os << std::endl; - } - - const char* Instruction::names[256] = {}; - InstructionFormatter Instruction::engine[256] = {}; - -} \ No newline at end of file diff --git a/src/instruction.hpp b/src/instruction.hpp index b1863b5..1904afc 100644 --- a/src/instruction.hpp +++ b/src/instruction.hpp @@ -29,7 +29,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #pragma once #include -#include #include #include "blake2/endian.h" @@ -37,8 +36,6 @@ namespace randomx { class Instruction; - typedef void(Instruction::*InstructionFormatter)(std::ostream&) const; - enum class InstructionType : uint16_t { IADD_RS = 0, IADD_M = 1, @@ -80,13 +77,6 @@ namespace randomx { void setImm32(uint32_t val) { return store32(&imm32, val); } - const char* getName() const { - return names[opcode]; - } - friend std::ostream& operator<<(std::ostream& os, const Instruction& i) { - i.print(os); - return os; - } int getModMem() const { return mod % 4; //bits 0-1 } @@ -105,45 +95,8 @@ namespace randomx { uint8_t src; uint8_t mod; uint32_t imm32; - private: - void print(std::ostream&) const; - static const char* names[256]; - static InstructionFormatter engine[256]; - void genAddressReg(std::ostream& os, int) const; - void genAddressImm(std::ostream& os) const; - void genAddressRegDst(std::ostream&, int) const; - void h_IADD_RS(std::ostream&) const; - void h_IADD_M(std::ostream&) const; - void h_ISUB_R(std::ostream&) const; - void h_ISUB_M(std::ostream&) const; - void h_IMUL_R(std::ostream&) const; - void h_IMUL_M(std::ostream&) const; - void h_IMULH_R(std::ostream&) const; - void h_IMULH_M(std::ostream&) const; - void h_ISMULH_R(std::ostream&) const; - void h_ISMULH_M(std::ostream&) const; - void h_IMUL_RCP(std::ostream&) const; - void h_INEG_R(std::ostream&) const; - void h_IXOR_R(std::ostream&) const; - void h_IXOR_M(std::ostream&) const; - void h_IROR_R(std::ostream&) const; - void h_IROL_R(std::ostream&) const; - void h_ISWAP_R(std::ostream&) const; - void h_FSWAP_R(std::ostream&) const; - void h_FADD_R(std::ostream&) const; - void h_FADD_M(std::ostream&) const; - void h_FSUB_R(std::ostream&) const; - void h_FSUB_M(std::ostream&) const; - void h_FSCAL_R(std::ostream&) const; - void h_FMUL_R(std::ostream&) const; - void h_FDIV_M(std::ostream&) const; - void h_FSQRT_R(std::ostream&) const; - void h_CBRANCH(std::ostream&) const; - void h_CFROUND(std::ostream&) const; - void h_ISTORE(std::ostream&) const; - void h_NOP(std::ostream&) const; }; static_assert(sizeof(Instruction) == 8, "Invalid size of struct randomx::Instruction"); static_assert(std::is_standard_layout(), "randomx::Instruction must be a standard-layout struct"); -} \ No newline at end of file +} diff --git a/src/instruction_weights.hpp b/src/instruction_weights.hpp deleted file mode 100644 index f6c8873..0000000 --- a/src/instruction_weights.hpp +++ /dev/null @@ -1,73 +0,0 @@ -/* -Copyright (c) 2018-2019, tevador - -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 holder 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 HOLDER 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. -*/ - -#pragma once - -#define REP0(x) -#define REP1(x) x, -#define REP2(x) REP1(x) x, -#define REP3(x) REP2(x) x, -#define REP4(x) REP3(x) x, -#define REP5(x) REP4(x) x, -#define REP6(x) REP5(x) x, -#define REP7(x) REP6(x) x, -#define REP8(x) REP7(x) x, -#define REP9(x) REP8(x) x, -#define REP10(x) REP9(x) x, -#define REP11(x) REP10(x) x, -#define REP12(x) REP11(x) x, -#define REP13(x) REP12(x) x, -#define REP14(x) REP13(x) x, -#define REP15(x) REP14(x) x, -#define REP16(x) REP15(x) x, -#define REP17(x) REP16(x) x, -#define REP18(x) REP17(x) x, -#define REP19(x) REP18(x) x, -#define REP20(x) REP19(x) x, -#define REP21(x) REP20(x) x, -#define REP22(x) REP21(x) x, -#define REP23(x) REP22(x) x, -#define REP24(x) REP23(x) x, -#define REP25(x) REP24(x) x, -#define REP26(x) REP25(x) x, -#define REP27(x) REP26(x) x, -#define REP28(x) REP27(x) x, -#define REP29(x) REP28(x) x, -#define REP30(x) REP29(x) x, -#define REP31(x) REP30(x) x, -#define REP32(x) REP31(x) x, -#define REP33(x) REP32(x) x, -#define REP40(x) REP32(x) REP8(x) -#define REP64(x) REP32(x) REP32(x) -#define REP128(x) REP32(x) REP32(x) REP32(x) REP32(x) -#define REP232(x) REP128(x) REP40(x) REP40(x) REP24(x) -#define REP256(x) REP128(x) REP128(x) -#define REPNX(x,N) REP##N(x) -#define REPN(x,N) REPNX(x,N) -#define NUM(x) x -#define WT(x) NUM(RANDOMX_FREQ_##x) diff --git a/src/program.hpp b/src/program.hpp index d443488..ef8ac74 100644 --- a/src/program.hpp +++ b/src/program.hpp @@ -29,7 +29,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #pragma once #include -#include #include "common.hpp" #include "instruction.hpp" #include "blake2/endian.h" @@ -46,10 +45,6 @@ namespace randomx { Instruction& operator()(int pc) { return programBuffer[pc]; } - friend std::ostream& operator<<(std::ostream& os, const Program& p) { - p.print(os); - return os; - } uint64_t getEntropy(int i) { return load64(&entropyBuffer[i]); } @@ -57,14 +52,8 @@ namespace randomx { return RandomX_CurrentConfig.ProgramSize; } private: - void print(std::ostream& os) const { - for (int i = 0; i < RandomX_CurrentConfig.ProgramSize; ++i) { - auto instr = programBuffer[i]; - os << instr; - } - } uint64_t entropyBuffer[16]; - Instruction programBuffer[512]; + Instruction programBuffer[RANDOMX_PROGRAM_MAX_SIZE]; }; static_assert(sizeof(Program) % 64 == 0, "Invalid size of class randomx::Program"); diff --git a/src/randomx.cpp b/src/randomx.cpp index 742f128..dde838b 100644 --- a/src/randomx.cpp +++ b/src/randomx.cpp @@ -34,7 +34,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "vm_compiled_light.hpp" #include "blake2/blake2.h" #include "jit_compiler_x86_static.hpp" -#include "assembly_generator_x86.hpp" #include RandomX_ConfigurationWownero::RandomX_ConfigurationWownero() @@ -127,33 +126,40 @@ RandomX_ConfigurationBase::RandomX_ConfigurationBase() fillAes4Rx4_Key[5] = rx_set_int_vec_i128(0xb272b7d2, 0xe9024d4e, 0x9c10b3d9, 0xc7566bf3); fillAes4Rx4_Key[6] = rx_set_int_vec_i128(0xf63befa7, 0x2ba9660a, 0xf765a38b, 0xf273c9e7); fillAes4Rx4_Key[7] = rx_set_int_vec_i128(0xc0b0762d, 0x0c06d1fd, 0x915839de, 0x7a7cd609); -} -void RandomX_ConfigurationBase::Apply() -{ #if defined(_M_X64) || defined(__x86_64__) { const uint8_t* a = (const uint8_t*)&randomx_sshash_prefetch; const uint8_t* b = (const uint8_t*)&randomx_sshash_end; memcpy(codeShhPrefetchTweaked, a, b - a); - *(uint32_t*)(codeShhPrefetchTweaked + 3) = ArgonMemory * 16 - 1; } - - const uint32_t DatasetBaseMask = DatasetBaseSize - RANDOMX_DATASET_ITEM_SIZE; { const uint8_t* a = (const uint8_t*)&randomx_program_read_dataset; const uint8_t* b = (const uint8_t*)&randomx_program_read_dataset_sshash_init; memcpy(codeReadDatasetTweaked, a, b - a); - *(uint32_t*)(codeReadDatasetTweaked + 7) = DatasetBaseMask; - *(uint32_t*)(codeReadDatasetTweaked + 23) = DatasetBaseMask; } { const uint8_t* a = (const uint8_t*)&randomx_program_read_dataset_sshash_init; const uint8_t* b = (const uint8_t*)&randomx_program_read_dataset_sshash_fin; memcpy(codeReadDatasetLightSshInitTweaked, a, b - a); - *(uint32_t*)(codeReadDatasetLightSshInitTweaked + 59) = DatasetBaseMask; + } + { + const uint8_t* a = (const uint8_t*)&randomx_program_loop_load; + const uint8_t* b = (const uint8_t*)&randomx_program_start; + memcpy(codeLoopLoadTweaked, a, b - a); } #endif +} + +void RandomX_ConfigurationBase::Apply() +{ +#if defined(_M_X64) || defined(__x86_64__) + *(uint32_t*)(codeShhPrefetchTweaked + 3) = ArgonMemory * 16 - 1; + const uint32_t DatasetBaseMask = DatasetBaseSize - RANDOMX_DATASET_ITEM_SIZE; + *(uint32_t*)(codeReadDatasetTweaked + 7) = DatasetBaseMask; + *(uint32_t*)(codeReadDatasetTweaked + 23) = DatasetBaseMask; + *(uint32_t*)(codeReadDatasetLightSshInitTweaked + 59) = DatasetBaseMask; +#endif CacheLineAlignMask_Calculated = (DatasetBaseSize - 1) & ~(RANDOMX_DATASET_ITEM_SIZE - 1); DatasetExtraItems_Calculated = DatasetExtraSize / RANDOMX_DATASET_ITEM_SIZE; @@ -166,13 +172,8 @@ void RandomX_ConfigurationBase::Apply() ScratchpadL3Mask64_Calculated = ((ScratchpadL3_Size / sizeof(uint64_t)) / 8 - 1) * 64; #if defined(_M_X64) || defined(__x86_64__) - { - const uint8_t* a = (const uint8_t*)&randomx_program_loop_load; - const uint8_t* b = (const uint8_t*)&randomx_program_start; - memcpy(codeLoopLoadTweaked, a, b - a); - *(uint32_t*)(codeLoopLoadTweaked + 4) = ScratchpadL3Mask64_Calculated; - *(uint32_t*)(codeLoopLoadTweaked + 50) = ScratchpadL3Mask64_Calculated; - } + *(uint32_t*)(codeLoopLoadTweaked + 4) = ScratchpadL3Mask64_Calculated; + *(uint32_t*)(codeLoopLoadTweaked + 50) = ScratchpadL3Mask64_Calculated; #endif ConditionMask_Calculated = (1 << JumpBits) - 1; @@ -188,11 +189,7 @@ void RandomX_ConfigurationBase::Apply() #define INST_HANDLE(x, prev) \ CEIL_##x = CEIL_##prev + RANDOMX_FREQ_##x; \ - for (int i = 0; i < RANDOMX_FREQ_##x; ++i, ++k) \ - { \ - randomx::AssemblyGeneratorX86::engine[k] = &randomx::AssemblyGeneratorX86::h_##x; \ - JIT_HANDLE(x, prev); \ - } + for (; k < CEIL_##x; ++k) { JIT_HANDLE(x, prev); } INST_HANDLE(IADD_RS, NULL); INST_HANDLE(IADD_M, IADD_RS); diff --git a/src/superscalar.cpp b/src/superscalar.cpp index dd22c8a..c0d496b 100644 --- a/src/superscalar.cpp +++ b/src/superscalar.cpp @@ -29,11 +29,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "configuration.h" #include "program.hpp" #include "blake2/endian.h" -#include -#include -#include -#include -#include #include "superscalar.hpp" #include "intrin_portable.h" #include "reciprocal.h" @@ -617,7 +612,7 @@ namespace randomx { //if this macro-op depends on the previous one, increase the starting cycle if needed //this handles an explicit dependency chain in IMUL_RCP if (mop.isDependent()) { - cycle = std::max(cycle, depCycle); + cycle = (cycle > depCycle) ? cycle : depCycle; } //move instructions are eliminated and don't need an execution unit if (mop.isEliminated()) { @@ -806,7 +801,7 @@ namespace randomx { Instruction& instr = prog(i); int latDst = prog.asicLatencies[instr.dst] + 1; int latSrc = instr.dst != instr.src ? prog.asicLatencies[instr.src] + 1 : 0; - prog.asicLatencies[instr.dst] = std::max(latDst, latSrc); + prog.asicLatencies[instr.dst] = (latDst > latSrc) ? latDst : latSrc; } //address register is the register with the highest ASIC latency diff --git a/src/superscalar_program.hpp b/src/superscalar_program.hpp index 7bcd484..dbb0b16 100644 --- a/src/superscalar_program.hpp +++ b/src/superscalar_program.hpp @@ -39,10 +39,6 @@ namespace randomx { Instruction& operator()(int pc) { return programBuffer[pc]; } - friend std::ostream& operator<<(std::ostream& os, const SuperscalarProgram& p) { - p.print(os); - return os; - } uint32_t getSize() { return size; } @@ -72,13 +68,6 @@ namespace randomx { int mulCount; int cpuLatencies[8]; int asicLatencies[8]; - private: - void print(std::ostream& os) const { - for (unsigned i = 0; i < size; ++i) { - auto instr = programBuffer[i]; - os << instr; - } - } }; } \ No newline at end of file diff --git a/src/tests/api-example1.c b/src/tests/api-example1.c deleted file mode 100644 index f45d54b..0000000 --- a/src/tests/api-example1.c +++ /dev/null @@ -1,24 +0,0 @@ -#include "../randomx.h" -#include - -int main() { - const char myKey[] = "RandomX example key"; - const char myInput[] = "RandomX example input"; - char hash[RANDOMX_HASH_SIZE]; - - randomx_cache *myCache = randomx_alloc_cache(RANDOMX_FLAG_DEFAULT); - randomx_init_cache(myCache, &myKey, sizeof myKey); - randomx_vm *myMachine = randomx_create_vm(RANDOMX_FLAG_DEFAULT, myCache, NULL); - - randomx_calculate_hash(myMachine, &myInput, sizeof myInput, hash); - - randomx_destroy_vm(myMachine); - randomx_release_cache(myCache); - - for (unsigned i = 0; i < RANDOMX_HASH_SIZE; ++i) - printf("%02x", hash[i] & 0xff); - - printf("\n"); - - return 0; -} diff --git a/src/tests/api-example2.cpp b/src/tests/api-example2.cpp deleted file mode 100644 index 5b3757e..0000000 --- a/src/tests/api-example2.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include "../randomx.h" -#include -#include -#include - -int main() { - const char myKey[] = "RandomX example key"; - const char myInput[] = "RandomX example input"; - char hash[RANDOMX_HASH_SIZE]; - - randomx_cache *myCache = randomx_alloc_cache((randomx_flags)(RANDOMX_FLAG_JIT | RANDOMX_FLAG_LARGE_PAGES)); - if (myCache == nullptr) { - std::cout << "Cache allocation failed" << std::endl; - return 1; - } - randomx_init_cache(myCache, myKey, sizeof myKey); - - randomx_dataset *myDataset = randomx_alloc_dataset(RANDOMX_FLAG_LARGE_PAGES); - if (myDataset == nullptr) { - std::cout << "Dataset allocation failed" << std::endl; - return 1; - } - - auto datasetItemCount = randomx_dataset_item_count(); - std::thread t1(&randomx_init_dataset, myDataset, myCache, 0, datasetItemCount / 2); - std::thread t2(&randomx_init_dataset, myDataset, myCache, datasetItemCount / 2, datasetItemCount - datasetItemCount / 2); - t1.join(); - t2.join(); - randomx_release_cache(myCache); - - randomx_vm *myMachine = randomx_create_vm((randomx_flags)(RANDOMX_FLAG_FULL_MEM | RANDOMX_FLAG_JIT | RANDOMX_FLAG_HARD_AES | RANDOMX_FLAG_LARGE_PAGES), nullptr, myDataset); - if (myMachine == nullptr) { - std::cout << "Failed to create a virtual machine" << std::endl; - return 1; - } - - randomx_calculate_hash(myMachine, &myInput, sizeof myInput, hash); - - randomx_destroy_vm(myMachine); - randomx_release_dataset(myDataset); - - for (unsigned i = 0; i < RANDOMX_HASH_SIZE; ++i) - std::cout << std::hex << ((int)hash[i] & 0xff); - - std::cout << std::endl; - - return 0; -} \ No newline at end of file diff --git a/src/tests/code-generator.cpp b/src/tests/code-generator.cpp deleted file mode 100644 index b151c3a..0000000 --- a/src/tests/code-generator.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/* -Copyright (c) 2018-2019, tevador - -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 holder 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 HOLDER 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. -*/ - -#include "utility.hpp" -#include "../common.hpp" -#include "../assembly_generator_x86.hpp" -#include "../superscalar.hpp" -#include "../aes_hash.hpp" -#include "../blake2/blake2.h" -#include "../program.hpp" - -const uint8_t seed[32] = { 191, 182, 222, 175, 249, 89, 134, 104, 241, 68, 191, 62, 162, 166, 61, 64, 123, 191, 227, 193, 118, 60, 188, 53, 223, 133, 175, 24, 123, 230, 55, 74 }; - -const uint8_t blockTemplate_[] = { - 0x07, 0x07, 0xf7, 0xa4, 0xf0, 0xd6, 0x05, 0xb3, 0x03, 0x26, 0x08, 0x16, 0xba, 0x3f, 0x10, 0x90, 0x2e, 0x1a, 0x14, - 0x5a, 0xc5, 0xfa, 0xd3, 0xaa, 0x3a, 0xf6, 0xea, 0x44, 0xc1, 0x18, 0x69, 0xdc, 0x4f, 0x85, 0x3f, 0x00, 0x2b, 0x2e, - 0xea, 0x00, 0x00, 0x00, 0x00, 0x77, 0xb2, 0x06, 0xa0, 0x2c, 0xa5, 0xb1, 0xd4, 0xce, 0x6b, 0xbf, 0xdf, 0x0a, 0xca, - 0xc3, 0x8b, 0xde, 0xd3, 0x4d, 0x2d, 0xcd, 0xee, 0xf9, 0x5c, 0xd2, 0x0c, 0xef, 0xc1, 0x2f, 0x61, 0xd5, 0x61, 0x09 -}; - -template -void generateAsm(uint32_t nonce) { - alignas(16) uint64_t hash[8]; - uint8_t blockTemplate[sizeof(blockTemplate_)]; - memcpy(blockTemplate, blockTemplate_, sizeof(blockTemplate)); - store32(blockTemplate + 39, nonce); - blake2b(hash, sizeof(hash), blockTemplate, sizeof(blockTemplate), nullptr, 0); - uint8_t scratchpad[randomx::ScratchpadSize]; - fillAes1Rx4((void*)hash, randomx::ScratchpadSize, scratchpad); - randomx::AssemblyGeneratorX86 asmX86; - randomx::Program p; - fillAes4Rx4(hash, sizeof(p), &p); - asmX86.generateProgram(p); - asmX86.printCode(std::cout); -} - -template -void generateNative(uint32_t nonce) { - alignas(16) uint64_t hash[8]; - uint8_t blockTemplate[sizeof(blockTemplate_)]; - memcpy(blockTemplate, blockTemplate_, sizeof(blockTemplate)); - store32(blockTemplate + 39, nonce); - blake2b(hash, sizeof(hash), blockTemplate, sizeof(blockTemplate), nullptr, 0); - uint8_t scratchpad[randomx::ScratchpadSize]; - fillAes1Rx4((void*)hash, randomx::ScratchpadSize, scratchpad); - alignas(16) randomx::Program prog; - fillAes1Rx4((void*)hash, sizeof(prog), &prog); - std::cout << prog << std::endl; -} - -void printUsage(const char* executable) { - std::cout << "Usage: " << executable << " [OPTIONS]" << std::endl; - std::cout << "Supported options:" << std::endl; - std::cout << " --softAes use software AES (default: x86 AES-NI)" << std::endl; - std::cout << " --nonce N seed nonce (default: 1000)" << std::endl; - std::cout << " --genAsm generate x86-64 asm code for nonce N" << std::endl; - std::cout << " --genNative generate RandomX code for nonce N" << std::endl; - std::cout << " --genSuperscalar generate superscalar program for nonce N" << std::endl; -} - -int main(int argc, char** argv) { - bool softAes, genAsm, genNative, genSuperscalar; - int nonce; - - readOption("--softAes", argc, argv, softAes); - readOption("--genAsm", argc, argv, genAsm); - readIntOption("--nonce", argc, argv, nonce, 1000); - readOption("--genNative", argc, argv, genNative); - readOption("--genSuperscalar", argc, argv, genSuperscalar); - - if (genSuperscalar) { - randomx::SuperscalarProgram p; - randomx::Blake2Generator gen(seed, nonce); - randomx::generateSuperscalar(p, gen); - randomx::AssemblyGeneratorX86 asmX86; - asmX86.generateAsm(p); - asmX86.printCode(std::cout); - return 0; - } - - if (genAsm) { - if (softAes) - generateAsm(nonce); - else - generateAsm(nonce); - return 0; - } - - if (genNative) { - if (softAes) - generateNative(nonce); - else - generateNative(nonce); - return 0; - } - - printUsage(argv[0]); - return 0; -} \ No newline at end of file diff --git a/src/tests/jit-performance.cpp b/src/tests/jit-performance.cpp deleted file mode 100644 index 57e8c7d..0000000 --- a/src/tests/jit-performance.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#include "../aes_hash.hpp" -#include "../jit_compiler_x86.hpp" -#include "../program.hpp" -#include "utility.hpp" -#include "stopwatch.hpp" -#include "../blake2/blake2.h" -#include "../reciprocal.h" - -int main(int argc, char** argv) { - int count; - readInt(argc, argv, count, 1000000); - - const char seed[] = "JIT performance test seed"; - uint8_t hash[64]; - - blake2b(&hash, sizeof hash, &seed, sizeof seed, nullptr, 0); - - randomx::ProgramConfiguration config; - - randomx::Program program; - randomx::JitCompilerX86 jit; - - std::cout << "Compiling " << count << " programs..." << std::endl; - - Stopwatch sw(true); - - for (int i = 0; i < count; ++i) { - fillAes1Rx4(hash, sizeof(program), &program); - auto addressRegisters = program.getEntropy(12); - config.readReg0 = 0 + (addressRegisters & 1); - addressRegisters >>= 1; - config.readReg1 = 2 + (addressRegisters & 1); - addressRegisters >>= 1; - config.readReg2 = 4 + (addressRegisters & 1); - addressRegisters >>= 1; - config.readReg3 = 6 + (addressRegisters & 1); - jit.generateProgram(program, config); - } - - std::cout << "Elapsed: " << sw.getElapsed() << " s" << std::endl; - - dump((const char*)jit.getProgramFunc(), randomx::CodeSize, "program.bin"); - return 0; -} \ No newline at end of file diff --git a/src/tests/perf-simulation.cpp b/src/tests/perf-simulation.cpp deleted file mode 100644 index 1f9b3f2..0000000 --- a/src/tests/perf-simulation.cpp +++ /dev/null @@ -1,662 +0,0 @@ -/* -Copyright (c) 2018-2019, tevador - -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 holder 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 HOLDER 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. -*/ - -#include "utility.hpp" -#include "../common.hpp" -#include "../aes_hash.hpp" -#include "../program.hpp" -#include "../blake2/blake2.h" -#include -#include - -int analyze(randomx::Program& p); -int executeInOrder(randomx::Program& p, randomx::Program& original, bool print, int executionPorts, int memoryPorts, bool speculate, int pipeline); -int executeOutOfOrder(randomx::Program& p, randomx::Program& original, bool print, int executionPorts, int memoryPorts, bool speculate, int pipeline); - -constexpr uint32_t DST_NOP = 0; -constexpr uint32_t DST_INT = 1; -constexpr uint32_t DST_FLT = 2; -constexpr uint32_t DST_MEM = 3; -constexpr uint32_t MASK_DST = 3; - -constexpr uint32_t SRC_NOP = 0; -constexpr uint32_t SRC_INT = 4; -constexpr uint32_t SRC_FLT = 8; -constexpr uint32_t SRC_MEM = 12; -constexpr uint32_t MASK_SRC = 12; - -constexpr uint32_t OP_CFROUND = 16; -constexpr uint32_t OP_SWAP = 32; -constexpr uint32_t OP_BRANCH = 48; -constexpr uint32_t MASK_EXT = 48; - -constexpr uint32_t OP_FLOAT = 64; -constexpr uint32_t BRANCH_TARGET = 128; - -//template -void generate(randomx::Program& p, uint32_t nonce) { - alignas(16) uint64_t hash[8]; - blake2b(hash, sizeof(hash), &nonce, sizeof(nonce), nullptr, 0); - fillAes1Rx4((void*)hash, sizeof(p), &p); -} - -bool has(randomx::Instruction& instr, uint32_t mask, uint32_t prop) { - return (instr.opcode & mask) == prop; -} - -bool has(randomx::Instruction& instr, uint32_t prop) { - return (instr.opcode & prop) != 0; -} - -int main(int argc, char** argv) { - int nonces, seed, executionPorts, memoryPorts, pipeline; - bool print, reorder, speculate; - readOption("--print", argc, argv, print); - readOption("--reorder", argc, argv, reorder); - readOption("--speculate", argc, argv, speculate); - readIntOption("--nonces", argc, argv, nonces, 1); - readIntOption("--seed", argc, argv, seed, 0); - readIntOption("--executionPorts", argc, argv, executionPorts, 4); - readIntOption("--memoryPorts", argc, argv, memoryPorts, 2); - readIntOption("--pipeline", argc, argv, pipeline, 3); - randomx::Program p, original; - double totalCycles = 0.0; - double jumpCount = 0; - for (int i = 0; i < nonces; ++i) { - generate(original, i ^ seed); - memcpy(&p, &original, sizeof(p)); - jumpCount += analyze(p); - totalCycles += - reorder - ? - executeOutOfOrder(p, original, print, executionPorts, memoryPorts, speculate, pipeline) - : - executeInOrder(p, original, print, executionPorts, memoryPorts, speculate, pipeline); - } - totalCycles /= nonces; - jumpCount /= nonces; - std::cout << "Execution took " << totalCycles << " cycles per program" << std::endl; - //std::cout << "Jump count: " << jumpCount << std::endl; - return 0; -} - -int executeInOrder(randomx::Program& p, randomx::Program& original, bool print, int executionPorts, int memoryPorts, bool speculate, int pipeline) { - int cycle = pipeline - 1; - int index = 0; - int branchCount = 0; - int int_reg_ready[randomx::RegistersCount] = { 0 }; - int flt_reg_ready[randomx::RegistersCount] = { 0 }; - //each workgroup takes 1 or 2 cycles (2 cycles if any instruction has a memory operand) - while (index < RANDOMX_PROGRAM_SIZE) { - int memoryAccesses = 0; - bool hasRound = false; - int workers = 0; - //std::cout << "-----------" << std::endl; - for (; workers < executionPorts && memoryAccesses < memoryPorts && index < RANDOMX_PROGRAM_SIZE; ++workers) { - auto& instr = p(index); - auto& origi = original(index); - origi.dst %= randomx::RegistersCount; - origi.src %= randomx::RegistersCount; - - //check dependencies - if (has(instr, MASK_SRC, SRC_INT) && int_reg_ready[instr.src] > cycle) - break; - - if (has(instr, MASK_SRC, SRC_MEM) && int_reg_ready[instr.src] > cycle - 1) - break; - - if (has(instr, MASK_DST, DST_MEM) && int_reg_ready[instr.dst] > cycle - 1) - break; - - if (has(instr, MASK_DST, DST_FLT) && flt_reg_ready[instr.dst] > cycle) - break; - - if (has(instr, MASK_DST, DST_INT) && int_reg_ready[instr.dst] > cycle) - break; - - if (hasRound && has(instr, OP_FLOAT)) - break; - - //execute - index++; - - if (has(instr, MASK_EXT, OP_BRANCH)) { - branchCount++; - } - - if (has(instr, MASK_DST, DST_FLT)) - flt_reg_ready[instr.dst] = cycle + 1; - - if (has(instr, MASK_DST, DST_INT)) - int_reg_ready[instr.dst] = cycle + 1; - - if (has(instr, MASK_EXT, OP_SWAP)) { - int_reg_ready[instr.src] = cycle + 1; - } - - if (has(instr, MASK_EXT, OP_CFROUND)) - hasRound = true; - - if (has(instr, MASK_SRC, SRC_MEM) || has(instr, MASK_DST, DST_MEM)) { - memoryAccesses++; - } - - if (print) - std::cout << std::setw(2) << (cycle + 1) << ": " << origi; - - //non-speculative execution must stall after branch - if (!speculate && has(instr, MASK_EXT, OP_BRANCH)) { - cycle += pipeline - 1; - break; - } - } - //std::cout << " workers: " << workers << std::endl; - cycle++; - } - if (speculate) { - //account for mispredicted branches - int i = 0; - while (branchCount--) { - auto entropy = p.getEntropy(i / 8); - entropy >> (i % 8) * 8; - if ((entropy & 0xff) == 0) // 1/256 chance to flush the pipeline - cycle += pipeline - 1; - } - } - return cycle; -} - -int executeOutOfOrder(randomx::Program& p, randomx::Program& original, bool print, int executionPorts, int memoryPorts, bool speculate, int pipeline) { - int index = 0; - int busyExecutionPorts[2 * RANDOMX_PROGRAM_SIZE] = { 0 }; - int busyMemoryPorts[2 * RANDOMX_PROGRAM_SIZE] = { 0 }; - int int_reg_ready[randomx::RegistersCount] = { 0 }; - int flt_reg_ready[randomx::RegistersCount] = { 0 }; - int fprcReady = 0; - int lastBranch = 0; - int branchCount = 0; - for (; index < RANDOMX_PROGRAM_SIZE; ++index) { - auto& instr = p(index); - int retireCycle = pipeline - 1; - - //non-speculative execution cannot reorder across branches - if (!speculate && !has(instr, MASK_EXT, OP_BRANCH)) - retireCycle = std::max(lastBranch + pipeline - 1, retireCycle); - - //check dependencies - if (has(instr, MASK_SRC, SRC_INT)) { - retireCycle = std::max(retireCycle, int_reg_ready[instr.src]); - int_reg_ready[instr.src] = retireCycle; - } - - if (has(instr, MASK_SRC, SRC_MEM)) { - retireCycle = std::max(retireCycle, int_reg_ready[instr.src] + 1); - //find free memory port - while (busyMemoryPorts[retireCycle - 1] >= memoryPorts) { - retireCycle++; - } - busyMemoryPorts[retireCycle - 1]++; - } - - if (has(instr, MASK_DST, DST_FLT)) { - retireCycle = std::max(retireCycle, flt_reg_ready[instr.dst]); - } - - if (has(instr, MASK_DST, DST_INT)) { - retireCycle = std::max(retireCycle, int_reg_ready[instr.dst]); - } - - //floating point operations depend on the fprc register - if (has(instr, OP_FLOAT)) - retireCycle = std::max(retireCycle, fprcReady); - - //execute - if (has(instr, MASK_DST, DST_MEM)) { - retireCycle = std::max(retireCycle, int_reg_ready[instr.dst] + 1); - //find free memory port - while (busyMemoryPorts[retireCycle - 1] >= memoryPorts) { - retireCycle++; - } - busyMemoryPorts[retireCycle - 1]++; - retireCycle++; - } - - if (has(instr, MASK_DST, DST_FLT)) { - //find free execution port - do { - retireCycle++; - } while (busyExecutionPorts[retireCycle - 1] >= executionPorts); - busyExecutionPorts[retireCycle - 1]++; - flt_reg_ready[instr.dst] = retireCycle; - } - - if (has(instr, MASK_DST, DST_INT)) { - //find free execution port - do { - retireCycle++; - } while (busyExecutionPorts[retireCycle - 1] >= executionPorts); - busyExecutionPorts[retireCycle - 1]++; - int_reg_ready[instr.dst] = retireCycle; - } - - if (has(instr, MASK_EXT, OP_SWAP)) { - int_reg_ready[instr.src] = retireCycle; - } - - if (has(instr, MASK_EXT, OP_CFROUND)) { - do { - retireCycle++; - } while (busyExecutionPorts[retireCycle - 1] >= executionPorts); - busyExecutionPorts[retireCycle - 1]++; - fprcReady = retireCycle; - } - - if (has(instr, MASK_EXT, OP_BRANCH)) { - /*if (!speculate && instr.mod == 1) { //simulated predication - do { - retireCycle++; - } while (busyExecutionPorts[retireCycle - 1] >= executionPorts); - busyExecutionPorts[retireCycle - 1]++; - int_reg_ready[instr.dst] = retireCycle; - }*/ - //else { - lastBranch = std::max(lastBranch, retireCycle); - branchCount++; - //} - } - - //print - auto& origi = original(index); - origi.dst %= randomx::RegistersCount; - origi.src %= randomx::RegistersCount; - if (print) { - std::cout << std::setw(2) << retireCycle << ": " << origi; - if (has(instr, MASK_EXT, OP_BRANCH)) { - std::cout << " jump: " << (int)instr.mod << std::endl; - } - } - } - int cycle = 0; - for (int i = 0; i < randomx::RegistersCount; ++i) { - cycle = std::max(cycle, int_reg_ready[i]); - } - for (int i = 0; i < randomx::RegistersCount; ++i) { - cycle = std::max(cycle, flt_reg_ready[i]); - } - if (speculate) { - //account for mispredicted branches - int i = 0; - while (branchCount--) { - auto entropy = p.getEntropy(i / 8); - entropy >> (i % 8) * 8; - if ((entropy & 0xff) == 0) // 1/256 chance to flush the pipeline - cycle += pipeline - 1; - } - } - return cycle; -} - -#include "../bytecode_machine.hpp" - -//old register selection -struct RegisterUsage { - int32_t lastUsed; - int32_t count; -}; - -inline int getConditionRegister(RegisterUsage(®isterUsage)[randomx::RegistersCount]) { - int min = INT_MAX; - int minCount = 0; - int minIndex; - //prefer registers that have been used as a condition register fewer times - for (unsigned i = 0; i < randomx::RegistersCount; ++i) { - if (registerUsage[i].lastUsed < min || (registerUsage[i].lastUsed == min && registerUsage[i].count < minCount)) { - min = registerUsage[i].lastUsed; - minCount = registerUsage[i].count; - minIndex = i; - } - } - return minIndex; -} - -int analyze(randomx::Program& p) { - int jumpCount = 0; - RegisterUsage registerUsage[randomx::RegistersCount]; - for (unsigned i = 0; i < randomx::RegistersCount; ++i) { - registerUsage[i].lastUsed = -1; - registerUsage[i].count = 0; - } - for (unsigned i = 0; i < RANDOMX_PROGRAM_SIZE; ++i) { - auto& instr = p(i); - int opcode = instr.opcode; - instr.opcode = 0; - - if (opcode < randomx::ceil_IADD_RS) { - instr.dst = instr.dst % randomx::RegistersCount; - instr.src = instr.src % randomx::RegistersCount; - instr.opcode |= SRC_INT; - instr.opcode |= DST_INT; - registerUsage[instr.dst].lastUsed = i; - continue; - } - - if (opcode < randomx::ceil_IADD_M) { - instr.dst = instr.dst % randomx::RegistersCount; - instr.src = instr.src % randomx::RegistersCount; - instr.opcode |= SRC_MEM; - instr.opcode |= DST_INT; - if (instr.src != instr.dst) { - instr.imm32 = (instr.getModMem() ? randomx::ScratchpadL1Mask : randomx::ScratchpadL2Mask); - } - else { - instr.imm32 &= randomx::ScratchpadL3Mask; - } - registerUsage[instr.dst].lastUsed = i; - continue; - } - - if (opcode < randomx::ceil_ISUB_R) { - instr.dst = instr.dst % randomx::RegistersCount; - instr.src = instr.src % randomx::RegistersCount; - instr.opcode |= DST_INT; - instr.opcode |= SRC_INT; - registerUsage[instr.dst].lastUsed = i; - continue; - } - - if (opcode < randomx::ceil_ISUB_M) { - instr.dst = instr.dst % randomx::RegistersCount; - instr.src = instr.src % randomx::RegistersCount; - instr.opcode |= SRC_MEM; - instr.opcode |= DST_INT; - if (instr.src != instr.dst) { - instr.imm32 = (instr.getModMem() ? randomx::ScratchpadL1Mask : randomx::ScratchpadL2Mask); - } - else { - instr.imm32 &= randomx::ScratchpadL3Mask; - } - registerUsage[instr.dst].lastUsed = i; - continue; - } - - if (opcode < randomx::ceil_IMUL_R) { - instr.dst = instr.dst % randomx::RegistersCount; - instr.src = instr.src % randomx::RegistersCount; - instr.opcode |= DST_INT; - instr.opcode |= SRC_INT; - registerUsage[instr.dst].lastUsed = i; - continue; - } - - if (opcode < randomx::ceil_IMUL_M) { - instr.dst = instr.dst % randomx::RegistersCount; - instr.src = instr.src % randomx::RegistersCount; - instr.opcode |= SRC_MEM; - instr.opcode |= DST_INT; - if (instr.src != instr.dst) { - instr.imm32 = (instr.getModMem() ? randomx::ScratchpadL1Mask : randomx::ScratchpadL2Mask); - } - else { - instr.imm32 &= randomx::ScratchpadL3Mask; - } - registerUsage[instr.dst].lastUsed = i; - continue; - } - - if (opcode < randomx::ceil_IMULH_R) { - instr.dst = instr.dst % randomx::RegistersCount; - instr.src = instr.src % randomx::RegistersCount; - instr.opcode |= DST_INT; - instr.opcode |= SRC_INT; - registerUsage[instr.dst].lastUsed = i; - continue; - } - - if (opcode < randomx::ceil_IMULH_M) { - instr.dst = instr.dst % randomx::RegistersCount; - instr.src = instr.src % randomx::RegistersCount; - instr.opcode |= SRC_MEM; - instr.opcode |= DST_INT; - if (instr.src != instr.dst) { - instr.imm32 = (instr.getModMem() ? randomx::ScratchpadL1Mask : randomx::ScratchpadL2Mask); - } - else { - instr.imm32 &= randomx::ScratchpadL3Mask; - } - registerUsage[instr.dst].lastUsed = i; - continue; - } - - if (opcode < randomx::ceil_ISMULH_R) { - instr.dst = instr.dst % randomx::RegistersCount; - instr.src = instr.src % randomx::RegistersCount; - instr.opcode |= DST_INT; - instr.opcode |= SRC_INT; - registerUsage[instr.dst].lastUsed = i; - continue; - } - - if (opcode < randomx::ceil_ISMULH_M) { - instr.dst = instr.dst % randomx::RegistersCount; - instr.src = instr.src % randomx::RegistersCount; - instr.opcode |= SRC_MEM; - instr.opcode |= DST_INT; - if (instr.src != instr.dst) { - instr.imm32 = (instr.getModMem() ? randomx::ScratchpadL1Mask : randomx::ScratchpadL2Mask); - } - else { - instr.imm32 &= randomx::ScratchpadL3Mask; - } - registerUsage[instr.dst].lastUsed = i; - continue; - } - - if (opcode < randomx::ceil_IMUL_RCP) { - uint64_t divisor = instr.getImm32(); - if (!randomx::isPowerOf2(divisor)) { - instr.dst = instr.dst % randomx::RegistersCount; - instr.opcode |= DST_INT; - registerUsage[instr.dst].lastUsed = i; - } - continue; - } - - if (opcode < randomx::ceil_INEG_R) { - instr.dst = instr.dst % randomx::RegistersCount; - instr.opcode |= DST_INT; - registerUsage[instr.dst].lastUsed = i; - continue; - } - - if (opcode < randomx::ceil_IXOR_R) { - instr.dst = instr.dst % randomx::RegistersCount; - instr.src = instr.src % randomx::RegistersCount; - instr.opcode |= DST_INT; - instr.opcode |= SRC_INT; - registerUsage[instr.dst].lastUsed = i; - continue; - } - - if (opcode < randomx::ceil_IXOR_M) { - instr.dst = instr.dst % randomx::RegistersCount; - instr.src = instr.src % randomx::RegistersCount; - instr.opcode |= SRC_MEM; - instr.opcode |= DST_INT; - if (instr.src != instr.dst) { - instr.imm32 = (instr.getModMem() ? randomx::ScratchpadL1Mask : randomx::ScratchpadL2Mask); - } - else { - instr.imm32 &= randomx::ScratchpadL3Mask; - } - registerUsage[instr.dst].lastUsed = i; - continue; - } - - if (opcode < randomx::ceil_IROR_R) { - instr.dst = instr.dst % randomx::RegistersCount; - instr.src = instr.src % randomx::RegistersCount; - instr.opcode |= DST_INT; - instr.opcode |= SRC_INT; - registerUsage[instr.dst].lastUsed = i; - continue; - } - - if (opcode < randomx::ceil_IROL_R) { - instr.dst = instr.dst % randomx::RegistersCount; - instr.src = instr.src % randomx::RegistersCount; - instr.opcode |= DST_INT; - instr.opcode |= SRC_INT; - registerUsage[instr.dst].lastUsed = i; - continue; - } - - if (opcode < randomx::ceil_ISWAP_R) { - instr.dst = instr.dst % randomx::RegistersCount; - instr.src = instr.src % randomx::RegistersCount; - if (instr.src != instr.dst) { - instr.opcode |= DST_INT; - instr.opcode |= SRC_INT; - instr.opcode |= OP_SWAP; - registerUsage[instr.dst].lastUsed = i; - registerUsage[instr.src].lastUsed = i; - } - continue; - } - - if (opcode < randomx::ceil_FSWAP_R) { - instr.dst = instr.dst % randomx::RegistersCount; - instr.opcode |= DST_FLT; - continue; - } - - if (opcode < randomx::ceil_FADD_R) { - instr.dst = instr.dst % randomx::RegisterCountFlt; - instr.opcode |= DST_FLT; - instr.opcode |= OP_FLOAT; - continue; - } - - if (opcode < randomx::ceil_FADD_M) { - instr.dst = instr.dst % randomx::RegisterCountFlt; - instr.src = instr.src % randomx::RegistersCount; - instr.opcode |= DST_FLT; - instr.opcode |= SRC_MEM; - instr.opcode |= OP_FLOAT; - instr.imm32 = (instr.getModMem() ? randomx::ScratchpadL1Mask : randomx::ScratchpadL2Mask); - continue; - } - - if (opcode < randomx::ceil_FSUB_R) { - instr.dst = instr.dst % randomx::RegisterCountFlt; - instr.opcode |= DST_FLT; - instr.opcode |= OP_FLOAT; - continue; - } - - if (opcode < randomx::ceil_FSUB_M) { - instr.dst = instr.dst % randomx::RegisterCountFlt; - instr.src = instr.src % randomx::RegistersCount; - instr.opcode |= DST_FLT; - instr.opcode |= SRC_MEM; - instr.opcode |= OP_FLOAT; - instr.imm32 = (instr.getModMem() ? randomx::ScratchpadL1Mask : randomx::ScratchpadL2Mask); - continue; - } - - if (opcode < randomx::ceil_FSCAL_R) { - instr.dst = instr.dst % randomx::RegisterCountFlt; - instr.opcode |= DST_FLT; - continue; - } - - if (opcode < randomx::ceil_FMUL_R) { - instr.dst = 4 + instr.dst % randomx::RegisterCountFlt; - instr.opcode |= DST_FLT; - instr.opcode |= OP_FLOAT; - continue; - } - - if (opcode < randomx::ceil_FDIV_M) { - instr.dst = 4 + instr.dst % randomx::RegisterCountFlt; - instr.src = instr.src % randomx::RegistersCount; - instr.opcode |= DST_FLT; - instr.opcode |= SRC_MEM; - instr.opcode |= OP_FLOAT; - instr.imm32 = (instr.getModMem() ? randomx::ScratchpadL1Mask : randomx::ScratchpadL2Mask); - continue; - } - - if (opcode < randomx::ceil_FSQRT_R) { - instr.dst = 4 + instr.dst % randomx::RegisterCountFlt; - instr.opcode |= DST_FLT; - instr.opcode |= OP_FLOAT; - continue; - } - - if (opcode < randomx::ceil_CBRANCH) { - instr.opcode |= OP_BRANCH; - instr.opcode |= DST_INT; - int reg = instr.dst % randomx::RegistersCount; - int target = registerUsage[reg].lastUsed; - int offset = (i - target); - instr.mod = offset; - jumpCount += offset; - p(target + 1).opcode |= BRANCH_TARGET; - registerUsage[reg].count++; - instr.dst = reg; - //mark all registers as used - for (unsigned j = 0; j < randomx::RegistersCount; ++j) { - registerUsage[j].lastUsed = i; - } - continue; - } - - if (opcode < randomx::ceil_CFROUND) { - instr.src = instr.src % randomx::RegistersCount; - instr.opcode |= SRC_INT; - instr.opcode |= OP_CFROUND; - continue; - } - - if (opcode < randomx::ceil_ISTORE) { - instr.dst = instr.dst % randomx::RegistersCount; - instr.src = instr.src % randomx::RegistersCount; - instr.opcode |= DST_MEM; - if (instr.getModCond() < randomx::StoreL3Condition) - instr.imm32 = (instr.getModMem() ? randomx::ScratchpadL1Mask : randomx::ScratchpadL2Mask); - else - instr.imm32 &= randomx::ScratchpadL3Mask; - continue; - } - - if (opcode < randomx::ceil_NOP) { - - } - } - return jumpCount; -} diff --git a/src/tests/rng-tests.cpp b/src/tests/rng-tests.cpp deleted file mode 100644 index fed4761..0000000 --- a/src/tests/rng-tests.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/* - cd ~ - wget http://simul.iro.umontreal.ca/testu01/TestU01.zip - unzip TestU01.zip - mkdir TestU01 - cd TestU01-1.2.3 - ./configure --prefix=`pwd`/../TestU01 - make -j8 - make install - cd ~/RandomX - g++ -O3 src/tests/rng-tests.cpp -lm -I ~/TestU01/include -L ~/TestU01/lib -L bin/ -l:libtestu01.a -l:libmylib.a -l:libprobdist.a -lrandomx -o bin/rng-tests -DRANDOMX_GEN=4R -DRANDOMX_TESTU01=Crush - bin/rng-tests 0 -*/ - -extern "C" { - #include "unif01.h" - #include "bbattery.h" -} - -#include "../aes_hash.hpp" -#include "../blake2/blake2.h" -#include "utility.hpp" -#include - -#ifndef RANDOMX_GEN -#error Please define RANDOMX_GEN with a value of 1R or 4R -#endif - -#ifndef RANDOMX_TESTU01 -#error Please define RANDOMX_TESTU01 with a value of SmallCrush, Crush or BigCrush -#endif - -#define STR(x) #x -#define CONCAT(a,b,c) a ## b ## c -#define GEN_NAME(x) "AesGenerator" STR(x) -#define GEN_FUNC(x) CONCAT(fillAes, x, x4) -#define TEST_SUITE(x) CONCAT(bbattery_, x,) - -constexpr int GeneratorStateSize = 64; -constexpr int GeneratorCapacity = GeneratorStateSize / sizeof(uint32_t); - -static unsigned long aesGenBits(void *param, void *state) { - uint32_t* statePtr = (uint32_t*)state; - int* indexPtr = (int*)param; - int stateIndex = *indexPtr; - if(stateIndex >= GeneratorCapacity) { - GEN_FUNC(RANDOMX_GEN)(statePtr, GeneratorStateSize, statePtr); - stateIndex = 0; - } - uint32_t next = statePtr[stateIndex]; - *indexPtr = stateIndex + 1; - return next; -} - -static double aesGenDouble(void *param, void *state) { - return aesGenBits (param, state) / unif01_NORM32; -} - -static void aesWriteState(void* state) { - char* statePtr = (char*)state; - for(int i = 0; i < 4; ++i) { - std::cout << "state" << i << " = "; - outputHex(std::cout, statePtr + (i * 16), 16); - std::cout << std::endl; - } -} - -int main(int argc, char** argv) { - if (argc != 2) { - std::cout << argv[0] << " " << std::endl; - return 1; - } - uint32_t state[GeneratorCapacity] = { 0 }; - int stateIndex = GeneratorCapacity; - char name[] = GEN_NAME(RANDOMX_GEN); - uint64_t seed = strtoull(argv[1], nullptr, 0); - if(seed) { - blake2b(&state, sizeof(state), &seed, sizeof(seed), nullptr, 0); - } - unif01_Gen gen; - gen.state = &state; - gen.param = &stateIndex; - gen.Write = &aesWriteState; - gen.GetU01 = &aesGenDouble; - gen.GetBits = &aesGenBits; - gen.name = (char*)name; - - gen.Write(gen.state); - std::cout << std::endl; - - TEST_SUITE(RANDOMX_TESTU01)(&gen); - return 0; -} \ No newline at end of file diff --git a/src/tests/runtime-distr.cpp b/src/tests/runtime-distr.cpp deleted file mode 100644 index b7663d0..0000000 --- a/src/tests/runtime-distr.cpp +++ /dev/null @@ -1,172 +0,0 @@ - -#include -#include "utility.hpp" -#include "stopwatch.hpp" -#include "../dataset.hpp" -#include "../vm_compiled.hpp" -#include "../blake2/blake2.h" - -struct Outlier { - Outlier(int idx, double rtime) : index(idx), runtime(rtime) {} - int index; - double runtime; -}; - -int main(int argc, char** argv) { - constexpr int distributionSize = 100; - int distribution[distributionSize + 1] = { 0 }; - Stopwatch sw; - alignas(16) uint64_t hash[8]; - - uint64_t checksum = 0; - double totalRuntime = 0; - double maxRuntime = 0; - std::vector outliers; - outliers.reserve(25); - randomx_flags flags = RANDOMX_FLAG_DEFAULT; - - bool softAes, largePages, jit, verify; - int totalCount, initThreadCount; - double binSize, offset; - int32_t seed; - - readOption("--verify", argc, argv, verify); - readOption("--jit", argc, argv, jit); - readOption("--softAes", argc, argv, softAes); - readIntOption("--nonces", argc, argv, totalCount, 10000); - readIntOption("--init", argc, argv, initThreadCount, 1); - readFloatOption("--binSize", argc, argv, binSize, 1e-3); - readFloatOption("--offset", argc, argv, offset, 0); - readIntOption("--seed", argc, argv, seed, 0); - readOption("--largePages", argc, argv, largePages); - - if (!verify) { - flags = (randomx_flags)(flags | RANDOMX_FLAG_FULL_MEM); - std::cout << "Measure program runtime" << std::endl; - } - else { - std::cout << "Measure verification time" << std::endl; - } - - std::cout << " - histogram offset: " << offset << std::endl; - std::cout << " - histogram bin size: " << binSize << std::endl; - - if (jit) { - flags = (randomx_flags)(flags | RANDOMX_FLAG_JIT); - std::cout << " - JIT compiled mode" << std::endl; - } - else { - std::cout << " - interpreted mode" << std::endl; - } - - if (softAes) { - std::cout << " - software AES mode" << std::endl; - } - else { - flags = (randomx_flags)(flags | RANDOMX_FLAG_HARD_AES); - std::cout << " - hardware AES mode" << std::endl; - } - - if (largePages) { - flags = (randomx_flags)(flags | RANDOMX_FLAG_LARGE_PAGES); - std::cout << " - large pages mode" << std::endl; - } - else { - std::cout << " - small pages mode" << std::endl; - } - - std::cout << "Initializing..." << std::endl; - - randomx_cache *cache = randomx_alloc_cache(flags); - randomx_dataset *dataset = nullptr; - if (cache == nullptr) { - std::cout << "Cache allocation failed" << std::endl; - return 1; - } - randomx_init_cache(cache, &seed, sizeof seed); - - if (!verify) { - blake2b(&hash, sizeof hash, &seed, sizeof seed, nullptr, 0); - - dataset = randomx_alloc_dataset(flags); - if (dataset == nullptr) { - std::cout << "Dataset allocation failed" << std::endl; - return 1; - } - - std::vector threads; - uint32_t datasetItemCount = randomx_dataset_item_count(); - if (initThreadCount > 1) { - auto perThread = datasetItemCount / initThreadCount; - auto remainder = datasetItemCount % initThreadCount; - uint32_t startItem = 0; - for (int i = 0; i < initThreadCount; ++i) { - auto count = perThread + (i == initThreadCount - 1 ? remainder : 0); - threads.push_back(std::thread(&randomx_init_dataset, dataset, cache, startItem, count)); - startItem += count; - } - for (unsigned i = 0; i < threads.size(); ++i) { - threads[i].join(); - } - } - else { - randomx_init_dataset(dataset, cache, 0, datasetItemCount); - } - randomx_release_cache(cache); - cache = nullptr; - } - - std::cout << "Running " << totalCount << " programs..." << std::endl; - - randomx_vm* vm = randomx_create_vm(flags, cache, dataset); - - if (!verify) { - vm->initScratchpad(&hash); - vm->resetRoundingMode(); - } - - for (int i = 0; i < totalCount; ++i) { - sw.restart(); - if (verify) - randomx_calculate_hash(vm, &i, sizeof i, &hash); - else - vm->run(&hash); - double elapsed = sw.getElapsed(); - //std::cout << "Elapsed: " << elapsed << std::endl; - totalRuntime += elapsed; - if (elapsed > maxRuntime) - maxRuntime = elapsed; - int bin = (elapsed - offset) / binSize; - bool outlier = false; - if (bin < 0) { - bin = 0; - outlier = true; - } - if (bin > distributionSize) { - bin = distributionSize; - outlier = true; - } - if (outlier && outliers.size() < outliers.capacity()) - outliers.push_back(Outlier(i, elapsed)); - distribution[bin]++; - if(!verify) - blake2b(hash, sizeof(hash), vm->getRegisterFile(), sizeof(randomx::RegisterFile), nullptr, 0); - checksum ^= hash[0]; - } - - for (int i = 0; i < distributionSize + 1; ++i) { - std::cout << i << " " << distribution[i] << std::endl; - } - - std::cout << "Average runtime: " << totalRuntime / totalCount << std::endl; - std::cout << "Maximum runtime: " << maxRuntime << std::endl; - std::cout << "Checksum: " << checksum << std::endl; - - std::cout << "Outliers: " << std::endl; - - for (Outlier& ol : outliers) { - std::cout << " " << ol.index << ": " << ol.runtime << std::endl; - } - - return 0; -} \ No newline at end of file diff --git a/src/tests/scratchpad-entropy.cpp b/src/tests/scratchpad-entropy.cpp deleted file mode 100644 index ecb3c7d..0000000 --- a/src/tests/scratchpad-entropy.cpp +++ /dev/null @@ -1,50 +0,0 @@ -#include -#include -#include "utility.hpp" -#include "../randomx.h" -#include "../virtual_machine.hpp" -#include "../blake2/endian.h" - -/* - Writes final scratchpads to disk as files with .spad extension, each file is 2048 KiB. - Command line parameters: - --count N number of files to generate (default = 1) - --seed S different seed will give different outputs (default = 0) - - Entropy can be estimated by compressing the files using 7zip in Ultra mode: - - 7z.exe a -t7z -m0=lzma2 -mx=9 scratchpads.7z *.spad -*/ - -int main(int argc, char** argv) { - int count, seedValue; - - readIntOption("--count", argc, argv, count, 1); - readIntOption("--seed", argc, argv, seedValue, 0); - - std::cout << "Generating " << count << " scratchpad(s) using seed " << seedValue << " ..." << std::endl; - - char seed[4]; - char input[4]; - char hash[RANDOMX_HASH_SIZE]; - - store32(&seed, seedValue); - - randomx_cache *cache = randomx_alloc_cache(RANDOMX_FLAG_DEFAULT); - randomx_init_cache(cache, &seed, sizeof seed); - randomx_vm *vm = randomx_create_vm(RANDOMX_FLAG_DEFAULT, cache, NULL); - - for (int i = 0; i < count; ++i) { - store32(&input, i); - randomx_calculate_hash(vm, &input, sizeof input, hash); - std::string filename("test-"); - filename += std::to_string(i); - filename += ".spad"; - dump((const char*)vm->getScratchpad(), randomx::ScratchpadSize, filename.c_str()); - } - - randomx_destroy_vm(vm); - randomx_release_cache(cache); - - return 0; -} diff --git a/src/tests/superscalar-avalanche.cpp b/src/tests/superscalar-avalanche.cpp deleted file mode 100644 index d9f916c..0000000 --- a/src/tests/superscalar-avalanche.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include -#include -#include -#include "../superscalar.hpp" -#include "../intrin_portable.h" - -const uint8_t seed[32] = { 191, 182, 222, 175, 249, 89, 134, 104, 241, 68, 191, 62, 162, 166, 61, 64, 123, 191, 227, 193, 118, 60, 188, 53, 223, 133, 175, 24, 123, 230, 55, 74 }; - -int main() { - - int insensitiveProgCount[64] = { 0 }; - std::vector dummy; - for (int bit = 0; bit < 64; ++bit) { - for (int i = 0; i < 10000; ++i) { - uint64_t ra[8] = { - 6364136223846793005ULL, - 9298410992540426748ULL, - 12065312585734608966ULL, - 9306329213124610396ULL, - 5281919268842080866ULL, - 10536153434571861004ULL, - 3398623926847679864ULL, - 9549104520008361294ULL, - }; - uint64_t rb[8]; - memcpy(rb, ra, sizeof rb); - rb[0] ^= (1ULL << bit); - randomx::SuperscalarProgram p; - randomx::Blake2Generator gen(seed, sizeof seed, i); - randomx::generateSuperscalar(p, gen); - randomx::executeSuperscalar(ra, p, nullptr); - randomx::executeSuperscalar(rb, p, nullptr); - uint64_t diff = 0; - for (int j = 0; j < 8; ++j) { - diff += __popcnt64(ra[j] ^ rb[j]); - } - if (diff < 192 || diff > 320) { - std::cout << "Seed: " << i << " diff = " << diff << std::endl; - insensitiveProgCount[bit]++; - } - } - } - for (int bit = 0; bit < 64; ++bit) { - std::cout << bit << " " << insensitiveProgCount[bit] << std::endl; - } - - return 0; -} \ No newline at end of file diff --git a/src/tests/superscalar-init.cpp b/src/tests/superscalar-init.cpp deleted file mode 100644 index 15554bb..0000000 --- a/src/tests/superscalar-init.cpp +++ /dev/null @@ -1,55 +0,0 @@ -#include -#include -#include -#include -#include "../superscalar.hpp" -#include "../common.hpp" - -int main() { - std::cout << "THIS PROGRAM REQUIRES MORE THAN 16 GB OF RAM TO COMPLETE" << std::endl; - std::vector dummy; - constexpr uint64_t superscalarMul0 = 6364136223846793005ULL; - constexpr uint64_t superscalarAdd1 = 0x810A978A59F5A1FC; //9298410992540426748ULL; //9298410992540426048ULL - constexpr uint64_t superscalarAdd2 = 12065312585734608966ULL; - constexpr uint64_t superscalarAdd3 = 0x8126B91CBF22495C; //9306329213124610396ULL; - constexpr uint64_t superscalarAdd4 = 5281919268842080866ULL; - constexpr uint64_t superscalarAdd5 = 10536153434571861004ULL; - constexpr uint64_t superscalarAdd6 = 3398623926847679864ULL; - constexpr uint64_t superscalarAdd7 = 9549104520008361294ULL; - constexpr uint32_t totalItems = randomx::DatasetSize / randomx::CacheLineSize; - std::unordered_set registerValues; - registerValues.reserve(totalItems); - registerValues.rehash(totalItems); - int collisionCount[9] = { 0 }; - for (uint32_t itemNumber = 0; itemNumber < totalItems; ++itemNumber) { - uint64_t rl[8]; - rl[0] = (itemNumber + 1) * superscalarMul0; - rl[1] = rl[0] ^ superscalarAdd1; - rl[2] = rl[0] ^ superscalarAdd2; - rl[3] = rl[0] ^ superscalarAdd3; - rl[4] = rl[0] ^ superscalarAdd4; - rl[5] = rl[0] ^ superscalarAdd5; - rl[6] = rl[0] ^ superscalarAdd6; - rl[7] = rl[0] ^ superscalarAdd7; - int blockCollisions = 0; - for (int i = 0; i < 8; ++i) { - uint64_t reducedValue = rl[i] & 0x3FFFFFFFFFFFF8; //bits 3-53 only - if (registerValues.find(reducedValue) != registerValues.end()) { - blockCollisions++; - std::cout << "Item " << itemNumber << ": collision of register r" << i << std::endl; - } - else { - registerValues.insert(reducedValue); - } - } - collisionCount[blockCollisions]++; - if ((itemNumber % (320 * 1024)) == 0) - std::cout << "Item " << itemNumber << " processed" << std::endl; - } - - for (int i = 0; i < 9; ++i) { - std::cout << i << " register(s) collide in " << collisionCount[i] << " items" << std::endl; - } - - return 0; -} \ No newline at end of file diff --git a/src/tests/superscalar-stats.cpp b/src/tests/superscalar-stats.cpp deleted file mode 100644 index d0322a4..0000000 --- a/src/tests/superscalar-stats.cpp +++ /dev/null @@ -1,52 +0,0 @@ -#include -#include -#include "../superscalar.hpp" -#include "../blake2_generator.hpp" - -const uint8_t seed[32] = { 191, 182, 222, 175, 249, 89, 134, 104, 241, 68, 191, 62, 162, 166, 61, 64, 123, 191, 227, 193, 118, 60, 188, 53, 223, 133, 175, 24, 123, 230, 55, 74 }; - -int main() { - - constexpr int count = 1000000; - int isnCounts[(int)randomx::SuperscalarInstructionType::COUNT] = { 0 }; - int64_t asicLatency = 0; - int64_t codesize = 0; - int64_t cpuLatency = 0; - int64_t macroOps = 0; - int64_t mulCount = 0; - int64_t size = 0; - for (int i = 0; i < count; ++i) { - randomx::SuperscalarProgram prog; - randomx::Blake2Generator gen(seed, i); - randomx::generateSuperscalar(prog, gen); - asicLatency += prog.asicLatency; - codesize += prog.codeSize; - cpuLatency += prog.cpuLatency; - macroOps += prog.macroOps; - mulCount += prog.mulCount; - size += prog.getSize(); - - for (unsigned j = 0; j < prog.getSize(); ++j) { - isnCounts[prog(j).opcode]++; - } - - if ((i + 1) % (count / 100) == 0) { - std::cout << "Completed " << ((i + 1) / (count / 100)) << "% ..." << std::endl; - } - } - - std::cout << "Avg. IPC: " << (macroOps / (double)cpuLatency) << std::endl; - std::cout << "Avg. ASIC latency: " << (asicLatency / (double)count) << std::endl; - std::cout << "Avg. CPU latency: " << (cpuLatency / (double)count) << std::endl; - std::cout << "Avg. code size: " << (codesize / (double)count) << std::endl; - std::cout << "Avg. x86 ops: " << (macroOps / (double)count) << std::endl; - std::cout << "Avg. mul. count: " << (mulCount / (double)count) << std::endl; - std::cout << "Avg. RandomX ops: " << (size / (double)count) << std::endl; - - std::cout << "Frequencies: " << std::endl; - for (unsigned j = 0; j < (int)randomx::SuperscalarInstructionType::COUNT; ++j) { - std::cout << j << " " << isnCounts[j] << " " << isnCounts[j] / (double)size << std::endl; - } - - return 0; -} \ No newline at end of file diff --git a/src/tests/tests.cpp b/src/tests/tests.cpp deleted file mode 100644 index 29cdb92..0000000 --- a/src/tests/tests.cpp +++ /dev/null @@ -1,1032 +0,0 @@ -#ifdef NDEBUG -#undef NDEBUG -#endif - -#include -#include -#include "utility.hpp" -#include "../bytecode_machine.hpp" -#include "../dataset.hpp" -#include "../blake2/endian.h" -#include "../blake2/blake2.h" -#include "../blake2_generator.hpp" -#include "../superscalar.hpp" -#include "../reciprocal.h" -#include "../intrin_portable.h" -#include "../jit_compiler.hpp" -#include "../aes_hash.hpp" - -struct CacheKey { - void* key; - size_t size = 0; -}; - -randomx_cache* cache; -randomx_vm* vm = nullptr; -CacheKey currentKey; - -template -void initCache(const char (&key)[N]) { - assert(cache != nullptr); - if (N - 1 == currentKey.size && memcmp(currentKey.key, key, N - 1) == 0) - return; - //std::cout << "randomx_init_cache with key "; - //outputHex(std::cout, key, N - 1); - //std::cout << std::endl; - randomx_init_cache(cache, key, N - 1); - currentKey.key = (void*)key; - currentKey.size = N - 1; - if (vm != nullptr) - randomx_vm_set_cache(vm, cache); -} - -template -void calcStringHash(const char(&key)[K], const char(&input)[H], void* output) { - initCache(key); - assert(vm != nullptr); - randomx_calculate_hash(vm, input, H - 1, output); -} - -template -void calcHexHash(const char(&key)[K], const char(&hex)[H], void* output) { - initCache(key); - assert(vm != nullptr); - char input[H / 2]; - hex2bin((char*)hex, H - 1, input); - randomx_calculate_hash(vm, input, sizeof(input), output); -} - -int testNo = 0; -int skipped = 0; - -template -void runTest(const char* name, bool condition, FUNC f) { - std::cout << "["; - std::cout.width(2); - std::cout << std::right << ++testNo << "] "; - std::cout.width(40); - std::cout << std::left << name << " ... "; - std::cout.flush(); - if (condition) { - f(); - std::cout << "PASSED" << std::endl; - } - else { - std::cout << "SKIPPED" << std::endl; - skipped++; - } -} - -int main() { - char testHash[32]; - - //std::cout << "Allocating randomx_cache..." << std::endl; - cache = randomx_alloc_cache(RANDOMX_FLAG_DEFAULT); - - runTest("Cache initialization", RANDOMX_ARGON_ITERATIONS == 3 && RANDOMX_ARGON_LANES == 1 && RANDOMX_ARGON_MEMORY == 262144 && stringsEqual(RANDOMX_ARGON_SALT, "RandomX\x03"), []() { - initCache("test key 000"); - uint64_t* cacheMemory = (uint64_t*)cache->memory; - assert(cacheMemory[0] == 0x191e0e1d23c02186); - assert(cacheMemory[1568413] == 0xf1b62fe6210bf8b1); - assert(cacheMemory[33554431] == 0x1f47f056d05cd99b); - }); - - runTest("SuperscalarHash generator", RANDOMX_SUPERSCALAR_LATENCY == 170, []() { - char sprogHash[32]; - randomx::SuperscalarProgram sprog; - const char key[] = "test key 000"; - constexpr size_t keySize = sizeof(key) - 1; - randomx::Blake2Generator gen(key, keySize); - - const char superscalarReferences[10][65] = { - "d3a4a6623738756f77e6104469102f082eff2a3e60be7ad696285ef7dfc72a61", - "f5e7e0bbc7e93c609003d6359208688070afb4a77165a552ff7be63b38dfbc86", - "85ed8b11734de5b3e9836641413a8f36e99e89694f419c8cd25c3f3f16c40c5a", - "5dd956292cf5d5704ad99e362d70098b2777b2a1730520be52f772ca48cd3bc0", - "6f14018ca7d519e9b48d91af094c0f2d7e12e93af0228782671a8640092af9e5", - "134be097c92e2c45a92f23208cacd89e4ce51f1009a0b900dbe83b38de11d791", - "268f9392c20c6e31371a5131f82bd7713d3910075f2f0468baafaa1abd2f3187", - "c668a05fd909714ed4a91e8d96d67b17e44329e88bc71e0672b529a3fc16be47", - "99739351315840963011e4c5d8e90ad0bfed3facdcb713fe8f7138fbf01c4c94", - "14ab53d61880471f66e80183968d97effd5492b406876060e595fcf9682f9295", - }; - - for (int i = 0; i < 10; ++i) { - randomx::generateSuperscalar(sprog, gen); - blake2b(sprogHash, sizeof(sprogHash), &sprog.programBuffer, sizeof(randomx::Instruction) * sprog.getSize(), nullptr, 0); - assert(equalsHex(sprogHash, superscalarReferences[i])); - } - }); - - runTest("randomx_reciprocal", true, []() { - assert(randomx_reciprocal(3) == 12297829382473034410U); - assert(randomx_reciprocal(13) == 11351842506898185609U); - assert(randomx_reciprocal(33) == 17887751829051686415U); - assert(randomx_reciprocal(65537) == 18446462603027742720U); - assert(randomx_reciprocal(15000001) == 10316166306300415204U); - assert(randomx_reciprocal(3845182035) == 10302264209224146340U); - assert(randomx_reciprocal(0xffffffff) == 9223372039002259456U); - }); - - runTest("randomx_reciprocal_fast", RANDOMX_HAVE_FAST_RECIPROCAL, []() { - assert(randomx_reciprocal_fast(3) == 12297829382473034410U); - assert(randomx_reciprocal_fast(13) == 11351842506898185609U); - assert(randomx_reciprocal_fast(33) == 17887751829051686415U); - assert(randomx_reciprocal_fast(65537) == 18446462603027742720U); - assert(randomx_reciprocal_fast(15000001) == 10316166306300415204U); - assert(randomx_reciprocal_fast(3845182035) == 10302264209224146340U); - assert(randomx_reciprocal_fast(0xffffffff) == 9223372039002259456U); - }); - - runTest("Dataset initialization (interpreter)", stringsEqual(RANDOMX_ARGON_SALT, "RandomX\x03"), []() { - initCache("test key 000"); - uint64_t datasetItem[8]; - randomx::initDatasetItem(cache, (uint8_t*)&datasetItem, 0); - assert(datasetItem[0] == 0x680588a85ae222db); - randomx::initDatasetItem(cache, (uint8_t*)&datasetItem, 10000000); - assert(datasetItem[0] == 0x7943a1f6186ffb72); - randomx::initDatasetItem(cache, (uint8_t*)&datasetItem, 20000000); - assert(datasetItem[0] == 0x9035244d718095e1); - randomx::initDatasetItem(cache, (uint8_t*)&datasetItem, 30000000); - assert(datasetItem[0] == 0x145a5091f7853099); - }); - - runTest("Dataset initialization (compiler)", RANDOMX_HAVE_COMPILER && stringsEqual(RANDOMX_ARGON_SALT, "RandomX\x03"), []() { - initCache("test key 000"); - randomx::JitCompiler jit; - jit.generateSuperscalarHash(cache->programs, cache->reciprocalCache); - jit.generateDatasetInitCode(); - uint64_t datasetItem[8]; - jit.getDatasetInitFunc()(cache, (uint8_t*)&datasetItem, 0, 1); - assert(datasetItem[0] == 0x680588a85ae222db); - jit.getDatasetInitFunc()(cache, (uint8_t*)&datasetItem, 10000000, 10000001); - assert(datasetItem[0] == 0x7943a1f6186ffb72); - jit.getDatasetInitFunc()(cache, (uint8_t*)&datasetItem, 20000000, 20000001); - assert(datasetItem[0] == 0x9035244d718095e1); - jit.getDatasetInitFunc()(cache, (uint8_t*)&datasetItem, 30000000, 30000001); - assert(datasetItem[0] == 0x145a5091f7853099); - }); - - runTest("AesGenerator1R", true, []() { - char state[64] = { 0 }; - hex2bin("6c19536eb2de31b6c0065f7f116e86f960d8af0c57210a6584c3237b9d064dc7", 64, state); - fillAes1Rx4(state, sizeof(state), state); - assert(equalsHex(state, "fa89397dd6ca422513aeadba3f124b5540324c4ad4b6db434394307a17c833ab")); - }); - - randomx::NativeRegisterFile reg; - randomx::BytecodeMachine decoder; - randomx::InstructionByteCode ibc; - alignas(16) randomx::ProgramConfiguration config; - constexpr int registerHigh = 192; - constexpr int registerDst = 0; - constexpr int registerSrc = 1; - int pc = 0; - constexpr uint32_t imm32 = 3234567890; - constexpr uint64_t imm64 = signExtend2sCompl(imm32); - - decoder.beginCompilation(reg); - - runTest("IADD_RS (decode)", RANDOMX_FREQ_IADD_RS > 0, [&] { - randomx::Instruction instr; - instr.opcode = randomx::ceil_IADD_RS - 1; - instr.dst = registerHigh | registerDst; - instr.src = registerHigh | registerSrc; - instr.mod = UINT8_MAX; - instr.setImm32(imm32); - decoder.compileInstruction(instr, pc, ibc); - assert(ibc.type == randomx::InstructionType::IADD_RS); - assert(ibc.idst == ®.r[registerDst]); - assert(ibc.isrc == ®.r[registerSrc]); - assert(ibc.shift == 3); - assert(ibc.imm == 0); - }); - - runTest("IADD_RS (execute)", RANDOMX_FREQ_IADD_RS > 0, [&] { - reg.r[registerDst] = 0x8000000000000000; - reg.r[registerSrc] = 0x1000000000000000; - decoder.executeInstruction(ibc, pc, nullptr, config); - assert(reg.r[registerDst] == 0); - }); - - runTest("IADD_RS with immediate (decode)", RANDOMX_FREQ_IADD_RS > 0, [&] { - randomx::Instruction instr; - instr.opcode = randomx::ceil_IADD_RS - 1; - instr.mod = 8; - instr.dst = registerHigh | randomx::RegisterNeedsDisplacement; - instr.src = registerHigh | registerSrc; - instr.setImm32(imm32); - decoder.compileInstruction(instr, pc, ibc); - assert(ibc.type == randomx::InstructionType::IADD_RS); - assert(ibc.idst == ®.r[randomx::RegisterNeedsDisplacement]); - assert(ibc.isrc == ®.r[registerSrc]); - assert(ibc.shift == 2); - assert(ibc.imm == imm64); - }); - - runTest("IADD_RS with immediate (decode)", RANDOMX_FREQ_IADD_RS > 0, [&] { - reg.r[randomx::RegisterNeedsDisplacement] = 0x8000000000000000; - reg.r[registerSrc] = 0x2000000000000000; - decoder.executeInstruction(ibc, pc, nullptr, config); - assert(reg.r[randomx::RegisterNeedsDisplacement] == imm64); - }); - - runTest("IADD_M (decode)", RANDOMX_FREQ_IADD_M > 0, [&] { - randomx::Instruction instr; - instr.opcode = randomx::ceil_IADD_M - 1; - instr.mod = 1; - instr.dst = registerHigh | registerDst; - instr.src = registerHigh | registerSrc; - instr.setImm32(imm32); - decoder.compileInstruction(instr, pc, ibc); - assert(ibc.type == randomx::InstructionType::IADD_M); - assert(ibc.idst == ®.r[registerDst]); - assert(ibc.isrc == ®.r[registerSrc]); - assert(ibc.imm == imm64); - assert(ibc.memMask == randomx::ScratchpadL1Mask); - }); - - runTest("ISUB_R (decode)", RANDOMX_FREQ_ISUB_R > 0, [&] { - randomx::Instruction instr; - instr.opcode = randomx::ceil_ISUB_R - 1; - instr.dst = registerHigh | registerDst; - instr.src = registerHigh | registerSrc; - instr.setImm32(imm32); - decoder.compileInstruction(instr, pc, ibc); - assert(ibc.type == randomx::InstructionType::ISUB_R); - assert(ibc.idst == ®.r[registerDst]); - assert(ibc.isrc == ®.r[registerSrc]); - }); - - runTest("ISUB_R (execute)", RANDOMX_FREQ_ISUB_R > 0, [&] { - reg.r[registerDst] = 1; - reg.r[registerSrc] = 0xFFFFFFFF; - decoder.executeInstruction(ibc, pc, nullptr, config); - assert(reg.r[registerDst] == 0xFFFFFFFF00000002); - }); - - runTest("ISUB_R with immediate (decode)", RANDOMX_FREQ_ISUB_R > 0, [&] { - randomx::Instruction instr; - instr.opcode = randomx::ceil_ISUB_R - 1; - instr.dst = registerHigh | registerDst; - instr.src = registerHigh | registerDst; - instr.setImm32(imm32); - decoder.compileInstruction(instr, pc, ibc); - assert(ibc.type == randomx::InstructionType::ISUB_R); - assert(ibc.idst == ®.r[registerDst]); - assert(ibc.isrc == &ibc.imm); - }); - - runTest("ISUB_R with immediate (decode)", RANDOMX_FREQ_ISUB_R > 0, [&] { - reg.r[registerDst] = 0; - decoder.executeInstruction(ibc, pc, nullptr, config); - assert(reg.r[registerDst] == (~imm64 + 1)); - }); - - runTest("ISUB_M (decode)", RANDOMX_FREQ_ISUB_M > 0, [&] { - randomx::Instruction instr; - instr.opcode = randomx::ceil_ISUB_M - 1; - instr.mod = 0; - instr.dst = registerHigh | registerDst; - instr.src = registerHigh | registerSrc; - instr.setImm32(imm32); - decoder.compileInstruction(instr, pc, ibc); - assert(ibc.type == randomx::InstructionType::ISUB_M); - assert(ibc.idst == ®.r[registerDst]); - assert(ibc.isrc == ®.r[registerSrc]); - assert(ibc.imm == imm64); - assert(ibc.memMask == randomx::ScratchpadL2Mask); - }); - - runTest("IMUL_R (decode)", RANDOMX_FREQ_IMUL_R > 0, [&] { - randomx::Instruction instr; - instr.opcode = randomx::ceil_IMUL_R - 1; - instr.dst = registerHigh | registerDst; - instr.src = registerHigh | registerSrc; - instr.setImm32(imm32); - decoder.compileInstruction(instr, pc, ibc); - assert(ibc.type == randomx::InstructionType::IMUL_R); - assert(ibc.idst == ®.r[registerDst]); - assert(ibc.isrc == ®.r[registerSrc]); - }); - - runTest("IMUL_R (execute)", RANDOMX_FREQ_IMUL_R > 0, [&] { - reg.r[registerDst] = 0xBC550E96BA88A72B; - reg.r[registerSrc] = 0xF5391FA9F18D6273; - decoder.executeInstruction(ibc, pc, nullptr, config); - assert(reg.r[registerDst] == 0x28723424A9108E51); - }); - - runTest("IMUL_R with immediate (decode)", RANDOMX_FREQ_IMUL_R > 0, [&] { - randomx::Instruction instr; - instr.opcode = randomx::ceil_IMUL_R - 1; - instr.dst = registerHigh | registerDst; - instr.src = registerHigh | registerDst; - instr.setImm32(imm32); - decoder.compileInstruction(instr, pc, ibc); - assert(ibc.type == randomx::InstructionType::IMUL_R); - assert(ibc.idst == ®.r[registerDst]); - assert(ibc.isrc == &ibc.imm); - }); - - runTest("IMUL_R with immediate (execute)", RANDOMX_FREQ_IMUL_R > 0, [&] { - reg.r[registerDst] = 1; - decoder.executeInstruction(ibc, pc, nullptr, config); - assert(reg.r[registerDst] == imm64); - }); - - runTest("IMUL_M (decode)", RANDOMX_FREQ_IMUL_M > 0, [&] { - randomx::Instruction instr; - instr.opcode = randomx::ceil_IMUL_M - 1; - instr.mod = 0; - instr.dst = registerHigh | registerDst; - instr.src = registerHigh | registerDst; - instr.setImm32(imm32); - decoder.compileInstruction(instr, pc, ibc); - assert(ibc.type == randomx::InstructionType::IMUL_M); - assert(ibc.idst == ®.r[registerDst]); - assert(*ibc.isrc == 0); - assert(ibc.imm == imm64); - assert(ibc.memMask == randomx::ScratchpadL3Mask); - }); - - runTest("IMULH_R (decode)", RANDOMX_FREQ_IMULH_R > 0, [&] { - randomx::Instruction instr; - instr.opcode = randomx::ceil_IMULH_R - 1; - instr.dst = registerHigh | registerDst; - instr.src = registerHigh | registerSrc; - instr.setImm32(imm32); - decoder.compileInstruction(instr, pc, ibc); - assert(ibc.type == randomx::InstructionType::IMULH_R); - assert(ibc.idst == ®.r[registerDst]); - assert(ibc.isrc == ®.r[registerSrc]); - }); - - runTest("IMULH_R (execute)", RANDOMX_FREQ_IMULH_R > 0, [&] { - reg.r[registerDst] = 0xBC550E96BA88A72B; - reg.r[registerSrc] = 0xF5391FA9F18D6273; - decoder.executeInstruction(ibc, pc, nullptr, config); - assert(reg.r[registerDst] == 0xB4676D31D2B34883); - }); - - runTest("IMULH_R squared (decode)", RANDOMX_FREQ_IMULH_R > 0, [&] { - randomx::Instruction instr; - instr.opcode = randomx::ceil_IMULH_R - 1; - instr.dst = registerHigh | registerDst; - instr.src = registerHigh | registerDst; - instr.setImm32(imm32); - decoder.compileInstruction(instr, pc, ibc); - assert(ibc.type == randomx::InstructionType::IMULH_R); - assert(ibc.idst == ®.r[registerDst]); - assert(ibc.isrc == ®.r[registerDst]); - }); - - runTest("IMULH_M (decode)", RANDOMX_FREQ_IMULH_M > 0, [&] { - randomx::Instruction instr; - instr.opcode = randomx::ceil_IMULH_M - 1; - instr.mod = 0; - instr.dst = registerHigh | registerDst; - instr.src = registerHigh | registerSrc; - instr.setImm32(imm32); - decoder.compileInstruction(instr, pc, ibc); - assert(ibc.type == randomx::InstructionType::IMULH_M); - assert(ibc.idst == ®.r[registerDst]); - assert(ibc.isrc == ®.r[registerSrc]); - assert(ibc.imm == imm64); - assert(ibc.memMask == randomx::ScratchpadL2Mask); - }); - - runTest("ISMULH_R (decode)", RANDOMX_FREQ_ISMULH_R > 0, [&] { - randomx::Instruction instr; - instr.opcode = randomx::ceil_ISMULH_R - 1; - instr.dst = registerHigh | registerDst; - instr.src = registerHigh | registerSrc; - instr.setImm32(imm32); - decoder.compileInstruction(instr, pc, ibc); - assert(ibc.type == randomx::InstructionType::ISMULH_R); - assert(ibc.idst == ®.r[registerDst]); - assert(ibc.isrc == ®.r[registerSrc]); - }); - - runTest("ISMULH_R (execute)", RANDOMX_FREQ_ISMULH_R > 0, [&] { - reg.r[registerDst] = 0xBC550E96BA88A72B; - reg.r[registerSrc] = 0xF5391FA9F18D6273; - decoder.executeInstruction(ibc, pc, nullptr, config); - assert(reg.r[registerDst] == 0x02D93EF1269D3EE5); - }); - - runTest("ISMULH_R squared (decode)", RANDOMX_FREQ_ISMULH_R > 0, [&] { - randomx::Instruction instr; - instr.opcode = randomx::ceil_ISMULH_R - 1; - instr.dst = registerHigh | registerDst; - instr.src = registerHigh | registerDst; - instr.setImm32(imm32); - decoder.compileInstruction(instr, pc, ibc); - assert(ibc.type == randomx::InstructionType::ISMULH_R); - assert(ibc.idst == ®.r[registerDst]); - assert(ibc.isrc == ®.r[registerDst]); - }); - - runTest("ISMULH_M (decode)", RANDOMX_FREQ_ISMULH_M > 0, [&] { - randomx::Instruction instr; - instr.opcode = randomx::ceil_ISMULH_M - 1; - instr.mod = 3; - instr.dst = registerHigh | registerDst; - instr.src = registerHigh | registerSrc; - instr.setImm32(imm32); - decoder.compileInstruction(instr, pc, ibc); - assert(ibc.type == randomx::InstructionType::ISMULH_M); - assert(ibc.idst == ®.r[registerDst]); - assert(ibc.isrc == ®.r[registerSrc]); - assert(ibc.imm == imm64); - assert(ibc.memMask == randomx::ScratchpadL1Mask); - }); - - runTest("IMUL_RCP (decode)", RANDOMX_FREQ_IMUL_RCP > 0, [&] { - randomx::Instruction instr; - instr.opcode = randomx::ceil_IMUL_RCP - 1; - instr.dst = registerHigh | registerDst; - instr.setImm32(imm32); - decoder.compileInstruction(instr, pc, ibc); - assert(ibc.type == randomx::InstructionType::IMUL_R); - assert(ibc.idst == ®.r[registerDst]); - assert(ibc.isrc == &ibc.imm); - assert(ibc.imm == randomx_reciprocal(imm32)); - }); - - runTest("IMUL_RCP zero imm32 (decode)", RANDOMX_FREQ_IMUL_RCP > 0, [&] { - randomx::Instruction instr; - instr.opcode = randomx::ceil_IMUL_RCP - 1; - instr.setImm32(0); - decoder.compileInstruction(instr, pc, ibc); - assert(ibc.type == randomx::InstructionType::NOP); - }); - - runTest("INEG_R (decode)", RANDOMX_FREQ_INEG_R > 0, [&] { - randomx::Instruction instr; - instr.opcode = randomx::ceil_INEG_R - 1; - instr.dst = registerHigh | registerDst; - instr.setImm32(imm32); - decoder.compileInstruction(instr, pc, ibc); - assert(ibc.type == randomx::InstructionType::INEG_R); - assert(ibc.idst == ®.r[registerDst]); - }); - - runTest("INEG_R (execute)", RANDOMX_FREQ_INEG_R > 0, [&] { - reg.r[registerDst] = 0xFFFFFFFFFFFFFFFF; - decoder.executeInstruction(ibc, pc, nullptr, config); - assert(reg.r[registerDst] == 1); - }); - - runTest("IXOR_R (decode)", RANDOMX_FREQ_IXOR_R > 0, [&] { - randomx::Instruction instr; - instr.opcode = randomx::ceil_IXOR_R - 1; - instr.dst = registerHigh | registerDst; - instr.src = registerHigh | registerSrc; - instr.setImm32(imm32); - decoder.compileInstruction(instr, pc, ibc); - assert(ibc.type == randomx::InstructionType::IXOR_R); - assert(ibc.idst == ®.r[registerDst]); - assert(ibc.isrc == ®.r[registerSrc]); - }); - - runTest("IXOR_R (execute)", RANDOMX_FREQ_IMUL_R > 0, [&] { - reg.r[registerDst] = 0x8888888888888888; - reg.r[registerSrc] = 0xAAAAAAAAAAAAAAAA; - decoder.executeInstruction(ibc, pc, nullptr, config); - assert(reg.r[registerDst] == 0x2222222222222222); - }); - - runTest("IXOR_R with immediate (decode)", RANDOMX_FREQ_IXOR_R > 0, [&] { - randomx::Instruction instr; - instr.opcode = randomx::ceil_IXOR_R - 1; - instr.dst = registerHigh | registerDst; - instr.src = registerHigh | registerDst; - instr.setImm32(imm32); - decoder.compileInstruction(instr, pc, ibc); - assert(ibc.type == randomx::InstructionType::IXOR_R); - assert(ibc.idst == ®.r[registerDst]); - assert(ibc.isrc == &ibc.imm); - }); - - runTest("IXOR_R with immediate (execute)", RANDOMX_FREQ_IXOR_R > 0, [&] { - reg.r[registerDst] = 0xFFFFFFFFFFFFFFFF; - decoder.executeInstruction(ibc, pc, nullptr, config); - assert(reg.r[registerDst] == ~imm64); - }); - - runTest("IXOR_M (decode)", RANDOMX_FREQ_IXOR_M > 0, [&] { - randomx::Instruction instr; - instr.opcode = randomx::ceil_IXOR_M - 1; - instr.dst = registerHigh | registerDst; - instr.src = registerHigh | registerDst; - instr.setImm32(imm32); - decoder.compileInstruction(instr, pc, ibc); - assert(ibc.type == randomx::InstructionType::IXOR_M); - assert(ibc.idst == ®.r[registerDst]); - assert(*ibc.isrc == 0); - assert(ibc.imm == imm64); - assert(ibc.memMask == randomx::ScratchpadL3Mask); - }); - - runTest("IROR_R (decode)", RANDOMX_FREQ_IROR_R > 0, [&] { - randomx::Instruction instr; - instr.opcode = randomx::ceil_IROR_R - 1; - instr.dst = registerHigh | registerDst; - instr.src = registerHigh | registerSrc; - instr.setImm32(imm32); - decoder.compileInstruction(instr, pc, ibc); - assert(ibc.type == randomx::InstructionType::IROR_R); - assert(ibc.idst == ®.r[registerDst]); - assert(ibc.isrc == ®.r[registerSrc]); - }); - - runTest("IROR_R (execute)", RANDOMX_FREQ_IROR_R > 0, [&] { - reg.r[registerDst] = 953360005391419562; - reg.r[registerSrc] = 4569451684712230561; - decoder.executeInstruction(ibc, pc, nullptr, config); - assert(reg.r[registerDst] == 0xD835C455069D81EF); - }); - - runTest("IROL_R (decode)", RANDOMX_FREQ_IROL_R > 0, [&] { - randomx::Instruction instr; - instr.opcode = randomx::ceil_IROL_R - 1; - instr.dst = registerHigh | registerDst; - instr.src = registerHigh | registerSrc; - instr.setImm32(imm32); - decoder.compileInstruction(instr, pc, ibc); - assert(ibc.type == randomx::InstructionType::IROL_R); - assert(ibc.idst == ®.r[registerDst]); - assert(ibc.isrc == ®.r[registerSrc]); - }); - - runTest("IROL_R (execute)", RANDOMX_FREQ_IROL_R > 0, [&] { - reg.r[registerDst] = 953360005391419562; - reg.r[registerSrc] = 4569451684712230561; - decoder.executeInstruction(ibc, pc, nullptr, config); - assert(reg.r[registerDst] == 6978065200552740799); - }); - - runTest("ISWAP_R (decode)", RANDOMX_FREQ_ISWAP_R > 0, [&] { - randomx::Instruction instr; - instr.opcode = randomx::ceil_ISWAP_R - 1; - instr.dst = registerHigh | registerDst; - instr.src = registerHigh | registerSrc; - instr.setImm32(imm32); - decoder.compileInstruction(instr, pc, ibc); - assert(ibc.type == randomx::InstructionType::ISWAP_R); - assert(ibc.idst == ®.r[registerDst]); - assert(ibc.isrc == ®.r[registerSrc]); - }); - - runTest("ISWAP_R (execute)", RANDOMX_FREQ_ISWAP_R > 0, [&] { - reg.r[registerDst] = 953360005391419562; - reg.r[registerSrc] = 4569451684712230561; - decoder.executeInstruction(ibc, pc, nullptr, config); - assert(reg.r[registerDst] == 4569451684712230561); - assert(reg.r[registerSrc] == 953360005391419562); - }); - - runTest("FSWAP_R (decode)", RANDOMX_FREQ_FSWAP_R > 0, [&] { - randomx::Instruction instr; - instr.opcode = randomx::ceil_FSWAP_R - 1; - instr.dst = registerHigh | registerDst; - decoder.compileInstruction(instr, pc, ibc); - assert(ibc.type == randomx::InstructionType::FSWAP_R); - assert(ibc.fdst == ®.f[registerDst]); - }); - - runTest("FSWAP_R (execute)", RANDOMX_FREQ_FSWAP_R > 0, [&] { - alignas(16) uint64_t vec[2]; - reg.f[registerDst] = rx_set_vec_f128(953360005391419562, 4569451684712230561); - decoder.executeInstruction(ibc, pc, nullptr, config); - rx_store_vec_f128((double*)&vec, reg.f[registerDst]); - assert(equalsHex((const char*)&vec, "aa886bb0df033b0da12e95e518f4693f")); - }); - - runTest("FADD_R (decode)", RANDOMX_FREQ_FADD_R > 0, [&] { - randomx::Instruction instr; - instr.opcode = randomx::ceil_FADD_R - 1; - instr.dst = registerHigh | registerDst; - instr.src = registerHigh | registerSrc; - instr.setImm32(imm32); - decoder.compileInstruction(instr, pc, ibc); - assert(ibc.type == randomx::InstructionType::FADD_R); - assert(ibc.fdst == ®.f[registerDst]); - assert(ibc.fsrc == ®.a[registerSrc]); - }); - - runTest("FADD_R RoundToNearest (execute)", RANDOMX_FREQ_FADD_R > 0, [&] { - alignas(16) uint64_t vec[2]; - reg.f[registerDst] = rx_set_vec_f128(0x3ffd2c97cc4ef015, 0xc1ce30b3c4223576); - reg.a[registerSrc] = rx_set_vec_f128(0x402a26a86a60c8fb, 0x40b8f684057a59e1); - rx_set_rounding_mode(RoundToNearest); - decoder.executeInstruction(ibc, pc, nullptr, config); - rx_store_vec_f128((double*)&vec, reg.f[registerDst]); - assert(equalsHex(&vec, "b932e048a730cec1fea6ea633bcc2d40")); - }); - - runTest("FADD_R RoundDown (execute)", RANDOMX_FREQ_FADD_R > 0, [&] { - alignas(16) uint64_t vec[2]; - reg.f[registerDst] = rx_set_vec_f128(0x3ffd2c97cc4ef015, 0xc1ce30b3c4223576); - reg.a[registerSrc] = rx_set_vec_f128(0x402a26a86a60c8fb, 0x40b8f684057a59e1); - rx_set_rounding_mode(RoundDown); - decoder.executeInstruction(ibc, pc, nullptr, config); - rx_store_vec_f128((double*)&vec, reg.f[registerDst]); - assert(equalsHex(&vec, "b932e048a730cec1fda6ea633bcc2d40")); - }); - - runTest("FADD_R RoundUp (execute)", RANDOMX_FREQ_FADD_R > 0, [&] { - alignas(16) uint64_t vec[2]; - reg.f[registerDst] = rx_set_vec_f128(0x3ffd2c97cc4ef015, 0xc1ce30b3c4223576); - reg.a[registerSrc] = rx_set_vec_f128(0x402a26a86a60c8fb, 0x40b8f684057a59e1); - rx_set_rounding_mode(RoundUp); - decoder.executeInstruction(ibc, pc, nullptr, config); - rx_store_vec_f128((double*)&vec, reg.f[registerDst]); - assert(equalsHex(&vec, "b832e048a730cec1fea6ea633bcc2d40")); - }); - - runTest("FADD_R RoundToZero (execute)", RANDOMX_FREQ_FADD_R > 0, [&] { - alignas(16) uint64_t vec[2]; - reg.f[registerDst] = rx_set_vec_f128(0x3ffd2c97cc4ef015, 0xc1ce30b3c4223576); - reg.a[registerSrc] = rx_set_vec_f128(0x402a26a86a60c8fb, 0x40b8f684057a59e1); - rx_set_rounding_mode(RoundToZero); - decoder.executeInstruction(ibc, pc, nullptr, config); - rx_store_vec_f128((double*)&vec, reg.f[registerDst]); - assert(equalsHex(&vec, "b832e048a730cec1fda6ea633bcc2d40")); - }); - - runTest("FADD_M (decode)", RANDOMX_FREQ_FADD_M > 0, [&] { - randomx::Instruction instr; - instr.opcode = randomx::ceil_FADD_M - 1; - instr.mod = 1; - instr.dst = registerHigh | registerDst; - instr.src = registerHigh | registerSrc; - instr.setImm32(imm32); - decoder.compileInstruction(instr, pc, ibc); - assert(ibc.type == randomx::InstructionType::FADD_M); - assert(ibc.fdst == ®.f[registerDst]); - assert(ibc.isrc == ®.r[registerSrc]); - assert(ibc.imm == imm64); - assert(ibc.memMask == randomx::ScratchpadL1Mask); - }); - - runTest("FADD_M (execute)", RANDOMX_FREQ_FADD_R > 0, [&] { - uint64_t mockScratchpad; - store64(&mockScratchpad, 0x1234567890abcdef); - alignas(16) uint64_t vec[2]; - reg.f[registerDst] = rx_set_vec_f128(0, 0); - reg.r[registerSrc] = 0xFFFFFFFFFFFFE930; - rx_set_rounding_mode(RoundToNearest); - decoder.executeInstruction(ibc, pc, (uint8_t*)&mockScratchpad, config); - rx_store_vec_f128((double*)&vec, reg.f[registerDst]); - assert(equalsHex(&vec, "000040840cd5dbc1000000785634b241")); - }); - - runTest("FSUB_R (decode)", RANDOMX_FREQ_FSUB_R > 0, [&] { - randomx::Instruction instr; - instr.opcode = randomx::ceil_FSUB_R - 1; - instr.dst = registerHigh | registerDst; - instr.src = registerHigh | registerSrc; - instr.setImm32(imm32); - decoder.compileInstruction(instr, pc, ibc); - assert(ibc.type == randomx::InstructionType::FSUB_R); - assert(ibc.fdst == ®.f[registerDst]); - assert(ibc.fsrc == ®.a[registerSrc]); - }); - - runTest("FSUB_M (decode)", RANDOMX_FREQ_FSUB_M > 0, [&] { - randomx::Instruction instr; - instr.opcode = randomx::ceil_FSUB_M - 1; - instr.mod = 2; - instr.dst = registerHigh | registerDst; - instr.src = registerHigh | registerSrc; - instr.setImm32(imm32); - decoder.compileInstruction(instr, pc, ibc); - assert(ibc.type == randomx::InstructionType::FSUB_M); - assert(ibc.fdst == ®.f[registerDst]); - assert(ibc.isrc == ®.r[registerSrc]); - assert(ibc.imm == imm64); - assert(ibc.memMask == randomx::ScratchpadL1Mask); - }); - - runTest("FSCAL_R (decode)", RANDOMX_FREQ_FSCAL_R > 0, [&] { - randomx::Instruction instr; - instr.opcode = randomx::ceil_FSCAL_R - 1; - instr.dst = registerHigh | registerDst; - instr.setImm32(imm32); - decoder.compileInstruction(instr, pc, ibc); - assert(ibc.type == randomx::InstructionType::FSCAL_R); - assert(ibc.fdst == ®.f[registerDst]); - }); - - runTest("FSCAL_R (execute)", RANDOMX_FREQ_FSCAL_R > 0, [&] { - alignas(16) uint64_t vec[2]; - reg.f[registerDst] = rx_set_vec_f128(0x41dbc35cef248783, 0x40fdfdabb6173d07); - decoder.executeInstruction(ibc, pc, nullptr, config); - rx_store_vec_f128((double*)&vec, reg.f[registerDst]); - assert(equalsHex((const char*)&vec, "073d17b6abfd0dc0838724ef5cc32bc1")); - }); - - runTest("FMUL_R (decode)", RANDOMX_FREQ_FMUL_R > 0, [&] { - randomx::Instruction instr; - instr.opcode = randomx::ceil_FMUL_R - 1; - instr.dst = registerHigh | registerDst; - instr.src = registerHigh | registerSrc; - instr.setImm32(imm32); - decoder.compileInstruction(instr, pc, ibc); - assert(ibc.type == randomx::InstructionType::FMUL_R); - assert(ibc.fdst == ®.e[registerDst]); - assert(ibc.fsrc == ®.a[registerSrc]); - }); - - runTest("FMUL_R RoundToNearest (execute)", RANDOMX_FREQ_FMUL_R > 0, [&] { - alignas(16) uint64_t vec[2]; - reg.e[registerDst] = rx_set_vec_f128(0x41dbc35cef248783, 0x40fdfdabb6173d07); - reg.a[registerSrc] = rx_set_vec_f128(0x40eba861aa31c7c0, 0x41c4561212ae2d50); - rx_set_rounding_mode(RoundToNearest); - decoder.executeInstruction(ibc, pc, nullptr, config); - rx_store_vec_f128((double*)&vec, reg.e[registerDst]); - assert(equalsHex(&vec, "69697aff350fd3422f1589cdecfed742")); - }); - - runTest("FMUL_R RoundDown/RoundToZero (execute)", RANDOMX_FREQ_FMUL_R > 0, [&] { - alignas(16) uint64_t vec[2]; - reg.e[registerDst] = rx_set_vec_f128(0x41dbc35cef248783, 0x40fdfdabb6173d07); - reg.a[registerSrc] = rx_set_vec_f128(0x40eba861aa31c7c0, 0x41c4561212ae2d50); - rx_set_rounding_mode(RoundDown); - decoder.executeInstruction(ibc, pc, nullptr, config); - rx_store_vec_f128((double*)&vec, reg.e[registerDst]); - assert(equalsHex(&vec, "69697aff350fd3422e1589cdecfed742")); - }); - - runTest("FMUL_R RoundUp (execute)", RANDOMX_FREQ_FMUL_R > 0, [&] { - alignas(16) uint64_t vec[2]; - reg.e[registerDst] = rx_set_vec_f128(0x41dbc35cef248783, 0x40fdfdabb6173d07); - reg.a[registerSrc] = rx_set_vec_f128(0x40eba861aa31c7c0, 0x41c4561212ae2d50); - rx_set_rounding_mode(RoundUp); - decoder.executeInstruction(ibc, pc, nullptr, config); - rx_store_vec_f128((double*)&vec, reg.e[registerDst]); - assert(equalsHex(&vec, "6a697aff350fd3422f1589cdecfed742")); - }); - - runTest("FDIV_M (decode)", RANDOMX_FREQ_FDIV_M > 0, [&] { - randomx::Instruction instr; - instr.opcode = randomx::ceil_FDIV_M - 1; - instr.mod = 3; - instr.dst = registerHigh | registerDst; - instr.src = registerHigh | registerSrc; - instr.setImm32(imm32); - decoder.compileInstruction(instr, pc, ibc); - assert(ibc.type == randomx::InstructionType::FDIV_M); - assert(ibc.fdst == ®.e[registerDst]); - assert(ibc.isrc == ®.r[registerSrc]); - assert(ibc.imm == imm64); - assert(ibc.memMask == randomx::ScratchpadL1Mask); - }); - - runTest("FDIV_M RoundToNearest (execute)", RANDOMX_FREQ_FDIV_M > 0, [&] { - alignas(16) uint64_t vec[2]; - alignas(16) uint32_t mockScratchpad[2]; - store32(&mockScratchpad[0], 0xd350a1b6); - store32(&mockScratchpad[1], 0x8b2460d9); - store64(&config.eMask[0], 0x3a0000000005d11a); - store64(&config.eMask[1], 0x39000000001ba31e); - reg.e[registerDst] = rx_set_vec_f128(0x41937f76fede16ee, 0x411b414296ce93b6); - reg.r[registerSrc] = 0xFFFFFFFFFFFFE930; - rx_set_rounding_mode(RoundToNearest); - decoder.executeInstruction(ibc, pc, (uint8_t*)&mockScratchpad, config); - rx_store_vec_f128((double*)&vec, reg.e[registerDst]); - assert(equalsHex(&vec, "e7b269639484434632474a66635ba547")); - }); - - runTest("FDIV_M RoundDown/RoundToZero (execute)", RANDOMX_FREQ_FDIV_M > 0, [&] { - alignas(16) uint64_t vec[2]; - alignas(16) uint32_t mockScratchpad[2]; - store32(&mockScratchpad[0], 0xd350a1b6); - store32(&mockScratchpad[1], 0x8b2460d9); - store64(&config.eMask[0], 0x3a0000000005d11a); - store64(&config.eMask[1], 0x39000000001ba31e); - reg.e[registerDst] = rx_set_vec_f128(0x41937f76fede16ee, 0x411b414296ce93b6); - reg.r[registerSrc] = 0xFFFFFFFFFFFFE930; - rx_set_rounding_mode(RoundDown); - decoder.executeInstruction(ibc, pc, (uint8_t*)&mockScratchpad, config); - rx_store_vec_f128((double*)&vec, reg.e[registerDst]); - assert(equalsHex(&vec, "e6b269639484434632474a66635ba547")); - }); - - runTest("FDIV_M RoundUp (execute)", RANDOMX_FREQ_FDIV_M > 0, [&] { - alignas(16) uint64_t vec[2]; - alignas(16) uint32_t mockScratchpad[2]; - store32(&mockScratchpad[0], 0xd350a1b6); - store32(&mockScratchpad[1], 0x8b2460d9); - store64(&config.eMask[0], 0x3a0000000005d11a); - store64(&config.eMask[1], 0x39000000001ba31e); - reg.e[registerDst] = rx_set_vec_f128(0x41937f76fede16ee, 0x411b414296ce93b6); - reg.r[registerSrc] = 0xFFFFFFFFFFFFE930; - rx_set_rounding_mode(RoundUp); - decoder.executeInstruction(ibc, pc, (uint8_t*)&mockScratchpad, config); - rx_store_vec_f128((double*)&vec, reg.e[registerDst]); - assert(equalsHex(&vec, "e7b269639484434633474a66635ba547")); - }); - - runTest("FSQRT_R (decode)", RANDOMX_FREQ_FSQRT_R > 0, [&] { - randomx::Instruction instr; - instr.opcode = randomx::ceil_FSQRT_R - 1; - instr.dst = registerHigh | registerDst; - decoder.compileInstruction(instr, pc, ibc); - assert(ibc.type == randomx::InstructionType::FSQRT_R); - assert(ibc.fdst == ®.e[registerDst]); - }); - - runTest("FSQRT_R RoundToNearest (execute)", RANDOMX_FREQ_FSQRT_R > 0, [&] { - alignas(16) uint64_t vec[2]; - reg.e[registerDst] = rx_set_vec_f128(0x41b6b21c11affea7, 0x40526a7e778d9824); - rx_set_rounding_mode(RoundToNearest); - decoder.executeInstruction(ibc, pc, nullptr, config); - rx_store_vec_f128((double*)&vec, reg.e[registerDst]); - assert(equalsHex(&vec, "e81f300b612a21408dbaa33f570ed340")); - }); - - runTest("FSQRT_R RoundDown/RoundToZero (execute)", RANDOMX_FREQ_FSQRT_R > 0, [&] { - alignas(16) uint64_t vec[2]; - reg.e[registerDst] = rx_set_vec_f128(0x41b6b21c11affea7, 0x40526a7e778d9824); - rx_set_rounding_mode(RoundDown); - decoder.executeInstruction(ibc, pc, nullptr, config); - rx_store_vec_f128((double*)&vec, reg.e[registerDst]); - assert(equalsHex(&vec, "e81f300b612a21408cbaa33f570ed340")); - }); - - runTest("FSQRT_R RoundUp (execute)", RANDOMX_FREQ_FSQRT_R > 0, [&] { - alignas(16) uint64_t vec[2]; - reg.e[registerDst] = rx_set_vec_f128(0x41b6b21c11affea7, 0x40526a7e778d9824); - rx_set_rounding_mode(RoundUp); - decoder.executeInstruction(ibc, pc, nullptr, config); - rx_store_vec_f128((double*)&vec, reg.e[registerDst]); - assert(equalsHex(&vec, "e91f300b612a21408dbaa33f570ed340")); - }); - - runTest("CBRANCH (decode) 100", RANDOMX_FREQ_CBRANCH > 0, [&] { - randomx::Instruction instr; - instr.opcode = randomx::ceil_CBRANCH - 1; - instr.dst = registerHigh | registerDst; - instr.setImm32(imm32); - instr.mod = 48; - decoder.compileInstruction(instr, 100, ibc); - assert(ibc.type == randomx::InstructionType::CBRANCH); - assert(ibc.idst == ®.r[registerDst]); - assert(ibc.imm == 0xFFFFFFFFC0CB9AD2); - assert(ibc.memMask == 0x7F800); - assert(ibc.target == pc); - }); - - runTest("CBRANCH (decode) 200", RANDOMX_FREQ_CBRANCH > 0, [&] { - randomx::Instruction instr; - instr.opcode = randomx::ceil_CBRANCH - 1; - instr.dst = registerHigh | registerDst; - instr.setImm32(imm32); - instr.mod = 48; - decoder.compileInstruction(instr, pc = 200, ibc); - assert(ibc.type == randomx::InstructionType::CBRANCH); - assert(ibc.idst == ®.r[registerDst]); - assert(ibc.imm == 0xFFFFFFFFC0CB9AD2); - assert(ibc.memMask == 0x7F800); - assert(ibc.target == 100); - }); - - runTest("CBRANCH not taken (execute)", RANDOMX_FREQ_CBRANCH > 0, [&] { - reg.r[registerDst] = 0; - decoder.executeInstruction(ibc, pc, nullptr, config); - assert(pc == 200); - }); - - runTest("CBRANCH taken (execute)", RANDOMX_FREQ_CBRANCH > 0, [&] { - reg.r[registerDst] = 0xFFFFFFFFFFFC6800; - decoder.executeInstruction(ibc, pc, nullptr, config); - assert(pc == ibc.target); - }); - - runTest("CFROUND (decode)", RANDOMX_FREQ_CFROUND > 0, [&] { - randomx::Instruction instr; - instr.opcode = randomx::ceil_CFROUND - 1; - instr.src = registerHigh | registerSrc; - instr.setImm32(imm32); - decoder.compileInstruction(instr, 100, ibc); - assert(ibc.type == randomx::InstructionType::CFROUND); - assert(ibc.isrc == ®.r[registerSrc]); - assert(ibc.imm == 18); - }); - - runTest("ISTORE L1 (decode)", RANDOMX_FREQ_ISTORE > 0, [&] { - randomx::Instruction instr; - instr.opcode = randomx::ceil_ISTORE - 1; - instr.src = registerHigh | registerSrc; - instr.dst = registerHigh | registerDst; - instr.setImm32(imm32); - instr.mod = 1; - decoder.compileInstruction(instr, pc, ibc); - assert(ibc.type == randomx::InstructionType::ISTORE); - assert(ibc.idst == ®.r[registerDst]); - assert(ibc.isrc == ®.r[registerSrc]); - assert(ibc.imm == imm64); - assert(ibc.memMask == randomx::ScratchpadL1Mask); - }); - - runTest("ISTORE L2 (decode)", RANDOMX_FREQ_ISTORE > 0, [&] { - randomx::Instruction instr; - instr.opcode = randomx::ceil_ISTORE - 1; - instr.src = registerHigh | registerSrc; - instr.dst = registerHigh | registerDst; - instr.setImm32(imm32); - instr.mod = 0; - decoder.compileInstruction(instr, pc, ibc); - assert(ibc.type == randomx::InstructionType::ISTORE); - assert(ibc.idst == ®.r[registerDst]); - assert(ibc.isrc == ®.r[registerSrc]); - assert(ibc.imm == imm64); - assert(ibc.memMask == randomx::ScratchpadL2Mask); - }); - - runTest("ISTORE L3 (decode)", RANDOMX_FREQ_ISTORE > 0, [&] { - randomx::Instruction instr; - instr.opcode = randomx::ceil_ISTORE - 1; - instr.src = registerHigh | registerSrc; - instr.dst = registerHigh | registerDst; - instr.setImm32(imm32); - instr.mod = 224; - decoder.compileInstruction(instr, pc, ibc); - assert(ibc.type == randomx::InstructionType::ISTORE); - assert(ibc.idst == ®.r[registerDst]); - assert(ibc.isrc == ®.r[registerSrc]); - assert(ibc.imm == imm64); - assert(ibc.memMask == randomx::ScratchpadL3Mask); - }); - - vm = randomx_create_vm(RANDOMX_FLAG_DEFAULT, cache, nullptr); - - auto test_a = [&] { - char hash[RANDOMX_HASH_SIZE]; - calcStringHash("test key 000", "This is a test", &hash); - assert(equalsHex(hash, "b33f8d10a8655d6f1925e3754adeb0a6da4c2f48a81cd4c220a412f1ef016a15")); - }; - - auto test_b = [&] { - char hash[RANDOMX_HASH_SIZE]; - calcStringHash("test key 000", "Lorem ipsum dolor sit amet", &hash); - assert(equalsHex(hash, "62ac336786ad3a7aff990beb2f643bd748d81dba585a52149d0baebdea0e9823")); - }; - - auto test_c = [&] { - char hash[RANDOMX_HASH_SIZE]; - calcStringHash("test key 000", "sed do eiusmod tempor incididunt ut labore et dolore magna aliqua", &hash); - assert(equalsHex(hash, "6c550ebe765f7b784d2c183552fbb6048b58f17a3f115baf2b968724eb2f7a23")); - }; - - auto test_d = [&] { - char hash[RANDOMX_HASH_SIZE]; - calcStringHash("test key 001", "sed do eiusmod tempor incididunt ut labore et dolore magna aliqua", &hash); - assert(equalsHex(hash, "cb602b9c498b67e31e519fbdc07e288de46f949b14ad620380df6250eaffbd4e")); - }; - - auto test_e = [&] { - char hash[RANDOMX_HASH_SIZE]; - calcHexHash("test key 001", "0b0b98bea7e805e0010a2126d287a2a0cc833d312cb786385a7c2f9de69d25537f584a9bc9977b00000000666fd8753bf61a8631f12984e3fd44f4014eca629276817b56f32e9b68bd82f416", &hash); - //std::cout << std::endl; - //outputHex(std::cout, (const char*)hash, sizeof(hash)); - //std::cout << std::endl; - assert(equalsHex(hash, "f60caf300917760337e8ce51487484e6a33d4aaa15aa79c985efb4ea00390918")); - }; - - runTest("Hash test 1a (interpreter)", stringsEqual(RANDOMX_ARGON_SALT, "RandomX\x03"), test_a); - - runTest("Hash test 1b (interpreter)", stringsEqual(RANDOMX_ARGON_SALT, "RandomX\x03"), test_b); - - runTest("Hash test 1c (interpreter)", stringsEqual(RANDOMX_ARGON_SALT, "RandomX\x03"), test_c); - - runTest("Hash test 1d (interpreter)", stringsEqual(RANDOMX_ARGON_SALT, "RandomX\x03"), test_d); - - runTest("Hash test 1e (interpreter)", stringsEqual(RANDOMX_ARGON_SALT, "RandomX\x03"), test_e); - - randomx_release_cache(cache); - cache = randomx_alloc_cache(RANDOMX_FLAG_JIT); - currentKey.size = 0; - randomx_destroy_vm(vm); - initCache("test key 000"); - vm = randomx_create_vm(RANDOMX_FLAG_JIT, cache, nullptr); - - runTest("Hash test 2a (compiler)", RANDOMX_HAVE_COMPILER && stringsEqual(RANDOMX_ARGON_SALT, "RandomX\x03"), test_a); - - runTest("Hash test 2b (compiler)", RANDOMX_HAVE_COMPILER && stringsEqual(RANDOMX_ARGON_SALT, "RandomX\x03"), test_b); - - runTest("Hash test 2c (compiler)", RANDOMX_HAVE_COMPILER && stringsEqual(RANDOMX_ARGON_SALT, "RandomX\x03"), test_c); - - runTest("Hash test 2d (compiler)", RANDOMX_HAVE_COMPILER && stringsEqual(RANDOMX_ARGON_SALT, "RandomX\x03"), test_d); - - runTest("Hash test 2e (compiler)", RANDOMX_HAVE_COMPILER && stringsEqual(RANDOMX_ARGON_SALT, "RandomX\x03"), test_e); - - std::cout << std::endl << "All tests PASSED" << std::endl; - - if (skipped) { - std::cout << skipped << " tests were SKIPPED due to incompatible configuration (see above)" << std::endl; - } -} \ No newline at end of file diff --git a/src/vm_interpreted.cpp b/src/vm_interpreted.cpp index c45606e..236d3ef 100644 --- a/src/vm_interpreted.cpp +++ b/src/vm_interpreted.cpp @@ -26,12 +26,6 @@ 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. */ -#include -#include -#include -#include -#include -#include #include "vm_interpreted.hpp" #include "dataset.hpp" #include "intrin_portable.h" diff --git a/src/vm_interpreted.hpp b/src/vm_interpreted.hpp index 75554fb..99c8885 100644 --- a/src/vm_interpreted.hpp +++ b/src/vm_interpreted.hpp @@ -65,7 +65,7 @@ namespace randomx { private: void execute(); - InstructionByteCode bytecode[512]; + InstructionByteCode bytecode[RANDOMX_PROGRAM_MAX_SIZE]; }; using InterpretedVmDefault = InterpretedVm, true>; diff --git a/vcxproj/api-example1.vcxproj b/vcxproj/api-example1.vcxproj deleted file mode 100644 index c38acc3..0000000 --- a/vcxproj/api-example1.vcxproj +++ /dev/null @@ -1,131 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 15.0 - {83EA3E54-5D91-4E01-8EF6-C1E718334F83} - apiexample1 - 10.0.17763.0 - - - - Application - true - v141 - MultiByte - - - Application - false - v141 - true - MultiByte - - - Application - true - v141 - MultiByte - - - Application - false - v141 - true - MultiByte - - - - - - - - - - - - - - - - - - - - - - - Level3 - MaxSpeed - true - true - true - true - - - true - true - - - - - Level3 - Disabled - true - true - - - - - Level3 - Disabled - true - true - - - - - Level3 - MaxSpeed - true - true - true - true - - - true - true - - - - - {3346a4ad-c438-4324-8b77-47a16452954b} - - - - - - - - - - - - \ No newline at end of file diff --git a/vcxproj/api-example1.vcxproj.filters b/vcxproj/api-example1.vcxproj.filters deleted file mode 100644 index 6cd41c2..0000000 --- a/vcxproj/api-example1.vcxproj.filters +++ /dev/null @@ -1,27 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - - - Header Files - - - \ No newline at end of file diff --git a/vcxproj/api-example2.vcxproj b/vcxproj/api-example2.vcxproj deleted file mode 100644 index 55ca878..0000000 --- a/vcxproj/api-example2.vcxproj +++ /dev/null @@ -1,128 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 15.0 - {44947B9C-E6B1-4C06-BD01-F8EF43B59223} - apiexample2 - 10.0.17763.0 - - - - Application - true - v141 - MultiByte - - - Application - false - v141 - true - MultiByte - - - Application - true - v141 - MultiByte - - - Application - false - v141 - true - MultiByte - - - - - - - - - - - - - - - - - - - - - - - Level3 - MaxSpeed - true - true - false - true - - - true - true - - - - - Level3 - Disabled - true - true - - - - - Level3 - Disabled - true - true - - - - - Level3 - MaxSpeed - true - true - true - true - - - true - true - - - - - {3346a4ad-c438-4324-8b77-47a16452954b} - - - - - - - - - \ No newline at end of file diff --git a/vcxproj/api-example2.vcxproj.filters b/vcxproj/api-example2.vcxproj.filters deleted file mode 100644 index c52d1e8..0000000 --- a/vcxproj/api-example2.vcxproj.filters +++ /dev/null @@ -1,22 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - \ No newline at end of file diff --git a/vcxproj/benchmark.vcxproj b/vcxproj/benchmark.vcxproj deleted file mode 100644 index 94835e1..0000000 --- a/vcxproj/benchmark.vcxproj +++ /dev/null @@ -1,132 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 15.0 - {1E8A2E2F-9F9F-43AA-BB19-9107FEC64A70} - benchmark - 10.0.17763.0 - - - - Application - true - v141 - MultiByte - - - Application - false - v141 - true - MultiByte - - - Application - true - v141 - MultiByte - - - Application - false - v141 - true - MultiByte - - - - - - - - - - - - - - - - - - - - - - - Level3 - MaxSpeed - true - true - false - true - - - true - true - - - - - Level3 - Disabled - true - true - - - - - Level3 - Disabled - false - true - - - - - Level3 - MaxSpeed - true - true - false - true - - - true - true - - - - - - - - - {3346a4ad-c438-4324-8b77-47a16452954b} - - - - - - - - - \ No newline at end of file diff --git a/vcxproj/benchmark.vcxproj.filters b/vcxproj/benchmark.vcxproj.filters deleted file mode 100644 index ea182de..0000000 --- a/vcxproj/benchmark.vcxproj.filters +++ /dev/null @@ -1,30 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - Source Files - - - - - Header Files - - - \ No newline at end of file diff --git a/vcxproj/code-generator.vcxproj b/vcxproj/code-generator.vcxproj deleted file mode 100644 index ee07739..0000000 --- a/vcxproj/code-generator.vcxproj +++ /dev/null @@ -1,129 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 15.0 - {3E490DEC-1874-43AA-92DA-1AC57C217EAC} - codegenerator - 10.0.17763.0 - - - - Application - true - v141 - MultiByte - - - Application - false - v141 - true - MultiByte - - - Application - true - v141 - MultiByte - - - Application - false - v141 - true - MultiByte - - - - - - - - - - - - - - - - - - - - - - - Level3 - MaxSpeed - true - true - true - true - - - true - true - 4194304 - - - - - Level3 - Disabled - true - true - - - - - Level3 - Disabled - true - true - - - - - Level3 - MaxSpeed - true - true - true - true - - - true - true - - - - - - - - {3346a4ad-c438-4324-8b77-47a16452954b} - - - - - - \ No newline at end of file diff --git a/vcxproj/code-generator.vcxproj.filters b/vcxproj/code-generator.vcxproj.filters deleted file mode 100644 index 7578ae6..0000000 --- a/vcxproj/code-generator.vcxproj.filters +++ /dev/null @@ -1,22 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - \ No newline at end of file diff --git a/vcxproj/h2inc.ps1 b/vcxproj/h2inc.ps1 deleted file mode 100644 index ded47b8..0000000 --- a/vcxproj/h2inc.ps1 +++ /dev/null @@ -1,90 +0,0 @@ -# The MIT License (MIT) -# -# Copyright (c) .NET Foundation and Contributors -# -# All rights reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -# C to MASM include file translator -# This is replacement for the deprecated h2inc tool that used to be part of VS. - -# -# The use of [console]::WriteLine (instead of Write-Output) is intentional. -# PowerShell 2.0 (installed by default on Windows 7) wraps lines written with -# Write-Output at whatever column width is being used by the current terminal, -# even when output is being redirected to a file. We can't have this behavior -# because it will cause the generated file to be malformed. -# - -Function ProcessFile($filePath) { - - [console]::WriteLine("; File start: $filePath") - - Get-Content $filePath | ForEach-Object { - - if ($_ -match "^\s*#\spragma") { - # Ignore pragmas - return - } - - if ($_ -match "^\s*#\s*include\s*`"(.*)`"") - { - # Expand includes. - ProcessFile(Join-Path (Split-Path -Parent $filePath) $Matches[1]) - return - } - - if ($_ -match "^\s*#define\s+(\S+)\s*(.*)") - { - # Augment #defines with their MASM equivalent - $name = $Matches[1] - $value = $Matches[2] - - # Note that we do not handle multiline constants - - # Strip comments from value - $value = $value -replace "//.*", "" - $value = $value -replace "/\*.*\*/", "" - - # Strip whitespaces from value - $value = $value -replace "\s+$", "" - - # ignore #defines with arguments - if ($name -notmatch "\(") { - $HEX_NUMBER_PATTERN = "\b0x(\w+)\b" - $DECIMAL_NUMBER_PATTERN = "(-?\b\d+\b)" - - if ($value -match $HEX_NUMBER_PATTERN -or $value -match $DECIMAL_NUMBER_PATTERN) { - $value = $value -replace $HEX_NUMBER_PATTERN, "0`$1h" # Convert hex constants - $value = $value -replace $DECIMAL_NUMBER_PATTERN, "`$1t" # Convert dec constants - [console]::WriteLine("$name EQU $value") - } else { - [console]::WriteLine("$name TEXTEQU <$value>") - } - } - } - - # [console]::WriteLine("$_") - } - - [console]::WriteLine("; File end: $filePath") -} - -ProcessFile $args[0] diff --git a/vcxproj/jit-performance.vcxproj b/vcxproj/jit-performance.vcxproj deleted file mode 100644 index 5028e93..0000000 --- a/vcxproj/jit-performance.vcxproj +++ /dev/null @@ -1,128 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 15.0 - {535F2111-FA81-4C76-A354-EDD2F9AA00E3} - jitperformance - 10.0.17763.0 - - - - Application - true - v141 - MultiByte - - - Application - false - v141 - true - MultiByte - - - Application - true - v141 - MultiByte - - - Application - false - v141 - true - MultiByte - - - - - - - - - - - - - - - - - - - - - - - Level3 - MaxSpeed - true - true - true - true - - - true - true - - - - - Level3 - Disabled - true - true - - - - - Level3 - Disabled - true - true - - - - - Level3 - MaxSpeed - true - true - true - true - - - true - true - - - - - - - - {3346a4ad-c438-4324-8b77-47a16452954b} - - - - - - \ No newline at end of file diff --git a/vcxproj/jit-performance.vcxproj.filters b/vcxproj/jit-performance.vcxproj.filters deleted file mode 100644 index 46a0be0..0000000 --- a/vcxproj/jit-performance.vcxproj.filters +++ /dev/null @@ -1,22 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - \ No newline at end of file diff --git a/vcxproj/perf-simulation.vcxproj b/vcxproj/perf-simulation.vcxproj deleted file mode 100644 index 7570a8b..0000000 --- a/vcxproj/perf-simulation.vcxproj +++ /dev/null @@ -1,128 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 15.0 - {F1FC7AC0-2773-4A57-AFA7-56BB07216AA2} - perfsimulation - 10.0.17763.0 - - - - Application - true - v141 - MultiByte - - - Application - false - v141 - true - MultiByte - - - Application - true - v141 - MultiByte - - - Application - false - v141 - true - MultiByte - - - - - - - - - - - - - - - - - - - - - - - Level3 - MaxSpeed - true - true - true - true - - - true - true - - - - - Level3 - Disabled - true - true - - - - - Level3 - Disabled - true - true - - - - - Level3 - MaxSpeed - true - true - true - true - - - true - true - - - - - - - - {3346a4ad-c438-4324-8b77-47a16452954b} - - - - - - \ No newline at end of file diff --git a/vcxproj/perf-simulation.vcxproj.filters b/vcxproj/perf-simulation.vcxproj.filters deleted file mode 100644 index 5870291..0000000 --- a/vcxproj/perf-simulation.vcxproj.filters +++ /dev/null @@ -1,22 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - \ No newline at end of file diff --git a/vcxproj/randomx-dll.vcxproj b/vcxproj/randomx-dll.vcxproj deleted file mode 100644 index 0377043..0000000 --- a/vcxproj/randomx-dll.vcxproj +++ /dev/null @@ -1,212 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 15.0 - {59560AD8-18E3-463E-A941-BBD808EC7C83} - Win32Proj - randomxdll - 10.0.17763.0 - - - - DynamicLibrary - true - v141 - Unicode - - - DynamicLibrary - false - v141 - true - Unicode - - - DynamicLibrary - true - v141 - Unicode - - - DynamicLibrary - false - v141 - true - Unicode - - - - - - - - - - - - - - - - - - - - - - false - - - true - - - true - - - false - randomx - - - - Use - Level3 - MaxSpeed - true - true - true - WIN32;NDEBUG;RANDOMXDLL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - - - Windows - true - true - true - - - - - Use - Level3 - Disabled - true - WIN32;_DEBUG;RANDOMXDLL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - - - Windows - true - - - - - Use - Level3 - Disabled - true - _DEBUG;RANDOMXDLL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - - - Windows - true - - - - - NotUsing - Level3 - MaxSpeed - true - true - false - NDEBUG;RANDOMXDLL_EXPORTS;_WINDOWS;_USRDLL;RANDOMX_EXPORT=__declspec(dllexport) - true - - - Windows - true - true - true - - - - - - - \ No newline at end of file diff --git a/vcxproj/randomx-dll.vcxproj.filters b/vcxproj/randomx-dll.vcxproj.filters deleted file mode 100644 index 038fb71..0000000 --- a/vcxproj/randomx-dll.vcxproj.filters +++ /dev/null @@ -1,176 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Source Files - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - \ No newline at end of file diff --git a/vcxproj/randomx.vcxproj b/vcxproj/randomx.vcxproj deleted file mode 100644 index d6d6e74..0000000 --- a/vcxproj/randomx.vcxproj +++ /dev/null @@ -1,199 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 15.0 - {3346A4AD-C438-4324-8B77-47A16452954B} - randomx - 10.0.17763.0 - - - - StaticLibrary - true - v141 - MultiByte - - - StaticLibrary - false - v141 - true - MultiByte - - - StaticLibrary - true - v141 - MultiByte - - - StaticLibrary - false - v141 - true - MultiByte - - - - - - - - - - - - - - - - - - - - - - - - Level3 - Disabled - false - true - - - - - Level4 - Disabled - false - true - - - - - Level3 - MaxSpeed - true - true - false - true - NoExtensions - - - true - true - UseLinkTimeCodeGeneration - false - - - - - Level4 - MaxSpeed - true - true - false - true - AssemblyCode - _MBCS;NDEBUG;%(PreprocessorDefinitions) - - - true - true - UseLinkTimeCodeGeneration - false - - - 4194304 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - jit_compiler_x86_static.lst - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/vcxproj/randomx.vcxproj.filters b/vcxproj/randomx.vcxproj.filters deleted file mode 100644 index 12f6187..0000000 --- a/vcxproj/randomx.vcxproj.filters +++ /dev/null @@ -1,194 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Source Files - - - \ No newline at end of file diff --git a/vcxproj/runtime-distr.vcxproj b/vcxproj/runtime-distr.vcxproj deleted file mode 100644 index 3a551eb..0000000 --- a/vcxproj/runtime-distr.vcxproj +++ /dev/null @@ -1,128 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 15.0 - {F207EC8C-C55F-46C0-8851-887A71574F54} - runtimedistr - 10.0.17763.0 - - - - Application - true - v141 - MultiByte - - - Application - false - v141 - true - MultiByte - - - Application - true - v141 - MultiByte - - - Application - false - v141 - true - MultiByte - - - - - - - - - - - - - - - - - - - - - - - Level3 - Disabled - true - true - - - - - Level3 - Disabled - true - true - - - - - Level3 - MaxSpeed - true - true - true - true - - - true - true - - - - - Level3 - MaxSpeed - true - true - true - true - - - true - true - - - - - - - - {3346a4ad-c438-4324-8b77-47a16452954b} - - - - - - \ No newline at end of file diff --git a/vcxproj/runtime-distr.vcxproj.filters b/vcxproj/runtime-distr.vcxproj.filters deleted file mode 100644 index bb53c1b..0000000 --- a/vcxproj/runtime-distr.vcxproj.filters +++ /dev/null @@ -1,22 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - \ No newline at end of file diff --git a/vcxproj/scratchpad-entropy.vcxproj b/vcxproj/scratchpad-entropy.vcxproj deleted file mode 100644 index 2e28337..0000000 --- a/vcxproj/scratchpad-entropy.vcxproj +++ /dev/null @@ -1,128 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 15.0 - {FF8BD408-AFD8-43C6-BE98-4D03B37E840B} - scratchpadentropy - 10.0.17763.0 - - - - Application - true - v141 - MultiByte - - - Application - false - v141 - true - MultiByte - - - Application - true - v141 - MultiByte - - - Application - false - v141 - true - MultiByte - - - - - - - - - - - - - - - - - - - - - - - Level3 - MaxSpeed - true - true - true - true - - - true - true - - - - - Level3 - Disabled - true - true - - - - - Level3 - Disabled - true - true - - - - - Level3 - MaxSpeed - true - true - true - true - - - true - true - - - - - - - - {3346a4ad-c438-4324-8b77-47a16452954b} - - - - - - \ No newline at end of file diff --git a/vcxproj/scratchpad-entropy.vcxproj.filters b/vcxproj/scratchpad-entropy.vcxproj.filters deleted file mode 100644 index a215bfa..0000000 --- a/vcxproj/scratchpad-entropy.vcxproj.filters +++ /dev/null @@ -1,22 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - \ No newline at end of file diff --git a/vcxproj/superscalar-avalanche.vcxproj b/vcxproj/superscalar-avalanche.vcxproj deleted file mode 100644 index 80d4afc..0000000 --- a/vcxproj/superscalar-avalanche.vcxproj +++ /dev/null @@ -1,130 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 15.0 - {CF34A7EF-7DC9-4077-94A5-76F5425EA938} - superscalaravalanche - 10.0.17763.0 - - - - Application - true - v141 - MultiByte - - - Application - false - v141 - true - MultiByte - - - Application - true - v141 - MultiByte - - - Application - false - v141 - true - MultiByte - - - - - - - - - - - - - - - - - - - - - - - - Level3 - MaxSpeed - true - true - false - true - - - true - true - - - - - Level3 - Disabled - true - true - - - - - Level3 - Disabled - true - true - - - - - Level3 - MaxSpeed - true - true - true - true - - - true - true - - - - - - - - {3346a4ad-c438-4324-8b77-47a16452954b} - - - - - - - \ No newline at end of file diff --git a/vcxproj/superscalar-avalanche.vcxproj.filters b/vcxproj/superscalar-avalanche.vcxproj.filters deleted file mode 100644 index 6f33fce..0000000 --- a/vcxproj/superscalar-avalanche.vcxproj.filters +++ /dev/null @@ -1,22 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - \ No newline at end of file diff --git a/vcxproj/superscalar-init.vcxproj b/vcxproj/superscalar-init.vcxproj deleted file mode 100644 index e17e2ec..0000000 --- a/vcxproj/superscalar-init.vcxproj +++ /dev/null @@ -1,130 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 15.0 - {E59DC709-9B12-4A53-BAF3-79398821C376} - superscalarinit - 10.0.17763.0 - - - - Application - true - v141 - MultiByte - - - Application - false - v141 - true - MultiByte - - - Application - true - v141 - MultiByte - - - Application - false - v141 - true - MultiByte - - - - - - - - - - - - - - - - - - - - - - - - Level3 - MaxSpeed - true - true - false - true - - - true - true - - - - - Level3 - Disabled - false - true - - - - - Level3 - Disabled - false - true - - - - - Level3 - MaxSpeed - true - true - false - true - - - true - true - - - - - - - - {3346a4ad-c438-4324-8b77-47a16452954b} - - - - - - - \ No newline at end of file diff --git a/vcxproj/superscalar-init.vcxproj.filters b/vcxproj/superscalar-init.vcxproj.filters deleted file mode 100644 index d78d281..0000000 --- a/vcxproj/superscalar-init.vcxproj.filters +++ /dev/null @@ -1,22 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - \ No newline at end of file diff --git a/vcxproj/superscalar-stats.vcxproj b/vcxproj/superscalar-stats.vcxproj deleted file mode 100644 index 33d26c5..0000000 --- a/vcxproj/superscalar-stats.vcxproj +++ /dev/null @@ -1,128 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 15.0 - {0173D560-8C12-46B3-B467-0C6E7573AA0B} - superscalarstats - 10.0.17763.0 - - - - Application - true - v141 - MultiByte - - - Application - false - v141 - true - MultiByte - - - Application - true - v141 - MultiByte - - - Application - false - v141 - true - MultiByte - - - - - - - - - - - - - - - - - - - - - - - Level3 - MaxSpeed - true - true - false - true - - - true - true - - - - - Level3 - Disabled - true - true - - - - - Level3 - Disabled - true - true - - - - - Level3 - MaxSpeed - true - true - true - true - - - true - true - - - - - - - - {3346a4ad-c438-4324-8b77-47a16452954b} - - - - - - \ No newline at end of file diff --git a/vcxproj/superscalar-stats.vcxproj.filters b/vcxproj/superscalar-stats.vcxproj.filters deleted file mode 100644 index 6d5129c..0000000 --- a/vcxproj/superscalar-stats.vcxproj.filters +++ /dev/null @@ -1,22 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - \ No newline at end of file diff --git a/vcxproj/tests.vcxproj b/vcxproj/tests.vcxproj deleted file mode 100644 index 7aa6d72..0000000 --- a/vcxproj/tests.vcxproj +++ /dev/null @@ -1,133 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 15.0 - {41F3F4DF-8113-4029-9915-FDDC44C43D49} - tests - 10.0.17763.0 - tests - - - - Application - true - v141 - MultiByte - - - Application - false - v141 - true - MultiByte - - - Application - true - v141 - MultiByte - - - Application - false - v141 - true - MultiByte - - - - - - - - - - - - - - - - - - - - - - - Level3 - MaxSpeed - true - true - true - true - - - true - true - - - - - Level3 - Disabled - true - true - - - - - Level3 - Disabled - true - true - - - - - Level3 - MaxSpeed - true - true - true - true - NoExtensions - - - true - true - - - - - - - - {3346a4ad-c438-4324-8b77-47a16452954b} - - - - - - - - - \ No newline at end of file diff --git a/vcxproj/tests.vcxproj.filters b/vcxproj/tests.vcxproj.filters deleted file mode 100644 index d04c815..0000000 --- a/vcxproj/tests.vcxproj.filters +++ /dev/null @@ -1,27 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Header Files - - - - - Source Files - - - \ No newline at end of file