From d7eefce583550d27e211bb127dcd7f8ef903be1d Mon Sep 17 00:00:00 2001 From: tevador Date: Sat, 20 Apr 2019 16:53:06 +0200 Subject: [PATCH] Removed capital letters from filenames --- src/Instruction.cpp | 6 +- src/Instruction.hpp | 16 +- src/Program.cpp | 31 --- src/Program.hpp | 4 +- src/{hashAes1Rx4.cpp => aes_hash.cpp} | 2 +- src/{hashAes1Rx4.hpp => aes_hash.hpp} | 4 +- src/allocator.cpp | 4 +- ...atorX86.cpp => assembly_generator_x86.cpp} | 14 +- ...atorX86.hpp => assembly_generator_x86.hpp} | 15 +- ...ake2Generator.cpp => blake2_benerator.cpp} | 11 +- ...ake2Generator.hpp => blake2_generator.hpp} | 7 +- src/dataset.cpp | 16 +- src/dataset.hpp | 11 +- ...ionWeights.hpp => instruction_weights.hpp} | 2 +- ...Portable.cpp => instructions_portable.cpp} | 15 +- src/{intrinPortable.h => intrin_portable.h} | 1 - ...itCompilerX86.cpp => jit_compiler_x86.cpp} | 28 +-- ...itCompilerX86.hpp => jit_compiler_x86.hpp} | 6 +- ...X86-static.S => jit_compiler_x86_static.S} | 0 ...static.hpp => jit_compiler_x86_static.hpp} | 4 +- ...tatic.asm => jit_compiler_x86_staticc.asm} | 0 src/main.cpp | 2 +- src/randomx.cpp | 10 +- src/reciprocal.c | 3 +- src/reciprocal.h | 3 +- src/{softAes.cpp => soft_aes.cpp} | 10 +- src/{softAes.h => soft_aes.h} | 3 +- ...perscalarGenerator.cpp => superscalar.cpp} | 8 +- ...perscalarGenerator.hpp => superscalar.hpp} | 8 +- src/superscalar_program.hpp | 2 +- ...VirtualMachine.cpp => virtual_machine.cpp} | 6 +- ...VirtualMachine.hpp => virtual_machine.hpp} | 4 +- src/{virtualMemory.cpp => virtual_memory.cpp} | 2 +- src/{virtualMemory.hpp => virtual_memory.hpp} | 0 ...iledVirtualMachine.cpp => vm_compiled.cpp} | 2 +- ...iledVirtualMachine.hpp => vm_compiled.hpp} | 7 +- ...rtualMachine.cpp => vm_compiled_light.cpp} | 2 +- ...rtualMachine.hpp => vm_compiled_light.hpp} | 6 +- ...dVirtualMachine.cpp => vm_interpreted.cpp} | 13 +- ...dVirtualMachine.hpp => vm_interpreted.hpp} | 7 +- ...alMachine.cpp => vm_interpreted_light.cpp} | 2 +- ...alMachine.hpp => vm_interpreted_light.hpp} | 3 +- vcxproj/randomx.vcxproj | 68 +++--- vcxproj/randomx.vcxproj.filters | 194 +++++++++--------- 44 files changed, 263 insertions(+), 299 deletions(-) delete mode 100644 src/Program.cpp rename src/{hashAes1Rx4.cpp => aes_hash.cpp} (99%) rename src/{hashAes1Rx4.hpp => aes_hash.hpp} (96%) rename src/{AssemblyGeneratorX86.cpp => assembly_generator_x86.cpp} (98%) rename src/{AssemblyGeneratorX86.hpp => assembly_generator_x86.hpp} (97%) rename src/{Blake2Generator.cpp => blake2_benerator.cpp} (80%) rename src/{Blake2Generator.hpp => blake2_generator.hpp} (92%) rename src/{instructionWeights.hpp => instruction_weights.hpp} (98%) rename src/{instructionsPortable.cpp => instructions_portable.cpp} (95%) rename src/{intrinPortable.h => intrin_portable.h} (99%) rename src/{JitCompilerX86.cpp => jit_compiler_x86.cpp} (99%) rename src/{JitCompilerX86.hpp => jit_compiler_x86.hpp} (98%) rename src/{JitCompilerX86-static.S => jit_compiler_x86_static.S} (100%) rename src/{JitCompilerX86-static.hpp => jit_compiler_x86_static.hpp} (98%) rename src/{JitCompilerX86-static.asm => jit_compiler_x86_staticc.asm} (100%) rename src/{softAes.cpp => soft_aes.cpp} (99%) rename src/{softAes.h => soft_aes.h} (97%) rename src/{superscalarGenerator.cpp => superscalar.cpp} (99%) rename src/{superscalarGenerator.hpp => superscalar.hpp} (94%) rename src/{VirtualMachine.cpp => virtual_machine.cpp} (98%) rename src/{VirtualMachine.hpp => virtual_machine.hpp} (97%) rename src/{virtualMemory.cpp => virtual_memory.cpp} (99%) rename src/{virtualMemory.hpp => virtual_memory.hpp} (100%) rename src/{CompiledVirtualMachine.cpp => vm_compiled.cpp} (98%) rename src/{CompiledVirtualMachine.hpp => vm_compiled.hpp} (93%) rename src/{CompiledLightVirtualMachine.cpp => vm_compiled_light.cpp} (97%) rename src/{CompiledLightVirtualMachine.hpp => vm_compiled_light.hpp} (93%) rename src/{InterpretedVirtualMachine.cpp => vm_interpreted.cpp} (99%) rename src/{InterpretedVirtualMachine.hpp => vm_interpreted.hpp} (96%) rename src/{InterpretedLightVirtualMachine.cpp => vm_interpreted_light.cpp} (97%) rename src/{InterpretedLightVirtualMachine.hpp => vm_interpreted_light.hpp} (95%) diff --git a/src/Instruction.cpp b/src/Instruction.cpp index ac687d0..24a44b7 100644 --- a/src/Instruction.cpp +++ b/src/Instruction.cpp @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with RandomX. If not, see. */ -#include "Instruction.hpp" +#include "instruction.hpp" #include "common.hpp" namespace randomx { @@ -330,7 +330,7 @@ namespace randomx { os << std::endl; } -#include "instructionWeights.hpp" +#include "instruction_weights.hpp" #define INST_NAME(x) REPN(#x, WT(x)) #define INST_HANDLE(x) REPN(&Instruction::h_##x, WT(x)) @@ -380,7 +380,7 @@ namespace randomx { INST_NAME(NOP) }; - InstructionVisualizer Instruction::engine[256] = { + InstructionFormatter Instruction::engine[256] = { //Integer INST_HANDLE(IADD_RS) INST_HANDLE(IADD_M) diff --git a/src/Instruction.hpp b/src/Instruction.hpp index 89db7e3..2fef4de 100644 --- a/src/Instruction.hpp +++ b/src/Instruction.hpp @@ -27,7 +27,7 @@ namespace randomx { class Instruction; - typedef void(Instruction::*InstructionVisualizer)(std::ostream&) const; + typedef void(Instruction::*InstructionFormatter)(std::ostream&) const; namespace InstructionType { constexpr int IADD_RS = 0; @@ -71,9 +71,6 @@ namespace randomx { class Instruction { public: - uint8_t opcode; - uint8_t dst; - uint8_t src; uint32_t getImm32() const { return load32(&imm32); } @@ -102,17 +99,20 @@ namespace randomx { void setMod(uint8_t val) { mod = val; } + + uint8_t opcode; + uint8_t dst; + uint8_t src; private: uint8_t mod; uint32_t imm32; + void print(std::ostream&) const; static const char* names[256]; - static InstructionVisualizer engine[256]; - + static InstructionFormatter engine[256]; void genAddressReg(std::ostream& os) const; void genAddressImm(std::ostream& os) const; void genAddressRegDst(std::ostream&) const; - void h_IADD_RS(std::ostream&) const; void h_IADD_M(std::ostream&) const; void h_IADD_RC(std::ostream&) const; @@ -152,6 +152,6 @@ namespace randomx { void h_NOP(std::ostream&) const; }; - static_assert(sizeof(Instruction) == 8, "Invalid alignment of struct Instruction"); + static_assert(sizeof(Instruction) == 8, "Invalid size of struct randomx::Instruction"); } \ No newline at end of file diff --git a/src/Program.cpp b/src/Program.cpp deleted file mode 100644 index 2b10f0b..0000000 --- a/src/Program.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* -Copyright (c) 2018 tevador - -This file is part of RandomX. - -RandomX is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -RandomX is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with RandomX. If not, see. -*/ - -#include "Program.hpp" -#include "hashAes1Rx4.hpp" - -namespace RandomX { - template - void ProgramBase::print(std::ostream& os) const { - for (int i = 0; i < RANDOMX_PROGRAM_SIZE; ++i) { - auto instr = programBuffer[i]; - os << instr; - } - } -} diff --git a/src/Program.hpp b/src/Program.hpp index c7ba0f9..630d42d 100644 --- a/src/Program.hpp +++ b/src/Program.hpp @@ -22,7 +22,7 @@ along with RandomX. If not, see. #include #include #include "common.hpp" -#include "Instruction.hpp" +#include "instruction.hpp" #include "blake2/endian.h" namespace randomx { @@ -58,5 +58,5 @@ namespace randomx { Instruction programBuffer[RANDOMX_PROGRAM_SIZE]; }; - static_assert(sizeof(Program) % 64 == 0, "Invalid size of class Program"); + static_assert(sizeof(Program) % 64 == 0, "Invalid size of class randomx::Program"); } diff --git a/src/hashAes1Rx4.cpp b/src/aes_hash.cpp similarity index 99% rename from src/hashAes1Rx4.cpp rename to src/aes_hash.cpp index a9069ea..9fbbb02 100644 --- a/src/hashAes1Rx4.cpp +++ b/src/aes_hash.cpp @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with RandomX. If not, see. */ -#include "softAes.h" +#include "soft_aes.h" /* Calculate a 512-bit hash of 'input' using 4 lanes of AES. diff --git a/src/hashAes1Rx4.hpp b/src/aes_hash.hpp similarity index 96% rename from src/hashAes1Rx4.hpp rename to src/aes_hash.hpp index 8c0c156..c29f7d9 100644 --- a/src/hashAes1Rx4.hpp +++ b/src/aes_hash.hpp @@ -17,7 +17,9 @@ You should have received a copy of the GNU General Public License along with RandomX. If not, see. */ -#include "softAes.h" +#pragma once + +#include template void hashAes1Rx4(const void *input, size_t inputSize, void *hash); diff --git a/src/allocator.cpp b/src/allocator.cpp index f5a9a06..456767f 100644 --- a/src/allocator.cpp +++ b/src/allocator.cpp @@ -20,8 +20,8 @@ along with RandomX. If not, see. #pragma once #include "allocator.hpp" -#include "virtualMemory.hpp" -#include "intrinPortable.h" +#include "intrin_portable.h" +#include "virtual_memory.hpp" #include "common.hpp" namespace randomx { diff --git a/src/AssemblyGeneratorX86.cpp b/src/assembly_generator_x86.cpp similarity index 98% rename from src/AssemblyGeneratorX86.cpp rename to src/assembly_generator_x86.cpp index be91988..485c549 100644 --- a/src/AssemblyGeneratorX86.cpp +++ b/src/assembly_generator_x86.cpp @@ -19,11 +19,11 @@ along with RandomX. If not, see. //#define TRACE #include -#include "AssemblyGeneratorX86.hpp" +#include "assembly_generator_x86.hpp" #include "common.hpp" #include "reciprocal.h" -#include "Program.hpp" -#include "superscalarGenerator.hpp" +#include "program.hpp" +#include "superscalar.hpp" namespace randomx { @@ -117,7 +117,7 @@ namespace randomx { asmCode << "mov " << regR[instr.dst] << ", rdx" << std::endl; break; case SuperscalarInstructionType::IMUL_RCP: - asmCode << "mov rax, " << (int64_t)reciprocal(instr.getImm32()) << std::endl; + asmCode << "mov rax, " << (int64_t)randomx_reciprocal(instr.getImm32()) << std::endl; asmCode << "imul " << regR[instr.dst] << ", rax" << std::endl; break; default: @@ -210,7 +210,7 @@ namespace randomx { asmCode << regR[instr.dst] << " = smulh(" << regR[instr.dst] << ", " << regR[instr.src] << ");" << std::endl; break; case SuperscalarInstructionType::IMUL_RCP: - asmCode << regR[instr.dst] << " *= " << (int64_t)reciprocal(instr.getImm32()) << ";" << std::endl; + asmCode << regR[instr.dst] << " *= " << (int64_t)randomx_reciprocal(instr.getImm32()) << ";" << std::endl; break; default: UNREACHABLE; @@ -477,7 +477,7 @@ namespace randomx { if (instr.getImm32() != 0) { registerUsage[instr.dst] = i; uint32_t divisor = instr.getImm32(); - asmCode << "\tmov rax, " << reciprocal(instr.getImm32()) << std::endl; + asmCode << "\tmov rax, " << randomx_reciprocal(instr.getImm32()) << std::endl; asmCode << "\timul " << regR[instr.dst] << ", rax" << std::endl; traceint(instr); } @@ -691,7 +691,7 @@ namespace randomx { tracenop(instr); } -#include "instructionWeights.hpp" +#include "instruction_weights.hpp" #define INST_HANDLE(x) REPN(&AssemblyGeneratorX86::h_##x, WT(x)) InstructionGenerator AssemblyGeneratorX86::engine[256] = { diff --git a/src/AssemblyGeneratorX86.hpp b/src/assembly_generator_x86.hpp similarity index 97% rename from src/AssemblyGeneratorX86.hpp rename to src/assembly_generator_x86.hpp index 417491c..f5b523f 100644 --- a/src/AssemblyGeneratorX86.hpp +++ b/src/assembly_generator_x86.hpp @@ -19,9 +19,6 @@ along with RandomX. If not, see. #pragma once -#include "Instruction.hpp" -#include "configuration.h" -#include "common.hpp" #include namespace randomx { @@ -29,6 +26,7 @@ namespace randomx { class Program; class SuperscalarProgram; class AssemblyGeneratorX86; + class Instruction; typedef void(AssemblyGeneratorX86::*InstructionGenerator)(Instruction&, int); @@ -41,22 +39,15 @@ namespace randomx { os << asmCode.rdbuf(); } private: - static InstructionGenerator engine[256]; - std::stringstream asmCode; - int registerUsage[8]; - void genAddressReg(Instruction&, const char*); void genAddressRegDst(Instruction&, int); int32_t genAddressImm(Instruction&); int getConditionRegister(); void handleCondition(Instruction&, int); - 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_IADD_RC(Instruction&, int); @@ -94,5 +85,9 @@ namespace randomx { void h_ISTORE(Instruction&, int); void h_FSTORE(Instruction&, int); void h_NOP(Instruction&, int); + + static InstructionGenerator engine[256]; + std::stringstream asmCode; + int registerUsage[8]; }; } \ No newline at end of file diff --git a/src/Blake2Generator.cpp b/src/blake2_benerator.cpp similarity index 80% rename from src/Blake2Generator.cpp rename to src/blake2_benerator.cpp index 2cc0129..4454abb 100644 --- a/src/Blake2Generator.cpp +++ b/src/blake2_benerator.cpp @@ -20,15 +20,16 @@ along with RandomX. If not, see. #include #include "blake2/blake2.h" #include "blake2/endian.h" -#include "Blake2Generator.hpp" -#include "common.hpp" +#include "blake2_generator.hpp" namespace randomx { - Blake2Generator::Blake2Generator(const void* seed, int nonce) : dataIndex(sizeof(data)) { + constexpr int maxSeedSize = 60; + + Blake2Generator::Blake2Generator(const void* seed, size_t seedSize, int nonce) : dataIndex(sizeof(data)) { memset(data, 0, sizeof(data)); - memcpy(data, seed, SeedSize); - store32(&data[60], nonce); + memcpy(data, seed, seedSize > maxSeedSize ? maxSeedSize : seedSize); + store32(&data[maxSeedSize], nonce); } uint8_t Blake2Generator::getByte() { diff --git a/src/Blake2Generator.hpp b/src/blake2_generator.hpp similarity index 92% rename from src/Blake2Generator.hpp rename to src/blake2_generator.hpp index fa85548..7124762 100644 --- a/src/Blake2Generator.hpp +++ b/src/blake2_generator.hpp @@ -18,19 +18,20 @@ along with RandomX. If not, see. */ #pragma once + #include namespace randomx { class Blake2Generator { public: - Blake2Generator(const void* seed, int nonce); + Blake2Generator(const void* seed, size_t seedSize, int nonce = 0); uint8_t getByte(); uint32_t getInt32(); private: + void checkData(const size_t); + uint8_t data[64]; size_t dataIndex; - - void checkData(const size_t); }; } \ No newline at end of file diff --git a/src/dataset.cpp b/src/dataset.cpp index e632547..a241697 100644 --- a/src/dataset.cpp +++ b/src/dataset.cpp @@ -17,6 +17,12 @@ You should have received a copy of the GNU General Public License along with RandomX. If not, see. */ +/* Original code from Argon2 reference source code package used under CC0 Licence + * https://github.com/P-H-C/phc-winner-argon2 + * Copyright 2015 + * Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves +*/ + #include #include #include @@ -26,9 +32,9 @@ along with RandomX. If not, see. #include "common.hpp" #include "dataset.hpp" -#include "virtualMemory.hpp" -#include "superscalarGenerator.hpp" -#include "Blake2Generator.hpp" +#include "virtual_memory.hpp" +#include "superscalar.hpp" +#include "blake2_generator.hpp" #include "reciprocal.h" #include "blake2/endian.h" #include "argon2.h" @@ -100,13 +106,13 @@ void randomx_cache::initialize(const void *seed, size_t seedSize) { fill_memory_blocks(&instance); reciprocalCache.clear(); - randomx::Blake2Generator gen(seed, 1000); + randomx::Blake2Generator gen(seed, seedSize, 1000); //TODO for (int i = 0; i < RANDOMX_CACHE_ACCESSES; ++i) { randomx::generateSuperscalar(programs[i], gen); for (unsigned j = 0; j < programs[i].getSize(); ++j) { auto& instr = programs[i](j); if (instr.opcode == randomx::SuperscalarInstructionType::IMUL_RCP) { - auto rcp = reciprocal(instr.getImm32()); + auto rcp = randomx_reciprocal(instr.getImm32()); instr.setImm32(reciprocalCache.size()); reciprocalCache.push_back(rcp); } diff --git a/src/dataset.hpp b/src/dataset.hpp index 12c2021..c6b1e83 100644 --- a/src/dataset.hpp +++ b/src/dataset.hpp @@ -21,29 +21,26 @@ along with RandomX. If not, see. #include #include -#include "intrinPortable.h" #include "common.hpp" -#include "randomx.h" -#include "Program.hpp" #include "superscalar_program.hpp" -#include "JitCompilerX86.hpp" +#include "jit_compiler_x86.hpp" #include "allocator.hpp" +/* Global scope for C binding */ struct randomx_dataset { virtual ~randomx_dataset() = 0; virtual bool allocate() = 0; uint8_t* memory = nullptr; }; +/* Global scope for C binding */ struct randomx_cache : public randomx_dataset { virtual randomx::DatasetInitFunc getInitFunc() = 0; - virtual void initialize(const void *seed, size_t seedSize); //argon2 + virtual void initialize(const void *seed, size_t seedSize); randomx::SuperscalarProgram programs[RANDOMX_CACHE_ACCESSES]; std::vector reciprocalCache; }; - - namespace randomx { template diff --git a/src/instructionWeights.hpp b/src/instruction_weights.hpp similarity index 98% rename from src/instructionWeights.hpp rename to src/instruction_weights.hpp index a95a464..7f9389e 100644 --- a/src/instructionWeights.hpp +++ b/src/instruction_weights.hpp @@ -101,4 +101,4 @@ along with RandomX. If not, see. #define REPCASE256(x) REPCASE128(x) REPCASE128(x) #define REPCASENX(x,N) REPCASE##N(x) #define REPCASEN(x,N) REPCASENX(x,N) -#define CASE_REP(x) REPCASEN(x, WT(x)) \ No newline at end of file +#define CASE_REP(x) REPCASEN(x, WT(x)) diff --git a/src/instructionsPortable.cpp b/src/instructions_portable.cpp similarity index 95% rename from src/instructionsPortable.cpp rename to src/instructions_portable.cpp index 59d19c5..ac12eed 100644 --- a/src/instructionsPortable.cpp +++ b/src/instructions_portable.cpp @@ -16,9 +16,9 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with RandomX. If not, see. */ + //#define DEBUG -#include "intrinPortable.h" -#include "blake2/endian.h" + #pragma STDC FENV_ACCESS on #include #include @@ -26,6 +26,8 @@ along with RandomX. If not, see. #include #endif #include "common.hpp" +#include "intrin_portable.h" +#include "blake2/endian.h" #if defined(__SIZEOF_INT128__) typedef unsigned __int128 uint128_t; @@ -87,14 +89,14 @@ along with RandomX. If not, see. uint64_t rotr(uint64_t a, int b) { return (a >> b) | (a << (64 - b)); } - #define HAS_ROTR + #define HAVE_ROTR #endif #ifndef HAVE_ROTL uint64_t rotl(uint64_t a, int b) { return (a << b) | (a >> (64 - b)); } - #define HAS_ROTL + #define HAVE_ROTL #endif #ifndef HAVE_MULH @@ -126,11 +128,6 @@ along with RandomX. If not, see. #define HAVE_SMULH #endif -// avoid undefined behavior of signed overflow -static inline int32_t safeSub(int32_t a, int32_t b) { - return int32_t(uint32_t(a) - uint32_t(b)); -} - #if __GNUC__ >= 5 #undef __has_builtin #define __has_builtin(x) 1 diff --git a/src/intrinPortable.h b/src/intrin_portable.h similarity index 99% rename from src/intrinPortable.h rename to src/intrin_portable.h index 972716f..221a56b 100644 --- a/src/intrinPortable.h +++ b/src/intrin_portable.h @@ -330,7 +330,6 @@ __m128d ieee_set_exponent(__m128d x) { } double loadDoublePortable(const void* addr); - uint64_t mulh(uint64_t, uint64_t); int64_t smulh(int64_t, int64_t); uint64_t rotl(uint64_t, int); diff --git a/src/JitCompilerX86.cpp b/src/jit_compiler_x86.cpp similarity index 99% rename from src/JitCompilerX86.cpp rename to src/jit_compiler_x86.cpp index 3b423a0..abd698a 100644 --- a/src/JitCompilerX86.cpp +++ b/src/jit_compiler_x86.cpp @@ -17,20 +17,14 @@ You should have received a copy of the GNU General Public License along with RandomX. If not, see. */ -#include -#include #include -#include "JitCompilerX86.hpp" -#include "Program.hpp" -#include "reciprocal.h" -#include "virtualMemory.hpp" -#include "intrinPortable.h" +#include "jit_compiler_x86.hpp" #define RANDOMX_JUMP +#if !defined(_M_X64) && !defined(__x86_64__) namespace randomx { -#if !defined(_M_X64) && !defined(__x86_64__) JitCompilerX86::JitCompilerX86() { throw std::runtime_error("JIT compiler only supports x86-64 CPUs"); } @@ -46,8 +40,19 @@ namespace randomx { size_t JitCompilerX86::getCodeSize() { return 0; } + +} #else +#include +#include +#include "jit_compiler_x86_static.hpp" +#include "superscalar.hpp" +#include "program.hpp" +#include "reciprocal.h" +#include "virtual_memory.hpp" + +namespace randomx { /* REGISTER ALLOCATION: @@ -87,9 +92,6 @@ namespace randomx { */ -#include "JitCompilerX86-static.hpp" -#include "superscalarGenerator.hpp" - #define NOP_TEST true const uint8_t* codePrologue = (uint8_t*)&randomx_program_prologue; @@ -675,7 +677,7 @@ namespace randomx { } registerUsage[instr.dst] = i; emit(MOV_RAX_I); - emit64(reciprocal(instr.getImm32())); + emit64(randomx_reciprocal(instr.getImm32())); emit(REX_IMUL_RM); emitByte(0xc0 + 8 * instr.dst); } @@ -1017,7 +1019,7 @@ namespace randomx { emitByte(0x90); } -#include "instructionWeights.hpp" +#include "instruction_weights.hpp" #define INST_HANDLE(x) REPN(&JitCompilerX86::h_##x, WT(x)) InstructionGeneratorX86 JitCompilerX86::engine[256] = { diff --git a/src/JitCompilerX86.hpp b/src/jit_compiler_x86.hpp similarity index 98% rename from src/JitCompilerX86.hpp rename to src/jit_compiler_x86.hpp index fd02434..fec2747 100644 --- a/src/JitCompilerX86.hpp +++ b/src/jit_compiler_x86.hpp @@ -19,11 +19,10 @@ along with RandomX. If not, see. #pragma once -#include "common.hpp" -#include "Instruction.hpp" -#include "superscalar_program.hpp" +#include #include #include +#include "common.hpp" namespace randomx { @@ -31,6 +30,7 @@ namespace randomx { class ProgramConfiguration; class SuperscalarProgram; class JitCompilerX86; + class Instruction; typedef void(JitCompilerX86::*InstructionGeneratorX86)(Instruction&, int); diff --git a/src/JitCompilerX86-static.S b/src/jit_compiler_x86_static.S similarity index 100% rename from src/JitCompilerX86-static.S rename to src/jit_compiler_x86_static.S diff --git a/src/JitCompilerX86-static.hpp b/src/jit_compiler_x86_static.hpp similarity index 98% rename from src/JitCompilerX86-static.hpp rename to src/jit_compiler_x86_static.hpp index 3bb56ac..5e8d0ce 100644 --- a/src/JitCompilerX86-static.hpp +++ b/src/jit_compiler_x86_static.hpp @@ -17,6 +17,8 @@ You should have received a copy of the GNU General Public License along with RandomX. If not, see. */ +#pragma once + extern "C" { void randomx_program_prologue(); void randomx_program_loop_begin(); @@ -36,4 +38,4 @@ extern "C" { void randomx_sshash_end(); void randomx_sshash_init(); void randomx_program_end(); -} \ No newline at end of file +} diff --git a/src/JitCompilerX86-static.asm b/src/jit_compiler_x86_staticc.asm similarity index 100% rename from src/JitCompilerX86-static.asm rename to src/jit_compiler_x86_staticc.asm diff --git a/src/main.cpp b/src/main.cpp index cbf2a61..0fb9d32 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -19,7 +19,7 @@ along with RandomX. If not, see. //#define TRACE //#include "AssemblyGeneratorX86.hpp" -#include "Stopwatch.hpp" +#include "stopwatch.hpp" //#include "blake2/blake2.h" #include "blake2/endian.h" #include diff --git a/src/randomx.cpp b/src/randomx.cpp index d45cfea..3f6a429 100644 --- a/src/randomx.cpp +++ b/src/randomx.cpp @@ -19,12 +19,10 @@ along with RandomX. If not, see. #include "randomx.h" #include "dataset.hpp" -#include "VirtualMachine.hpp" -#include "./InterpretedVirtualMachine.hpp" -#include "./InterpretedLightVirtualMachine.hpp" -#include "./CompiledVirtualMachine.hpp" -#include "./CompiledLightVirtualMachine.hpp" -#include "virtualMemory.hpp" +#include "vm_interpreted.hpp" +#include "vm_interpreted_light.hpp" +#include "vm_compiled.hpp" +#include "vm_compiled_light.hpp" #include "blake2/blake2.h" extern "C" { diff --git a/src/reciprocal.c b/src/reciprocal.c index c414702..862d7ec 100644 --- a/src/reciprocal.c +++ b/src/reciprocal.c @@ -19,7 +19,6 @@ along with RandomX. If not, see. #include "reciprocal.h" - /* Calculates rcp = 2**x / divisor for highest integer x such that rcp < 2**64. @@ -34,7 +33,7 @@ along with RandomX. If not, see. ret */ -uint64_t reciprocal(uint64_t divisor) { +uint64_t randomx_reciprocal(uint64_t divisor) { const uint64_t p2exp63 = 1ULL << 63; diff --git a/src/reciprocal.h b/src/reciprocal.h index 0d13394..4132d6e 100644 --- a/src/reciprocal.h +++ b/src/reciprocal.h @@ -18,13 +18,14 @@ along with RandomX. If not, see. */ #pragma once + #include #if defined(__cplusplus) extern "C" { #endif - uint64_t reciprocal(uint64_t); +uint64_t randomx_reciprocal(uint64_t); #if defined(__cplusplus) } diff --git a/src/softAes.cpp b/src/soft_aes.cpp similarity index 99% rename from src/softAes.cpp rename to src/soft_aes.cpp index b51d92c..81dc66b 100644 --- a/src/softAes.cpp +++ b/src/soft_aes.cpp @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with RandomX. If not, see. */ -#include "softAes.h" +#include "soft_aes.h" alignas(16) const uint8_t sbox[256] = { 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, @@ -321,8 +321,8 @@ alignas(16) const uint32_t lutDec3[256] = { __m128i soft_aesenc(__m128i in, __m128i key) { uint32_t s0, s1, s2, s3; - s0 = _mm_cvtsi128_si32(_mm_shuffle_epi32(in, 0xFF)); - s1 = _mm_cvtsi128_si32(_mm_shuffle_epi32(in, 0xAA)); + s0 = _mm_cvtsi128_si32(_mm_shuffle_epi32(in, 0xff)); + s1 = _mm_cvtsi128_si32(_mm_shuffle_epi32(in, 0xaa)); s2 = _mm_cvtsi128_si32(_mm_shuffle_epi32(in, 0x55)); s3 = _mm_cvtsi128_si32(in); @@ -339,8 +339,8 @@ __m128i soft_aesenc(__m128i in, __m128i key) { __m128i soft_aesdec(__m128i in, __m128i key) { uint32_t s0, s1, s2, s3; - s0 = _mm_cvtsi128_si32(_mm_shuffle_epi32(in, 0xFF)); - s1 = _mm_cvtsi128_si32(_mm_shuffle_epi32(in, 0xAA)); + s0 = _mm_cvtsi128_si32(_mm_shuffle_epi32(in, 0xff)); + s1 = _mm_cvtsi128_si32(_mm_shuffle_epi32(in, 0xaa)); s2 = _mm_cvtsi128_si32(_mm_shuffle_epi32(in, 0x55)); s3 = _mm_cvtsi128_si32(in); diff --git a/src/softAes.h b/src/soft_aes.h similarity index 97% rename from src/softAes.h rename to src/soft_aes.h index 9054ef1..12e9ce4 100644 --- a/src/softAes.h +++ b/src/soft_aes.h @@ -18,8 +18,9 @@ along with RandomX. If not, see. */ #pragma once + #include -#include "intrinPortable.h" +#include "intrin_portable.h" __m128i soft_aesenc(__m128i in, __m128i key); diff --git a/src/superscalarGenerator.cpp b/src/superscalar.cpp similarity index 99% rename from src/superscalarGenerator.cpp rename to src/superscalar.cpp index 98d8658..3537f35 100644 --- a/src/superscalarGenerator.cpp +++ b/src/superscalar.cpp @@ -25,8 +25,8 @@ along with RandomX. If not, see. #include #include #include -#include "superscalarGenerator.hpp" -#include "intrinPortable.h" +#include "superscalar.hpp" +#include "intrin_portable.h" #include "reciprocal.h" namespace randomx { @@ -885,11 +885,11 @@ namespace randomx { if (reciprocals != nullptr) r[instr.dst] *= (*reciprocals)[instr.getImm32()]; else - r[instr.dst] *= reciprocal(instr.getImm32()); + r[instr.dst] *= randomx_reciprocal(instr.getImm32()); break; default: UNREACHABLE; } } } -} \ No newline at end of file +} diff --git a/src/superscalarGenerator.hpp b/src/superscalar.hpp similarity index 94% rename from src/superscalarGenerator.hpp rename to src/superscalar.hpp index 71d38b1..b599c2a 100644 --- a/src/superscalarGenerator.hpp +++ b/src/superscalar.hpp @@ -18,9 +18,11 @@ along with RandomX. If not, see. */ #pragma once -#include "superscalar_program.hpp" -#include "Blake2Generator.hpp" + +#include #include +#include "superscalar_program.hpp" +#include "blake2_generator.hpp" namespace randomx { // Intel Ivy Bridge reference @@ -45,5 +47,5 @@ namespace randomx { } void generateSuperscalar(SuperscalarProgram& prog, Blake2Generator& gen); - void executeSuperscalar(int_reg_t(&r)[8], SuperscalarProgram& prog, std::vector *reciprocals = nullptr); + void executeSuperscalar(uint64_t(&r)[8], SuperscalarProgram& prog, std::vector *reciprocals = nullptr); } \ No newline at end of file diff --git a/src/superscalar_program.hpp b/src/superscalar_program.hpp index d4296ca..5d83a39 100644 --- a/src/superscalar_program.hpp +++ b/src/superscalar_program.hpp @@ -20,7 +20,7 @@ along with RandomX. If not, see. #pragma once #include -#include "Instruction.hpp" +#include "instruction.hpp" #include "configuration.h" namespace randomx { diff --git a/src/VirtualMachine.cpp b/src/virtual_machine.cpp similarity index 98% rename from src/VirtualMachine.cpp rename to src/virtual_machine.cpp index 9fd102e..e232f8c 100644 --- a/src/VirtualMachine.cpp +++ b/src/virtual_machine.cpp @@ -17,13 +17,13 @@ You should have received a copy of the GNU General Public License along with RandomX. If not, see. */ -#include "VirtualMachine.hpp" +#include "virtual_machine.hpp" #include "common.hpp" -#include "hashAes1Rx4.hpp" +#include "aes_hash.hpp" #include "blake2/blake2.h" #include #include -#include "intrinPortable.h" +#include "intrin_portable.h" #include "allocator.hpp" randomx_vm::~randomx_vm() { diff --git a/src/VirtualMachine.hpp b/src/virtual_machine.hpp similarity index 97% rename from src/VirtualMachine.hpp rename to src/virtual_machine.hpp index bf83a03..0f788f6 100644 --- a/src/VirtualMachine.hpp +++ b/src/virtual_machine.hpp @@ -21,8 +21,7 @@ along with RandomX. If not, see. #include #include "common.hpp" -#include "dataset.hpp" -#include "Program.hpp" +#include "program.hpp" /* Global namespace for C binding */ class randomx_vm { @@ -38,7 +37,6 @@ public: randomx::RegisterFile *getRegisterFile() { return ® } - protected: void initialize(); alignas(64) randomx::Program program; diff --git a/src/virtualMemory.cpp b/src/virtual_memory.cpp similarity index 99% rename from src/virtualMemory.cpp rename to src/virtual_memory.cpp index 17b91da..f524bef 100644 --- a/src/virtualMemory.cpp +++ b/src/virtual_memory.cpp @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with RandomX. If not, see. */ -#include "virtualMemory.hpp" +#include "virtual_memory.hpp" #include diff --git a/src/virtualMemory.hpp b/src/virtual_memory.hpp similarity index 100% rename from src/virtualMemory.hpp rename to src/virtual_memory.hpp diff --git a/src/CompiledVirtualMachine.cpp b/src/vm_compiled.cpp similarity index 98% rename from src/CompiledVirtualMachine.cpp rename to src/vm_compiled.cpp index 639fc8c..098245e 100644 --- a/src/CompiledVirtualMachine.cpp +++ b/src/vm_compiled.cpp @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with RandomX. If not, see. */ -#include "CompiledVirtualMachine.hpp" +#include "vm_compiled.hpp" #include "common.hpp" namespace randomx { diff --git a/src/CompiledVirtualMachine.hpp b/src/vm_compiled.hpp similarity index 93% rename from src/CompiledVirtualMachine.hpp rename to src/vm_compiled.hpp index 94fb856..0556afe 100644 --- a/src/CompiledVirtualMachine.hpp +++ b/src/vm_compiled.hpp @@ -20,8 +20,11 @@ along with RandomX. If not, see. #pragma once #include -#include "VirtualMachine.hpp" -#include "JitCompilerX86.hpp" +#include +#include "virtual_machine.hpp" +#include "jit_compiler_x86.hpp" +#include "allocator.hpp" +#include "dataset.hpp" namespace randomx { diff --git a/src/CompiledLightVirtualMachine.cpp b/src/vm_compiled_light.cpp similarity index 97% rename from src/CompiledLightVirtualMachine.cpp rename to src/vm_compiled_light.cpp index ab3c8e3..c817191 100644 --- a/src/CompiledLightVirtualMachine.cpp +++ b/src/vm_compiled_light.cpp @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with RandomX. If not, see. */ -#include "CompiledLightVirtualMachine.hpp" +#include "vm_compiled_light.hpp" #include "common.hpp" #include diff --git a/src/CompiledLightVirtualMachine.hpp b/src/vm_compiled_light.hpp similarity index 93% rename from src/CompiledLightVirtualMachine.hpp rename to src/vm_compiled_light.hpp index 813ddbf..e66e786 100644 --- a/src/CompiledLightVirtualMachine.hpp +++ b/src/vm_compiled_light.hpp @@ -18,11 +18,9 @@ along with RandomX. If not, see. */ #pragma once -//#define TRACEVM + #include -#include "CompiledVirtualMachine.hpp" -#include "JitCompilerX86.hpp" -#include "intrinPortable.h" +#include "vm_compiled.hpp" namespace randomx { diff --git a/src/InterpretedVirtualMachine.cpp b/src/vm_interpreted.cpp similarity index 99% rename from src/InterpretedVirtualMachine.cpp rename to src/vm_interpreted.cpp index 5c40890..55b7fbd 100644 --- a/src/InterpretedVirtualMachine.cpp +++ b/src/vm_interpreted.cpp @@ -16,20 +16,21 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with RandomX. If not, see. */ + //#define TRACE //#define FPUCHECK #define RANDOMX_JUMP -#include "InterpretedVirtualMachine.hpp" -#include "dataset.hpp" + #include #include #include #include #include #include -#include #include -#include "intrinPortable.h" +#include "vm_interpreted.hpp" +#include "dataset.hpp" +#include "intrin_portable.h" #include "reciprocal.h" #ifdef FPUCHECK @@ -465,7 +466,7 @@ namespace randomx { } }*/ -#include "instructionWeights.hpp" +#include "instruction_weights.hpp" template void InterpretedVm::precompileProgram(int_reg_t(&r)[8], __m128d (&f)[4], __m128d (&e)[4], __m128d (&a)[4]) { @@ -652,7 +653,7 @@ namespace randomx { auto dst = instr.dst % RegistersCount; ibc.type = InstructionType::IMUL_R; ibc.idst = &r[dst]; - ibc.imm = reciprocal(divisor); + ibc.imm = randomx_reciprocal(divisor); ibc.isrc = &ibc.imm; registerUsage[instr.dst] = i; } diff --git a/src/InterpretedVirtualMachine.hpp b/src/vm_interpreted.hpp similarity index 96% rename from src/InterpretedVirtualMachine.hpp rename to src/vm_interpreted.hpp index bcf42ca..10e1ccf 100644 --- a/src/InterpretedVirtualMachine.hpp +++ b/src/vm_interpreted.hpp @@ -20,10 +20,11 @@ along with RandomX. If not, see. #pragma once #include -#include "VirtualMachine.hpp" -#include "Program.hpp" -#include "intrinPortable.h" #include +#include "common.hpp" +#include "virtual_machine.hpp" +#include "intrin_portable.h" +#include "allocator.hpp" namespace randomx { diff --git a/src/InterpretedLightVirtualMachine.cpp b/src/vm_interpreted_light.cpp similarity index 97% rename from src/InterpretedLightVirtualMachine.cpp rename to src/vm_interpreted_light.cpp index 76f633f..791f448 100644 --- a/src/InterpretedLightVirtualMachine.cpp +++ b/src/vm_interpreted_light.cpp @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with RandomX. If not, see. */ -#include "InterpretedLightVirtualMachine.hpp" +#include "vm_interpreted_light.hpp" #include "dataset.hpp" namespace randomx { diff --git a/src/InterpretedLightVirtualMachine.hpp b/src/vm_interpreted_light.hpp similarity index 95% rename from src/InterpretedLightVirtualMachine.hpp rename to src/vm_interpreted_light.hpp index ab94a07..657452c 100644 --- a/src/InterpretedLightVirtualMachine.hpp +++ b/src/vm_interpreted_light.hpp @@ -20,8 +20,7 @@ along with RandomX. If not, see. #pragma once #include -#include "InterpretedVirtualMachine.hpp" -#include "superscalar_program.hpp" +#include "vm_interpreted.hpp" namespace randomx { diff --git a/vcxproj/randomx.vcxproj b/vcxproj/randomx.vcxproj index 1ed504b..a3fe530 100644 --- a/vcxproj/randomx.vcxproj +++ b/vcxproj/randomx.vcxproj @@ -127,60 +127,58 @@ - - + + - - + + - - - - - - + + + + + + - + - - - + + + - - + - - + + - - + + - - - - - - - - + + + + + + + + - - + + - - - + + - - + + diff --git a/vcxproj/randomx.vcxproj.filters b/vcxproj/randomx.vcxproj.filters index 2e6958a..847c9b1 100644 --- a/vcxproj/randomx.vcxproj.filters +++ b/vcxproj/randomx.vcxproj.filters @@ -24,69 +24,66 @@ 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 + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + Source Files - - Source Files - - + Source Files @@ -97,85 +94,82 @@ 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 + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + Header Files