Removed capital letters from filenames

This commit is contained in:
tevador 2019-04-20 16:53:06 +02:00
parent d7276d5786
commit d7eefce583
44 changed files with 263 additions and 299 deletions

View File

@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License
along with RandomX. If not, see<http://www.gnu.org/licenses/>.
*/
#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)

View File

@ -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");
}

View File

@ -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<http://www.gnu.org/licenses/>.
*/
#include "Program.hpp"
#include "hashAes1Rx4.hpp"
namespace RandomX {
template<size_t PROGRAM_SIZE>
void ProgramBase::print(std::ostream& os) const {
for (int i = 0; i < RANDOMX_PROGRAM_SIZE; ++i) {
auto instr = programBuffer[i];
os << instr;
}
}
}

View File

@ -22,7 +22,7 @@ along with RandomX. If not, see<http://www.gnu.org/licenses/>.
#include <cstdint>
#include <ostream>
#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");
}

View File

@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License
along with RandomX. If not, see<http://www.gnu.org/licenses/>.
*/
#include "softAes.h"
#include "soft_aes.h"
/*
Calculate a 512-bit hash of 'input' using 4 lanes of AES.

View File

@ -17,7 +17,9 @@ You should have received a copy of the GNU General Public License
along with RandomX. If not, see<http://www.gnu.org/licenses/>.
*/
#include "softAes.h"
#pragma once
#include <cstddef>
template<bool softAes>
void hashAes1Rx4(const void *input, size_t inputSize, void *hash);

View File

@ -20,8 +20,8 @@ along with RandomX. If not, see<http://www.gnu.org/licenses/>.
#pragma once
#include "allocator.hpp"
#include "virtualMemory.hpp"
#include "intrinPortable.h"
#include "intrin_portable.h"
#include "virtual_memory.hpp"
#include "common.hpp"
namespace randomx {

View File

@ -19,11 +19,11 @@ along with RandomX. If not, see<http://www.gnu.org/licenses/>.
//#define TRACE
#include <climits>
#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] = {

View File

@ -19,9 +19,6 @@ along with RandomX. If not, see<http://www.gnu.org/licenses/>.
#pragma once
#include "Instruction.hpp"
#include "configuration.h"
#include "common.hpp"
#include <sstream>
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];
};
}

View File

@ -20,15 +20,16 @@ along with RandomX. If not, see<http://www.gnu.org/licenses/>.
#include <stddef.h>
#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() {

View File

@ -18,19 +18,20 @@ along with RandomX. If not, see<http://www.gnu.org/licenses/>.
*/
#pragma once
#include <cstdint>
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);
};
}

View File

@ -17,6 +17,12 @@ You should have received a copy of the GNU General Public License
along with RandomX. If not, see<http://www.gnu.org/licenses/>.
*/
/* 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 <new>
#include <algorithm>
#include <stdexcept>
@ -26,9 +32,9 @@ along with RandomX. If not, see<http://www.gnu.org/licenses/>.
#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);
}

View File

@ -21,29 +21,26 @@ along with RandomX. If not, see<http://www.gnu.org/licenses/>.
#include <cstdint>
#include <vector>
#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<uint64_t> reciprocalCache;
};
namespace randomx {
template<class Allocator>

View File

@ -101,4 +101,4 @@ along with RandomX. If not, see<http://www.gnu.org/licenses/>.
#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))
#define CASE_REP(x) REPCASEN(x, WT(x))

View File

@ -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<http://www.gnu.org/licenses/>.
*/
//#define DEBUG
#include "intrinPortable.h"
#include "blake2/endian.h"
#pragma STDC FENV_ACCESS on
#include <cfenv>
#include <cmath>
@ -26,6 +26,8 @@ along with RandomX. If not, see<http://www.gnu.org/licenses/>.
#include <iostream>
#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<http://www.gnu.org/licenses/>.
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<http://www.gnu.org/licenses/>.
#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

View File

@ -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);

View File

@ -17,20 +17,14 @@ You should have received a copy of the GNU General Public License
along with RandomX. If not, see<http://www.gnu.org/licenses/>.
*/
#include <cstring>
#include <climits>
#include <stdexcept>
#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 <cstring>
#include <climits>
#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] = {

View File

@ -19,11 +19,10 @@ along with RandomX. If not, see<http://www.gnu.org/licenses/>.
#pragma once
#include "common.hpp"
#include "Instruction.hpp"
#include "superscalar_program.hpp"
#include <cstdint>
#include <cstring>
#include <vector>
#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);

View File

@ -17,6 +17,8 @@ You should have received a copy of the GNU General Public License
along with RandomX. If not, see<http://www.gnu.org/licenses/>.
*/
#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();
}
}

View File

