10b57cec5SDimitry Andric//===-- RISCVCallingConv.td - Calling Conventions RISCV ----*- tablegen -*-===// 20b57cec5SDimitry Andric// 30b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric// 70b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric// 90b57cec5SDimitry Andric// This describes the calling conventions for the RISCV architecture. 100b57cec5SDimitry Andric// 110b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 120b57cec5SDimitry Andric 130b57cec5SDimitry Andric// The RISC-V calling convention is handled with custom code in 140b57cec5SDimitry Andric// RISCVISelLowering.cpp (CC_RISCV). 150b57cec5SDimitry Andric 160b57cec5SDimitry Andricdef CSR_ILP32_LP64 170b57cec5SDimitry Andric : CalleeSavedRegs<(add X1, X3, X4, X8, X9, (sequence "X%u", 18, 27))>; 180b57cec5SDimitry Andric 190b57cec5SDimitry Andricdef CSR_ILP32F_LP64F 200b57cec5SDimitry Andric : CalleeSavedRegs<(add CSR_ILP32_LP64, 21*8bcb0991SDimitry Andric F8_F, F9_F, (sequence "F%u_F", 18, 27))>; 220b57cec5SDimitry Andric 230b57cec5SDimitry Andricdef CSR_ILP32D_LP64D 240b57cec5SDimitry Andric : CalleeSavedRegs<(add CSR_ILP32_LP64, 25*8bcb0991SDimitry Andric F8_D, F9_D, (sequence "F%u_D", 18, 27))>; 260b57cec5SDimitry Andric 270b57cec5SDimitry Andric// Needed for implementation of RISCVRegisterInfo::getNoPreservedMask() 280b57cec5SDimitry Andricdef CSR_NoRegs : CalleeSavedRegs<(add)>; 290b57cec5SDimitry Andric 300b57cec5SDimitry Andric// Interrupt handler needs to save/restore all registers that are used, 310b57cec5SDimitry Andric// both Caller and Callee saved registers. 320b57cec5SDimitry Andricdef CSR_Interrupt : CalleeSavedRegs<(add X1, 330b57cec5SDimitry Andric (sequence "X%u", 3, 9), 340b57cec5SDimitry Andric (sequence "X%u", 10, 11), 350b57cec5SDimitry Andric (sequence "X%u", 12, 17), 360b57cec5SDimitry Andric (sequence "X%u", 18, 27), 370b57cec5SDimitry Andric (sequence "X%u", 28, 31))>; 380b57cec5SDimitry Andric 390b57cec5SDimitry Andric// Same as CSR_Interrupt, but including all 32-bit FP registers. 400b57cec5SDimitry Andricdef CSR_XLEN_F32_Interrupt: CalleeSavedRegs<(add X1, 410b57cec5SDimitry Andric (sequence "X%u", 3, 9), 420b57cec5SDimitry Andric (sequence "X%u", 10, 11), 430b57cec5SDimitry Andric (sequence "X%u", 12, 17), 440b57cec5SDimitry Andric (sequence "X%u", 18, 27), 450b57cec5SDimitry Andric (sequence "X%u", 28, 31), 46*8bcb0991SDimitry Andric (sequence "F%u_F", 0, 7), 47*8bcb0991SDimitry Andric (sequence "F%u_F", 10, 11), 48*8bcb0991SDimitry Andric (sequence "F%u_F", 12, 17), 49*8bcb0991SDimitry Andric (sequence "F%u_F", 28, 31), 50*8bcb0991SDimitry Andric (sequence "F%u_F", 8, 9), 51*8bcb0991SDimitry Andric (sequence "F%u_F", 18, 27))>; 520b57cec5SDimitry Andric 530b57cec5SDimitry Andric// Same as CSR_Interrupt, but including all 64-bit FP registers. 540b57cec5SDimitry Andricdef CSR_XLEN_F64_Interrupt: CalleeSavedRegs<(add X1, 550b57cec5SDimitry Andric (sequence "X%u", 3, 9), 560b57cec5SDimitry Andric (sequence "X%u", 10, 11), 570b57cec5SDimitry Andric (sequence "X%u", 12, 17), 580b57cec5SDimitry Andric (sequence "X%u", 18, 27), 590b57cec5SDimitry Andric (sequence "X%u", 28, 31), 60*8bcb0991SDimitry Andric (sequence "F%u_D", 0, 7), 61*8bcb0991SDimitry Andric (sequence "F%u_D", 10, 11), 62*8bcb0991SDimitry Andric (sequence "F%u_D", 12, 17), 63*8bcb0991SDimitry Andric (sequence "F%u_D", 28, 31), 64*8bcb0991SDimitry Andric (sequence "F%u_D", 8, 9), 65*8bcb0991SDimitry Andric (sequence "F%u_D", 18, 27))>; 66