diff --git a/makefile b/makefile
index c3694f3..7cd9a9d 100644
--- a/makefile
+++ b/makefile
@@ -12,13 +12,13 @@ OBJDIR=obj
LDFLAGS=-lpthread
RXA=$(BINDIR)/randomx.a
BINARIES=$(RXA) $(BINDIR)/benchmark $(BINDIR)/code-generator
-RXOBJS=$(addprefix $(OBJDIR)/,aes_hash.o argon2_ref.o dataset.o jit_compiler_x86.o soft_aes.o virtual_memory.o vm_interpreted.o allocator.o assembly_generator_x86.o instruction.o randomx.o superscalar.o vm_compiled.o vm_interpreted_light.o argon2_core.o blake2_generator.o instructions_portable.o reciprocal.o virtual_machine.o vm_compiled_light.o blake2b.o)
+RXOBJS=$(addprefix $(OBJDIR)/,aes_hash.o argon2_ref.o dataset.o soft_aes.o virtual_memory.o vm_interpreted.o allocator.o assembly_generator_x86.o instruction.o randomx.o superscalar.o vm_compiled.o vm_interpreted_light.o argon2_core.o blake2_generator.o instructions_portable.o reciprocal.o virtual_machine.o vm_compiled_light.o blake2b.o)
ifeq ($(PLATFORM),amd64)
- RXOBJS += $(OBJDIR)/jit_compiler_x86_static.o
+ RXOBJS += $(addprefix $(OBJDIR)/,jit_compiler_x86_static.o jit_compiler_x86.o)
CXXFLAGS += -maes
endif
ifeq ($(PLATFORM),x86_64)
- RXOBJS += $(OBJDIR)/jit_compiler_x86_static.o
+ RXOBJS += $(addprefix $(OBJDIR)/,jit_compiler_x86_static.o jit_compiler_x86.o)
CXXFLAGS += -maes
endif
diff --git a/src/common.hpp b/src/common.hpp
index 56023ce..9753fe9 100644
--- a/src/common.hpp
+++ b/src/common.hpp
@@ -83,6 +83,17 @@ namespace randomx {
#endif
#endif
+#if defined(_M_X64) || defined(__x86_64__)
+ class JitCompilerX86;
+ using JitCompiler = JitCompilerX86;
+#elif defined(__aarch64__)
+ class JitCompilerA64;
+ using JitCompiler = JitCompilerA64;
+#else
+ class JitCompilerFallback;
+ using JitCompiler = JitCompilerFallback;
+#endif
+
using addr_t = uint32_t;
using int_reg_t = uint64_t;
diff --git a/src/dataset.cpp b/src/dataset.cpp
index 789aee3..819e855 100644
--- a/src/dataset.cpp
+++ b/src/dataset.cpp
@@ -39,7 +39,7 @@ along with RandomX. If not, see.
#include "blake2/endian.h"
#include "argon2.h"
#include "argon2_core.h"
-#include "jit_compiler_x86.hpp"
+#include "jit_compiler.hpp"
#include "intrin_portable.h"
static_assert(RANDOMX_ARGON_MEMORY % (RANDOMX_ARGON_LANES * ARGON2_SYNC_POINTS) == 0, "RANDOMX_ARGON_MEMORY - invalid value");
diff --git a/src/dataset.hpp b/src/dataset.hpp
index 57c1650..20d939a 100644
--- a/src/dataset.hpp
+++ b/src/dataset.hpp
@@ -32,15 +32,11 @@ struct randomx_dataset {
randomx::DatasetDeallocFunc* dealloc;
};
-namespace randomx {
- class JitCompilerX86;
-}
-
/* Global scope for C binding */
struct randomx_cache {
uint8_t* memory = nullptr;
randomx::CacheDeallocFunc* dealloc;
- randomx::JitCompilerX86* jit;
+ randomx::JitCompiler* jit;
randomx::CacheInitializeFunc* initialize;
randomx::DatasetInitFunc* datasetInit;
randomx::SuperscalarProgram programs[RANDOMX_CACHE_ACCESSES];
diff --git a/src/jit_compiler.hpp b/src/jit_compiler.hpp
new file mode 100644
index 0000000..72063c8
--- /dev/null
+++ b/src/jit_compiler.hpp
@@ -0,0 +1,28 @@
+/*
+Copyright (c) 2019 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.
+*/
+
+#pragma once
+
+#if defined(_M_X64) || defined(__x86_64__)
+#include "jit_compiler_x86.hpp"
+#elif defined(__aarch64__)
+#include "jit_compiler_a64.hpp"
+#else
+#include "jit_compiler_fallback.hpp"
+#endif
diff --git a/src/jit_compiler_a64.hpp b/src/jit_compiler_a64.hpp
new file mode 100644
index 0000000..85154da
--- /dev/null
+++ b/src/jit_compiler_a64.hpp
@@ -0,0 +1,64 @@
+/*
+Copyright (c) 2019 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.
+*/
+
+#pragma once
+
+#include
+#include
+#include
+#include "common.hpp"
+
+namespace randomx {
+
+ class Program;
+ class ProgramConfiguration;
+ class SuperscalarProgram;
+
+ class JitCompilerA64 {
+ public:
+ JitCompilerA64() {
+ throw std::runtime_error("ARM64 JIT compiler is not implemented yet.");
+ }
+ void generateProgram(Program&, ProgramConfiguration&) {
+
+ }
+ void generateProgramLight(Program&, ProgramConfiguration&, uint32_t) {
+
+ }
+ template
+ void generateSuperscalarHash(SuperscalarProgram(&programs)[N], std::vector &) {
+
+ }
+ void generateDatasetInitCode() {
+
+ }
+ ProgramFunc* getProgramFunc() {
+ return nullptr;
+ }
+ DatasetInitFunc* getDatasetInitFunc() {
+ return nullptr;
+ }
+ uint8_t* getCode() {
+ return nullptr;
+ }
+ size_t getCodeSize() {
+ return 0;
+ }
+ };
+}
\ No newline at end of file
diff --git a/src/jit_compiler_fallback.hpp b/src/jit_compiler_fallback.hpp
new file mode 100644
index 0000000..be4d2f1
--- /dev/null
+++ b/src/jit_compiler_fallback.hpp
@@ -0,0 +1,64 @@
+/*
+Copyright (c) 2019 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.
+*/
+
+#pragma once
+
+#include
+#include
+#include
+#include "common.hpp"
+
+namespace randomx {
+
+ class Program;
+ class ProgramConfiguration;
+ class SuperscalarProgram;
+
+ class JitCompilerFallback {
+ public:
+ JitCompilerFallback() {
+ throw std::runtime_error("JIT compilation is not supported on this platform");
+ }
+ void generateProgram(Program&, ProgramConfiguration&) {
+
+ }
+ void generateProgramLight(Program&, ProgramConfiguration&, uint32_t) {
+
+ }
+ template
+ void generateSuperscalarHash(SuperscalarProgram(&programs)[N], std::vector &) {
+
+ }
+ void generateDatasetInitCode() {
+
+ }
+ ProgramFunc* getProgramFunc() {
+ return nullptr;
+ }
+ DatasetInitFunc* getDatasetInitFunc() {
+ return nullptr;
+ }
+ uint8_t* getCode() {
+ return nullptr;
+ }
+ size_t getCodeSize() {
+ return 0;
+ }
+ };
+}
\ No newline at end of file
diff --git a/src/jit_compiler_x86.cpp b/src/jit_compiler_x86.cpp
index 9a1c412..206dc9f 100644
--- a/src/jit_compiler_x86.cpp
+++ b/src/jit_compiler_x86.cpp
@@ -18,48 +18,9 @@ along with RandomX. If not, see.
*/
#include
-#include "jit_compiler_x86.hpp"
-
-#if !defined(_M_X64) && !defined(__x86_64__)
-namespace randomx {
-
- JitCompilerX86::JitCompilerX86() {
- throw std::runtime_error("JIT compiler only supports x86-64 CPUs");
- }
-
- JitCompilerX86::~JitCompilerX86() {
-
- }
-
- void JitCompilerX86::generateProgram(Program& p, ProgramConfiguration& pcfg) {
-
- }
-
- void JitCompilerX86::generateProgramLight(Program& p, ProgramConfiguration& pcfg, uint32_t datasetOffset) {
-
- }
-
- template
- void JitCompilerX86::generateSuperscalarHash(SuperscalarProgram(&programs)[N], std::vector &reciprocalCache) {
-
- }
-
- template
- void JitCompilerX86::generateSuperscalarHash(SuperscalarProgram(&programs)[RANDOMX_CACHE_ACCESSES], std::vector &reciprocalCache);
-
- void JitCompilerX86::generateDatasetInitCode() {
-
- }
-
- size_t JitCompilerX86::getCodeSize() {
- return 0;
- }
-
-}
-#else
-
#include
#include
+#include "jit_compiler_x86.hpp"
#include "jit_compiler_x86_static.hpp"
#include "superscalar.hpp"
#include "program.hpp"
@@ -838,4 +799,3 @@ namespace randomx {
};
}
-#endif
diff --git a/src/randomx.cpp b/src/randomx.cpp
index 7178115..3c53cb9 100644
--- a/src/randomx.cpp
+++ b/src/randomx.cpp
@@ -42,7 +42,7 @@ extern "C" {
case RANDOMX_FLAG_JIT:
cache->dealloc = &randomx::deallocCache;
- cache->jit = new randomx::JitCompilerX86();
+ cache->jit = new randomx::JitCompiler();
cache->initialize = &randomx::initCacheCompile;
cache->datasetInit = cache->jit->getDatasetInitFunc();
cache->memory = (uint8_t*)randomx::DefaultAllocator::allocMemory(randomx::CacheSize);
@@ -58,7 +58,7 @@ extern "C" {
case RANDOMX_FLAG_JIT | RANDOMX_FLAG_LARGE_PAGES:
cache->dealloc = &randomx::deallocCache;
- cache->jit = new randomx::JitCompilerX86();
+ cache->jit = new randomx::JitCompiler();
cache->initialize = &randomx::initCacheCompile;
cache->datasetInit = cache->jit->getDatasetInitFunc();
cache->memory = (uint8_t*)randomx::LargePageAllocator::allocMemory(randomx::CacheSize);
diff --git a/src/vm_compiled.hpp b/src/vm_compiled.hpp
index e780d60..aca2028 100644
--- a/src/vm_compiled.hpp
+++ b/src/vm_compiled.hpp
@@ -22,7 +22,7 @@ along with RandomX. If not, see.
#include
#include
#include "virtual_machine.hpp"
-#include "jit_compiler_x86.hpp"
+#include "jit_compiler.hpp"
#include "allocator.hpp"
#include "dataset.hpp"
@@ -53,7 +53,7 @@ namespace randomx {
protected:
void execute();
- JitCompilerX86 compiler;
+ JitCompiler compiler;
};
using CompiledVmDefault = CompiledVm, true>;
diff --git a/vcxproj/randomx.vcxproj b/vcxproj/randomx.vcxproj
index a5de676..b3e10f9 100644
--- a/vcxproj/randomx.vcxproj
+++ b/vcxproj/randomx.vcxproj
@@ -160,6 +160,9 @@ SET ERRORLEVEL = 0
+
+
+
diff --git a/vcxproj/randomx.vcxproj.filters b/vcxproj/randomx.vcxproj.filters
index 311955b..f4c53fe 100644
--- a/vcxproj/randomx.vcxproj.filters
+++ b/vcxproj/randomx.vcxproj.filters
@@ -158,6 +158,15 @@
Header Files
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+