[PATCH] D52961: [RISCV] Introduce the RISCVMatInt::generateInstSeq helper

Alex Bradbury via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 6 03:26:06 PDT 2018


asb created this revision.
asb added reviewers: apazos, shiva0217, sameer.abuasal.
Herald added subscribers: jocewei, PkmX, rkruppe, the_o, brucehoult, MartinMosbeck, rogfer01, mgrang, edward-jones, zzheng, kito-cheng, sabuasal, simoncook, johnrusso, rbar, mgorny.

Logic to load 32-bit and 64-bit immediates is currently present in
RISCVAsmParser::emitLoadImm in order to support the li pseudoinstruction. With
the introduction of RV64 codegen, there is a greater benefit of sharing
immediate materialisation logic between the MC layer and codegen. The
generateInstSeq helper allows this by producing a vector of simple structs
representing the chosen instructions. This can then be consumed in the MC
layer to produce MCInsts or at instruction selection time to produce
appropriate SelectionDAG node. Sharing this logic means that both the li
pseudoinstruction and codegen can benefit from future optimisations, and
that this logic can be used for materialising constants during RV64 codegen.

This patch does contain a behaviour change: addi will now be produced on RV64
when no lui is necessary to materialise the constant. In that case addiw takes
x0 as the source register, so is semantically identical to addi.


https://reviews.llvm.org/D52961

Files:
  lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  lib/Target/RISCV/Utils/CMakeLists.txt
  lib/Target/RISCV/Utils/RISCVMatInt.cpp
  lib/Target/RISCV/Utils/RISCVMatInt.h
  test/MC/RISCV/rv64c-aliases-valid.s
  test/MC/RISCV/rv64i-aliases-valid.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52961.168566.patch
Type: text/x-patch
Size: 12668 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181006/4386efec/attachment.bin>


More information about the llvm-commits mailing list