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

Method generateProgramLight

src/crypto/RandomX/jit_compiler_a64.cpp:171–226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

169}
170
171void JitCompilerA64::generateProgramLight(Program& program, ProgramConfiguration& config, uint32_t datasetOffset)
172{
173 uint32_t codePos = MainLoopBegin + 4;
174
175 // and w16, w10, ScratchpadL3Mask64
176 emit32(0x121A0000 | 16 | (10 << 5) | ((Log2(RANDOMX_SCRATCHPAD_L3) - 7) << 10), code, codePos);
177
178 // and w17, w18, ScratchpadL3Mask64
179 emit32(0x121A0000 | 17 | (18 << 5) | ((Log2(RANDOMX_SCRATCHPAD_L3) - 7) << 10), code, codePos);
180
181 codePos = PrologueSize;
182 literalPos = ImulRcpLiteralsEnd;
183 num32bitLiterals = 0;
184
185 for (uint32_t i = 0; i < RegistersCount; ++i)
186 reg_changed_offset[i] = codePos;
187
188 for (uint32_t i = 0; i < program.getSize(); ++i)
189 {
190 Instruction& instr = program(i);
191 instr.src %= RegistersCount;
192 instr.dst %= RegistersCount;
193 (this->*engine[instr.opcode])(instr, codePos);
194 }
195
196 // Update spMix2
197 // eor w18, config.readReg2, config.readReg3
198 emit32(ARMV8A::EOR32 | 18 | (IntRegMap[config.readReg2] << 5) | (IntRegMap[config.readReg3] << 16), code, codePos);
199
200 // Jump back to the main loop
201 const uint32_t offset = (((uint8_t*)randomx_program_aarch64_vm_instructions_end_light) - ((uint8_t*)randomx_program_aarch64)) - codePos;
202 emit32(ARMV8A::B | (offset / 4), code, codePos);
203
204 // and w2, w9, CacheLineAlignMask
205 codePos = (((uint8_t*)randomx_program_aarch64_light_cacheline_align_mask) - ((uint8_t*)randomx_program_aarch64));
206 emit32(0x121A0000 | 2 | (9 << 5) | ((Log2(RANDOMX_DATASET_BASE_SIZE) - 7) << 10), code, codePos);
207
208 // Update spMix1
209 // eor x10, config.readReg0, config.readReg1
210 codePos = ((uint8_t*)randomx_program_aarch64_update_spMix1) - ((uint8_t*)randomx_program_aarch64);
211 emit32(ARMV8A::EOR | 10 | (IntRegMap[config.readReg0] << 5) | (IntRegMap[config.readReg1] << 16), code, codePos);
212
213 // Apply dataset offset
214 codePos = ((uint8_t*)randomx_program_aarch64_light_dataset_offset) - ((uint8_t*)randomx_program_aarch64);
215
216 datasetOffset /= CacheLineSize;
217 const uint32_t imm_lo = datasetOffset & ((1 << 12) - 1);
218 const uint32_t imm_hi = datasetOffset >> 12;
219
220 emit32(ARMV8A::ADD_IMM_LO | 2 | (2 << 5) | (imm_lo << 10), code, codePos);
221 emit32(ARMV8A::ADD_IMM_HI | 2 | (2 << 5) | (imm_hi << 10), code, codePos);
222
223#ifdef __GNUC__
224 __builtin___clear_cache(reinterpret_cast<char*>(code + MainLoopBegin), reinterpret_cast<char*>(code + codePos));
225#endif
226}
227
228template<size_t N>

Callers 1

runMethod · 0.45

Calls 2

Log2Function · 0.85
getSizeMethod · 0.45

Tested by

no test coverage detected