llvm.org GIT mirror llvm / 31c8a6d
Add a description of the X86-64 calling convention and the return conventions. This doesn't do anything yet, but may in the future. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34636 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 13 years ago
2 changed file(s) with 143 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
122122 24];
123123 }
124124
125 //===----------------------------------------------------------------------===//
126 // Calling Conventions
127 //===----------------------------------------------------------------------===//
128
129 include "X86CallingConv.td"
130
131
132 //===----------------------------------------------------------------------===//
133 // Assembly Printers
134 //===----------------------------------------------------------------------===//
135
125136 // The X86 target supports two different syntaxes for emitting machine code.
126137 // This is controlled by the -x86-asm-syntax={att|intel}
127138 def ATTAsmWriter : AsmWriter {
0 //===- X86CallingConv.td - Calling Conventions for X86 32/64 ----*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file was developed by the LLVM research group and is distributed under
5 // the University of Illinois Open Source License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This describes the calling conventions for the X86-32 and X86-64
10 // architectures.
11 //
12 //===----------------------------------------------------------------------===//
13
14
15 class CCAction;
16 class CallingConv;
17
18
19 /// CCMatchType - If the current argument is one of the specified types, apply
20 /// Action A.
21 class CCMatchType VTs, CCAction A> : CCAction {
22 }
23
24 /// CCMatchIf - If the predicate matches, apply A.
25 class CCMatchIf : CCAction {
26 string Predicate = predicate;
27 }
28
29 /// CCAssignToReg - This action matches if there is a register in the specified
30 /// list that is still available. If so, it assigns the value to the first
31 /// available register and succeeds.
32 class CCAssignToReg regList> : CCAction {
33 list RegList = regList;
34 }
35
36 /// CCAssignToStack - This action always matches: it assigns the value to a
37 /// stack slot of the specified size and alignment on the stack.
38 class CCAssignToStack : CCAction {
39 int Size = size;
40 int Align = align;
41 }
42
43
44
45 /// CCPromoteToType - If applied, this promotes the specified current value to
46 /// the specified type.
47 class CCPromoteToType : CCAction {
48 ValueType DestTy = destTy;
49 }
50
51 /// CCDelegateTo - This action invokes the specified sub-calling-convention. It
52 /// is successful if the specified CC matches.
53 class CCDelegateTo : CCAction {
54 CallingConv CC = cc;
55 }
56
57
58 class CallingConv actions> {
59 list Actions = actions;
60 }
61
62 //===----------------------------------------------------------------------===//
63 // Return Value Calling Conventions
64 //===----------------------------------------------------------------------===//
65
66 def RetCC_X86Common : CallingConv<[
67 // Scalar values are returned in AX first, then DX.
68 CCMatchType<[i8] , CCAssignToReg<[AL]>>,
69 CCMatchType<[i16], CCAssignToReg<[AX]>>,
70 CCMatchType<[i32], CCAssignToReg<[EAX, EDX]>>,
71 CCMatchType<[i64], CCAssignToReg<[RAX, RDX]>>,
72
73 // Vector types are always returned in XMM0. If the target doesn't have XMM0,
74 // it won't have vector types.
75 CCMatchType<[v16i8, v8i16, v4i32, v2i64, v4f32, v2f64], CCAssignToReg<[XMM0]>>
76 ]>;
77
78 // Return conventions for the X86-32 C calling convention.
79 def RetCC_X86_32_C : CallingConv<[
80 // The X86-32 calling convention returns FP values in ST0, otherwise it is the
81 // same as the common X86 calling conv.
82 CCMatchType<[f32], CCAssignToReg<[ST0]>>,
83 CCMatchType<[f64], CCAssignToReg<[ST0]>>,
84 CCDelegateTo
85 ]>;
86
87 // Return conventions for the X86-32 Fast calling convention.
88 def RetCC_X86_32_Fast : CallingConv<[
89 // The X86-32 fastcc returns FP values in XMM0 if the target has SSE2,
90 // otherwise it is the the C calling conventions.
91 CCMatchType<[f32], CCMatchIf<"Subtarget->hasSSE2()", CCAssignToReg<[XMM0]>>>,
92 CCMatchType<[f64], CCMatchIf<"Subtarget->hasSSE2()", CCAssignToReg<[XMM0]>>>,
93 CCDelegateTo
94 ]>;
95
96 // Return conventions for the X86-64 C calling convention.
97 def RetCC_X86_64_C : CallingConv<[
98 // The X86-64 calling convention always returns FP values in XMM0.
99 CCMatchType<[f32], CCAssignToReg<[XMM0]>>,
100 CCMatchType<[f64], CCAssignToReg<[XMM0]>>,
101 CCDelegateTo
102 ]>;
103
104
105 //===----------------------------------------------------------------------===//
106 // Argument Calling Conventions
107 //===----------------------------------------------------------------------===//
108
109
110 def CC_X86_64_C : CallingConv<[
111 // Promote i8/i16 arguments to i32.
112 CCMatchType<[i8, i16], CCPromoteToType>,
113
114 // The first 6 integer arguments are passed in integer registers.
115 CCMatchType<[i32], CCAssignToReg<[EDI, ESI, EDX, ECX, R8D, R9D]>>,
116 CCMatchType<[i64], CCAssignToReg<[RDI, RSI, RDX, RCX, R8 , R9 ]>>,
117
118 // The first 8 FP/Vector arguments are passed in XMM registers.
119 CCMatchType<[f32, f64, v16i8, v8i16, v4i32, v2i64, v4f32, v2f64],
120 CCAssignToReg<[XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7]>>,
121
122 // Integer/FP values get stored in stack slots that are 8 bytes in size and
123 // 8-byte aligned if there are no more registers to hold them.
124 CCMatchType<[i32, i64, f32, f64], CCAssignToStack<8, 8>>,
125
126 // Vectors get 16-byte stack slots that are 16-byte aligned.
127 CCMatchType<[v16i8, v8i16, v4i32, v2i64, v4f32, v2f64],
128 CCAssignToStack<16, 16>>
129 ]>;
130
131