@ -19,7 +19,7 @@ along with RandomX. If not, see<http://www.gnu.org/licenses/>.
//#define TRACE
//#include "AssemblyGeneratorX86.hpp"
#include "Stopwatch.hpp"
#include "stopwatch.hpp"
//#include "blake2/blake2.h"
#include "blake2/endian.h"
#include <fstream>

View File

@ -19,12 +19,10 @@ along with RandomX. If not, see<http://www.gnu.org/licenses/>.
#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" {

View File

@ -19,7 +19,6 @@ along with RandomX. If not, see<http://www.gnu.org/licenses/>.
#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<http://www.gnu.org/licenses/>.
ret
*/
uint64_t reciprocal(uint64_t divisor) {
uint64_t randomx_reciprocal(uint64_t divisor) {
const uint64_t p2exp63 = 1ULL << 63;

View File

@ -18,13 +18,14 @@ along with RandomX. If not, see<http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stdint.h>
#if defined(__cplusplus)
extern "C" {
#endif
uint64_t reciprocal(uint64_t);
uint64_t randomx_reciprocal(uint64_t);
#if defined(__cplusplus)
}

View File

@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License
along with RandomX. If not, see<http://www.gnu.org/licenses/>.
*/
#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);

View File

@ -18,8 +18,9 @@ along with RandomX. If not, see<http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stdint.h>
#include "intrinPortable.h"
#include "intrin_portable.h"
__m128i soft_aesenc(__m128i in, __m128i key);

View File

@ -25,8 +25,8 @@ along with RandomX. If not, see<http://www.gnu.org/licenses/>.
#include <algorithm>
#include <stdexcept>
#include <iomanip>
#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;
}
}
}
}
}

View File

@ -18,9 +18,11 @@ along with RandomX. If not, see<http://www.gnu.org/licenses/>.
*/
#pragma once
#include "superscalar_program.hpp"
#include "Blake2Generator.hpp"
#include <cstdint>
#include <vector>
#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<uint64_t> *reciprocals = nullptr);
void executeSuperscalar(uint64_t(&r)[8], SuperscalarProgram& prog, std::vector<uint64_t> *reciprocals = nullptr);
}

View File

