[PATCH] D116493: [AVR] Generate ELPM for loading byte/word from extended program memory

Ayke via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 3 12:00:50 PST 2022


aykevl added a comment.

For my context, I believe this is for devices that have a larger flash memory, such as the ATmega2560?

I haven't looked too deeply at the code yet.



================
Comment at: llvm/lib/Target/AVR/AVRExpandPseudoInsts.cpp:828
+    const AVRSubtarget &STI = MBB.getParent()->getSubtarget<AVRSubtarget>();
+    Register TmpReg = scavengeGPR8(MI);
+    int Bank = MI.getOperand(2).getImm();
----------------
There is actually a much more elegant way to do this: by giving ELPMRdZ (and similar) instructions an extra LD8 input and output register. This makes sure the register allocator allocates a spare register for this instruction. The `scavengeGPR8` method is really just a hack to find an unused register and it can fail if no register is available. In addition, by telling the register allocator you need an LD8 register, you don't need the if/else below.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D116493/new/

https://reviews.llvm.org/D116493



More information about the llvm-commits mailing list