From dc31c61b18f01b21e18ccea4de0a010569e81887 Mon Sep 17 00:00:00 2001 From: Alex Bradbury Date: Mon, 11 Dec 2017 12:49:02 +0000 Subject: [RISCV] Add custom CC_RISCV calling convention and improved call support The TableGen-based calling convention definitions are inflexible, while writing a function to implement the calling convention is very straight-forward, and allows difficult cases to be handled more easily. With this patch adds support for: * Passing large scalars according to the RV32I calling convention * Byval arguments * Passing values on the stack when the argument registers are exhausted The custom CC_RISCV calling convention is also used for returns. This patch also documents the ABI lowering that a language frontend is expected to perform. I would like to work to simplify these requirements over time, but this will require further discussion within the LLVM community. We add PendingArgFlags CCState, as a companion to PendingLocs. The PendingLocs vector is used by a number of backends to handle arguments that are split during legalisation. However CCValAssign doesn't keep track of the original argument alignment. Therefore, add a PendingArgFlags vector which can be used to keep track of the ISD::ArgFlagsTy for every value added to PendingLocs. Differential Revision: https://reviews.llvm.org/D39898 llvm-svn: 320359 --- llvm/lib/Target/RISCV/RISCVCallingConv.td | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'llvm/lib/Target/RISCV/RISCVCallingConv.td') diff --git a/llvm/lib/Target/RISCV/RISCVCallingConv.td b/llvm/lib/Target/RISCV/RISCVCallingConv.td index 0b7a523424c..d2b17c64c9c 100644 --- a/llvm/lib/Target/RISCV/RISCVCallingConv.td +++ b/llvm/lib/Target/RISCV/RISCVCallingConv.td @@ -11,20 +11,8 @@ // //===----------------------------------------------------------------------===// -// RISCV 32-bit C return-value convention. -def RetCC_RISCV32 : CallingConv<[CCIfType<[i32], CCAssignToReg<[X10, X11]>>]>; - -// RISCV 32-bit C Calling convention. -def CC_RISCV32 : CallingConv<[ - // Promote i8/i16 args to i32 - CCIfType<[ i8, i16 ], CCPromoteToType>, - - // All arguments get passed in integer registers if there is space. - CCIfType<[i32], CCAssignToReg<[ X10, X11, X12, X13, X14, X15, X16, X17]>>, - - // Could be assigned to the stack in 8-byte aligned units, but unsupported - CCAssignToStack<8, 8> -]>; +// The RISC-V calling convention is handled with custom code in +// RISCVISelLowering.cpp (CC_RISCV). def CSR : CalleeSavedRegs<(add X1, X3, X4, X8, X9, (sequence "X%u", 18, 27))>; -- cgit v1.2.3