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
#define RANDOMX_GEN_ARGS
Definition bytecode_machine.hpp:102
#define OPCODE_CEIL_DECLARE(curr, prev)
Definition bytecode_machine.hpp:67
#define RANDOMX_EXE_ARGS
Definition bytecode_machine.hpp:101
Definition bytecode_machine.hpp:108
static void exe_FDIV_M(RANDOMX_EXE_ARGS)
Definition bytecode_machine.hpp:242
static void exe_IMULH_R(RANDOMX_EXE_ARGS)
Definition bytecode_machine.hpp:169
static void exe_FMUL_R(RANDOMX_EXE_ARGS)
Definition bytecode_machine.hpp:238
static void exe_ISMULH_R(RANDOMX_EXE_ARGS)
Definition bytecode_machine.hpp:177
static void exe_ISUB_M(RANDOMX_EXE_ARGS)
Definition bytecode_machine.hpp:157
static void exe_IMULH_M(RANDOMX_EXE_ARGS)
Definition bytecode_machine.hpp:173
static void exe_FSWAP_R(RANDOMX_EXE_ARGS)
Definition bytecode_machine.hpp:211
static void exe_ISUB_R(RANDOMX_EXE_ARGS)
Definition bytecode_machine.hpp:153
static void exe_FSQRT_R(RANDOMX_EXE_ARGS)
Definition bytecode_machine.hpp:250
static void exe_IMUL_R(RANDOMX_EXE_ARGS)
Definition bytecode_machine.hpp:161
static rx_vec_f128 maskRegisterExponentMantissa(ProgramConfiguration &config, rx_vec_f128 x)
Definition bytecode_machine.hpp:269
static void executeBytecode(InstructionByteCode bytecode[RANDOMX_PROGRAM_SIZE], uint8_t *scratchpad, ProgramConfiguration &config)
Definition bytecode_machine.hpp:126
static void exe_FSCAL_R(RANDOMX_EXE_ARGS)
Definition bytecode_machine.hpp:233
void compileInstruction(RANDOMX_GEN_ARGS)
Definition bytecode_machine.cpp:81
void beginCompilation(NativeRegisterFile ®File)
Definition bytecode_machine.hpp:110
static void exe_FSUB_R(RANDOMX_EXE_ARGS)
Definition bytecode_machine.hpp:224
static const int_reg_t zero
Definition bytecode_machine.hpp:278
static void exe_IADD_M(RANDOMX_EXE_ARGS)
Definition bytecode_machine.hpp:149
static void exe_FADD_M(RANDOMX_EXE_ARGS)
Definition bytecode_machine.hpp:219
static void exe_IMUL_M(RANDOMX_EXE_ARGS)
Definition bytecode_machine.hpp:165
static void exe_IROL_R(RANDOMX_EXE_ARGS)
Definition bytecode_machine.hpp:201
static void exe_ISMULH_M(RANDOMX_EXE_ARGS)
Definition bytecode_machine.hpp:181
static void exe_IROR_R(RANDOMX_EXE_ARGS)
Definition bytecode_machine.hpp:197
NativeRegisterFile * nreg
Definition bytecode_machine.hpp:280
static void exe_ISTORE(RANDOMX_EXE_ARGS)
Definition bytecode_machine.hpp:265
static void exe_IXOR_M(RANDOMX_EXE_ARGS)
Definition bytecode_machine.hpp:193
void compileProgram(Program &program, InstructionByteCode bytecode[RANDOMX_PROGRAM_SIZE], NativeRegisterFile ®File)
Definition bytecode_machine.hpp:117
static void exe_CFROUND(RANDOMX_EXE_ARGS)
Definition bytecode_machine.hpp:261
static void exe_FSUB_M(RANDOMX_EXE_ARGS)
Definition bytecode_machine.hpp:228
static void exe_INEG_R(RANDOMX_EXE_ARGS)
Definition bytecode_machine.hpp:185
static void * getScratchpadAddress(InstructionByteCode &ibc, uint8_t *scratchpad)
Definition bytecode_machine.hpp:282
static void exe_FADD_R(RANDOMX_EXE_ARGS)
Definition bytecode_machine.hpp:215
static void executeInstruction(RANDOMX_EXE_ARGS)
Definition bytecode_machine.cpp:40
static void exe_ISWAP_R(RANDOMX_EXE_ARGS)
Definition bytecode_machine.hpp:205
int registerUsage[RegistersCount]
Definition bytecode_machine.hpp:279
static void exe_IXOR_R(RANDOMX_EXE_ARGS)
Definition bytecode_machine.hpp:189
static void exe_IADD_RS(RANDOMX_EXE_ARGS)
Definition bytecode_machine.hpp:145
static void exe_CBRANCH(RANDOMX_EXE_ARGS)
Definition bytecode_machine.hpp:254
Definition program.hpp:44
#define RANDOMX_PROGRAM_SIZE
Definition configuration.h:56
static FORCE_INLINE uint64_t load64(const void *src)
Definition endian.h:50
static FORCE_INLINE void store64(void *dst, uint64_t w)
Definition endian.h:86
int64_t smulh(int64_t a, int64_t b)
Definition instructions_portable.cpp:125
uint64_t rotl(uint64_t a, unsigned int b)
Definition instructions_portable.cpp:99
uint64_t rotr(uint64_t a, unsigned int b)
Definition instructions_portable.cpp:92
void rx_set_rounding_mode(uint32_t mode)
Definition instructions_portable.cpp:141
uint64_t mulh(uint64_t a, uint64_t b)
Definition instructions_portable.cpp:108
FORCE_INLINE rx_vec_f128 rx_add_vec_f128(rx_vec_f128 a, rx_vec_f128 b)
Definition intrin_portable.h:566
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_xor_vec_f128(rx_vec_f128 a, rx_vec_f128 b)
Definition intrin_portable.h:628
FORCE_INLINE rx_vec_f128 rx_or_vec_f128(rx_vec_f128 a, rx_vec_f128 b)
Definition intrin_portable.h:642
FORCE_INLINE rx_vec_f128 rx_set1_vec_f128(uint64_t x)
Definition intrin_portable.h:621
FORCE_INLINE rx_vec_f128 rx_swap_vec_f128(rx_vec_f128 a)
Definition intrin_portable.h:559
FORCE_INLINE rx_vec_f128 rx_and_vec_f128(rx_vec_f128 a, rx_vec_f128 b)
Definition intrin_portable.h:635
FORCE_INLINE rx_vec_f128 rx_load_vec_f128(const double *pd)
Definition intrin_portable.h:547
FORCE_INLINE rx_vec_f128 rx_sub_vec_f128(rx_vec_f128 a, rx_vec_f128 b)
Definition intrin_portable.h:573
FORCE_INLINE rx_vec_f128 rx_mul_vec_f128(rx_vec_f128 a, rx_vec_f128 b)
Definition intrin_portable.h:580
FORCE_INLINE rx_vec_f128 rx_div_vec_f128(rx_vec_f128 a, rx_vec_f128 b)
Definition intrin_portable.h:587
FORCE_INLINE rx_vec_f128 rx_cvt_packed_int_vec_f128(const void *addr)
Definition intrin_portable.h:709
FORCE_INLINE rx_vec_f128 rx_sqrt_vec_f128(rx_vec_f128 a)
Definition intrin_portable.h:594
constexpr int64_t unsigned64ToSigned2sCompl(uint64_t x)
Definition intrin_portable.h:38
Definition cryptonote_config.h:221
Definition allocator.cpp:35
uint64_t int_reg_t
Definition common.hpp:140
constexpr int RegisterCountFlt
Definition common.hpp:157
constexpr int RegistersCount
Definition common.hpp:156
constexpr uint64_t dynamicMantissaMask
Definition common.hpp:173
void(BytecodeMachine::* InstructionGenBytecode)(RANDOMX_GEN_ARGS)
Definition bytecode_machine.hpp:106
InstructionType
Definition instruction.hpp:42
@ IMUL_M
Definition instruction.hpp:48
@ IROL_R
Definition instruction.hpp:58
@ IMULH_R
Definition instruction.hpp:49
@ NOP
Definition instruction.hpp:72
@ IXOR_R
Definition instruction.hpp:55
@ FADD_M
Definition instruction.hpp:62
@ ISWAP_R
Definition instruction.hpp:59
@ FMUL_R
Definition instruction.hpp:66
@ ISUB_M
Definition instruction.hpp:46
@ FSWAP_R
Definition instruction.hpp:60
@ IMUL_R
Definition instruction.hpp:47
@ IXOR_M
Definition instruction.hpp:56
@ FDIV_M
Definition instruction.hpp:67
@ INEG_R
Definition instruction.hpp:54
@ FSQRT_R
Definition instruction.hpp:68
@ IADD_RS
Definition instruction.hpp:43
@ ISUB_R
Definition instruction.hpp:45
@ CFROUND
Definition instruction.hpp:70
@ FSUB_M
Definition instruction.hpp:64
@ ISTORE
Definition instruction.hpp:71
@ IROR_R
Definition instruction.hpp:57
@ IMULH_M
Definition instruction.hpp:50
@ ISMULH_M
Definition instruction.hpp:52
@ IMUL_RCP
Definition instruction.hpp:53
@ ISMULH_R
Definition instruction.hpp:51
@ FSUB_R
Definition instruction.hpp:63
@ FSCAL_R
Definition instruction.hpp:65
@ IADD_M
Definition instruction.hpp:44
@ FADD_R
Definition instruction.hpp:61
@ CBRANCH
Definition instruction.hpp:69
constexpr int ceil_NULL
Definition bytecode_machine.hpp:68
signed short int16_t
Definition stdint.h:122
unsigned short uint16_t
Definition stdint.h:125
signed __int64 int64_t
Definition stdint.h:135
unsigned int uint32_t
Definition stdint.h:126
unsigned char uint8_t
Definition stdint.h:124
unsigned __int64 uint64_t
Definition stdint.h:136
Definition bytecode_machine.hpp:46
int64_t simm
Definition bytecode_machine.hpp:57
int_reg_t * idst
Definition bytecode_machine.hpp:48
const rx_vec_f128 * fsrc
Definition bytecode_machine.hpp:53
InstructionType type
Definition bytecode_machine.hpp:59
uint64_t imm
Definition bytecode_machine.hpp:56
uint32_t memMask
Definition bytecode_machine.hpp:64
const int_reg_t * isrc
Definition bytecode_machine.hpp:52
int16_t target
Definition bytecode_machine.hpp:61
uint16_t shift
Definition bytecode_machine.hpp:62
rx_vec_f128 * fdst
Definition bytecode_machine.hpp:49
Definition bytecode_machine.hpp:39
rx_vec_f128 f[RegisterCountFlt]
Definition bytecode_machine.hpp:41
rx_vec_f128 e[RegisterCountFlt]
Definition bytecode_machine.hpp:42
rx_vec_f128 a[RegisterCountFlt]
Definition bytecode_machine.hpp:43
int_reg_t r[RegistersCount]
Definition bytecode_machine.hpp:40
Definition program.hpp:39
Definition intrin_portable.h:534