Skip to content

Commit

Permalink
aarch64 JIT: support soft AES
Browse files Browse the repository at this point in the history
  • Loading branch information
SChernykh committed Sep 27, 2023
1 parent fcf9f12 commit a99d803
Show file tree
Hide file tree
Showing 3 changed files with 527 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/jit_compiler_a64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,15 @@ void JitCompilerA64::generateProgram(Program& program, ProgramConfiguration& con
if (flags & RANDOMX_FLAG_V2) {
codePos = ((uint8_t*)randomx_program_aarch64_v2_FE_mix) - ((uint8_t*)randomx_program_aarch64);

// Disable the jump to RandomX v1 FE mix code by writing "movi v28.4s, 0" instruction
emit32(0x4F00041C, code, codePos);
if (flags & RANDOMX_FLAG_HARD_AES) {
// Disable the jump to RandomX v1 FE mix code by writing "movi v28.4s, 0" instruction
emit32(0x4F00041C, code, codePos);
}
else {
// Jump to RandomX v2 FE mix soft AES code by writing "b randomx_program_aarch64_v2_FE_mix_soft_aes" instruction
const uint32_t offset = (uint8_t*)randomx_program_aarch64_v2_FE_mix_soft_aes - (uint8_t*)randomx_program_aarch64_v2_FE_mix;
emit32(ARMV8A::B | (offset / 4), code, codePos);
}
}

#ifdef __GNUC__
Expand Down Expand Up @@ -228,8 +235,15 @@ void JitCompilerA64::generateProgramLight(Program& program, ProgramConfiguration
if (flags & RANDOMX_FLAG_V2) {
codePos = ((uint8_t*)randomx_program_aarch64_v2_FE_mix) - ((uint8_t*)randomx_program_aarch64);

// Disable the jump to RandomX v1 FE mix code by writing "movi v28.4s, 0" instruction
emit32(0x4F00041C, code, codePos);
if (flags & RANDOMX_FLAG_HARD_AES) {
// Disable the jump to RandomX v1 FE mix code by writing "movi v28.4s, 0" instruction
emit32(0x4F00041C, code, codePos);
}
else {
// Jump to RandomX v2 FE mix soft AES code by writing "b randomx_program_aarch64_v2_FE_mix_soft_aes" instruction
const uint32_t offset = (uint8_t*)randomx_program_aarch64_v2_FE_mix_soft_aes - (uint8_t*)randomx_program_aarch64_v2_FE_mix;
emit32(ARMV8A::B | (offset / 4), code, codePos);
}
}

// Apply dataset offset
Expand Down
Loading

0 comments on commit a99d803

Please sign in to comment.