[PATCH] D100704: [Thumb1][MachineOutliner] Add Machine Outliner support for Thumb1

Benson Chu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 17 07:12:46 PDT 2021


pestctrl created this revision.
Herald added subscribers: hiraditya, kristof.beyls.
pestctrl requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

MachineOutliner support was previously added for Thumb2 and ARM modes, but
Thumb1 support was left out, as there is no idiomatic way to push the LR onto
the stack and then restore it back into the LR, which is required for
MachineOutlinerDefault and repeated sequences that have calls in them. The
other outlining strategies can be done in the same manner as Thumb2, because
they all use Thumb1 instructions.

This patch enables Thumb1 support for the outliner, and introduces an idiom for
saving and restoring the LR under certain circumstances. If there is an unused
register in a repeated sequence, then saving the LR is possible by this
sequence of instructions:

PUSH R4 <https://reviews.llvm.org/source/lld/>     ;; Free up an auxilary register
PUSH LR     ;; LR must go on the top of the stack

......      ;; Original sequence of instructions

POP R4 <https://reviews.llvm.org/source/lld/>      ;; Pop LR off the stack into R4 <https://reviews.llvm.org/source/lld/>

  ;; (Cannot be directly popped into LR)

MOV LR, R4 <https://reviews.llvm.org/source/lld/>  ;; Move LR into the correct register
POP R4 <https://reviews.llvm.org/source/lld/>      ;; Pop the original value of R4 <https://reviews.llvm.org/source/lld/> into R4 <https://reviews.llvm.org/source/lld/>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100704

Files:
  llvm/include/llvm/CodeGen/MachineOutliner.h
  llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
  llvm/lib/Target/ARM/ARMBaseInstrInfo.h
  llvm/lib/Target/ARM/Thumb1InstrInfo.cpp
  llvm/lib/Target/ARM/Thumb1InstrInfo.h
  llvm/test/CodeGen/ARM/machine-outliner-default.mir
  llvm/test/CodeGen/ARM/machine-outliner-lr-regsave.mir
  llvm/test/CodeGen/ARM/machine-outliner-no-lr-save.mir
  llvm/test/CodeGen/ARM/machine-outliner-tail.ll
  llvm/test/CodeGen/ARM/machine-outliner-thumb-cfi-call.mir
  llvm/test/CodeGen/ARM/machine-outliner-thumb-cfi-frame.mir
  llvm/test/CodeGen/ARM/machine-outliner-thunk.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100704.338304.patch
Type: text/x-patch
Size: 65153 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210417/85f5613c/attachment.bin>


More information about the llvm-commits mailing list