[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)
commit22c091fc3cb19af03bc0c49805760556d11c10b3
tree13f537874355696919ae7cb8d580392a295273d5
parent553ac560aa6b7c0a6df876ad06e3477b8ddafa7a
[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

llvm-svn: 346937
llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
llvm/lib/Target/RISCV/Utils/CMakeLists.txt
llvm/lib/Target/RISCV/Utils/RISCVMatInt.cpp [new file with mode: 0644]
llvm/lib/Target/RISCV/Utils/RISCVMatInt.h [new file with mode: 0644]
llvm/test/MC/RISCV/rv64c-aliases-valid.s
llvm/test/MC/RISCV/rv64i-aliases-valid.s