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

Ben Shi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 23 06:09:12 PST 2022


benshi001 accepted this revision.
benshi001 added inline comments.
This revision is now accepted and ready to land.


================
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 {
----------------
aykevl wrote:
> 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?
I agree with you. Actually I am planing and investigating implementation of avttiny.


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