1 //===- HexagonCallingConv.td ----------------------------------------------===//
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 class CCIfArgIsVarArg<CCAction A>
10 : CCIf<"State.isVarArg() && "
11 "ValNo >= static_cast<HexagonCCState&>(State)"
12 ".getNumNamedVarArgParams()", A>;
14 def CC_HexagonStack: CallingConv<[
15 CCIfType<[i32,v2i16,v4i8],
16 CCAssignToStack<4,4>>,
17 CCIfType<[i64,v2i32,v4i16,v8i8],
21 def CC_Hexagon_Legacy: CallingConv<[
23 CCPromoteToType<i32>>,
25 CCBitConvertToType<i32>>,
27 CCBitConvertToType<i64>>,
32 CCDelegateTo<CC_HexagonStack>>,
34 // Pass split values in pairs, allocate odd register if necessary.
37 CCCustom<"CC_SkipOdd">>>,
39 CCIfType<[i32,v2i16,v4i8],
40 CCAssignToReg<[R0,R1,R2,R3,R4,R5]>>,
41 // Make sure to allocate any skipped 32-bit register, so it does not get
42 // allocated to a subsequent 32-bit value.
43 CCIfType<[i64,v2i32,v4i16,v8i8],
44 CCCustom<"CC_SkipOdd">>,
45 CCIfType<[i64,v2i32,v4i16,v8i8],
46 CCAssignToReg<[D0,D1,D2]>>,
48 CCDelegateTo<CC_HexagonStack>
51 def CC_Hexagon: CallingConv<[
53 CCPromoteToType<i32>>,
55 CCBitConvertToType<i32>>,
57 CCBitConvertToType<i64>>,
62 CCDelegateTo<CC_HexagonStack>>,
64 // Pass split values in pairs, allocate odd register if necessary.
67 CCCustom<"CC_SkipOdd">>>,
69 CCIfType<[i32,v2i16,v4i8],
70 CCAssignToReg<[R0,R1,R2,R3,R4,R5]>>,
71 // Make sure to allocate any skipped 32-bit register, so it does not get
72 // allocated to a subsequent 32-bit value.
73 CCIfType<[i64,v2i32,v4i16,v8i8],
74 CCCustom<"CC_SkipOdd">>,
75 CCIfType<[i64,v2i32,v4i16,v8i8],
76 CCAssignToReg<[D0,D1,D2]>>,
78 CCDelegateTo<CC_HexagonStack>
81 def RetCC_Hexagon: CallingConv<[
83 CCPromoteToType<i32>>,
85 CCBitConvertToType<i32>>,
87 CCBitConvertToType<i64>>,
89 // Small structures are returned in a pair of registers, (which is
90 // always r1:0). In such case, what is returned are two i32 values
91 // without any additional information (in ArgFlags) stating that
92 // they are parts of a structure. Because of that there is no way
93 // to differentiate that situation from an attempt to return two
94 // values, so always assign R0 and R1.
96 CCAssignToReg<[R0,R1]>>,
97 CCIfType<[i32,v2i16,v4i8],
98 CCAssignToReg<[R0,R1]>>,
99 CCIfType<[i64,v2i32,v4i16,v8i8],
104 class CCIfHvx64<CCAction A>
105 : CCIf<"State.getMachineFunction().getSubtarget<HexagonSubtarget>()"
106 ".useHVX64BOps()", A>;
108 class CCIfHvx128<CCAction A>
109 : CCIf<"State.getMachineFunction().getSubtarget<HexagonSubtarget>()"
110 ".useHVX128BOps()", A>;
112 def CC_Hexagon_HVX: CallingConv<[
115 CCIfType<[v16i32,v32i16,v64i8],
116 CCAssignToReg<[V0,V1,V2,V3,V4,V5,V6,V7,V8,V9,V10,V11,V12,V13,V14,V15]>>>,
118 CCIfType<[v32i32,v64i16,v128i8],
119 CCAssignToReg<[W0,W1,W2,W3,W4,W5,W6,W7]>>>,
121 CCIfType<[v16i32,v32i16,v64i8],
122 CCAssignToStack<64,64>>>,
124 CCIfType<[v32i32,v64i16,v128i8],
125 CCAssignToStack<128,64>>>,
129 CCIfType<[v32i32,v64i16,v128i8,v32f32,v64f16],
130 CCAssignToReg<[V0,V1,V2,V3,V4,V5,V6,V7,V8,V9,V10,V11,V12,V13,V14,V15]>>>,
132 CCIfType<[v64i32,v128i16,v256i8,v64f32,v128f16],
133 CCAssignToReg<[W0,W1,W2,W3,W4,W5,W6,W7]>>>,
135 CCIfType<[v32i32,v64i16,v128i8,v32f32,v64f16],
136 CCAssignToStack<128,128>>>,
138 CCIfType<[v64i32,v128i16,v256i8,v64f32,v128f16],
139 CCAssignToStack<256,128>>>,
141 CCDelegateTo<CC_Hexagon>
144 def RetCC_Hexagon_HVX: CallingConv<[
147 CCIfType<[v16i32,v32i16,v64i8],
148 CCAssignToReg<[V0]>>>,
150 CCIfType<[v32i32,v64i16,v128i8],
151 CCAssignToReg<[W0]>>>,
155 CCIfType<[v32i32,v64i16,v128i8,v32f32,v64f16],
156 CCAssignToReg<[V0]>>>,
158 CCIfType<[v64i32,v128i16,v256i8,v64f32,v128f16],
159 CCAssignToReg<[W0]>>>,
161 CCDelegateTo<RetCC_Hexagon>