OSDN Git Service

[RISCV] Introduce the RISCVMatInt::generateInstSeq helper
authorAlex Bradbury <asb@lowrisc.org>
Thu, 15 Nov 2018 10:11:31 +0000 (10:11 +0000)
committerAlex Bradbury <asb@lowrisc.org>
Thu, 15 Nov 2018 10:11:31 +0000 (10:11 +0000)
commit19fcc06d24e97dc059246705ea87a47477806226
treea0e69f4c414ff895566744972e0724e3f03b8b4a
parent02d063949d2e72e0f60d1c2ac67283bf4ca27ddc
[RISCV] Introduce the RISCVMatInt::generateInstSeq helper

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.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@346937 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
lib/Target/RISCV/Utils/CMakeLists.txt
lib/Target/RISCV/Utils/RISCVMatInt.cpp [new file with mode: 0644]
lib/Target/RISCV/Utils/RISCVMatInt.h [new file with mode: 0644]
test/MC/RISCV/rv64c-aliases-valid.s
test/MC/RISCV/rv64i-aliases-valid.s