• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1//===- Nios2CallingConv.td - Calling Conventions for Nios2 -*- tablegen -*-===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9// This describes the calling conventions for Nios2 architecture.
10//===----------------------------------------------------------------------===//
11
12/// CCIfSubtarget - Match if the current subtarget has a feature F.
13class CCIfSubtarget<string F, CCAction A>:
14  CCIf<!strconcat("State.getTarget().getSubtarget<Nios2Subtarget>().", F), A>;
15
16def 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]>>,
19
20  // Alternatively, they are assigned to the stack in 4-byte aligned units.
21  CCAssignToStack<4, 4>
22]>;
23
24def 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>>
32]>;
33
34def CSR : CalleeSavedRegs<(add RA, FP, (sequence "R%u", 16, 23))>;
35