-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
Looking at the AArch64 assembly, it's full of mov sequences to load constants, for example:
0x0000ffff7c9c21d4: mov x0, #0x89c0
0x0000ffff7c9c21d8: movk x0, #0x1b80, lsl #16
0x0000ffff7c9c21dc: movk x0, #0xffff, lsl #32
Ideally these constants should be placed in a constants table and loaded with a single ldr instruction (plus the initial adrp instruction to load the table base).
Code patching should be updated to patch the table contents.
SPARC already has this - see LoadConstantFromTable in SPARCMoveFactory.
AArch64 has a commented out reference a LoadConstantFromTable, but no other code, so looks like there may have once been a plan to add this (... or it was just copied from SPARC).
Anything using const2reg should be patched this way. As a first pass maybe just do constants not marked as needsImmAnnotation and non zero (as zero constants are usually patched up later too - might be useful to make this more obvious in the code). However, that's a very reduced subset, so may show no obvious gains.
Small constants can still use a mov.
Need to be careful to make sure the loads don't result in tlb and cache misses.