[RISCV] Implement RISCV ABI lowering
authorAlex Bradbury <asb@lowrisc.org>
Mon, 15 Jan 2018 17:54:52 +0000 (17:54 +0000)
committerAlex Bradbury <asb@lowrisc.org>
Mon, 15 Jan 2018 17:54:52 +0000 (17:54 +0000)
commit8cbdd4892fcd030965bd10f36d3484cb82bee329
tree47fbde790a31d54a3debaf103ea55e21c14b3bb4
parent674f9128b7520ad43d3358724baf0f89baeeda02
[RISCV] Implement RISCV ABI lowering

RISCVABIInfo is implemented in terms of XLen, supporting both RV32 and RV64.
Unfortunately we need to count argument registers in the frontend in order to
determine when to emit signext and zeroext attributes. Integer scalars are
extended according to their type up to 32-bits and then sign-extended to XLen
when passed in registers, but are anyext when passed on the stack. This patch
only implements the base integer (soft float) ABIs.

For more information on the RISC-V ABI, see [the ABI
doc](https://github.com/riscv/riscv-elf-psabi-doc/blob/master/riscv-elf.md),
my [golden model](https://github.com/lowRISC/riscv-calling-conv-model), and
the [LLVM RISC-V calling convention
patch](https://reviews.llvm.org/D39898#2d1595b4) (specifically the comment
documenting frontend expectations).

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

llvm-svn: 322494
clang/lib/CodeGen/TargetInfo.cpp
clang/test/CodeGen/riscv32-abi.c [new file with mode: 0644]
clang/test/CodeGen/riscv64-abi.c [new file with mode: 0644]
clang/test/Driver/riscv32-toolchain.c
clang/test/Driver/riscv64-toolchain.c