[PATCH] D117425: [AVR] Make use of the constant value 0 in R1

Ayke via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jan 22 10:40:06 PST 2022


aykevl added inline comments.


================
Comment at: llvm/lib/Target/AVR/AVRISelLowering.cpp:1699
+// Insert a read from R1, which almost always contains the value 0.
+MachineBasicBlock *
+AVRTargetLowering::insertCopyR1(MachineInstr &MI, MachineBasicBlock *BB) const {
----------------
benshi001 wrote:
> benshi001 wrote:
> > I think we need to check the device family, AFAIK, r17 is used as zero_reg on avr-tiny family.
> do we need to make a helper function `int getRegZero(void)` in `AVRSubtarget.h`, just like I have done as `getIORegRAMPZ(void)` ? The new helper function will return r17 for avr-tiny devices.
You are correct. However, there are many other places in the compiler that assume `R1` is the zero register (and `R0` is the scratch register). For example, here:
https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/AVR/AVRRegisterInfo.cpp#L53-L57
I agree we should use `R16` and `R17` for avr-tiny, but I would prefer to do that all in once patch. I can do that after this patch and D117725 have landed? What do you think?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117425



More information about the llvm-commits mailing list