67 #define OPCODE_CEIL_DECLARE(curr, prev) constexpr int ceil_ ## curr = ceil_ ## prev + RANDOMX_FREQ_ ## curr; 99 #undef OPCODE_CEIL_DECLARE 101 #define RANDOMX_EXE_ARGS InstructionByteCode& ibc, int& pc, uint8_t* scratchpad, ProgramConfiguration& config 102 #define RANDOMX_GEN_ARGS Instruction& instr, int i, InstructionByteCode& ibc 104 class BytecodeMachine;
120 auto& instr = program(
i);
121 auto& ibc = bytecode[
i];
128 auto& ibc = bytecode[pc];
134 #ifdef RANDOMX_GEN_TABLE 136 auto generator = genTable[instr.opcode];
137 (this->*generator)(instr,
i, ibc);
146 *ibc.idst += (*ibc.isrc << ibc.shift) + ibc.imm;
154 *ibc.idst -= *ibc.isrc;
162 *ibc.idst *= *ibc.isrc;
170 *ibc.idst =
mulh(*ibc.idst, *ibc.isrc);
186 *ibc.idst = ~(*ibc.idst) + 1;
190 *ibc.idst ^= *ibc.isrc;
198 *ibc.idst =
rotr(*ibc.idst, *ibc.isrc & 63);
202 *ibc.idst =
rotl(*ibc.idst, *ibc.isrc & 63);
255 *ibc.idst += ibc.imm;
256 if ((*ibc.idst & ibc.memMask) == 0) {
266 store64(scratchpad + ((*ibc.idst + ibc.imm) & ibc.memMask), *ibc.isrc);
284 return scratchpad + addr;
287 #ifdef RANDOMX_GEN_TABLE InstructionType type
Definition: bytecode_machine.hpp:59
static void exe_IADD_M(RANDOMX_EXE_ARGS)
Definition: bytecode_machine.hpp:149
static void exe_IXOR_R(RANDOMX_EXE_ARGS)
Definition: bytecode_machine.hpp:189
static void exe_IROR_R(RANDOMX_EXE_ARGS)
Definition: bytecode_machine.hpp:197
Definition: allocator.cpp:35
static void exe_IMUL_R(RANDOMX_EXE_ARGS)
Definition: bytecode_machine.hpp:161
uint32_t memMask
Definition: bytecode_machine.hpp:64
int16_t target
Definition: bytecode_machine.hpp:61
int i
Definition: pymoduletest.py:23
static void exe_FMUL_R(RANDOMX_EXE_ARGS)
Definition: bytecode_machine.hpp:238
void(BytecodeMachine::* InstructionGenBytecode)(RANDOMX_GEN_ARGS)
Definition: bytecode_machine.hpp:106
constexpr uint64_t dynamicMantissaMask
Definition: common.hpp:173
Definition: intrin_portable.h:534
static void exe_FSQRT_R(RANDOMX_EXE_ARGS)
Definition: bytecode_machine.hpp:250
#define RANDOMX_EXE_ARGS
Definition: bytecode_machine.hpp:101
constexpr int ceil_NULL
Definition: bytecode_machine.hpp:68
unsigned short uint16_t
Definition: stdint.h:125
Definition: cryptonote_config.h:220
FORCE_INLINE rx_vec_f128 rx_set_vec_f128(uint64_t x1, uint64_t x0)
Definition: intrin_portable.h:614
FORCE_INLINE rx_vec_f128 rx_and_vec_f128(rx_vec_f128 a, rx_vec_f128 b)
Definition: intrin_portable.h:635
static void exe_FSUB_M(RANDOMX_EXE_ARGS)
Definition: bytecode_machine.hpp:228
unsigned char uint8_t
Definition: stdint.h:124
uint64_t imm
Definition: bytecode_machine.hpp:56
uint64_t rotl(uint64_t a, unsigned int b)
Definition: instructions_portable.cpp:99
int64_t smulh(int64_t a, int64_t b)
Definition: instructions_portable.cpp:125
static void exe_ISTORE(RANDOMX_EXE_ARGS)
Definition: bytecode_machine.hpp:265
static void exe_IMUL_M(RANDOMX_EXE_ARGS)
Definition: bytecode_machine.hpp:165
FORCE_INLINE rx_vec_f128 rx_or_vec_f128(rx_vec_f128 a, rx_vec_f128 b)
Definition: intrin_portable.h:642
static FORCE_INLINE uint64_t load64(const void *src)
Definition: endian.h:50
NativeRegisterFile * nreg
Definition: bytecode_machine.hpp:280
constexpr int64_t unsigned64ToSigned2sCompl(uint64_t x)
Definition: intrin_portable.h:38
const int_reg_t * isrc
Definition: bytecode_machine.hpp:52
static void exe_ISUB_M(RANDOMX_EXE_ARGS)
Definition: bytecode_machine.hpp:157
static void exe_FSWAP_R(RANDOMX_EXE_ARGS)
Definition: bytecode_machine.hpp:211
Definition: program.hpp:39
FORCE_INLINE rx_vec_f128 rx_add_vec_f128(rx_vec_f128 a, rx_vec_f128 b)
Definition: intrin_portable.h:566
rx_vec_f128 a[RegisterCountFlt]
Definition: bytecode_machine.hpp:43
static void exe_INEG_R(RANDOMX_EXE_ARGS)
Definition: bytecode_machine.hpp:185
static void exe_IMULH_M(RANDOMX_EXE_ARGS)
Definition: bytecode_machine.hpp:173
static void exe_FADD_M(RANDOMX_EXE_ARGS)
Definition: bytecode_machine.hpp:219
unsigned int uint32_t
Definition: stdint.h:126
static void executeBytecode(InstructionByteCode bytecode[RANDOMX_PROGRAM_SIZE], uint8_t *scratchpad, ProgramConfiguration &config)
Definition: bytecode_machine.hpp:126
signed short int16_t
Definition: stdint.h:122
FORCE_INLINE rx_vec_f128 rx_set1_vec_f128(uint64_t x)
Definition: intrin_portable.h:621
static void executeInstruction(RANDOMX_EXE_ARGS)
Definition: bytecode_machine.cpp:40
static void exe_ISMULH_R(RANDOMX_EXE_ARGS)
Definition: bytecode_machine.hpp:177
int_reg_t * idst
Definition: bytecode_machine.hpp:48
Definition: program.hpp:44
static void exe_IADD_RS(RANDOMX_EXE_ARGS)
Definition: bytecode_machine.hpp:145
#define RANDOMX_PROGRAM_SIZE
Definition: configuration.h:56
rx_vec_f128 * fdst
Definition: bytecode_machine.hpp:49
static void exe_FADD_R(RANDOMX_EXE_ARGS)
Definition: bytecode_machine.hpp:215
unsigned __int64 uint64_t
Definition: stdint.h:136
constexpr int RegisterCountFlt
Definition: common.hpp:157
rx_vec_f128 e[RegisterCountFlt]
Definition: bytecode_machine.hpp:42
Definition: bytecode_machine.hpp:108
static void exe_CFROUND(RANDOMX_EXE_ARGS)
Definition: bytecode_machine.hpp:261
FORCE_INLINE rx_vec_f128 rx_xor_vec_f128(rx_vec_f128 a, rx_vec_f128 b)
Definition: intrin_portable.h:628
FORCE_INLINE rx_vec_f128 rx_swap_vec_f128(rx_vec_f128 a)
Definition: intrin_portable.h:559
static void exe_ISMULH_M(RANDOMX_EXE_ARGS)
Definition: bytecode_machine.hpp:181
FORCE_INLINE rx_vec_f128 rx_mul_vec_f128(rx_vec_f128 a, rx_vec_f128 b)
Definition: intrin_portable.h:580
#define RANDOMX_GEN_ARGS
Definition: bytecode_machine.hpp:102
uint64_t int_reg_t
Definition: common.hpp:140
static void exe_FSCAL_R(RANDOMX_EXE_ARGS)
Definition: bytecode_machine.hpp:233
static void exe_FDIV_M(RANDOMX_EXE_ARGS)
Definition: bytecode_machine.hpp:242
FORCE_INLINE rx_vec_f128 rx_div_vec_f128(rx_vec_f128 a, rx_vec_f128 b)
Definition: intrin_portable.h:587
const rx_vec_f128 * fsrc
Definition: bytecode_machine.hpp:53
InstructionType
Definition: instruction.hpp:42
FORCE_INLINE rx_vec_f128 rx_load_vec_f128(const double *pd)
Definition: intrin_portable.h:547
int_reg_t r[RegistersCount]
Definition: bytecode_machine.hpp:40
static void exe_IXOR_M(RANDOMX_EXE_ARGS)
Definition: bytecode_machine.hpp:193
static void exe_IMULH_R(RANDOMX_EXE_ARGS)
Definition: bytecode_machine.hpp:169
uint64_t mulh(uint64_t a, uint64_t b)
Definition: instructions_portable.cpp:108
constexpr int RegistersCount
Definition: common.hpp:156
Definition: bytecode_machine.hpp:46
signed __int64 int64_t
Definition: stdint.h:135
void beginCompilation(NativeRegisterFile ®File)
Definition: bytecode_machine.hpp:110
int registerUsage[RegistersCount]
Definition: bytecode_machine.hpp:279
OPCODE_CEIL_DECLARE(IADD_RS, NULL)
void rx_set_rounding_mode(uint32_t mode)
Definition: instructions_portable.cpp:141
static FORCE_INLINE void store64(void *dst, uint64_t w)
Definition: endian.h:86
uint64_t rotr(uint64_t a, unsigned int b)
Definition: instructions_portable.cpp:92
static void exe_FSUB_R(RANDOMX_EXE_ARGS)
Definition: bytecode_machine.hpp:224
int64_t simm
Definition: bytecode_machine.hpp:57
static void exe_IROL_R(RANDOMX_EXE_ARGS)
Definition: bytecode_machine.hpp:201
static void exe_ISWAP_R(RANDOMX_EXE_ARGS)
Definition: bytecode_machine.hpp:205
FORCE_INLINE rx_vec_f128 rx_sqrt_vec_f128(rx_vec_f128 a)
Definition: intrin_portable.h:594
uint16_t shift
Definition: bytecode_machine.hpp:62
Definition: bytecode_machine.hpp:39
rx_vec_f128 f[RegisterCountFlt]
Definition: bytecode_machine.hpp:41
static rx_vec_f128 maskRegisterExponentMantissa(ProgramConfiguration &config, rx_vec_f128 x)
Definition: bytecode_machine.hpp:269
void compileInstruction(RANDOMX_GEN_ARGS)
Definition: bytecode_machine.cpp:81
void compileProgram(Program &program, InstructionByteCode bytecode[RANDOMX_PROGRAM_SIZE], NativeRegisterFile ®File)
Definition: bytecode_machine.hpp:117
static void exe_CBRANCH(RANDOMX_EXE_ARGS)
Definition: bytecode_machine.hpp:254
FORCE_INLINE rx_vec_f128 rx_sub_vec_f128(rx_vec_f128 a, rx_vec_f128 b)
Definition: intrin_portable.h:573
static const int_reg_t zero
Definition: bytecode_machine.hpp:278
FORCE_INLINE rx_vec_f128 rx_cvt_packed_int_vec_f128(const void *addr)
Definition: intrin_portable.h:709
static void exe_ISUB_R(RANDOMX_EXE_ARGS)
Definition: bytecode_machine.hpp:153
static void * getScratchpadAddress(InstructionByteCode &ibc, uint8_t *scratchpad)
Definition: bytecode_machine.hpp:282