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: 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 RetCC_Hexagon: CallingConv<[
53 CCPromoteToType<i32>>,
55 CCBitConvertToType<i32>>,
57 CCBitConvertToType<i64>>,
59 // Small structures are returned in a pair of registers, (which is
60 // always r1:0). In such case, what is returned are two i32 values
61 // without any additional information (in ArgFlags) stating that
62 // they are parts of a structure. Because of that there is no way
63 // to differentiate that situation from an attempt to return two
64 // values, so always assign R0 and R1.
66 CCAssignToReg<[R0,R1]>>,
67 CCIfType<[i32,v2i16,v4i8],
68 CCAssignToReg<[R0,R1]>>,
69 CCIfType<[i64,v2i32,v4i16,v8i8],
74 class CCIfHvx64<CCAction A>
75 : CCIf<"State.getMachineFunction().getSubtarget<HexagonSubtarget>()"
76 ".useHVX64BOps()", A>;
78 class CCIfHvx128<CCAction A>
79 : CCIf<"State.getMachineFunction().getSubtarget<HexagonSubtarget>()"
80 ".useHVX128BOps()", A>;
82 def CC_Hexagon_HVX: CallingConv<[
85 CCIfType<[v16i32,v32i16,v64i8],
86 CCAssignToReg<[V0,V1,V2,V3,V4,V5,V6,V7,V8,V9,V10,V11,V12,V13,V14,V15]>>>,
88 CCIfType<[v32i32,v64i16,v128i8],
89 CCAssignToReg<[W0,W1,W2,W3,W4,W5,W6,W7]>>>,
91 CCIfType<[v16i32,v32i16,v64i8],
92 CCAssignToStack<64,64>>>,
94 CCIfType<[v32i32,v64i16,v128i8],
95 CCAssignToStack<128,64>>>,
99 CCIfType<[v32i32,v64i16,v128i8],
100 CCAssignToReg<[V0,V1,V2,V3,V4,V5,V6,V7,V8,V9,V10,V11,V12,V13,V14,V15]>>>,
102 CCIfType<[v64i32,v128i16,v256i8],
103 CCAssignToReg<[W0,W1,W2,W3,W4,W5,W6,W7]>>>,
105 CCIfType<[v32i32,v64i16,v128i8],
106 CCAssignToStack<128,128>>>,
108 CCIfType<[v64i32,v128i16,v256i8],
109 CCAssignToStack<256,128>>>,
111 CCDelegateTo<CC_Hexagon>
114 def RetCC_Hexagon_HVX: CallingConv<[
117 CCIfType<[v16i32,v32i16,v64i8],
118 CCAssignToReg<[V0]>>>,
120 CCIfType<[v32i32,v64i16,v128i8],
121 CCAssignToReg<[W0]>>>,
125 CCIfType<[v32i32,v64i16,v128i8],
126 CCAssignToReg<[V0]>>>,
128 CCIfType<[v64i32,v128i16,v256i8],
129 CCAssignToReg<[W0]>>>,
131 CCDelegateTo<RetCC_Hexagon>