[RISCV] Add scalable offset under very large stack size.
authorHsiangkai Wang <kai.wang@sifive.com>
Thu, 8 Apr 2021 02:49:10 +0000 (10:49 +0800)
committerHsiangkai Wang <kai.wang@sifive.com>
Thu, 8 Apr 2021 06:46:05 +0000 (14:46 +0800)
commitba72bdef3250ce2ef602d7a07af6a5a6c5255fde
treedd4eea5d003f10ca59b7ef6fab97ac06621b5660
parentb8cd6681156a533dd6d4b3f0f5a1acf1116bc347
[RISCV] Add scalable offset under very large stack size.

If the stack size is larger than 12 bits, we have to use a scratch
register to store the stack size. Before we introduce the scalable stack
offset, we could simplify

%0 = ADDI %stack.0, 0

=>

%scratch = ... # sequence of instructions to move the offset into
%%scratch
%0 = ADD %fp, %scratch

However, if the offset contains scalable part, we need to consider it.

%0 = ADDI %stack.0, 0

=>

%scratch = ... # sequence of instructions to move the offset into
%%scratch
%scratch = ADD %fp, %scratch
%scalable_offset = ... # sequence of instructions for vscaled-offset.
%0 = ADD/SUB %scratch, %scalable_offset

Differential Revision: https://reviews.llvm.org/D100035
llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
llvm/test/CodeGen/RISCV/rvv/addi-scalable-offset.mir