MCPcopy Create free account
hub / github.com/LUX-Core/lux / generateProgram

Method generateProgram

src/crypto/RandomX/jit_compiler_a64.cpp:120–169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

118}
119
120void JitCompilerA64::generateProgram(Program& program, ProgramConfiguration& config)
121{
122 uint32_t codePos = MainLoopBegin + 4;
123
124 // and w16, w10, ScratchpadL3Mask64
125 emit32(0x121A0000 | 16 | (10 << 5) | ((Log2(RANDOMX_SCRATCHPAD_L3) - 7) << 10), code, codePos);
126
127 // and w17, w18, ScratchpadL3Mask64
128 emit32(0x121A0000 | 17 | (18 << 5) | ((Log2(RANDOMX_SCRATCHPAD_L3) - 7) << 10), code, codePos);
129
130 codePos = PrologueSize;
131 literalPos = ImulRcpLiteralsEnd;
132 num32bitLiterals = 0;
133
134 for (uint32_t i = 0; i < RegistersCount; ++i)
135 reg_changed_offset[i] = codePos;
136
137 for (uint32_t i = 0; i < program.getSize(); ++i)
138 {
139 Instruction& instr = program(i);
140 instr.src %= RegistersCount;
141 instr.dst %= RegistersCount;
142 (this->*engine[instr.opcode])(instr, codePos);
143 }
144
145 // Update spMix2
146 // eor w18, config.readReg2, config.readReg3
147 emit32(ARMV8A::EOR32 | 18 | (IntRegMap[config.readReg2] << 5) | (IntRegMap[config.readReg3] << 16), code, codePos);
148
149 // Jump back to the main loop
150 const uint32_t offset = (((uint8_t*)randomx_program_aarch64_vm_instructions_end) - ((uint8_t*)randomx_program_aarch64)) - codePos;
151 emit32(ARMV8A::B | (offset / 4), code, codePos);
152
153 // and w18, w18, CacheLineAlignMask
154 codePos = (((uint8_t*)randomx_program_aarch64_cacheline_align_mask1) - ((uint8_t*)randomx_program_aarch64));
155 emit32(0x121A0000 | 18 | (18 << 5) | ((Log2(RANDOMX_DATASET_BASE_SIZE) - 7) << 10), code, codePos);
156
157 // and w10, w10, CacheLineAlignMask
158 codePos = (((uint8_t*)randomx_program_aarch64_cacheline_align_mask2) - ((uint8_t*)randomx_program_aarch64));
159 emit32(0x121A0000 | 10 | (10 << 5) | ((Log2(RANDOMX_DATASET_BASE_SIZE) - 7) << 10), code, codePos);
160
161 // Update spMix1
162 // eor x10, config.readReg0, config.readReg1
163 codePos = ((uint8_t*)randomx_program_aarch64_update_spMix1) - ((uint8_t*)randomx_program_aarch64);
164 emit32(ARMV8A::EOR | 10 | (IntRegMap[config.readReg0] << 5) | (IntRegMap[config.readReg1] << 16), code, codePos);
165
166#ifdef __GNUC__
167 __builtin___clear_cache(reinterpret_cast<char*>(code + MainLoopBegin), reinterpret_cast<char*>(code + codePos));
168#endif
169}
170
171void JitCompilerA64::generateProgramLight(Program& program, ProgramConfiguration& config, uint32_t datasetOffset)
172{

Callers

nothing calls this directly

Calls 2

Log2Function · 0.85
getSizeMethod · 0.45

Tested by

no test coverage detected