1 //===- Nios2CallingConv.td - Calling Conventions for Nios2 -*- tablegen -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
9 // This describes the calling conventions for Nios2 architecture.
10 //===----------------------------------------------------------------------===//
12 /// CCIfSubtarget - Match if the current subtarget has a feature F.
13 class CCIfSubtarget<string F, CCAction A>:
14 CCIf<!strconcat("State.getTarget().getSubtarget<Nios2Subtarget>().", F), A>;
16 def CC_Nios2 : CallingConv<[
17 // i32 f32 arguments get passed in integer registers if there is space.
18 CCIfType<[i32, f32], CCAssignToReg<[R4, R5, R6, R7]>>,
20 // Alternatively, they are assigned to the stack in 4-byte aligned units.
24 def RetCC_Nios2EABI : CallingConv<[
25 // i32 are returned in registers R2, R3
26 CCIfType<[i32], CCAssignToReg<[R2, R3]>>,
27 // In case of floating point (FPH2 instr.) also use the same register set
28 CCIfType<[f32], CCAssignToReg<[R2, R3]>>,
29 CCIfByVal<CCPassByVal<4, 4>>,
30 // Stack parameter slots for i32 is 32-bit words and 4-byte aligned.
31 CCIfType<[i32], CCAssignToStack<4, 4>>
34 def CSR : CalleeSavedRegs<(add RA, FP, (sequence "R%u", 16, 23))>;