@ -20,7 +20,7 @@ along with RandomX. If not, see<http://www.gnu.org/licenses/>.
#pragma once
#include <cstdint>
#include "Instruction.hpp"
#include "instruction.hpp"
#include "configuration.h"
namespace randomx {

View File

@ -17,13 +17,13 @@ You should have received a copy of the GNU General Public License
along with RandomX. If not, see<http://www.gnu.org/licenses/>.
*/
#include "VirtualMachine.hpp"
#include "virtual_machine.hpp"
#include "common.hpp"
#include "hashAes1Rx4.hpp"
#include "aes_hash.hpp"
#include "blake2/blake2.h"
#include <cstring>
#include <iomanip>
#include "intrinPortable.h"
#include "intrin_portable.h"
#include "allocator.hpp"
randomx_vm::~randomx_vm() {

View File

@ -21,8 +21,7 @@ along with RandomX. If not, see<http://www.gnu.org/licenses/>.
#include <cstdint>
#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 &reg;
}
protected:
void initialize();
alignas(64) randomx::Program program;

View File

@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License
along with RandomX. If not, see<http://www.gnu.org/licenses/>.
*/
#include "virtualMemory.hpp"
#include "virtual_memory.hpp"
#include <stdexcept>

View File

@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License
along with RandomX. If not, see<http://www.gnu.org/licenses/>.
*/
#include "CompiledVirtualMachine.hpp"
#include "vm_compiled.hpp"
#include "common.hpp"
namespace randomx {

View File

@ -20,8 +20,11 @@ along with RandomX. If not, see<http://www.gnu.org/licenses/>.
#pragma once
#include <new>
#include "VirtualMachine.hpp"
#include "JitCompilerX86.hpp"
#include <cstdint>
#include "virtual_machine.hpp"
#include "jit_compiler_x86.hpp"
#include "allocator.hpp"
#include "dataset.hpp"
namespace randomx {

View File

@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License
along with RandomX. If not, see<http://www.gnu.org/licenses/>.
*/
#include "CompiledLightVirtualMachine.hpp"
#include "vm_compiled_light.hpp"
#include "common.hpp"
#include <stdexcept>

View File

@ -18,11 +18,9 @@ along with RandomX. If not, see<http://www.gnu.org/licenses/>.
*/
#pragma once
//#define TRACEVM
#include <new>
#include "CompiledVirtualMachine.hpp"
#include "JitCompilerX86.hpp"
#include "intrinPortable.h"
#include "vm_compiled.hpp"
namespace randomx {

View File

@ -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<http://www.gnu.org/licenses/>.
*/
//#define TRACE
//#define FPUCHECK
#define RANDOMX_JUMP
#include "InterpretedVirtualMachine.hpp"
#include "dataset.hpp"
#include <iostream>
#include <iomanip>
#include <stdexcept>
#include <sstream>
#include <cmath>
#include <cfloat>
#include <thread>
#include <climits>
#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<class Allocator, bool softAes>
void InterpretedVm<Allocator, softAes>::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;
}

View File

@ -20,10 +20,11 @@ along with RandomX. If not, see<http://www.gnu.org/licenses/>.
#pragma once
#include <new>
#include "VirtualMachine.hpp"
#include "Program.hpp"
#include "intrinPortable.h"
#include <vector>
#include "common.hpp"
#include "virtual_machine.hpp"
#include "intrin_portable.h"
#include "allocator.hpp"
namespace randomx {

View File

@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License
along with RandomX. If not, see<http://www.gnu.org/licenses/>.
*/
#include "InterpretedLightVirtualMachine.hpp"
#include "vm_interpreted_light.hpp"
#include "dataset.hpp"
namespace randomx {

View File

@ -20,8 +20,7 @@ along with RandomX. If not, see<http://www.gnu.org/licenses/>.
#pragma once
#include <new>
#include "InterpretedVirtualMachine.hpp"
#include "superscalar_program.hpp"
#include "vm_interpreted.hpp"
namespace randomx {

View File

@ -127,60 +127,58 @@
<ClCompile Include="..\src\allocator.cpp" />
<ClCompile Include="..\src\argon2_core.c" />
<ClCompile Include="..\src\argon2_ref.c" />
<ClCompile Include="..\src\AssemblyGeneratorX86.cpp" />
<ClCompile Include="..\src\Blake2Generator.cpp" />
<ClCompile Include="..\src\assembly_generator_x86.cpp" />
<ClCompile Include="..\src\blake2_benerator.cpp" />
<ClCompile Include="..\src\blake2\blake2b.c" />
<ClCompile Include="..\src\CompiledLightVirtualMachine.cpp" />
<ClCompile Include="..\src\CompiledVirtualMachine.cpp" />
<ClCompile Include="..\src\vm_compiled_light.cpp" />
<ClCompile Include="..\src\vm_compiled.cpp" />
<ClCompile Include="..\src\dataset.cpp" />
<ClCompile Include="..\src\hashAes1Rx4.cpp" />
<ClCompile Include="..\src\Instruction.cpp" />
<ClCompile Include="..\src\instructionsPortable.cpp" />
<ClCompile Include="..\src\InterpretedLightVirtualMachine.cpp" />
<ClCompile Include="..\src\InterpretedVirtualMachine.cpp" />
<ClCompile Include="..\src\JitCompilerX86.cpp" />
<ClCompile Include="..\src\aes_hash.cpp" />
<ClCompile Include="..\src\instruction.cpp" />
<ClCompile Include="..\src\instructions_portable.cpp" />
<ClCompile Include="..\src\vm_interpreted_light.cpp" />
<ClCompile Include="..\src\vm_interpreted.cpp" />
<ClCompile Include="..\src\jit_compiler_x86.cpp" />
<ClCompile Include="..\src\randomx.cpp" />
<ClCompile Include="..\src\superscalarGenerator.cpp" />
<ClCompile Include="..\src\superscalar.cpp" />
<ClCompile Include="..\src\main.cpp" />
<ClCompile Include="..\src\reciprocal.c" />
<ClCompile Include="..\src\softAes.cpp" />
<ClCompile Include="..\src\VirtualMachine.cpp" />
<ClCompile Include="..\src\virtualMemory.cpp" />
<ClCompile Include="..\src\soft_aes.cpp" />
<ClCompile Include="..\src\virtual_machine.cpp" />
<ClCompile Include="..\src\virtual_memory.cpp" />
</ItemGroup>
<ItemGroup>
<MASM Include="..\src\JitCompilerX86-static.asm" />
<MASM Include="..\src\squareHash.asm" />
<MASM Include="..\src\jit_compiler_x86_staticc.asm" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\src\allocator.hpp" />
<ClInclude Include="..\src\argon2.h" />
<ClInclude Include="..\src\argon2_core.h" />
<ClInclude Include="..\src\AssemblyGeneratorX86.hpp" />
<ClInclude Include="..\src\Blake2Generator.hpp" />
<ClInclude Include="..\src\assembly_generator_x86.hpp" />
<ClInclude Include="..\src\blake2_generator.hpp" />
<ClInclude Include="..\src\catch.hpp" />
<ClInclude Include="..\src\common.hpp" />
<ClInclude Include="..\src\CompiledLightVirtualMachine.hpp" />
<ClInclude Include="..\src\CompiledVirtualMachine.hpp" />
<ClInclude Include="..\src\vm_compiled_light.hpp" />
<ClInclude Include="..\src\vm_compiled.hpp" />
<ClInclude Include="..\src\configuration.h" />
<ClInclude Include="..\src\dataset.hpp" />
<ClInclude Include="..\src\hashAes1Rx4.hpp" />
<ClInclude Include="..\src\Instruction.hpp" />
<ClInclude Include="..\src\instructionWeights.hpp" />
<ClInclude Include="..\src\InterpretedLightVirtualMachine.hpp" />
<ClInclude Include="..\src\InterpretedVirtualMachine.hpp" />
<ClInclude Include="..\src\intrinPortable.h" />
<ClInclude Include="..\src\JitCompilerX86-static.hpp" />
<ClInclude Include="..\src\JitCompilerX86.hpp" />
<ClInclude Include="..\src\aes_hash.hpp" />
<ClInclude Include="..\src\instruction.hpp" />
<ClInclude Include="..\src\instruction_weights.hpp" />
<ClInclude Include="..\src\vm_interpreted_light.hpp" />
<ClInclude Include="..\src\vm_interpreted.hpp" />
<ClInclude Include="..\src\intrin_portable.h" />
<ClInclude Include="..\src\jit_compiler_x86_static.hpp" />
<ClInclude Include="..\src\jit_compiler_x86.hpp" />
<ClInclude Include="..\src\randomx.h" />
<ClInclude Include="..\src\superscalarGenerator.hpp" />
<ClInclude Include="..\src\Program.hpp" />
<ClInclude Include="..\src\superscalar.hpp" />
<ClInclude Include="..\src\program.hpp" />
<ClInclude Include="..\src\reciprocal.h" />
<ClInclude Include="..\src\softAes.h" />
<ClInclude Include="..\src\squareHash.h" />
<ClInclude Include="..\src\Stopwatch.hpp" />
<ClInclude Include="..\src\soft_aes.h" />
<ClInclude Include="..\src\stopwatch.hpp" />
<ClInclude Include="..\src\superscalar_program.hpp" />
<ClInclude Include="..\src\VirtualMachine.hpp" />
<ClInclude Include="..\src\virtualMemory.hpp" />
<ClInclude Include="..\src\virtual_machine.hpp" />
<ClInclude Include="..\src\virtual_memory.hpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

View File

@ -24,69 +24,66 @@
<ClCompile Include="..\src\reciprocal.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\AssemblyGeneratorX86.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\CompiledLightVirtualMachine.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\CompiledVirtualMachine.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\dataset.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\hashAes1Rx4.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\Instruction.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\instructionsPortable.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\InterpretedVirtualMachine.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\JitCompilerX86.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\softAes.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\VirtualMachine.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\virtualMemory.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\blake2\blake2b.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\Blake2Generator.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\superscalarGenerator.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\randomx.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\allocator.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\InterpretedLightVirtualMachine.cpp">
<ClCompile Include="..\src\assembly_generator_x86.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\blake2_benerator.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\vm_compiled_light.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\vm_compiled.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\aes_hash.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\instruction.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\instructions_portable.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\vm_interpreted_light.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\jit_compiler_x86.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\soft_aes.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\superscalar.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\virtual_machine.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\vm_interpreted.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\virtual_memory.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<MASM Include="..\src\JitCompilerX86-static.asm">
<Filter>Source Files</Filter>
</MASM>
<MASM Include="..\src\squareHash.asm">
<MASM Include="..\src\jit_compiler_x86_staticc.asm">
<Filter>Source Files</Filter>
</MASM>
</ItemGroup>
@ -97,85 +94,82 @@
<ClInclude Include="..\src\argon2_core.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\AssemblyGeneratorX86.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\catch.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\common.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\CompiledLightVirtualMachine.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\CompiledVirtualMachine.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\configuration.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\dataset.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\hashAes1Rx4.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\Instruction.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\instructionWeights.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\InterpretedVirtualMachine.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\intrinPortable.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\JitCompilerX86.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\JitCompilerX86-static.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\Program.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\reciprocal.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\softAes.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\squareHash.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\Stopwatch.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\VirtualMachine.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\virtualMemory.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\Blake2Generator.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\superscalarGenerator.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\randomx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\allocator.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\InterpretedLightVirtualMachine.hpp">
<ClInclude Include="..\src\superscalar_program.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\superscalar_program.hpp">
<ClInclude Include="..\src\assembly_generator_x86.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\blake2_generator.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\aes_hash.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\instruction.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\instruction_weights.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\vm_compiled_light.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\vm_compiled.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\vm_interpreted_light.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\vm_interpreted.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\intrin_portable.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\jit_compiler_x86.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\jit_compiler_x86_static.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\program.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\soft_aes.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\stopwatch.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\virtual_machine.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\virtual_memory.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\superscalar.hpp">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>