[all-commits] [llvm/llvm-project] d1d300: [AVR] Do not emit instructions invalid for attiny10

Ayke via All-commits all-commits at lists.llvm.org
Thu Dec 22 08:05:21 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d1d3005c9fe6a1ded17d4cad373cae85c743e7f3
      https://github.com/llvm/llvm-project/commit/d1d3005c9fe6a1ded17d4cad373cae85c743e7f3
  Author: Ayke van Laethem <aykevanlaethem at gmail.com>
  Date:   2022-12-22 (Thu, 22 Dec 2022)

  Changed paths:
    M llvm/lib/Target/AVR/AVRExpandPseudoInsts.cpp
    M llvm/lib/Target/AVR/AVRFrameLowering.cpp
    M llvm/lib/Target/AVR/AVRInstrInfo.td
    M llvm/lib/Target/AVR/AVRRegisterInfo.cpp
    M llvm/test/CodeGen/AVR/calling-conv/c/tiny.ll
    M llvm/test/CodeGen/AVR/directmem.ll
    M llvm/test/CodeGen/AVR/pseudo/LDDWRdPtrQ.mir
    M llvm/test/CodeGen/AVR/pseudo/LDWRdPtr.mir
    M llvm/test/CodeGen/AVR/pseudo/STDWPtrQRr.mir
    M llvm/test/CodeGen/AVR/pseudo/STWPtrRr.mir
    M llvm/test/CodeGen/AVR/return.ll

  Log Message:
  -----------
  [AVR] Do not emit instructions invalid for attiny10

The attiny4/attiny5/attiny9/attiny10 have a slightly modified
instruction set that drops a number of useful instructions. This patch
makes sure to not emit them on these "reduced tiny" cores.

The affected instructions are:

  * lds and sts (load/store directly from data)
  * ldd and std (load/store with displacement)
  * adiw and sbiw (add/sub register pairs)
  * various other instructions that were emitted without checking
    whether the chip actually supports them (movw, adiw, etc)

There is a variant on lds and sts on these chips, but it can only
address a limited portion of the address space and is mainly useful to
load/store I/O registers (as an extension to the in and out
instructions). I have not implemented it here, implementing it can be
done in a separate patch.

This patch is not optimal. I'm sure it can be improved a lot. For
example, we could teach the instruction selector to not select lddw/stdw
instructions so that the weird pointer adjustments are not necessary.
But for now I've focused just on correctness, not on code quality.

Updates: https://github.com/llvm/llvm-project/issues/53459

Differential Revision: https://reviews.llvm.org/D131867




More information about the All-commits mailing list