1 //===-- RISCVCallingConv.td - Calling Conventions RISC-V ---*- tablegen -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This describes the calling conventions for the RISC-V architecture.
11 //===----------------------------------------------------------------------===//
13 // The RISC-V calling convention is handled with custom code in
14 // RISCVISelLowering.cpp (CC_RISCV).
16 def CSR_ILP32E_LP64E : CalleeSavedRegs<(add X1, X8, X9)>;
19 : CalleeSavedRegs<(add CSR_ILP32E_LP64E, (sequence "X%u", 18, 27))>;
22 : CalleeSavedRegs<(add CSR_ILP32_LP64,
23 F8_F, F9_F, (sequence "F%u_F", 18, 27))>;
26 : CalleeSavedRegs<(add CSR_ILP32_LP64,
27 F8_D, F9_D, (sequence "F%u_D", 18, 27))>;
29 defvar CSR_V = (add (sequence "V%u", 1, 7), (sequence "V%u", 24, 31),
30 V2M2, V4M2, V6M2, V24M2, V26M2, V28M2, V30M2,
31 V4M4, V24M4, V28M4, V24M8);
34 : CalleeSavedRegs<(add CSR_ILP32_LP64, CSR_V)>;
36 def CSR_ILP32F_LP64F_V
37 : CalleeSavedRegs<(add CSR_ILP32F_LP64F, CSR_V)>;
39 def CSR_ILP32D_LP64D_V
40 : CalleeSavedRegs<(add CSR_ILP32D_LP64D, CSR_V)>;
42 // Needed for implementation of RISCVRegisterInfo::getNoPreservedMask()
43 def CSR_NoRegs : CalleeSavedRegs<(add)>;
45 // Interrupt handler needs to save/restore all registers that are used,
46 // both Caller and Callee saved registers.
47 def CSR_Interrupt : CalleeSavedRegs<(add X1, (sequence "X%u", 5, 31))>;
49 // Same as CSR_Interrupt, but including all 32-bit FP registers.
50 def CSR_XLEN_F32_Interrupt: CalleeSavedRegs<(add CSR_Interrupt,
51 (sequence "F%u_F", 0, 31))>;
53 // Same as CSR_Interrupt, but including all 64-bit FP registers.
54 def CSR_XLEN_F64_Interrupt: CalleeSavedRegs<(add CSR_Interrupt,
55 (sequence "F%u_D", 0, 31))>;
57 // Same as CSR_Interrupt, but excluding X16-X31.
58 def CSR_Interrupt_RVE : CalleeSavedRegs<(sub CSR_Interrupt,
59 (sequence "X%u", 16, 31))>;
61 // Same as CSR_XLEN_F32_Interrupt, but excluding X16-X31.
62 def CSR_XLEN_F32_Interrupt_RVE: CalleeSavedRegs<(sub CSR_XLEN_F32_Interrupt,
63 (sequence "X%u", 16, 31))>;
65 // Same as CSR_XLEN_F64_Interrupt, but excluding X16-X31.
66 def CSR_XLEN_F64_Interrupt_RVE: CalleeSavedRegs<(sub CSR_XLEN_F64_Interrupt,
67 (sequence "X%u", 16, 31))>;